babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306
  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. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. 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>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. 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;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. 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;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. 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;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.plane" {
  1937. import { DeepImmutable } from "babylonjs/types";
  1938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1939. /**
  1940. * Represens a plane by the equation ax + by + cz + d = 0
  1941. */
  1942. export class Plane {
  1943. private static _TmpMatrix;
  1944. /**
  1945. * Normal of the plane (a,b,c)
  1946. */
  1947. normal: Vector3;
  1948. /**
  1949. * d component of the plane
  1950. */
  1951. d: number;
  1952. /**
  1953. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1954. * @param a a component of the plane
  1955. * @param b b component of the plane
  1956. * @param c c component of the plane
  1957. * @param d d component of the plane
  1958. */
  1959. constructor(a: number, b: number, c: number, d: number);
  1960. /**
  1961. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1962. */
  1963. asArray(): number[];
  1964. /**
  1965. * @returns a new plane copied from the current Plane.
  1966. */
  1967. clone(): Plane;
  1968. /**
  1969. * @returns the string "Plane".
  1970. */
  1971. getClassName(): string;
  1972. /**
  1973. * @returns the Plane hash code.
  1974. */
  1975. getHashCode(): number;
  1976. /**
  1977. * Normalize the current Plane in place.
  1978. * @returns the updated Plane.
  1979. */
  1980. normalize(): Plane;
  1981. /**
  1982. * Applies a transformation the plane and returns the result
  1983. * @param transformation the transformation matrix to be applied to the plane
  1984. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1985. */
  1986. transform(transformation: DeepImmutable<Matrix>): Plane;
  1987. /**
  1988. * Compute the dot product between the point and the plane normal
  1989. * @param point point to calculate the dot product with
  1990. * @returns the dot product (float) of the point coordinates and the plane normal.
  1991. */
  1992. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1993. /**
  1994. * Updates the current Plane from the plane defined by the three given points.
  1995. * @param point1 one of the points used to contruct the plane
  1996. * @param point2 one of the points used to contruct the plane
  1997. * @param point3 one of the points used to contruct the plane
  1998. * @returns the updated Plane.
  1999. */
  2000. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2001. /**
  2002. * Checks if the plane is facing a given direction
  2003. * @param direction the direction to check if the plane is facing
  2004. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2005. * @returns True is the vector "direction" is the same side than the plane normal.
  2006. */
  2007. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2008. /**
  2009. * Calculates the distance to a point
  2010. * @param point point to calculate distance to
  2011. * @returns the signed distance (float) from the given point to the Plane.
  2012. */
  2013. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2014. /**
  2015. * Creates a plane from an array
  2016. * @param array the array to create a plane from
  2017. * @returns a new Plane from the given array.
  2018. */
  2019. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2020. /**
  2021. * Creates a plane from three points
  2022. * @param point1 point used to create the plane
  2023. * @param point2 point used to create the plane
  2024. * @param point3 point used to create the plane
  2025. * @returns a new Plane defined by the three given points.
  2026. */
  2027. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2028. /**
  2029. * Creates a plane from an origin point and a normal
  2030. * @param origin origin of the plane to be constructed
  2031. * @param normal normal of the plane to be constructed
  2032. * @returns a new Plane the normal vector to this plane at the given origin point.
  2033. * Note : the vector "normal" is updated because normalized.
  2034. */
  2035. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Calculates the distance from a plane and a point
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @param point point to calculate distance to
  2041. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2042. */
  2043. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2044. }
  2045. }
  2046. declare module "babylonjs/Maths/math.vector" {
  2047. import { Viewport } from "babylonjs/Maths/math.viewport";
  2048. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2049. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2050. import { Plane } from "babylonjs/Maths/math.plane";
  2051. /**
  2052. * Class representing a vector containing 2 coordinates
  2053. */
  2054. export class Vector2 {
  2055. /** defines the first coordinate */
  2056. x: number;
  2057. /** defines the second coordinate */
  2058. y: number;
  2059. /**
  2060. * Creates a new Vector2 from the given x and y coordinates
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. */
  2064. constructor(
  2065. /** defines the first coordinate */
  2066. x?: number,
  2067. /** defines the second coordinate */
  2068. y?: number);
  2069. /**
  2070. * Gets a string with the Vector2 coordinates
  2071. * @returns a string with the Vector2 coordinates
  2072. */
  2073. toString(): string;
  2074. /**
  2075. * Gets class name
  2076. * @returns the string "Vector2"
  2077. */
  2078. getClassName(): string;
  2079. /**
  2080. * Gets current vector hash code
  2081. * @returns the Vector2 hash code as a number
  2082. */
  2083. getHashCode(): number;
  2084. /**
  2085. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2086. * @param array defines the source array
  2087. * @param index defines the offset in source array
  2088. * @returns the current Vector2
  2089. */
  2090. toArray(array: FloatArray, index?: number): Vector2;
  2091. /**
  2092. * Copy the current vector to an array
  2093. * @returns a new array with 2 elements: the Vector2 coordinates.
  2094. */
  2095. asArray(): number[];
  2096. /**
  2097. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2098. * @param source defines the source Vector2
  2099. * @returns the current updated Vector2
  2100. */
  2101. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2102. /**
  2103. * Sets the Vector2 coordinates with the given floats
  2104. * @param x defines the first coordinate
  2105. * @param y defines the second coordinate
  2106. * @returns the current updated Vector2
  2107. */
  2108. copyFromFloats(x: number, y: number): Vector2;
  2109. /**
  2110. * Sets the Vector2 coordinates with the given floats
  2111. * @param x defines the first coordinate
  2112. * @param y defines the second coordinate
  2113. * @returns the current updated Vector2
  2114. */
  2115. set(x: number, y: number): Vector2;
  2116. /**
  2117. * Add another vector with the current one
  2118. * @param otherVector defines the other vector
  2119. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2120. */
  2121. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2122. /**
  2123. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2124. * @param otherVector defines the other vector
  2125. * @param result defines the target vector
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2129. /**
  2130. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2131. * @param otherVector defines the other vector
  2132. * @returns the current updated Vector2
  2133. */
  2134. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2135. /**
  2136. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2137. * @param otherVector defines the other vector
  2138. * @returns a new Vector2
  2139. */
  2140. addVector3(otherVector: Vector3): Vector2;
  2141. /**
  2142. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2
  2145. */
  2146. subtract(otherVector: Vector2): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Multiplies in place the current Vector2 coordinates by the given ones
  2162. * @param otherVector defines the other vector
  2163. * @returns the current updated Vector2
  2164. */
  2165. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2166. /**
  2167. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns a new Vector2
  2184. */
  2185. multiplyByFloats(x: number, y: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2
  2190. */
  2191. divide(otherVector: Vector2): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Divides the current Vector2 coordinates by the given ones
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 with current Vector2 negated coordinates
  2207. * @returns a new Vector2
  2208. */
  2209. negate(): Vector2;
  2210. /**
  2211. * Negate this vector in place
  2212. * @returns this
  2213. */
  2214. negateInPlace(): Vector2;
  2215. /**
  2216. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2217. * @param result defines the Vector3 object where to store the result
  2218. * @returns the current Vector2
  2219. */
  2220. negateToRef(result: Vector2): Vector2;
  2221. /**
  2222. * Multiply the Vector2 coordinates by scale
  2223. * @param scale defines the scaling factor
  2224. * @returns the current updated Vector2
  2225. */
  2226. scaleInPlace(scale: number): Vector2;
  2227. /**
  2228. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2229. * @param scale defines the scaling factor
  2230. * @returns a new Vector2
  2231. */
  2232. scale(scale: number): Vector2;
  2233. /**
  2234. * Scale the current Vector2 values by a factor to a given Vector2
  2235. * @param scale defines the scale factor
  2236. * @param result defines the Vector2 object where to store the result
  2237. * @returns the unmodified current Vector2
  2238. */
  2239. scaleToRef(scale: number, result: Vector2): Vector2;
  2240. /**
  2241. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2242. * @param scale defines the scale factor
  2243. * @param result defines the Vector2 object where to store the result
  2244. * @returns the unmodified current Vector2
  2245. */
  2246. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2247. /**
  2248. * Gets a boolean if two vectors are equals
  2249. * @param otherVector defines the other vector
  2250. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2251. */
  2252. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets a boolean if two vectors are equals (using an epsilon value)
  2255. * @param otherVector defines the other vector
  2256. * @param epsilon defines the minimal distance to consider equality
  2257. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2258. */
  2259. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2260. /**
  2261. * Gets a new Vector2 from current Vector2 floored values
  2262. * @returns a new Vector2
  2263. */
  2264. floor(): Vector2;
  2265. /**
  2266. * Gets a new Vector2 from current Vector2 floored values
  2267. * @returns a new Vector2
  2268. */
  2269. fract(): Vector2;
  2270. /**
  2271. * Gets the length of the vector
  2272. * @returns the vector length (float)
  2273. */
  2274. length(): number;
  2275. /**
  2276. * Gets the vector squared length
  2277. * @returns the vector squared length (float)
  2278. */
  2279. lengthSquared(): number;
  2280. /**
  2281. * Normalize the vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. normalize(): Vector2;
  2285. /**
  2286. * Gets a new Vector2 copied from the Vector2
  2287. * @returns a new Vector2
  2288. */
  2289. clone(): Vector2;
  2290. /**
  2291. * Gets a new Vector2(0, 0)
  2292. * @returns a new Vector2
  2293. */
  2294. static Zero(): Vector2;
  2295. /**
  2296. * Gets a new Vector2(1, 1)
  2297. * @returns a new Vector2
  2298. */
  2299. static One(): Vector2;
  2300. /**
  2301. * Gets a new Vector2 set from the given index element of the given array
  2302. * @param array defines the data source
  2303. * @param offset defines the offset in the data source
  2304. * @returns a new Vector2
  2305. */
  2306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2307. /**
  2308. * Sets "result" from the given index element of the given array
  2309. * @param array defines the data source
  2310. * @param offset defines the offset in the data source
  2311. * @param result defines the target vector
  2312. */
  2313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2314. /**
  2315. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2316. * @param value1 defines 1st point of control
  2317. * @param value2 defines 2nd point of control
  2318. * @param value3 defines 3rd point of control
  2319. * @param value4 defines 4th point of control
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * 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".
  2326. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2327. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2328. * @param value defines the value to clamp
  2329. * @param min defines the lower limit
  2330. * @param max defines the upper limit
  2331. * @returns a new Vector2
  2332. */
  2333. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2334. /**
  2335. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2336. * @param value1 defines the 1st control point
  2337. * @param tangent1 defines the outgoing tangent
  2338. * @param value2 defines the 2nd control point
  2339. * @param tangent2 defines the incoming tangent
  2340. * @param amount defines the interpolation factor
  2341. * @returns a new Vector2
  2342. */
  2343. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2344. /**
  2345. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2346. * @param start defines the start vector
  2347. * @param end defines the end vector
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Gets the dot product of the vector "left" and the vector "right"
  2354. * @param left defines first vector
  2355. * @param right defines second vector
  2356. * @returns the dot product (float)
  2357. */
  2358. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2359. /**
  2360. * Returns a new Vector2 equal to the normalized given vector
  2361. * @param vector defines the vector to normalize
  2362. * @returns a new Vector2
  2363. */
  2364. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2365. /**
  2366. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2367. * @param left defines 1st vector
  2368. * @param right defines 2nd vector
  2369. * @returns a new Vector2
  2370. */
  2371. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2372. /**
  2373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2374. * @param left defines 1st vector
  2375. * @param right defines 2nd vector
  2376. * @returns a new Vector2
  2377. */
  2378. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2379. /**
  2380. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2381. * @param vector defines the vector to transform
  2382. * @param transformation defines the matrix to apply
  2383. * @returns a new Vector2
  2384. */
  2385. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2386. /**
  2387. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2388. * @param vector defines the vector to transform
  2389. * @param transformation defines the matrix to apply
  2390. * @param result defines the target vector
  2391. */
  2392. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2393. /**
  2394. * Determines if a given vector is included in a triangle
  2395. * @param p defines the vector to test
  2396. * @param p0 defines 1st triangle point
  2397. * @param p1 defines 2nd triangle point
  2398. * @param p2 defines 3rd triangle point
  2399. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2400. */
  2401. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2402. /**
  2403. * Gets the distance between the vectors "value1" and "value2"
  2404. * @param value1 defines first vector
  2405. * @param value2 defines second vector
  2406. * @returns the distance between vectors
  2407. */
  2408. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2409. /**
  2410. * Returns the squared distance between the vectors "value1" and "value2"
  2411. * @param value1 defines first vector
  2412. * @param value2 defines second vector
  2413. * @returns the squared distance between vectors
  2414. */
  2415. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2416. /**
  2417. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2418. * @param value1 defines first vector
  2419. * @param value2 defines second vector
  2420. * @returns a new Vector2
  2421. */
  2422. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2423. /**
  2424. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2425. * @param p defines the middle point
  2426. * @param segA defines one point of the segment
  2427. * @param segB defines the other point of the segment
  2428. * @returns the shortest distance
  2429. */
  2430. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2431. }
  2432. /**
  2433. * Class used to store (x,y,z) vector representation
  2434. * A Vector3 is the main object used in 3D geometry
  2435. * It can represent etiher the coordinates of a point the space, either a direction
  2436. * Reminder: js uses a left handed forward facing system
  2437. */
  2438. export class Vector3 {
  2439. /**
  2440. * Defines the first coordinates (on X axis)
  2441. */
  2442. x: number;
  2443. /**
  2444. * Defines the second coordinates (on Y axis)
  2445. */
  2446. y: number;
  2447. /**
  2448. * Defines the third coordinates (on Z axis)
  2449. */
  2450. z: number;
  2451. private static _UpReadOnly;
  2452. private static _ZeroReadOnly;
  2453. /**
  2454. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2455. * @param x defines the first coordinates (on X axis)
  2456. * @param y defines the second coordinates (on Y axis)
  2457. * @param z defines the third coordinates (on Z axis)
  2458. */
  2459. constructor(
  2460. /**
  2461. * Defines the first coordinates (on X axis)
  2462. */
  2463. x?: number,
  2464. /**
  2465. * Defines the second coordinates (on Y axis)
  2466. */
  2467. y?: number,
  2468. /**
  2469. * Defines the third coordinates (on Z axis)
  2470. */
  2471. z?: number);
  2472. /**
  2473. * Creates a string representation of the Vector3
  2474. * @returns a string with the Vector3 coordinates.
  2475. */
  2476. toString(): string;
  2477. /**
  2478. * Gets the class name
  2479. * @returns the string "Vector3"
  2480. */
  2481. getClassName(): string;
  2482. /**
  2483. * Creates the Vector3 hash code
  2484. * @returns a number which tends to be unique between Vector3 instances
  2485. */
  2486. getHashCode(): number;
  2487. /**
  2488. * Creates an array containing three elements : the coordinates of the Vector3
  2489. * @returns a new array of numbers
  2490. */
  2491. asArray(): number[];
  2492. /**
  2493. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2494. * @param array defines the destination array
  2495. * @param index defines the offset in the destination array
  2496. * @returns the current Vector3
  2497. */
  2498. toArray(array: FloatArray, index?: number): Vector3;
  2499. /**
  2500. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2501. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2502. */
  2503. toQuaternion(): Quaternion;
  2504. /**
  2505. * Adds the given vector to the current Vector3
  2506. * @param otherVector defines the second operand
  2507. * @returns the current updated Vector3
  2508. */
  2509. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Adds the given coordinates to the current Vector3
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Subtract the given vector from the current Vector3
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the resulting Vector3
  2541. */
  2542. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  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. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2567. /**
  2568. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2569. * @returns a new Vector3
  2570. */
  2571. negate(): Vector3;
  2572. /**
  2573. * Negate this vector in place
  2574. * @returns this
  2575. */
  2576. negateInPlace(): Vector3;
  2577. /**
  2578. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. negateToRef(result: Vector3): Vector3;
  2583. /**
  2584. * Multiplies the Vector3 coordinates by the float "scale"
  2585. * @param scale defines the multiplier factor
  2586. * @returns the current updated Vector3
  2587. */
  2588. scaleInPlace(scale: number): Vector3;
  2589. /**
  2590. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2591. * @param scale defines the multiplier factor
  2592. * @returns a new Vector3
  2593. */
  2594. scale(scale: number): Vector3;
  2595. /**
  2596. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2597. * @param scale defines the multiplier factor
  2598. * @param result defines the Vector3 object where to store the result
  2599. * @returns the current Vector3
  2600. */
  2601. scaleToRef(scale: number, result: Vector3): Vector3;
  2602. /**
  2603. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2604. * @param scale defines the scale factor
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the unmodified current Vector3
  2607. */
  2608. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2609. /**
  2610. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2611. * @param origin defines the origin of the projection ray
  2612. * @param plane defines the plane to project to
  2613. * @returns the projected vector3
  2614. */
  2615. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2616. /**
  2617. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2618. * @param origin defines the origin of the projection ray
  2619. * @param plane defines the plane to project to
  2620. * @param result defines the Vector3 where to store the result
  2621. */
  2622. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2623. /**
  2624. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2625. * @param otherVector defines the second operand
  2626. * @returns true if both vectors are equals
  2627. */
  2628. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2629. /**
  2630. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2631. * @param otherVector defines the second operand
  2632. * @param epsilon defines the minimal distance to define values as equals
  2633. * @returns true if both vectors are distant less than epsilon
  2634. */
  2635. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2636. /**
  2637. * Returns true if the current Vector3 coordinates equals the given floats
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @returns true if both vectors are equals
  2642. */
  2643. equalsToFloats(x: number, y: number, z: number): boolean;
  2644. /**
  2645. * Multiplies the current Vector3 coordinates by the given ones
  2646. * @param otherVector defines the second operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2650. /**
  2651. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2652. * @param otherVector defines the second operand
  2653. * @returns the new Vector3
  2654. */
  2655. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2658. * @param otherVector defines the second operand
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the new Vector3
  2669. */
  2670. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2673. * @param otherVector defines the second operand
  2674. * @returns the new Vector3
  2675. */
  2676. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2677. /**
  2678. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2679. * @param otherVector defines the second operand
  2680. * @param result defines the Vector3 object where to store the result
  2681. * @returns the current Vector3
  2682. */
  2683. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2684. /**
  2685. * Divides the current Vector3 coordinates by the given ones.
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. divideInPlace(otherVector: Vector3): Vector3;
  2690. /**
  2691. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2692. * @param other defines the second operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2698. * @param other defines the second operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2702. /**
  2703. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the maximal 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. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2720. * Check if is non uniform within a certain amount of decimal places to account for this
  2721. * @param epsilon the amount the values can differ
  2722. * @returns if the the vector is non uniform to a certain number of decimal places
  2723. */
  2724. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2725. /**
  2726. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2727. */
  2728. get isNonUniform(): boolean;
  2729. /**
  2730. * Gets a new Vector3 from current Vector3 floored values
  2731. * @returns a new Vector3
  2732. */
  2733. floor(): Vector3;
  2734. /**
  2735. * Gets a new Vector3 from current Vector3 floored values
  2736. * @returns a new Vector3
  2737. */
  2738. fract(): Vector3;
  2739. /**
  2740. * Gets the length of the Vector3
  2741. * @returns the length of the Vector3
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Gets the squared length of the Vector3
  2746. * @returns squared length of the Vector3
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalize the current Vector3.
  2751. * Please note that this is an in place operation.
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalize(): Vector3;
  2755. /**
  2756. * Reorders the x y z properties of the vector in place
  2757. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2758. * @returns the current updated vector
  2759. */
  2760. reorderInPlace(order: string): this;
  2761. /**
  2762. * Rotates the vector around 0,0,0 by a quaternion
  2763. * @param quaternion the rotation quaternion
  2764. * @param result vector to store the result
  2765. * @returns the resulting vector
  2766. */
  2767. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2768. /**
  2769. * Rotates a vector around a given point
  2770. * @param quaternion the rotation quaternion
  2771. * @param point the point to rotate around
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2776. /**
  2777. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2778. * The cross product is then orthogonal to both current and "other"
  2779. * @param other defines the right operand
  2780. * @returns the cross product
  2781. */
  2782. cross(other: Vector3): Vector3;
  2783. /**
  2784. * Normalize the current Vector3 with the given input length.
  2785. * Please note that this is an in place operation.
  2786. * @param len the length of the vector
  2787. * @returns the current updated Vector3
  2788. */
  2789. normalizeFromLength(len: number): Vector3;
  2790. /**
  2791. * Normalize the current Vector3 to a new vector
  2792. * @returns the new Vector3
  2793. */
  2794. normalizeToNew(): Vector3;
  2795. /**
  2796. * Normalize the current Vector3 to the reference
  2797. * @param reference define the Vector3 to update
  2798. * @returns the updated Vector3
  2799. */
  2800. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2801. /**
  2802. * Creates a new Vector3 copied from the current Vector3
  2803. * @returns the new Vector3
  2804. */
  2805. clone(): Vector3;
  2806. /**
  2807. * Copies the given vector coordinates to the current Vector3 ones
  2808. * @param source defines the source Vector3
  2809. * @returns the current updated Vector3
  2810. */
  2811. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2812. /**
  2813. * Copies the given floats to the current Vector3 coordinates
  2814. * @param x defines the x coordinate of the operand
  2815. * @param y defines the y coordinate of the operand
  2816. * @param z defines the z coordinate of the operand
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFromFloats(x: number, y: number, z: number): 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. set(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given float to the current Vector3 coordinates
  2830. * @param v defines the x, y and z coordinates of the operand
  2831. * @returns the current updated Vector3
  2832. */
  2833. setAll(v: number): Vector3;
  2834. /**
  2835. * Get the clip factor between two vectors
  2836. * @param vector0 defines the first operand
  2837. * @param vector1 defines the second operand
  2838. * @param axis defines the axis to use
  2839. * @param size defines the size along the axis
  2840. * @returns the clip factor
  2841. */
  2842. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2843. /**
  2844. * Get angle between two vectors
  2845. * @param vector0 angle between vector0 and vector1
  2846. * @param vector1 angle between vector0 and vector1
  2847. * @param normal direction of the normal
  2848. * @return the angle between vector0 and vector1
  2849. */
  2850. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2851. /**
  2852. * Returns a new Vector3 set from the index "offset" of the given array
  2853. * @param array defines the source array
  2854. * @param offset defines the offset in the source array
  2855. * @returns the new Vector3
  2856. */
  2857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2860. * @param array defines the source array
  2861. * @param offset defines the offset in the source array
  2862. * @returns the new Vector3
  2863. * @deprecated Please use FromArray instead.
  2864. */
  2865. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2873. /**
  2874. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2875. * @param array defines the source array
  2876. * @param offset defines the offset in the source array
  2877. * @param result defines the Vector3 where to store the result
  2878. * @deprecated Please use FromArrayToRef instead.
  2879. */
  2880. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the given floats.
  2883. * @param x defines the x coordinate of the source
  2884. * @param y defines the y coordinate of the source
  2885. * @param z defines the z coordinate of the source
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2891. * @returns a new empty Vector3
  2892. */
  2893. static Zero(): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2896. * @returns a new unit Vector3
  2897. */
  2898. static One(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2901. * @returns a new up Vector3
  2902. */
  2903. static Up(): Vector3;
  2904. /**
  2905. * Gets a up Vector3 that must not be updated
  2906. */
  2907. static get UpReadOnly(): DeepImmutable<Vector3>;
  2908. /**
  2909. * Gets a zero Vector3 that must not be updated
  2910. */
  2911. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2912. /**
  2913. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2914. * @returns a new down Vector3
  2915. */
  2916. static Down(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2919. * @param rightHandedSystem is the scene right-handed (negative z)
  2920. * @returns a new forward Vector3
  2921. */
  2922. static Forward(rightHandedSystem?: boolean): Vector3;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2925. * @param rightHandedSystem is the scene right-handed (negative-z)
  2926. * @returns a new forward Vector3
  2927. */
  2928. static Backward(rightHandedSystem?: boolean): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2931. * @returns a new right Vector3
  2932. */
  2933. static Right(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2936. * @returns a new left Vector3
  2937. */
  2938. static Left(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2941. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @returns the transformed Vector3
  2945. */
  2946. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" coordinates 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. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2957. * This method computes tranformed coordinates only, not transformed direction vectors
  2958. * @param x define the x coordinate of the source vector
  2959. * @param y define the y coordinate of the source vector
  2960. * @param z define the z coordinate of the source vector
  2961. * @param transformation defines the transformation matrix
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2967. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @returns the new Vector3
  2971. */
  2972. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2973. /**
  2974. * Sets the given vector "result" 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. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param x define the x coordinate of the source vector
  2985. * @param y define the y coordinate of the source vector
  2986. * @param z define the z coordinate of the source vector
  2987. * @param transformation defines the transformation matrix
  2988. * @param result defines the Vector3 where to store the result
  2989. */
  2990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2991. /**
  2992. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2993. * @param value1 defines the first control point
  2994. * @param value2 defines the second control point
  2995. * @param value3 defines the third control point
  2996. * @param value4 defines the fourth control point
  2997. * @param amount defines the amount on the spline to use
  2998. * @returns the new Vector3
  2999. */
  3000. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3001. /**
  3002. * 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"
  3003. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3004. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3005. * @param value defines the current value
  3006. * @param min defines the lower range value
  3007. * @param max defines the upper range value
  3008. * @returns the new Vector3
  3009. */
  3010. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * 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"
  3013. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3014. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3015. * @param value defines the current value
  3016. * @param min defines the lower range value
  3017. * @param max defines the upper range value
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3021. /**
  3022. * Checks if a given vector is inside a specific range
  3023. * @param v defines the vector to test
  3024. * @param min defines the minimum range
  3025. * @param max defines the maximum range
  3026. */
  3027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3028. /**
  3029. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3030. * @param value1 defines the first control point
  3031. * @param tangent1 defines the first tangent vector
  3032. * @param value2 defines the second control point
  3033. * @param tangent2 defines the second tangent vector
  3034. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3035. * @returns the new Vector3
  3036. */
  3037. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3040. * @param start defines the start value
  3041. * @param end defines the end value
  3042. * @param amount max defines amount between both (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "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. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3054. /**
  3055. * Returns the dot product (float) between the vectors "left" and "right"
  3056. * @param left defines the left operand
  3057. * @param right defines the right operand
  3058. * @returns the dot product
  3059. */
  3060. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3061. /**
  3062. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3063. * The cross product is then orthogonal to both "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the cross product
  3067. */
  3068. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3069. /**
  3070. * Sets the given vector "result" with the cross product of "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. * @param result defines the Vector3 where to store the result
  3075. */
  3076. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3077. /**
  3078. * Returns a new Vector3 as the normalization of the given vector
  3079. * @param vector defines the Vector3 to normalize
  3080. * @returns the new Vector3
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3083. /**
  3084. * Sets the given vector "result" with the normalization of the given first vector
  3085. * @param vector defines the Vector3 to normalize
  3086. * @param result defines the Vector3 where to store the result
  3087. */
  3088. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3089. /**
  3090. * Project a Vector3 onto screen space
  3091. * @param vector defines the Vector3 to project
  3092. * @param world defines the world matrix to use
  3093. * @param transform defines the transform (view x projection) matrix to use
  3094. * @param viewport defines the screen viewport to use
  3095. * @returns the new Vector3
  3096. */
  3097. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3098. /** @hidden */
  3099. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3100. /**
  3101. * Unproject from screen space to object space
  3102. * @param source defines the screen space Vector3 to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param transform defines the transform (view x projection) matrix to use
  3107. * @returns the new Vector3
  3108. */
  3109. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3110. /**
  3111. * Unproject from screen space to object space
  3112. * @param source defines the screen space Vector3 to use
  3113. * @param viewportWidth defines the current width of the viewport
  3114. * @param viewportHeight defines the current height of the viewport
  3115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3116. * @param view defines the view matrix to use
  3117. * @param projection defines the projection matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param sourceX defines the screen space x coordinate to use
  3135. * @param sourceY defines the screen space y coordinate to use
  3136. * @param sourceZ defines the screen space z coordinate to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param view defines the view matrix to use
  3141. * @param projection defines the projection matrix to use
  3142. * @param result defines the Vector3 where to store the result
  3143. */
  3144. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3145. /**
  3146. * Gets the minimal coordinate values between two Vector3
  3147. * @param left defines the first operand
  3148. * @param right defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Gets the maximal coordinate values between two Vector3
  3154. * @param left defines the first operand
  3155. * @param right defines the second operand
  3156. * @returns the new Vector3
  3157. */
  3158. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Returns the distance between the vectors "value1" and "value2"
  3161. * @param value1 defines the first operand
  3162. * @param value2 defines the second operand
  3163. * @returns the distance
  3164. */
  3165. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3166. /**
  3167. * Returns the squared distance between the vectors "value1" and "value2"
  3168. * @param value1 defines the first operand
  3169. * @param value2 defines the second operand
  3170. * @returns the squared distance
  3171. */
  3172. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3173. /**
  3174. * Returns a new Vector3 located at the center between "value1" and "value2"
  3175. * @param value1 defines the first operand
  3176. * @param value2 defines the second operand
  3177. * @returns the new Vector3
  3178. */
  3179. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3180. /**
  3181. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3182. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3183. * to something in order to rotate it from its local system to the given target system
  3184. * Note: axis1, axis2 and axis3 are normalized during this operation
  3185. * @param axis1 defines the first axis
  3186. * @param axis2 defines the second axis
  3187. * @param axis3 defines the third axis
  3188. * @returns a new Vector3
  3189. */
  3190. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @param ref defines the Vector3 where to store the result
  3197. */
  3198. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3199. }
  3200. /**
  3201. * Vector4 class created for EulerAngle class conversion to Quaternion
  3202. */
  3203. export class Vector4 {
  3204. /** x value of the vector */
  3205. x: number;
  3206. /** y value of the vector */
  3207. y: number;
  3208. /** z value of the vector */
  3209. z: number;
  3210. /** w value of the vector */
  3211. w: number;
  3212. /**
  3213. * Creates a Vector4 object from the given floats.
  3214. * @param x x value of the vector
  3215. * @param y y value of the vector
  3216. * @param z z value of the vector
  3217. * @param w w value of the vector
  3218. */
  3219. constructor(
  3220. /** x value of the vector */
  3221. x: number,
  3222. /** y value of the vector */
  3223. y: number,
  3224. /** z value of the vector */
  3225. z: number,
  3226. /** w value of the vector */
  3227. w: number);
  3228. /**
  3229. * Returns the string with the Vector4 coordinates.
  3230. * @returns a string containing all the vector values
  3231. */
  3232. toString(): string;
  3233. /**
  3234. * Returns the string "Vector4".
  3235. * @returns "Vector4"
  3236. */
  3237. getClassName(): string;
  3238. /**
  3239. * Returns the Vector4 hash code.
  3240. * @returns a unique hash code
  3241. */
  3242. getHashCode(): number;
  3243. /**
  3244. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3245. * @returns the resulting array
  3246. */
  3247. asArray(): number[];
  3248. /**
  3249. * Populates the given array from the given index with the Vector4 coordinates.
  3250. * @param array array to populate
  3251. * @param index index of the array to start at (default: 0)
  3252. * @returns the Vector4.
  3253. */
  3254. toArray(array: FloatArray, index?: number): Vector4;
  3255. /**
  3256. * Adds the given vector to the current Vector4.
  3257. * @param otherVector the vector to add
  3258. * @returns the updated Vector4.
  3259. */
  3260. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3263. * @param otherVector the vector to add
  3264. * @returns the resulting vector
  3265. */
  3266. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3269. * @param otherVector the vector to add
  3270. * @param result the vector to store the result
  3271. * @returns the current Vector4.
  3272. */
  3273. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3274. /**
  3275. * Subtract in place the given vector from the current Vector4.
  3276. * @param otherVector the vector to subtract
  3277. * @returns the updated Vector4.
  3278. */
  3279. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3282. * @param otherVector the vector to add
  3283. * @returns the new vector with the result
  3284. */
  3285. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3288. * @param otherVector the vector to subtract
  3289. * @param result the vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. */
  3296. /**
  3297. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3298. * @param x value to subtract
  3299. * @param y value to subtract
  3300. * @param z value to subtract
  3301. * @param w value to subtract
  3302. * @returns new vector containing the result
  3303. */
  3304. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3305. /**
  3306. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3307. * @param x value to subtract
  3308. * @param y value to subtract
  3309. * @param z value to subtract
  3310. * @param w value to subtract
  3311. * @param result the vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3315. /**
  3316. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3317. * @returns a new vector with the negated values
  3318. */
  3319. negate(): Vector4;
  3320. /**
  3321. * Negate this vector in place
  3322. * @returns this
  3323. */
  3324. negateInPlace(): Vector4;
  3325. /**
  3326. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3327. * @param result defines the Vector3 object where to store the result
  3328. * @returns the current Vector4
  3329. */
  3330. negateToRef(result: Vector4): Vector4;
  3331. /**
  3332. * Multiplies the current Vector4 coordinates by scale (float).
  3333. * @param scale the number to scale with
  3334. * @returns the updated Vector4.
  3335. */
  3336. scaleInPlace(scale: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3339. * @param scale the number to scale with
  3340. * @returns a new vector with the result
  3341. */
  3342. scale(scale: number): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3345. * @param scale the number to scale with
  3346. * @param result a vector to store the result in
  3347. * @returns the current Vector4.
  3348. */
  3349. scaleToRef(scale: number, result: Vector4): Vector4;
  3350. /**
  3351. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3352. * @param scale defines the scale factor
  3353. * @param result defines the Vector4 object where to store the result
  3354. * @returns the unmodified current Vector4
  3355. */
  3356. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3357. /**
  3358. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3359. * @param otherVector the vector to compare against
  3360. * @returns true if they are equal
  3361. */
  3362. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3363. /**
  3364. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3365. * @param otherVector vector to compare against
  3366. * @param epsilon (Default: very small number)
  3367. * @returns true if they are equal
  3368. */
  3369. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3370. /**
  3371. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3372. * @param x x value to compare against
  3373. * @param y y value to compare against
  3374. * @param z z value to compare against
  3375. * @param w w value to compare against
  3376. * @returns true if equal
  3377. */
  3378. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3379. /**
  3380. * Multiplies in place the current Vector4 by the given one.
  3381. * @param otherVector vector to multiple with
  3382. * @returns the updated Vector4.
  3383. */
  3384. multiplyInPlace(otherVector: Vector4): Vector4;
  3385. /**
  3386. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3387. * @param otherVector vector to multiple with
  3388. * @returns resulting new vector
  3389. */
  3390. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3393. * @param otherVector vector to multiple with
  3394. * @param result vector to store the result
  3395. * @returns the current Vector4.
  3396. */
  3397. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3400. * @param x x value multiply with
  3401. * @param y y value multiply with
  3402. * @param z z value multiply with
  3403. * @param w w value multiply with
  3404. * @returns resulting new vector
  3405. */
  3406. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3407. /**
  3408. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3409. * @param otherVector vector to devide with
  3410. * @returns resulting new vector
  3411. */
  3412. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3415. * @param otherVector vector to devide with
  3416. * @param result vector to store the result
  3417. * @returns the current Vector4.
  3418. */
  3419. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3420. /**
  3421. * Divides the current Vector3 coordinates by the given ones.
  3422. * @param otherVector vector to devide with
  3423. * @returns the updated Vector3.
  3424. */
  3425. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3428. * @param other defines the second operand
  3429. * @returns the current updated Vector4
  3430. */
  3431. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3434. * @param other defines the second operand
  3435. * @returns the current updated Vector4
  3436. */
  3437. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Gets a new Vector4 from current Vector4 floored values
  3440. * @returns a new Vector4
  3441. */
  3442. floor(): Vector4;
  3443. /**
  3444. * Gets a new Vector4 from current Vector3 floored values
  3445. * @returns a new Vector4
  3446. */
  3447. fract(): Vector4;
  3448. /**
  3449. * Returns the Vector4 length (float).
  3450. * @returns the length
  3451. */
  3452. length(): number;
  3453. /**
  3454. * Returns the Vector4 squared length (float).
  3455. * @returns the length squared
  3456. */
  3457. lengthSquared(): number;
  3458. /**
  3459. * Normalizes in place the Vector4.
  3460. * @returns the updated Vector4.
  3461. */
  3462. normalize(): Vector4;
  3463. /**
  3464. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3465. * @returns this converted to a new vector3
  3466. */
  3467. toVector3(): Vector3;
  3468. /**
  3469. * Returns a new Vector4 copied from the current one.
  3470. * @returns the new cloned vector
  3471. */
  3472. clone(): Vector4;
  3473. /**
  3474. * Updates the current Vector4 with the given one coordinates.
  3475. * @param source the source vector to copy from
  3476. * @returns the updated Vector4.
  3477. */
  3478. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the current Vector4 coordinates with the given floats.
  3481. * @param x float to copy from
  3482. * @param y float to copy from
  3483. * @param z float to copy from
  3484. * @param w float to copy from
  3485. * @returns the updated Vector4.
  3486. */
  3487. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3488. /**
  3489. * Updates the current Vector4 coordinates with the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @returns the updated Vector4.
  3495. */
  3496. set(x: number, y: number, z: number, w: number): Vector4;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y, z and w coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set from the starting index of the given array.
  3505. * @param array the array to pull values from
  3506. * @param offset the offset into the array to start at
  3507. * @returns the new vector
  3508. */
  3509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3510. /**
  3511. * Updates the given vector "result" from the starting index of the given array.
  3512. * @param array the array to pull values from
  3513. * @param offset the offset into the array to start at
  3514. * @param result the vector to store the result in
  3515. */
  3516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3517. /**
  3518. * Updates the given vector "result" from the starting index of the given Float32Array.
  3519. * @param array the array to pull values from
  3520. * @param offset the offset into the array to start at
  3521. * @param result the vector to store the result in
  3522. */
  3523. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3524. /**
  3525. * Updates the given vector "result" coordinates from the given floats.
  3526. * @param x float to set from
  3527. * @param y float to set from
  3528. * @param z float to set from
  3529. * @param w float to set from
  3530. * @param result the vector to the floats in
  3531. */
  3532. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3533. /**
  3534. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3535. * @returns the new vector
  3536. */
  3537. static Zero(): Vector4;
  3538. /**
  3539. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3540. * @returns the new vector
  3541. */
  3542. static One(): Vector4;
  3543. /**
  3544. * Returns a new normalized Vector4 from the given one.
  3545. * @param vector the vector to normalize
  3546. * @returns the vector
  3547. */
  3548. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3549. /**
  3550. * Updates the given vector "result" from the normalization of the given one.
  3551. * @param vector the vector to normalize
  3552. * @param result the vector to store the result in
  3553. */
  3554. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3555. /**
  3556. * Returns a vector with the minimum values from the left and right vectors
  3557. * @param left left vector to minimize
  3558. * @param right right vector to minimize
  3559. * @returns a new vector with the minimum of the left and right vector values
  3560. */
  3561. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a vector with the maximum values from the left and right vectors
  3564. * @param left left vector to maximize
  3565. * @param right right vector to maximize
  3566. * @returns a new vector with the maximum of the left and right vector values
  3567. */
  3568. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3569. /**
  3570. * Returns the distance (float) between the vectors "value1" and "value2".
  3571. * @param value1 value to calulate the distance between
  3572. * @param value2 value to calulate the distance between
  3573. * @return the distance between the two vectors
  3574. */
  3575. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3576. /**
  3577. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3578. * @param value1 value to calulate the distance between
  3579. * @param value2 value to calulate the distance between
  3580. * @return the distance between the two vectors squared
  3581. */
  3582. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3583. /**
  3584. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3585. * @param value1 value to calulate the center between
  3586. * @param value2 value to calulate the center between
  3587. * @return the center between the two vectors
  3588. */
  3589. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3592. * This methods computes transformed normalized direction vectors only.
  3593. * @param vector the vector to transform
  3594. * @param transformation the transformation matrix to apply
  3595. * @returns the new vector
  3596. */
  3597. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3598. /**
  3599. * Sets the given vector "result" 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. * @param result the vector to store the result in
  3604. */
  3605. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param x value to transform
  3610. * @param y value to transform
  3611. * @param z value to transform
  3612. * @param w value to transform
  3613. * @param transformation the transformation matrix to apply
  3614. * @param result the vector to store the results in
  3615. */
  3616. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3617. /**
  3618. * Creates a new Vector4 from a Vector3
  3619. * @param source defines the source data
  3620. * @param w defines the 4th component (default is 0)
  3621. * @returns a new Vector4
  3622. */
  3623. static FromVector3(source: Vector3, w?: number): Vector4;
  3624. }
  3625. /**
  3626. * Class used to store quaternion data
  3627. * @see https://en.wikipedia.org/wiki/Quaternion
  3628. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3629. */
  3630. export class Quaternion {
  3631. /** defines the first component (0 by default) */
  3632. x: number;
  3633. /** defines the second component (0 by default) */
  3634. y: number;
  3635. /** defines the third component (0 by default) */
  3636. z: number;
  3637. /** defines the fourth component (1.0 by default) */
  3638. w: number;
  3639. /**
  3640. * Creates a new Quaternion from the given floats
  3641. * @param x defines the first component (0 by default)
  3642. * @param y defines the second component (0 by default)
  3643. * @param z defines the third component (0 by default)
  3644. * @param w defines the fourth component (1.0 by default)
  3645. */
  3646. constructor(
  3647. /** defines the first component (0 by default) */
  3648. x?: number,
  3649. /** defines the second component (0 by default) */
  3650. y?: number,
  3651. /** defines the third component (0 by default) */
  3652. z?: number,
  3653. /** defines the fourth component (1.0 by default) */
  3654. w?: number);
  3655. /**
  3656. * Gets a string representation for the current quaternion
  3657. * @returns a string with the Quaternion coordinates
  3658. */
  3659. toString(): string;
  3660. /**
  3661. * Gets the class name of the quaternion
  3662. * @returns the string "Quaternion"
  3663. */
  3664. getClassName(): string;
  3665. /**
  3666. * Gets a hash code for this quaternion
  3667. * @returns the quaternion hash code
  3668. */
  3669. getHashCode(): number;
  3670. /**
  3671. * Copy the quaternion to an array
  3672. * @returns a new array populated with 4 elements from the quaternion coordinates
  3673. */
  3674. asArray(): number[];
  3675. /**
  3676. * Check if two quaternions are equals
  3677. * @param otherQuaternion defines the second operand
  3678. * @return true if the current quaternion and the given one coordinates are strictly equals
  3679. */
  3680. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3683. * @param otherQuaternion defines the other quaternion
  3684. * @param epsilon defines the minimal distance to consider equality
  3685. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3686. */
  3687. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3688. /**
  3689. * Clone the current quaternion
  3690. * @returns a new quaternion copied from the current one
  3691. */
  3692. clone(): Quaternion;
  3693. /**
  3694. * Copy a quaternion to the current one
  3695. * @param other defines the other quaternion
  3696. * @returns the updated current quaternion
  3697. */
  3698. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Updates the current quaternion with the given float coordinates
  3701. * @param x defines the x coordinate
  3702. * @param y defines the y coordinate
  3703. * @param z defines the z coordinate
  3704. * @param w defines the w coordinate
  3705. * @returns the updated current quaternion
  3706. */
  3707. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given float coordinates
  3710. * @param x defines the x coordinate
  3711. * @param y defines the y coordinate
  3712. * @param z defines the z coordinate
  3713. * @param w defines the w coordinate
  3714. * @returns the updated current quaternion
  3715. */
  3716. set(x: number, y: number, z: number, w: number): Quaternion;
  3717. /**
  3718. * Adds two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3721. */
  3722. add(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Add a quaternion to the current one
  3725. * @param other defines the quaternion to add
  3726. * @returns the current quaternion
  3727. */
  3728. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3729. /**
  3730. * Subtract two quaternions
  3731. * @param other defines the second operand
  3732. * @returns a new quaternion as the subtraction result of the given one from the current one
  3733. */
  3734. subtract(other: Quaternion): Quaternion;
  3735. /**
  3736. * Multiplies the current quaternion by a scale factor
  3737. * @param value defines the scale factor
  3738. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3739. */
  3740. scale(value: number): Quaternion;
  3741. /**
  3742. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3743. * @param scale defines the scale factor
  3744. * @param result defines the Quaternion object where to store the result
  3745. * @returns the unmodified current quaternion
  3746. */
  3747. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3748. /**
  3749. * Multiplies in place the current quaternion by a scale factor
  3750. * @param value defines the scale factor
  3751. * @returns the current modified quaternion
  3752. */
  3753. scaleInPlace(value: number): Quaternion;
  3754. /**
  3755. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3756. * @param scale defines the scale factor
  3757. * @param result defines the Quaternion object where to store the result
  3758. * @returns the unmodified current quaternion
  3759. */
  3760. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3761. /**
  3762. * Multiplies two quaternions
  3763. * @param q1 defines the second operand
  3764. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3765. */
  3766. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3767. /**
  3768. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3769. * @param q1 defines the second operand
  3770. * @param result defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3774. /**
  3775. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @returns the currentupdated quaternion
  3778. */
  3779. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3780. /**
  3781. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3782. * @param ref defines the target quaternion
  3783. * @returns the current quaternion
  3784. */
  3785. conjugateToRef(ref: Quaternion): Quaternion;
  3786. /**
  3787. * Conjugates in place (1-q) the current quaternion
  3788. * @returns the current updated quaternion
  3789. */
  3790. conjugateInPlace(): Quaternion;
  3791. /**
  3792. * Conjugates in place (1-q) the current quaternion
  3793. * @returns a new quaternion
  3794. */
  3795. conjugate(): Quaternion;
  3796. /**
  3797. * Gets length of current quaternion
  3798. * @returns the quaternion length (float)
  3799. */
  3800. length(): number;
  3801. /**
  3802. * Normalize in place the current quaternion
  3803. * @returns the current updated quaternion
  3804. */
  3805. normalize(): Quaternion;
  3806. /**
  3807. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3808. * @param order is a reserved parameter and is ignore for now
  3809. * @returns a new Vector3 containing the Euler angles
  3810. */
  3811. toEulerAngles(order?: string): Vector3;
  3812. /**
  3813. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3814. * @param result defines the vector which will be filled with the Euler angles
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns the current unchanged quaternion
  3817. */
  3818. toEulerAnglesToRef(result: Vector3): Quaternion;
  3819. /**
  3820. * Updates the given rotation matrix with the current quaternion values
  3821. * @param result defines the target matrix
  3822. * @returns the current unchanged quaternion
  3823. */
  3824. toRotationMatrix(result: Matrix): Quaternion;
  3825. /**
  3826. * Updates the current quaternion from the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @returns the current updated quaternion
  3829. */
  3830. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3831. /**
  3832. * Creates a new quaternion from a rotation matrix
  3833. * @param matrix defines the source matrix
  3834. * @returns a new quaternion created from the given rotation matrix values
  3835. */
  3836. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3837. /**
  3838. * Updates the given quaternion with the given rotation matrix values
  3839. * @param matrix defines the source matrix
  3840. * @param result defines the target quaternion
  3841. */
  3842. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3843. /**
  3844. * Returns the dot product (float) between the quaternions "left" and "right"
  3845. * @param left defines the left operand
  3846. * @param right defines the right operand
  3847. * @returns the dot product
  3848. */
  3849. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3850. /**
  3851. * Checks if the two quaternions are close to each other
  3852. * @param quat0 defines the first quaternion to check
  3853. * @param quat1 defines the second quaternion to check
  3854. * @returns true if the two quaternions are close to each other
  3855. */
  3856. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates an empty quaternion
  3859. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3860. */
  3861. static Zero(): Quaternion;
  3862. /**
  3863. * Inverse a given quaternion
  3864. * @param q defines the source quaternion
  3865. * @returns a new quaternion as the inverted current quaternion
  3866. */
  3867. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Inverse a given quaternion
  3870. * @param q defines the source quaternion
  3871. * @param result the quaternion the result will be stored in
  3872. * @returns the result quaternion
  3873. */
  3874. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3875. /**
  3876. * Creates an identity quaternion
  3877. * @returns the identity quaternion
  3878. */
  3879. static Identity(): Quaternion;
  3880. /**
  3881. * Gets a boolean indicating if the given quaternion is identity
  3882. * @param quaternion defines the quaternion to check
  3883. * @returns true if the quaternion is identity
  3884. */
  3885. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3886. /**
  3887. * Creates a quaternion from a rotation around an axis
  3888. * @param axis defines the axis to use
  3889. * @param angle defines the angle to use
  3890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3891. */
  3892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3893. /**
  3894. * Creates a rotation around an axis and stores it into the given quaternion
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @param result defines the target quaternion
  3898. * @returns the target quaternion
  3899. */
  3900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3901. /**
  3902. * Creates a new quaternion from data stored into an array
  3903. * @param array defines the data source
  3904. * @param offset defines the offset in the source array where the data starts
  3905. * @returns a new quaternion
  3906. */
  3907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3908. /**
  3909. * Updates the given quaternion "result" from the starting index of the given array.
  3910. * @param array the array to pull values from
  3911. * @param offset the offset into the array to start at
  3912. * @param result the quaternion to store the result in
  3913. */
  3914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3915. /**
  3916. * Create a quaternion from Euler rotation angles
  3917. * @param x Pitch
  3918. * @param y Yaw
  3919. * @param z Roll
  3920. * @returns the new Quaternion
  3921. */
  3922. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3923. /**
  3924. * Updates a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @param result the quaternion to store the result
  3929. * @returns the updated quaternion
  3930. */
  3931. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3932. /**
  3933. * Create a quaternion from Euler rotation vector
  3934. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3935. * @returns the new Quaternion
  3936. */
  3937. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3938. /**
  3939. * Updates a quaternion from Euler rotation vector
  3940. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3941. * @param result the quaternion to store the result
  3942. * @returns the updated quaternion
  3943. */
  3944. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3945. /**
  3946. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3947. * @param yaw defines the rotation around Y axis
  3948. * @param pitch defines the rotation around X axis
  3949. * @param roll defines the rotation around Z axis
  3950. * @returns the new quaternion
  3951. */
  3952. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3953. /**
  3954. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  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. * @param result defines the target quaternion
  3959. */
  3960. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3961. /**
  3962. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3963. * @param alpha defines the rotation around first axis
  3964. * @param beta defines the rotation around second axis
  3965. * @param gamma defines the rotation around third axis
  3966. * @returns the new quaternion
  3967. */
  3968. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  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. * @param result defines the target quaternion
  3975. */
  3976. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3977. /**
  3978. * 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)
  3979. * @param axis1 defines the first axis
  3980. * @param axis2 defines the second axis
  3981. * @param axis3 defines the third axis
  3982. * @returns the new quaternion
  3983. */
  3984. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3985. /**
  3986. * 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
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @param ref defines the target quaternion
  3991. */
  3992. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3993. /**
  3994. * Interpolates between two quaternions
  3995. * @param left defines first quaternion
  3996. * @param right defines second quaternion
  3997. * @param amount defines the gradient to use
  3998. * @returns the new interpolated quaternion
  3999. */
  4000. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4001. /**
  4002. * Interpolates between two quaternions and stores it into a target quaternion
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @param result defines the target quaternion
  4007. */
  4008. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4009. /**
  4010. * Interpolate between two quaternions using Hermite interpolation
  4011. * @param value1 defines first quaternion
  4012. * @param tangent1 defines the incoming tangent
  4013. * @param value2 defines second quaternion
  4014. * @param tangent2 defines the outgoing tangent
  4015. * @param amount defines the target quaternion
  4016. * @returns the new interpolated quaternion
  4017. */
  4018. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4019. }
  4020. /**
  4021. * Class used to store matrix data (4x4)
  4022. */
  4023. export class Matrix {
  4024. private static _updateFlagSeed;
  4025. private static _identityReadOnly;
  4026. private _isIdentity;
  4027. private _isIdentityDirty;
  4028. private _isIdentity3x2;
  4029. private _isIdentity3x2Dirty;
  4030. /**
  4031. * Gets the update flag of the matrix which is an unique number for the matrix.
  4032. * It will be incremented every time the matrix data change.
  4033. * You can use it to speed the comparison between two versions of the same matrix.
  4034. */
  4035. updateFlag: number;
  4036. private readonly _m;
  4037. /**
  4038. * Gets the internal data of the matrix
  4039. */
  4040. get m(): DeepImmutable<Float32Array>;
  4041. /** @hidden */
  4042. _markAsUpdated(): void;
  4043. /** @hidden */
  4044. private _updateIdentityStatus;
  4045. /**
  4046. * Creates an empty matrix (filled with zeros)
  4047. */
  4048. constructor();
  4049. /**
  4050. * Check if the current matrix is identity
  4051. * @returns true is the matrix is the identity matrix
  4052. */
  4053. isIdentity(): boolean;
  4054. /**
  4055. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4056. * @returns true is the matrix is the identity matrix
  4057. */
  4058. isIdentityAs3x2(): boolean;
  4059. /**
  4060. * Gets the determinant of the matrix
  4061. * @returns the matrix determinant
  4062. */
  4063. determinant(): number;
  4064. /**
  4065. * Returns the matrix as a Float32Array
  4066. * @returns the matrix underlying array
  4067. */
  4068. toArray(): DeepImmutable<Float32Array>;
  4069. /**
  4070. * Returns the matrix as a Float32Array
  4071. * @returns the matrix underlying array.
  4072. */
  4073. asArray(): DeepImmutable<Float32Array>;
  4074. /**
  4075. * Inverts the current matrix in place
  4076. * @returns the current inverted matrix
  4077. */
  4078. invert(): Matrix;
  4079. /**
  4080. * Sets all the matrix elements to zero
  4081. * @returns the current matrix
  4082. */
  4083. reset(): Matrix;
  4084. /**
  4085. * Adds the current matrix with a second one
  4086. * @param other defines the matrix to add
  4087. * @returns a new matrix as the addition of the current matrix and the given one
  4088. */
  4089. add(other: DeepImmutable<Matrix>): Matrix;
  4090. /**
  4091. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4092. * @param other defines the matrix to add
  4093. * @param result defines the target matrix
  4094. * @returns the current matrix
  4095. */
  4096. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4097. /**
  4098. * Adds in place the given matrix to the current matrix
  4099. * @param other defines the second operand
  4100. * @returns the current updated matrix
  4101. */
  4102. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4103. /**
  4104. * Sets the given matrix to the current inverted Matrix
  4105. * @param other defines the target matrix
  4106. * @returns the unmodified current matrix
  4107. */
  4108. invertToRef(other: Matrix): Matrix;
  4109. /**
  4110. * add a value at the specified position in the current Matrix
  4111. * @param index the index of the value within the matrix. between 0 and 15.
  4112. * @param value the value to be added
  4113. * @returns the current updated matrix
  4114. */
  4115. addAtIndex(index: number, value: number): Matrix;
  4116. /**
  4117. * mutiply the specified position in the current Matrix by a value
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. multiplyAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * Inserts the translation vector (using 3 floats) in the current matrix
  4125. * @param x defines the 1st component of the translation
  4126. * @param y defines the 2nd component of the translation
  4127. * @param z defines the 3rd component of the translation
  4128. * @returns the current updated matrix
  4129. */
  4130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4131. /**
  4132. * Adds 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. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Inserts the translation vector in the current matrix
  4141. * @param vector3 defines the translation to insert
  4142. * @returns the current updated matrix
  4143. */
  4144. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4145. /**
  4146. * Gets the translation value of the current matrix
  4147. * @returns a new Vector3 as the extracted translation from the matrix
  4148. */
  4149. getTranslation(): Vector3;
  4150. /**
  4151. * Fill a Vector3 with the extracted translation from the matrix
  4152. * @param result defines the Vector3 where to store the translation
  4153. * @returns the current matrix
  4154. */
  4155. getTranslationToRef(result: Vector3): Matrix;
  4156. /**
  4157. * Remove rotation and scaling part from the matrix
  4158. * @returns the updated matrix
  4159. */
  4160. removeRotationAndScaling(): Matrix;
  4161. /**
  4162. * Multiply two matrices
  4163. * @param other defines the second operand
  4164. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4165. */
  4166. multiply(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Copy the current matrix from the given one
  4169. * @param other defines the source matrix
  4170. * @returns the current updated matrix
  4171. */
  4172. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Populates the given array from the starting index with the current matrix values
  4175. * @param array defines the target array
  4176. * @param offset defines the offset in the target array where to start storing values
  4177. * @returns the current matrix
  4178. */
  4179. copyToArray(array: Float32Array, offset?: number): Matrix;
  4180. /**
  4181. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4182. * @param other defines the second operand
  4183. * @param result defines the matrix where to store the multiplication
  4184. * @returns the current matrix
  4185. */
  4186. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4187. /**
  4188. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the array where to store the multiplication
  4191. * @param offset defines the offset in the target array where to start storing values
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4195. /**
  4196. * Check equality between this matrix and a second one
  4197. * @param value defines the second matrix to compare
  4198. * @returns true is the current matrix and the given one values are strictly equal
  4199. */
  4200. equals(value: DeepImmutable<Matrix>): boolean;
  4201. /**
  4202. * Clone the current matrix
  4203. * @returns a new matrix from the current matrix
  4204. */
  4205. clone(): Matrix;
  4206. /**
  4207. * Returns the name of the current matrix class
  4208. * @returns the string "Matrix"
  4209. */
  4210. getClassName(): string;
  4211. /**
  4212. * Gets the hash code of the current matrix
  4213. * @returns the hash code
  4214. */
  4215. getHashCode(): number;
  4216. /**
  4217. * Decomposes the current Matrix into a translation, rotation and scaling components
  4218. * @param scale defines the scale vector3 given as a reference to update
  4219. * @param rotation defines the rotation quaternion given as a reference to update
  4220. * @param translation defines the translation vector3 given as a reference to update
  4221. * @returns true if operation was successful
  4222. */
  4223. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4224. /**
  4225. * Gets specific row of the matrix
  4226. * @param index defines the number of the row to get
  4227. * @returns the index-th row of the current matrix as a new Vector4
  4228. */
  4229. getRow(index: number): Nullable<Vector4>;
  4230. /**
  4231. * Sets the index-th row of the current matrix to the vector4 values
  4232. * @param index defines the number of the row to set
  4233. * @param row defines the target vector4
  4234. * @returns the updated current matrix
  4235. */
  4236. setRow(index: number, row: Vector4): Matrix;
  4237. /**
  4238. * Compute the transpose of the matrix
  4239. * @returns the new transposed matrix
  4240. */
  4241. transpose(): Matrix;
  4242. /**
  4243. * Compute the transpose of the matrix and store it in a given matrix
  4244. * @param result defines the target matrix
  4245. * @returns the current matrix
  4246. */
  4247. transposeToRef(result: Matrix): Matrix;
  4248. /**
  4249. * Sets the index-th row of the current matrix with the given 4 x float values
  4250. * @param index defines the row index
  4251. * @param x defines the x component to set
  4252. * @param y defines the y component to set
  4253. * @param z defines the z component to set
  4254. * @param w defines the w component to set
  4255. * @returns the updated current matrix
  4256. */
  4257. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4258. /**
  4259. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4260. * @param scale defines the scale factor
  4261. * @returns a new matrix
  4262. */
  4263. scale(scale: number): Matrix;
  4264. /**
  4265. * Scale the current matrix values by a factor to a given result matrix
  4266. * @param scale defines the scale factor
  4267. * @param result defines the matrix to store the result
  4268. * @returns the current matrix
  4269. */
  4270. scaleToRef(scale: number, result: Matrix): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor and add the result to a given matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the Matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4280. * @param ref matrix to store the result
  4281. */
  4282. toNormalMatrix(ref: Matrix): void;
  4283. /**
  4284. * Gets only rotation part of the current matrix
  4285. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4286. */
  4287. getRotationMatrix(): Matrix;
  4288. /**
  4289. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4290. * @param result defines the target matrix to store data to
  4291. * @returns the current matrix
  4292. */
  4293. getRotationMatrixToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Toggles model matrix from being right handed to left handed in place and vice versa
  4296. */
  4297. toggleModelMatrixHandInPlace(): void;
  4298. /**
  4299. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4300. */
  4301. toggleProjectionMatrixHandInPlace(): void;
  4302. /**
  4303. * Creates a matrix from an array
  4304. * @param array defines the source array
  4305. * @param offset defines an offset in the source array
  4306. * @returns a new Matrix set from the starting index of the given array
  4307. */
  4308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4309. /**
  4310. * Copy the content of an array into a given matrix
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @param result defines the target matrix
  4314. */
  4315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4316. /**
  4317. * Stores an array into a matrix after having multiplied each component by a given factor
  4318. * @param array defines the source array
  4319. * @param offset defines the offset in the source array
  4320. * @param scale defines the scaling factor
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4324. /**
  4325. * Gets an identity matrix that must not be updated
  4326. */
  4327. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4328. /**
  4329. * Stores a list of values (16) inside a given matrix
  4330. * @param initialM11 defines 1st value of 1st row
  4331. * @param initialM12 defines 2nd value of 1st row
  4332. * @param initialM13 defines 3rd value of 1st row
  4333. * @param initialM14 defines 4th value of 1st row
  4334. * @param initialM21 defines 1st value of 2nd row
  4335. * @param initialM22 defines 2nd value of 2nd row
  4336. * @param initialM23 defines 3rd value of 2nd row
  4337. * @param initialM24 defines 4th value of 2nd row
  4338. * @param initialM31 defines 1st value of 3rd row
  4339. * @param initialM32 defines 2nd value of 3rd row
  4340. * @param initialM33 defines 3rd value of 3rd row
  4341. * @param initialM34 defines 4th value of 3rd row
  4342. * @param initialM41 defines 1st value of 4th row
  4343. * @param initialM42 defines 2nd value of 4th row
  4344. * @param initialM43 defines 3rd value of 4th row
  4345. * @param initialM44 defines 4th value of 4th row
  4346. * @param result defines the target matrix
  4347. */
  4348. 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;
  4349. /**
  4350. * Creates new matrix from a list of values (16)
  4351. * @param initialM11 defines 1st value of 1st row
  4352. * @param initialM12 defines 2nd value of 1st row
  4353. * @param initialM13 defines 3rd value of 1st row
  4354. * @param initialM14 defines 4th value of 1st row
  4355. * @param initialM21 defines 1st value of 2nd row
  4356. * @param initialM22 defines 2nd value of 2nd row
  4357. * @param initialM23 defines 3rd value of 2nd row
  4358. * @param initialM24 defines 4th value of 2nd row
  4359. * @param initialM31 defines 1st value of 3rd row
  4360. * @param initialM32 defines 2nd value of 3rd row
  4361. * @param initialM33 defines 3rd value of 3rd row
  4362. * @param initialM34 defines 4th value of 3rd row
  4363. * @param initialM41 defines 1st value of 4th row
  4364. * @param initialM42 defines 2nd value of 4th row
  4365. * @param initialM43 defines 3rd value of 4th row
  4366. * @param initialM44 defines 4th value of 4th row
  4367. * @returns the new matrix
  4368. */
  4369. 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;
  4370. /**
  4371. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4372. * @param scale defines the scale vector3
  4373. * @param rotation defines the rotation quaternion
  4374. * @param translation defines the translation vector3
  4375. * @returns a new matrix
  4376. */
  4377. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * Sets a matrix to a value 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. * @param result defines the target matrix
  4384. */
  4385. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * Creates a new identity matrix
  4388. * @returns a new identity matrix
  4389. */
  4390. static Identity(): Matrix;
  4391. /**
  4392. * Creates a new identity matrix and stores the result in a given matrix
  4393. * @param result defines the target matrix
  4394. */
  4395. static IdentityToRef(result: Matrix): void;
  4396. /**
  4397. * Creates a new zero matrix
  4398. * @returns a new zero matrix
  4399. */
  4400. static Zero(): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis
  4403. * @param angle defines the angle (in radians) to use
  4404. * @return the new matrix
  4405. */
  4406. static RotationX(angle: number): Matrix;
  4407. /**
  4408. * Creates a new matrix as the invert of a given matrix
  4409. * @param source defines the source matrix
  4410. * @returns the new matrix
  4411. */
  4412. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationXToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Y axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationY(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationYToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the Z axis
  4433. * @param angle defines the angle (in radians) to use
  4434. * @return the new matrix
  4435. */
  4436. static RotationZ(angle: number): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationZToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the given axis
  4445. * @param axis defines the axis to use
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @param result defines the target matrix
  4455. */
  4456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4457. /**
  4458. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4459. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4460. * @param from defines the vector to align
  4461. * @param to defines the vector to align to
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4465. /**
  4466. * Creates a rotation matrix
  4467. * @param yaw defines the yaw angle in radians (Y axis)
  4468. * @param pitch defines the pitch angle in radians (X axis)
  4469. * @param roll defines the roll angle in radians (X axis)
  4470. * @returns the new rotation matrix
  4471. */
  4472. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4473. /**
  4474. * Creates a rotation matrix and stores it in a given 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. * @param result defines the target matrix
  4479. */
  4480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4481. /**
  4482. * Creates a scaling matrix
  4483. * @param x defines the scale factor on X axis
  4484. * @param y defines the scale factor on Y axis
  4485. * @param z defines the scale factor on Z axis
  4486. * @returns the new matrix
  4487. */
  4488. static Scaling(x: number, y: number, z: number): Matrix;
  4489. /**
  4490. * Creates a scaling matrix and stores it in a given 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. * @param result defines the target matrix
  4495. */
  4496. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4497. /**
  4498. * Creates a translation matrix
  4499. * @param x defines the translation on X axis
  4500. * @param y defines the translation on Y axis
  4501. * @param z defines the translationon Z axis
  4502. * @returns the new matrix
  4503. */
  4504. static Translation(x: number, y: number, z: number): Matrix;
  4505. /**
  4506. * Creates a translation matrix and stores it in a given 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. * @param result defines the target matrix
  4511. */
  4512. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4513. /**
  4514. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4515. * @param startValue defines the start value
  4516. * @param endValue defines the end value
  4517. * @param gradient defines the gradient factor
  4518. * @returns the new matrix
  4519. */
  4520. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4521. /**
  4522. * Set the given matrix "result" as 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. * @param result defines the Matrix object where to store data
  4527. */
  4528. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4529. /**
  4530. * Builds a new matrix whose values are computed by:
  4531. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4532. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4533. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4534. * @param startValue defines the first matrix
  4535. * @param endValue defines the second matrix
  4536. * @param gradient defines the gradient between the two matrices
  4537. * @returns the new matrix
  4538. */
  4539. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4540. /**
  4541. * Update a matrix to values which are computed by:
  4542. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4543. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4544. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4545. * @param startValue defines the first matrix
  4546. * @param endValue defines the second matrix
  4547. * @param gradient defines the gradient between the two matrices
  4548. * @param result defines the target matrix
  4549. */
  4550. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4551. /**
  4552. * 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"
  4553. * This function works in left handed mode
  4554. * @param eye defines the final position of the entity
  4555. * @param target defines where the entity should look at
  4556. * @param up defines the up vector for the entity
  4557. * @returns the new matrix
  4558. */
  4559. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4560. /**
  4561. * 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".
  4562. * This function works in left handed mode
  4563. * @param eye defines the final position of the entity
  4564. * @param target defines where the entity should look at
  4565. * @param up defines the up vector for the entity
  4566. * @param result defines the target matrix
  4567. */
  4568. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * 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"
  4571. * This function works in right handed mode
  4572. * @param eye defines the final position of the entity
  4573. * @param target defines where the entity should look at
  4574. * @param up defines the up vector for the entity
  4575. * @returns the new matrix
  4576. */
  4577. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * 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".
  4580. * This function works in right handed mode
  4581. * @param eye defines the final position of the entity
  4582. * @param target defines where the entity should look at
  4583. * @param up defines the up vector for the entity
  4584. * @param result defines the target matrix
  4585. */
  4586. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Create a left-handed orthographic projection matrix
  4589. * @param width defines the viewport width
  4590. * @param height defines the viewport height
  4591. * @param znear defines the near clip plane
  4592. * @param zfar defines the far clip plane
  4593. * @returns a new matrix as a left-handed orthographic projection matrix
  4594. */
  4595. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4596. /**
  4597. * Store a left-handed orthographic projection to a given matrix
  4598. * @param width defines the viewport width
  4599. * @param height defines the viewport height
  4600. * @param znear defines the near clip plane
  4601. * @param zfar defines the far clip plane
  4602. * @param result defines the target matrix
  4603. */
  4604. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4605. /**
  4606. * Create a left-handed orthographic projection matrix
  4607. * @param left defines the viewport left coordinate
  4608. * @param right defines the viewport right coordinate
  4609. * @param bottom defines the viewport bottom coordinate
  4610. * @param top defines the viewport top coordinate
  4611. * @param znear defines the near clip plane
  4612. * @param zfar defines the far clip plane
  4613. * @returns a new matrix as a left-handed orthographic projection matrix
  4614. */
  4615. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4616. /**
  4617. * Stores a left-handed orthographic projection into a given matrix
  4618. * @param left defines the viewport left coordinate
  4619. * @param right defines the viewport right coordinate
  4620. * @param bottom defines the viewport bottom coordinate
  4621. * @param top defines the viewport top coordinate
  4622. * @param znear defines the near clip plane
  4623. * @param zfar defines the far clip plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4627. /**
  4628. * Creates a right-handed orthographic projection matrix
  4629. * @param left defines the viewport left coordinate
  4630. * @param right defines the viewport right coordinate
  4631. * @param bottom defines the viewport bottom coordinate
  4632. * @param top defines the viewport top coordinate
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a right-handed orthographic projection matrix
  4636. */
  4637. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a right-handed orthographic projection into a given matrix
  4640. * @param left defines the viewport left coordinate
  4641. * @param right defines the viewport right coordinate
  4642. * @param bottom defines the viewport bottom coordinate
  4643. * @param top defines the viewport top coordinate
  4644. * @param znear defines the near clip plane
  4645. * @param zfar defines the far clip plane
  4646. * @param result defines the target matrix
  4647. */
  4648. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4649. /**
  4650. * Creates a left-handed perspective projection matrix
  4651. * @param width defines the viewport width
  4652. * @param height defines the viewport height
  4653. * @param znear defines the near clip plane
  4654. * @param zfar defines the far clip plane
  4655. * @returns a new matrix as a left-handed perspective projection matrix
  4656. */
  4657. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4658. /**
  4659. * Creates a left-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a left-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a left-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Creates a right-handed perspective projection matrix
  4689. * @param fov defines the horizontal field of view
  4690. * @param aspect defines the aspect ratio
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @returns a new matrix as a right-handed perspective projection matrix
  4694. */
  4695. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4696. /**
  4697. * Stores a right-handed perspective projection into a given matrix
  4698. * @param fov defines the horizontal field of view
  4699. * @param aspect defines the aspect ratio
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4704. */
  4705. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4706. /**
  4707. * Stores a right-handed perspective projection into a given matrix
  4708. * @param fov defines the horizontal field of view
  4709. * @param aspect defines the aspect ratio
  4710. * @param znear defines the near clip plane
  4711. * @param zfar not used as infinity is used as far clip
  4712. * @param result defines the target matrix
  4713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4714. */
  4715. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4716. /**
  4717. * Stores a perspective projection for WebVR info a given matrix
  4718. * @param fov defines the field of view
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @param result defines the target matrix
  4722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4723. */
  4724. static PerspectiveFovWebVRToRef(fov: {
  4725. upDegrees: number;
  4726. downDegrees: number;
  4727. leftDegrees: number;
  4728. rightDegrees: number;
  4729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4730. /**
  4731. * Computes a complete transformation matrix
  4732. * @param viewport defines the viewport to use
  4733. * @param world defines the world matrix
  4734. * @param view defines the view matrix
  4735. * @param projection defines the projection matrix
  4736. * @param zmin defines the near clip plane
  4737. * @param zmax defines the far clip plane
  4738. * @returns the transformation matrix
  4739. */
  4740. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4741. /**
  4742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4743. * @param matrix defines the matrix to use
  4744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4745. */
  4746. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4747. /**
  4748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4749. * @param matrix defines the matrix to use
  4750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4751. */
  4752. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4753. /**
  4754. * Compute the transpose of a given matrix
  4755. * @param matrix defines the matrix to transpose
  4756. * @returns the new matrix
  4757. */
  4758. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4759. /**
  4760. * Compute the transpose of a matrix and store it in a target matrix
  4761. * @param matrix defines the matrix to transpose
  4762. * @param result defines the target matrix
  4763. */
  4764. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4765. /**
  4766. * Computes a reflection matrix from a plane
  4767. * @param plane defines the reflection plane
  4768. * @returns a new matrix
  4769. */
  4770. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4771. /**
  4772. * Computes a reflection matrix from a plane
  4773. * @param plane defines the reflection plane
  4774. * @param result defines the target matrix
  4775. */
  4776. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4777. /**
  4778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4779. * @param xaxis defines the value of the 1st axis
  4780. * @param yaxis defines the value of the 2nd axis
  4781. * @param zaxis defines the value of the 3rd axis
  4782. * @param result defines the target matrix
  4783. */
  4784. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4785. /**
  4786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4787. * @param quat defines the quaternion to use
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4791. }
  4792. /**
  4793. * @hidden
  4794. */
  4795. export class TmpVectors {
  4796. static Vector2: Vector2[];
  4797. static Vector3: Vector3[];
  4798. static Vector4: Vector4[];
  4799. static Quaternion: Quaternion[];
  4800. static Matrix: Matrix[];
  4801. }
  4802. }
  4803. declare module "babylonjs/Maths/math.path" {
  4804. import { DeepImmutable, Nullable } from "babylonjs/types";
  4805. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4806. /**
  4807. * Defines potential orientation for back face culling
  4808. */
  4809. export enum Orientation {
  4810. /**
  4811. * Clockwise
  4812. */
  4813. CW = 0,
  4814. /** Counter clockwise */
  4815. CCW = 1
  4816. }
  4817. /** Class used to represent a Bezier curve */
  4818. export class BezierCurve {
  4819. /**
  4820. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4821. * @param t defines the time
  4822. * @param x1 defines the left coordinate on X axis
  4823. * @param y1 defines the left coordinate on Y axis
  4824. * @param x2 defines the right coordinate on X axis
  4825. * @param y2 defines the right coordinate on Y axis
  4826. * @returns the interpolated value
  4827. */
  4828. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4829. }
  4830. /**
  4831. * Defines angle representation
  4832. */
  4833. export class Angle {
  4834. private _radians;
  4835. /**
  4836. * Creates an Angle object of "radians" radians (float).
  4837. * @param radians the angle in radians
  4838. */
  4839. constructor(radians: number);
  4840. /**
  4841. * Get value in degrees
  4842. * @returns the Angle value in degrees (float)
  4843. */
  4844. degrees(): number;
  4845. /**
  4846. * Get value in radians
  4847. * @returns the Angle value in radians (float)
  4848. */
  4849. radians(): number;
  4850. /**
  4851. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4852. * @param a defines first vector
  4853. * @param b defines second vector
  4854. * @returns a new Angle
  4855. */
  4856. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4857. /**
  4858. * Gets a new Angle object from the given float in radians
  4859. * @param radians defines the angle value in radians
  4860. * @returns a new Angle
  4861. */
  4862. static FromRadians(radians: number): Angle;
  4863. /**
  4864. * Gets a new Angle object from the given float in degrees
  4865. * @param degrees defines the angle value in degrees
  4866. * @returns a new Angle
  4867. */
  4868. static FromDegrees(degrees: number): Angle;
  4869. }
  4870. /**
  4871. * This represents an arc in a 2d space.
  4872. */
  4873. export class Arc2 {
  4874. /** Defines the start point of the arc */
  4875. startPoint: Vector2;
  4876. /** Defines the mid point of the arc */
  4877. midPoint: Vector2;
  4878. /** Defines the end point of the arc */
  4879. endPoint: Vector2;
  4880. /**
  4881. * Defines the center point of the arc.
  4882. */
  4883. centerPoint: Vector2;
  4884. /**
  4885. * Defines the radius of the arc.
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Defines the angle of the arc (from mid point to end point).
  4890. */
  4891. angle: Angle;
  4892. /**
  4893. * Defines the start angle of the arc (from start point to middle point).
  4894. */
  4895. startAngle: Angle;
  4896. /**
  4897. * Defines the orientation of the arc (clock wise/counter clock wise).
  4898. */
  4899. orientation: Orientation;
  4900. /**
  4901. * Creates an Arc object from the three given points : start, middle and end.
  4902. * @param startPoint Defines the start point of the arc
  4903. * @param midPoint Defines the midlle point of the arc
  4904. * @param endPoint Defines the end point of the arc
  4905. */
  4906. constructor(
  4907. /** Defines the start point of the arc */
  4908. startPoint: Vector2,
  4909. /** Defines the mid point of the arc */
  4910. midPoint: Vector2,
  4911. /** Defines the end point of the arc */
  4912. endPoint: Vector2);
  4913. }
  4914. /**
  4915. * Represents a 2D path made up of multiple 2D points
  4916. */
  4917. export class Path2 {
  4918. private _points;
  4919. private _length;
  4920. /**
  4921. * If the path start and end point are the same
  4922. */
  4923. closed: boolean;
  4924. /**
  4925. * Creates a Path2 object from the starting 2D coordinates x and y.
  4926. * @param x the starting points x value
  4927. * @param y the starting points y value
  4928. */
  4929. constructor(x: number, y: number);
  4930. /**
  4931. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4932. * @param x the added points x value
  4933. * @param y the added points y value
  4934. * @returns the updated Path2.
  4935. */
  4936. addLineTo(x: number, y: number): Path2;
  4937. /**
  4938. * 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.
  4939. * @param midX middle point x value
  4940. * @param midY middle point y value
  4941. * @param endX end point x value
  4942. * @param endY end point y value
  4943. * @param numberOfSegments (default: 36)
  4944. * @returns the updated Path2.
  4945. */
  4946. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4947. /**
  4948. * Closes the Path2.
  4949. * @returns the Path2.
  4950. */
  4951. close(): Path2;
  4952. /**
  4953. * Gets the sum of the distance between each sequential point in the path
  4954. * @returns the Path2 total length (float).
  4955. */
  4956. length(): number;
  4957. /**
  4958. * Gets the points which construct the path
  4959. * @returns the Path2 internal array of points.
  4960. */
  4961. getPoints(): Vector2[];
  4962. /**
  4963. * Retreives the point at the distance aways from the starting point
  4964. * @param normalizedLengthPosition the length along the path to retreive the point from
  4965. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4966. */
  4967. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4968. /**
  4969. * Creates a new path starting from an x and y position
  4970. * @param x starting x value
  4971. * @param y starting y value
  4972. * @returns a new Path2 starting at the coordinates (x, y).
  4973. */
  4974. static StartingAt(x: number, y: number): Path2;
  4975. }
  4976. /**
  4977. * Represents a 3D path made up of multiple 3D points
  4978. */
  4979. export class Path3D {
  4980. /**
  4981. * an array of Vector3, the curve axis of the Path3D
  4982. */
  4983. path: Vector3[];
  4984. private _curve;
  4985. private _distances;
  4986. private _tangents;
  4987. private _normals;
  4988. private _binormals;
  4989. private _raw;
  4990. private _alignTangentsWithPath;
  4991. private readonly _pointAtData;
  4992. /**
  4993. * new Path3D(path, normal, raw)
  4994. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4995. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4996. * @param path an array of Vector3, the curve axis of the Path3D
  4997. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4998. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4999. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5000. */
  5001. constructor(
  5002. /**
  5003. * an array of Vector3, the curve axis of the Path3D
  5004. */
  5005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5006. /**
  5007. * Returns the Path3D array of successive Vector3 designing its curve.
  5008. * @returns the Path3D array of successive Vector3 designing its curve.
  5009. */
  5010. getCurve(): Vector3[];
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getPoints(): Vector3[];
  5016. /**
  5017. * @returns the computed length (float) of the path.
  5018. */
  5019. length(): number;
  5020. /**
  5021. * Returns an array populated with tangent vectors on each Path3D curve point.
  5022. * @returns an array populated with tangent vectors on each Path3D curve point.
  5023. */
  5024. getTangents(): Vector3[];
  5025. /**
  5026. * Returns an array populated with normal vectors on each Path3D curve point.
  5027. * @returns an array populated with normal vectors on each Path3D curve point.
  5028. */
  5029. getNormals(): Vector3[];
  5030. /**
  5031. * Returns an array populated with binormal vectors on each Path3D curve point.
  5032. * @returns an array populated with binormal vectors on each Path3D curve point.
  5033. */
  5034. getBinormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5037. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5038. */
  5039. getDistances(): number[];
  5040. /**
  5041. * Returns an interpolated point along this path
  5042. * @param position the position of the point along this path, from 0.0 to 1.0
  5043. * @returns a new Vector3 as the point
  5044. */
  5045. getPointAt(position: number): Vector3;
  5046. /**
  5047. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5050. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5051. */
  5052. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5057. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5058. */
  5059. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5064. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5065. */
  5066. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5071. */
  5072. getDistanceAt(position: number): number;
  5073. /**
  5074. * Returns the array index of the previous point of an interpolated point along this path
  5075. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5076. * @returns the array index
  5077. */
  5078. getPreviousPointIndexAt(position: number): number;
  5079. /**
  5080. * 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)
  5081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5082. * @returns the sub position
  5083. */
  5084. getSubPositionAt(position: number): number;
  5085. /**
  5086. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5087. * @param target the vector of which to get the closest position to
  5088. * @returns the position of the closest virtual point on this path to the target vector
  5089. */
  5090. getClosestPositionTo(target: Vector3): number;
  5091. /**
  5092. * Returns a sub path (slice) of this path
  5093. * @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
  5094. * @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
  5095. * @returns a sub path (slice) of this path
  5096. */
  5097. slice(start?: number, end?: number): Path3D;
  5098. /**
  5099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5100. * @param path path which all values are copied into the curves points
  5101. * @param firstNormal which should be projected onto the curve
  5102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5103. * @returns the same object updated.
  5104. */
  5105. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5106. private _compute;
  5107. private _getFirstNonNullVector;
  5108. private _getLastNonNullVector;
  5109. private _normalVector;
  5110. /**
  5111. * Updates the point at data for an interpolated point along this curve
  5112. * @param position the position of the point along this curve, from 0.0 to 1.0
  5113. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5114. * @returns the (updated) point at data
  5115. */
  5116. private _updatePointAtData;
  5117. /**
  5118. * Updates the point at data from the specified parameters
  5119. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5120. * @param point the interpolated point
  5121. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5122. */
  5123. private _setPointAtData;
  5124. /**
  5125. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5126. */
  5127. private _updateInterpolationMatrix;
  5128. }
  5129. /**
  5130. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5131. * A Curve3 is designed from a series of successive Vector3.
  5132. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5133. */
  5134. export class Curve3 {
  5135. private _points;
  5136. private _length;
  5137. /**
  5138. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5139. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5140. * @param v1 (Vector3) the control point
  5141. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5142. * @param nbPoints (integer) the wanted number of points in the curve
  5143. * @returns the created Curve3
  5144. */
  5145. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5146. /**
  5147. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5148. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5149. * @param v1 (Vector3) the first control point
  5150. * @param v2 (Vector3) the second control point
  5151. * @param v3 (Vector3) the end point of the Cubic Bezier
  5152. * @param nbPoints (integer) the wanted number of points in the curve
  5153. * @returns the created Curve3
  5154. */
  5155. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5156. /**
  5157. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5158. * @param p1 (Vector3) the origin point of the Hermite Spline
  5159. * @param t1 (Vector3) the tangent vector at the origin point
  5160. * @param p2 (Vector3) the end point of the Hermite Spline
  5161. * @param t2 (Vector3) the tangent vector at the end point
  5162. * @param nbPoints (integer) the wanted number of points in the curve
  5163. * @returns the created Curve3
  5164. */
  5165. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5166. /**
  5167. * Returns a Curve3 object along a CatmullRom Spline curve :
  5168. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5169. * @param nbPoints (integer) the wanted number of points between each curve control points
  5170. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5178. * @param points points which make up the curve
  5179. */
  5180. constructor(points: Vector3[]);
  5181. /**
  5182. * @returns the Curve3 stored array of successive Vector3
  5183. */
  5184. getPoints(): Vector3[];
  5185. /**
  5186. * @returns the computed length (float) of the curve.
  5187. */
  5188. length(): number;
  5189. /**
  5190. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5191. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5192. * curveA and curveB keep unchanged.
  5193. * @param curve the curve to continue from this curve
  5194. * @returns the newly constructed curve
  5195. */
  5196. continue(curve: DeepImmutable<Curve3>): Curve3;
  5197. private _computeLength;
  5198. }
  5199. }
  5200. declare module "babylonjs/Animations/easing" {
  5201. /**
  5202. * This represents the main contract an easing function should follow.
  5203. * Easing functions are used throughout the animation system.
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export interface IEasingFunction {
  5207. /**
  5208. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5209. * of the easing function.
  5210. * The link below provides some of the most common examples of easing functions.
  5211. * @see https://easings.net/
  5212. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5213. * @returns the corresponding value on the curve defined by the easing function
  5214. */
  5215. ease(gradient: number): number;
  5216. }
  5217. /**
  5218. * Base class used for every default easing function.
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class EasingFunction implements IEasingFunction {
  5222. /**
  5223. * Interpolation follows the mathematical formula associated with the easing function.
  5224. */
  5225. static readonly EASINGMODE_EASEIN: number;
  5226. /**
  5227. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5228. */
  5229. static readonly EASINGMODE_EASEOUT: number;
  5230. /**
  5231. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5232. */
  5233. static readonly EASINGMODE_EASEINOUT: number;
  5234. private _easingMode;
  5235. /**
  5236. * Sets the easing mode of the current function.
  5237. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5238. */
  5239. setEasingMode(easingMode: number): void;
  5240. /**
  5241. * Gets the current easing mode.
  5242. * @returns the easing mode
  5243. */
  5244. getEasingMode(): number;
  5245. /**
  5246. * @hidden
  5247. */
  5248. easeInCore(gradient: number): number;
  5249. /**
  5250. * Given an input gradient between 0 and 1, this returns the corresponding value
  5251. * of the easing function.
  5252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5253. * @returns the corresponding value on the curve defined by the easing function
  5254. */
  5255. ease(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a circle shape (see link below).
  5259. * @see https://easings.net/#easeInCirc
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class CircleEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a ease back shape (see link below).
  5268. * @see https://easings.net/#easeInBack
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BackEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the amplitude of the function */
  5273. amplitude: number;
  5274. /**
  5275. * Instantiates a back ease easing
  5276. * @see https://easings.net/#easeInBack
  5277. * @param amplitude Defines the amplitude of the function
  5278. */
  5279. constructor(
  5280. /** Defines the amplitude of the function */
  5281. amplitude?: number);
  5282. /** @hidden */
  5283. easeInCore(gradient: number): number;
  5284. }
  5285. /**
  5286. * Easing function with a bouncing shape (see link below).
  5287. * @see https://easings.net/#easeInBounce
  5288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5289. */
  5290. export class BounceEase extends EasingFunction implements IEasingFunction {
  5291. /** Defines the number of bounces */
  5292. bounces: number;
  5293. /** Defines the amplitude of the bounce */
  5294. bounciness: number;
  5295. /**
  5296. * Instantiates a bounce easing
  5297. * @see https://easings.net/#easeInBounce
  5298. * @param bounces Defines the number of bounces
  5299. * @param bounciness Defines the amplitude of the bounce
  5300. */
  5301. constructor(
  5302. /** Defines the number of bounces */
  5303. bounces?: number,
  5304. /** Defines the amplitude of the bounce */
  5305. bounciness?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a power of 3 shape (see link below).
  5311. * @see https://easings.net/#easeInCubic
  5312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class CubicEase extends EasingFunction implements IEasingFunction {
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. /**
  5319. * Easing function with an elastic shape (see link below).
  5320. * @see https://easings.net/#easeInElastic
  5321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5324. /** Defines the number of oscillations*/
  5325. oscillations: number;
  5326. /** Defines the amplitude of the oscillations*/
  5327. springiness: number;
  5328. /**
  5329. * Instantiates an elastic easing function
  5330. * @see https://easings.net/#easeInElastic
  5331. * @param oscillations Defines the number of oscillations
  5332. * @param springiness Defines the amplitude of the oscillations
  5333. */
  5334. constructor(
  5335. /** Defines the number of oscillations*/
  5336. oscillations?: number,
  5337. /** Defines the amplitude of the oscillations*/
  5338. springiness?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an exponential shape (see link below).
  5344. * @see https://easings.net/#easeInExpo
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the exponent of the function */
  5349. exponent: number;
  5350. /**
  5351. * Instantiates an exponential easing function
  5352. * @see https://easings.net/#easeInExpo
  5353. * @param exponent Defines the exponent of the function
  5354. */
  5355. constructor(
  5356. /** Defines the exponent of the function */
  5357. exponent?: number);
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a power shape (see link below).
  5363. * @see https://easings.net/#easeInQuad
  5364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class PowerEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the power of the function */
  5368. power: number;
  5369. /**
  5370. * Instantiates an power base easing function
  5371. * @see https://easings.net/#easeInQuad
  5372. * @param power Defines the power of the function
  5373. */
  5374. constructor(
  5375. /** Defines the power of the function */
  5376. power?: number);
  5377. /** @hidden */
  5378. easeInCore(gradient: number): number;
  5379. }
  5380. /**
  5381. * Easing function with a power of 2 shape (see link below).
  5382. * @see https://easings.net/#easeInQuad
  5383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5384. */
  5385. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a power of 4 shape (see link below).
  5391. * @see https://easings.net/#easeInQuart
  5392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5395. /** @hidden */
  5396. easeInCore(gradient: number): number;
  5397. }
  5398. /**
  5399. * Easing function with a power of 5 shape (see link below).
  5400. * @see https://easings.net/#easeInQuint
  5401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5402. */
  5403. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5404. /** @hidden */
  5405. easeInCore(gradient: number): number;
  5406. }
  5407. /**
  5408. * Easing function with a sin shape (see link below).
  5409. * @see https://easings.net/#easeInSine
  5410. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5411. */
  5412. export class SineEase extends EasingFunction implements IEasingFunction {
  5413. /** @hidden */
  5414. easeInCore(gradient: number): number;
  5415. }
  5416. /**
  5417. * Easing function with a bezier shape (see link below).
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5420. */
  5421. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5422. /** Defines the x component of the start tangent in the bezier curve */
  5423. x1: number;
  5424. /** Defines the y component of the start tangent in the bezier curve */
  5425. y1: number;
  5426. /** Defines the x component of the end tangent in the bezier curve */
  5427. x2: number;
  5428. /** Defines the y component of the end tangent in the bezier curve */
  5429. y2: number;
  5430. /**
  5431. * Instantiates a bezier function
  5432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5433. * @param x1 Defines the x component of the start tangent in the bezier curve
  5434. * @param y1 Defines the y component of the start tangent in the bezier curve
  5435. * @param x2 Defines the x component of the end tangent in the bezier curve
  5436. * @param y2 Defines the y component of the end tangent in the bezier curve
  5437. */
  5438. constructor(
  5439. /** Defines the x component of the start tangent in the bezier curve */
  5440. x1?: number,
  5441. /** Defines the y component of the start tangent in the bezier curve */
  5442. y1?: number,
  5443. /** Defines the x component of the end tangent in the bezier curve */
  5444. x2?: number,
  5445. /** Defines the y component of the end tangent in the bezier curve */
  5446. y2?: number);
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/math.color" {
  5452. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to hold a RBG color
  5455. */
  5456. export class Color3 {
  5457. /**
  5458. * Defines the red component (between 0 and 1, default is 0)
  5459. */
  5460. r: number;
  5461. /**
  5462. * Defines the green component (between 0 and 1, default is 0)
  5463. */
  5464. g: number;
  5465. /**
  5466. * Defines the blue component (between 0 and 1, default is 0)
  5467. */
  5468. b: number;
  5469. /**
  5470. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5471. * @param r defines the red component (between 0 and 1, default is 0)
  5472. * @param g defines the green component (between 0 and 1, default is 0)
  5473. * @param b defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number);
  5488. /**
  5489. * Creates a string with the Color3 current values
  5490. * @returns the string representation of the Color3 object
  5491. */
  5492. toString(): string;
  5493. /**
  5494. * Returns the string "Color3"
  5495. * @returns "Color3"
  5496. */
  5497. getClassName(): string;
  5498. /**
  5499. * Compute the Color3 hash code
  5500. * @returns an unique number that can be used to hash Color3 objects
  5501. */
  5502. getHashCode(): number;
  5503. /**
  5504. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color3 object
  5508. */
  5509. toArray(array: FloatArray, index?: number): Color3;
  5510. /**
  5511. * Returns a new Color4 object from the current Color3 and the given alpha
  5512. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5513. * @returns a new Color4 object
  5514. */
  5515. toColor4(alpha?: number): Color4;
  5516. /**
  5517. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5518. * @returns the new array
  5519. */
  5520. asArray(): number[];
  5521. /**
  5522. * Returns the luminance value
  5523. * @returns a float value
  5524. */
  5525. toLuminance(): number;
  5526. /**
  5527. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5528. * @param otherColor defines the second operand
  5529. * @returns the new Color3 object
  5530. */
  5531. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5532. /**
  5533. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5534. * @param otherColor defines the second operand
  5535. * @param result defines the Color3 object where to store the result
  5536. * @returns the current Color3
  5537. */
  5538. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5539. /**
  5540. * Determines equality between Color3 objects
  5541. * @param otherColor defines the second operand
  5542. * @returns true if the rgb values are equal to the given ones
  5543. */
  5544. equals(otherColor: DeepImmutable<Color3>): boolean;
  5545. /**
  5546. * Determines equality between the current Color3 object and a set of r,b,g values
  5547. * @param r defines the red component to check
  5548. * @param g defines the green component to check
  5549. * @param b defines the blue component to check
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equalsFloats(r: number, g: number, b: number): boolean;
  5553. /**
  5554. * Multiplies in place each rgb value by scale
  5555. * @param scale defines the scaling factor
  5556. * @returns the updated Color3
  5557. */
  5558. scale(scale: number): Color3;
  5559. /**
  5560. * Multiplies the rgb values by scale and stores the result into "result"
  5561. * @param scale defines the scaling factor
  5562. * @param result defines the Color3 object where to store the result
  5563. * @returns the unmodified current Color3
  5564. */
  5565. scaleToRef(scale: number, result: Color3): Color3;
  5566. /**
  5567. * Scale the current Color3 values by a factor and add the result to a given Color3
  5568. * @param scale defines the scale factor
  5569. * @param result defines color to store the result into
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Clamps the rgb values by the min and max values and stores the result into "result"
  5575. * @param min defines minimum clamping value (default is 0)
  5576. * @param max defines maximum clamping value (default is 1)
  5577. * @param result defines color to store the result into
  5578. * @returns the original Color3
  5579. */
  5580. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5581. /**
  5582. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5583. * @param otherColor defines the second operand
  5584. * @returns the new Color3
  5585. */
  5586. add(otherColor: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5589. * @param otherColor defines the second operand
  5590. * @param result defines Color3 object to store the result into
  5591. * @returns the unmodified current Color3
  5592. */
  5593. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5594. /**
  5595. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5596. * @param otherColor defines the second operand
  5597. * @returns the new Color3
  5598. */
  5599. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5600. /**
  5601. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5602. * @param otherColor defines the second operand
  5603. * @param result defines Color3 object to store the result into
  5604. * @returns the unmodified current Color3
  5605. */
  5606. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5607. /**
  5608. * Copy the current object
  5609. * @returns a new Color3 copied the current one
  5610. */
  5611. clone(): Color3;
  5612. /**
  5613. * Copies the rgb values from the source in the current Color3
  5614. * @param source defines the source Color3 object
  5615. * @returns the updated Color3 object
  5616. */
  5617. copyFrom(source: DeepImmutable<Color3>): Color3;
  5618. /**
  5619. * Updates the Color3 rgb values from the given floats
  5620. * @param r defines the red component to read from
  5621. * @param g defines the green component to read from
  5622. * @param b defines the blue component to read from
  5623. * @returns the current Color3 object
  5624. */
  5625. copyFromFloats(r: number, g: number, b: number): 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. set(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Compute the Color3 hexadecimal code as a string
  5636. * @returns a string containing the hexadecimal representation of the Color3 object
  5637. */
  5638. toHexString(): string;
  5639. /**
  5640. * Computes a new Color3 converted from the current one to linear space
  5641. * @returns a new Color3 object
  5642. */
  5643. toLinearSpace(): Color3;
  5644. /**
  5645. * Converts current color in rgb space to HSV values
  5646. * @returns a new color3 representing the HSV values
  5647. */
  5648. toHSV(): Color3;
  5649. /**
  5650. * Converts current color in rgb space to HSV values
  5651. * @param result defines the Color3 where to store the HSV values
  5652. */
  5653. toHSVToRef(result: Color3): void;
  5654. /**
  5655. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5656. * @param convertedColor defines the Color3 object where to store the linear space version
  5657. * @returns the unmodified Color3
  5658. */
  5659. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5660. /**
  5661. * Computes a new Color3 converted from the current one to gamma space
  5662. * @returns a new Color3 object
  5663. */
  5664. toGammaSpace(): Color3;
  5665. /**
  5666. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5667. * @param convertedColor defines the Color3 object where to store the gamma space version
  5668. * @returns the unmodified Color3
  5669. */
  5670. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5671. private static _BlackReadOnly;
  5672. /**
  5673. * Convert Hue, saturation and value to a Color3 (RGB)
  5674. * @param hue defines the hue
  5675. * @param saturation defines the saturation
  5676. * @param value defines the value
  5677. * @param result defines the Color3 where to store the RGB values
  5678. */
  5679. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5680. /**
  5681. * Creates a new Color3 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromHexString(hex: string): Color3;
  5686. /**
  5687. * Creates a new Color3 from the starting index of the given array
  5688. * @param array defines the source array
  5689. * @param offset defines an offset in the source array
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5693. /**
  5694. * Creates a new Color3 from integer values (< 256)
  5695. * @param r defines the red component to read from (value between 0 and 255)
  5696. * @param g defines the green component to read from (value between 0 and 255)
  5697. * @param b defines the blue component to read from (value between 0 and 255)
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromInts(r: number, g: number, b: number): Color3;
  5701. /**
  5702. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5703. * @param start defines the start Color3 value
  5704. * @param end defines the end Color3 value
  5705. * @param amount defines the gradient value between start and end
  5706. * @returns a new Color3 object
  5707. */
  5708. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param left defines the start value
  5712. * @param right defines the end value
  5713. * @param amount defines the gradient factor
  5714. * @param result defines the Color3 object where to store the result
  5715. */
  5716. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5717. /**
  5718. * Returns a Color3 value containing a red color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Red(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a green color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Green(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a blue color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Blue(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a black color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Black(): Color3;
  5737. /**
  5738. * Gets a Color3 value containing a black color that must not be updated
  5739. */
  5740. static get BlackReadOnly(): DeepImmutable<Color3>;
  5741. /**
  5742. * Returns a Color3 value containing a white color
  5743. * @returns a new Color3 object
  5744. */
  5745. static White(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a purple color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Purple(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a magenta color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Magenta(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a yellow color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Yellow(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a gray color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Gray(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a teal color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Teal(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a random color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Random(): Color3;
  5776. }
  5777. /**
  5778. * Class used to hold a RBGA color
  5779. */
  5780. export class Color4 {
  5781. /**
  5782. * Defines the red component (between 0 and 1, default is 0)
  5783. */
  5784. r: number;
  5785. /**
  5786. * Defines the green component (between 0 and 1, default is 0)
  5787. */
  5788. g: number;
  5789. /**
  5790. * Defines the blue component (between 0 and 1, default is 0)
  5791. */
  5792. b: number;
  5793. /**
  5794. * Defines the alpha component (between 0 and 1, default is 1)
  5795. */
  5796. a: number;
  5797. /**
  5798. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5799. * @param r defines the red component (between 0 and 1, default is 0)
  5800. * @param g defines the green component (between 0 and 1, default is 0)
  5801. * @param b defines the blue component (between 0 and 1, default is 0)
  5802. * @param a defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. constructor(
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r?: number,
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g?: number,
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b?: number,
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a?: number);
  5821. /**
  5822. * Adds in place the given Color4 values to the current Color4 object
  5823. * @param right defines the second operand
  5824. * @returns the current updated Color4 object
  5825. */
  5826. addInPlace(right: DeepImmutable<Color4>): Color4;
  5827. /**
  5828. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5829. * @returns the new array
  5830. */
  5831. asArray(): number[];
  5832. /**
  5833. * Stores from the starting index in the given array the Color4 successive values
  5834. * @param array defines the array where to store the r,g,b components
  5835. * @param index defines an optional index in the target array to define where to start storing values
  5836. * @returns the current Color4 object
  5837. */
  5838. toArray(array: number[], index?: number): Color4;
  5839. /**
  5840. * Determines equality between Color4 objects
  5841. * @param otherColor defines the second operand
  5842. * @returns true if the rgba values are equal to the given ones
  5843. */
  5844. equals(otherColor: DeepImmutable<Color4>): boolean;
  5845. /**
  5846. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5847. * @param right defines the second operand
  5848. * @returns a new Color4 object
  5849. */
  5850. add(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5853. * @param right defines the second operand
  5854. * @returns a new Color4 object
  5855. */
  5856. subtract(right: DeepImmutable<Color4>): Color4;
  5857. /**
  5858. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5859. * @param right defines the second operand
  5860. * @param result defines the Color4 object where to store the result
  5861. * @returns the current Color4 object
  5862. */
  5863. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5864. /**
  5865. * Creates a new Color4 with the current Color4 values multiplied by scale
  5866. * @param scale defines the scaling factor to apply
  5867. * @returns a new Color4 object
  5868. */
  5869. scale(scale: number): Color4;
  5870. /**
  5871. * Multiplies the current Color4 values by scale and stores the result in "result"
  5872. * @param scale defines the scaling factor to apply
  5873. * @param result defines the Color4 object where to store the result
  5874. * @returns the current unmodified Color4
  5875. */
  5876. scaleToRef(scale: number, result: Color4): Color4;
  5877. /**
  5878. * Scale the current Color4 values by a factor and add the result to a given Color4
  5879. * @param scale defines the scale factor
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the unmodified current Color4
  5882. */
  5883. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Clamps the rgb values by the min and max values and stores the result into "result"
  5886. * @param min defines minimum clamping value (default is 0)
  5887. * @param max defines maximum clamping value (default is 1)
  5888. * @param result defines color to store the result into.
  5889. * @returns the cuurent Color4
  5890. */
  5891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5892. /**
  5893. * Multipy an Color4 value by another and return a new Color4 object
  5894. * @param color defines the Color4 value to multiply by
  5895. * @returns a new Color4 object
  5896. */
  5897. multiply(color: Color4): Color4;
  5898. /**
  5899. * Multipy a Color4 value by another and push the result in a reference value
  5900. * @param color defines the Color4 value to multiply by
  5901. * @param result defines the Color4 to fill the result in
  5902. * @returns the result Color4
  5903. */
  5904. multiplyToRef(color: Color4, result: Color4): Color4;
  5905. /**
  5906. * Creates a string with the Color4 current values
  5907. * @returns the string representation of the Color4 object
  5908. */
  5909. toString(): string;
  5910. /**
  5911. * Returns the string "Color4"
  5912. * @returns "Color4"
  5913. */
  5914. getClassName(): string;
  5915. /**
  5916. * Compute the Color4 hash code
  5917. * @returns an unique number that can be used to hash Color4 objects
  5918. */
  5919. getHashCode(): number;
  5920. /**
  5921. * Creates a new Color4 copied from the current one
  5922. * @returns a new Color4 object
  5923. */
  5924. clone(): Color4;
  5925. /**
  5926. * Copies the given Color4 values into the current one
  5927. * @param source defines the source Color4 object
  5928. * @returns the current updated Color4 object
  5929. */
  5930. copyFrom(source: Color4): Color4;
  5931. /**
  5932. * Copies the given float values into the current one
  5933. * @param r defines the red component to read from
  5934. * @param g defines the green component to read from
  5935. * @param b defines the blue component to read from
  5936. * @param a defines the alpha component to read from
  5937. * @returns the current updated Color4 object
  5938. */
  5939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5940. /**
  5941. * Copies the given float values into the current one
  5942. * @param r defines the red component to read from
  5943. * @param g defines the green component to read from
  5944. * @param b defines the blue component to read from
  5945. * @param a defines the alpha component to read from
  5946. * @returns the current updated Color4 object
  5947. */
  5948. set(r: number, g: number, b: number, a: number): Color4;
  5949. /**
  5950. * Compute the Color4 hexadecimal code as a string
  5951. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5952. * @returns a string containing the hexadecimal representation of the Color4 object
  5953. */
  5954. toHexString(returnAsColor3?: boolean): string;
  5955. /**
  5956. * Computes a new Color4 converted from the current one to linear space
  5957. * @returns a new Color4 object
  5958. */
  5959. toLinearSpace(): Color4;
  5960. /**
  5961. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5962. * @param convertedColor defines the Color4 object where to store the linear space version
  5963. * @returns the unmodified Color4
  5964. */
  5965. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5966. /**
  5967. * Computes a new Color4 converted from the current one to gamma space
  5968. * @returns a new Color4 object
  5969. */
  5970. toGammaSpace(): Color4;
  5971. /**
  5972. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5973. * @param convertedColor defines the Color4 object where to store the gamma space version
  5974. * @returns the unmodified Color4
  5975. */
  5976. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 from the string containing valid hexadecimal values
  5979. * @param hex defines a string containing valid hexadecimal values
  5980. * @returns a new Color4 object
  5981. */
  5982. static FromHexString(hex: string): Color4;
  5983. /**
  5984. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5985. * @param left defines the start value
  5986. * @param right defines the end value
  5987. * @param amount defines the gradient factor
  5988. * @returns a new Color4 object
  5989. */
  5990. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5991. /**
  5992. * Set the given "result" 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. * @param result defines the Color4 object where to store data
  5997. */
  5998. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5999. /**
  6000. * Creates a new Color4 from a Color3 and an alpha value
  6001. * @param color3 defines the source Color3 to read from
  6002. * @param alpha defines the alpha component (1.0 by default)
  6003. * @returns a new Color4 object
  6004. */
  6005. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6006. /**
  6007. * Creates a new Color4 from the starting index element of the given array
  6008. * @param array defines the source array to read from
  6009. * @param offset defines the offset in the source array
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6013. /**
  6014. * Creates a new Color3 from integer values (< 256)
  6015. * @param r defines the red component to read from (value between 0 and 255)
  6016. * @param g defines the green component to read from (value between 0 and 255)
  6017. * @param b defines the blue component to read from (value between 0 and 255)
  6018. * @param a defines the alpha component to read from (value between 0 and 255)
  6019. * @returns a new Color3 object
  6020. */
  6021. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6022. /**
  6023. * Check the content of a given array and convert it to an array containing RGBA data
  6024. * If the original array was already containing count * 4 values then it is returned directly
  6025. * @param colors defines the array to check
  6026. * @param count defines the number of RGBA data to expect
  6027. * @returns an array containing count * 4 values (RGBA)
  6028. */
  6029. static CheckColors4(colors: number[], count: number): number[];
  6030. }
  6031. /**
  6032. * @hidden
  6033. */
  6034. export class TmpColors {
  6035. static Color3: Color3[];
  6036. static Color4: Color4[];
  6037. }
  6038. }
  6039. declare module "babylonjs/Animations/animationKey" {
  6040. /**
  6041. * Defines an interface which represents an animation key frame
  6042. */
  6043. export interface IAnimationKey {
  6044. /**
  6045. * Frame of the key frame
  6046. */
  6047. frame: number;
  6048. /**
  6049. * Value at the specifies key frame
  6050. */
  6051. value: any;
  6052. /**
  6053. * The input tangent for the cubic hermite spline
  6054. */
  6055. inTangent?: any;
  6056. /**
  6057. * The output tangent for the cubic hermite spline
  6058. */
  6059. outTangent?: any;
  6060. /**
  6061. * The animation interpolation type
  6062. */
  6063. interpolation?: AnimationKeyInterpolation;
  6064. }
  6065. /**
  6066. * Enum for the animation key frame interpolation type
  6067. */
  6068. export enum AnimationKeyInterpolation {
  6069. /**
  6070. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6071. */
  6072. STEP = 1
  6073. }
  6074. }
  6075. declare module "babylonjs/Animations/animationRange" {
  6076. /**
  6077. * Represents the range of an animation
  6078. */
  6079. export class AnimationRange {
  6080. /**The name of the animation range**/
  6081. name: string;
  6082. /**The starting frame of the animation */
  6083. from: number;
  6084. /**The ending frame of the animation*/
  6085. to: number;
  6086. /**
  6087. * Initializes the range of an animation
  6088. * @param name The name of the animation range
  6089. * @param from The starting frame of the animation
  6090. * @param to The ending frame of the animation
  6091. */
  6092. constructor(
  6093. /**The name of the animation range**/
  6094. name: string,
  6095. /**The starting frame of the animation */
  6096. from: number,
  6097. /**The ending frame of the animation*/
  6098. to: number);
  6099. /**
  6100. * Makes a copy of the animation range
  6101. * @returns A copy of the animation range
  6102. */
  6103. clone(): AnimationRange;
  6104. }
  6105. }
  6106. declare module "babylonjs/Animations/animationEvent" {
  6107. /**
  6108. * Composed of a frame, and an action function
  6109. */
  6110. export class AnimationEvent {
  6111. /** The frame for which the event is triggered **/
  6112. frame: number;
  6113. /** The event to perform when triggered **/
  6114. action: (currentFrame: number) => void;
  6115. /** Specifies if the event should be triggered only once**/
  6116. onlyOnce?: boolean | undefined;
  6117. /**
  6118. * Specifies if the animation event is done
  6119. */
  6120. isDone: boolean;
  6121. /**
  6122. * Initializes the animation event
  6123. * @param frame The frame for which the event is triggered
  6124. * @param action The event to perform when triggered
  6125. * @param onlyOnce Specifies if the event should be triggered only once
  6126. */
  6127. constructor(
  6128. /** The frame for which the event is triggered **/
  6129. frame: number,
  6130. /** The event to perform when triggered **/
  6131. action: (currentFrame: number) => void,
  6132. /** Specifies if the event should be triggered only once**/
  6133. onlyOnce?: boolean | undefined);
  6134. /** @hidden */
  6135. _clone(): AnimationEvent;
  6136. }
  6137. }
  6138. declare module "babylonjs/Behaviors/behavior" {
  6139. import { Nullable } from "babylonjs/types";
  6140. /**
  6141. * Interface used to define a behavior
  6142. */
  6143. export interface Behavior<T> {
  6144. /** gets or sets behavior's name */
  6145. name: string;
  6146. /**
  6147. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6148. */
  6149. init(): void;
  6150. /**
  6151. * Called when the behavior is attached to a target
  6152. * @param target defines the target where the behavior is attached to
  6153. */
  6154. attach(target: T): void;
  6155. /**
  6156. * Called when the behavior is detached from its target
  6157. */
  6158. detach(): void;
  6159. }
  6160. /**
  6161. * Interface implemented by classes supporting behaviors
  6162. */
  6163. export interface IBehaviorAware<T> {
  6164. /**
  6165. * Attach a behavior
  6166. * @param behavior defines the behavior to attach
  6167. * @returns the current host
  6168. */
  6169. addBehavior(behavior: Behavior<T>): T;
  6170. /**
  6171. * Remove a behavior from the current object
  6172. * @param behavior defines the behavior to detach
  6173. * @returns the current host
  6174. */
  6175. removeBehavior(behavior: Behavior<T>): T;
  6176. /**
  6177. * Gets a behavior using its name to search
  6178. * @param name defines the name to search
  6179. * @returns the behavior or null if not found
  6180. */
  6181. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6182. }
  6183. }
  6184. declare module "babylonjs/Misc/smartArray" {
  6185. /**
  6186. * Defines an array and its length.
  6187. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6188. */
  6189. export interface ISmartArrayLike<T> {
  6190. /**
  6191. * The data of the array.
  6192. */
  6193. data: Array<T>;
  6194. /**
  6195. * The active length of the array.
  6196. */
  6197. length: number;
  6198. }
  6199. /**
  6200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6201. */
  6202. export class SmartArray<T> implements ISmartArrayLike<T> {
  6203. /**
  6204. * The full set of data from the array.
  6205. */
  6206. data: Array<T>;
  6207. /**
  6208. * The active length of the array.
  6209. */
  6210. length: number;
  6211. protected _id: number;
  6212. /**
  6213. * Instantiates a Smart Array.
  6214. * @param capacity defines the default capacity of the array.
  6215. */
  6216. constructor(capacity: number);
  6217. /**
  6218. * Pushes a value at the end of the active data.
  6219. * @param value defines the object to push in the array.
  6220. */
  6221. push(value: T): void;
  6222. /**
  6223. * Iterates over the active data and apply the lambda to them.
  6224. * @param func defines the action to apply on each value.
  6225. */
  6226. forEach(func: (content: T) => void): void;
  6227. /**
  6228. * Sorts the full sets of data.
  6229. * @param compareFn defines the comparison function to apply.
  6230. */
  6231. sort(compareFn: (a: T, b: T) => number): void;
  6232. /**
  6233. * Resets the active data to an empty array.
  6234. */
  6235. reset(): void;
  6236. /**
  6237. * Releases all the data from the array as well as the array.
  6238. */
  6239. dispose(): void;
  6240. /**
  6241. * Concats the active data with a given array.
  6242. * @param array defines the data to concatenate with.
  6243. */
  6244. concat(array: any): void;
  6245. /**
  6246. * Returns the position of a value in the active data.
  6247. * @param value defines the value to find the index for
  6248. * @returns the index if found in the active data otherwise -1
  6249. */
  6250. indexOf(value: T): number;
  6251. /**
  6252. * Returns whether an element is part of the active data.
  6253. * @param value defines the value to look for
  6254. * @returns true if found in the active data otherwise false
  6255. */
  6256. contains(value: T): boolean;
  6257. private static _GlobalId;
  6258. }
  6259. /**
  6260. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6261. * The data in this array can only be present once
  6262. */
  6263. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6264. private _duplicateId;
  6265. /**
  6266. * Pushes a value at the end of the active data.
  6267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6268. * @param value defines the object to push in the array.
  6269. */
  6270. push(value: T): void;
  6271. /**
  6272. * Pushes a value at the end of the active data.
  6273. * If the data is already present, it won t be added again
  6274. * @param value defines the object to push in the array.
  6275. * @returns true if added false if it was already present
  6276. */
  6277. pushNoDuplicate(value: T): boolean;
  6278. /**
  6279. * Resets the active data to an empty array.
  6280. */
  6281. reset(): void;
  6282. /**
  6283. * Concats the active data with a given array.
  6284. * This ensures no dupplicate will be present in the result.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concatWithNoDuplicate(array: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Cameras/cameraInputsManager" {
  6291. import { Nullable } from "babylonjs/types";
  6292. import { Camera } from "babylonjs/Cameras/camera";
  6293. /**
  6294. * @ignore
  6295. * This is a list of all the different input types that are available in the application.
  6296. * Fo instance: ArcRotateCameraGamepadInput...
  6297. */
  6298. export var CameraInputTypes: {};
  6299. /**
  6300. * This is the contract to implement in order to create a new input class.
  6301. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6302. */
  6303. export interface ICameraInput<TCamera extends Camera> {
  6304. /**
  6305. * Defines the camera the input is attached to.
  6306. */
  6307. camera: Nullable<TCamera>;
  6308. /**
  6309. * Gets the class name of the current intput.
  6310. * @returns the class name
  6311. */
  6312. getClassName(): string;
  6313. /**
  6314. * Get the friendly name associated with the input class.
  6315. * @returns the input friendly name
  6316. */
  6317. getSimpleName(): string;
  6318. /**
  6319. * Attach the input controls to a specific dom element to get the input from.
  6320. * @param element Defines the element the controls should be listened from
  6321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6322. */
  6323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6324. /**
  6325. * Detach the current controls from the specified dom element.
  6326. * @param element Defines the element to stop listening the inputs from
  6327. */
  6328. detachControl(element: Nullable<HTMLElement>): void;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs?: () => void;
  6334. }
  6335. /**
  6336. * Represents a map of input types to input instance or input index to input instance.
  6337. */
  6338. export interface CameraInputsMap<TCamera extends Camera> {
  6339. /**
  6340. * Accessor to the input by input type.
  6341. */
  6342. [name: string]: ICameraInput<TCamera>;
  6343. /**
  6344. * Accessor to the input by input index.
  6345. */
  6346. [idx: number]: ICameraInput<TCamera>;
  6347. }
  6348. /**
  6349. * This represents the input manager used within a camera.
  6350. * It helps dealing with all the different kind of input attached to a camera.
  6351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6352. */
  6353. export class CameraInputsManager<TCamera extends Camera> {
  6354. /**
  6355. * Defines the list of inputs attahed to the camera.
  6356. */
  6357. attached: CameraInputsMap<TCamera>;
  6358. /**
  6359. * Defines the dom element the camera is collecting inputs from.
  6360. * This is null if the controls have not been attached.
  6361. */
  6362. attachedElement: Nullable<HTMLElement>;
  6363. /**
  6364. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. noPreventDefault: boolean;
  6367. /**
  6368. * Defined the camera the input manager belongs to.
  6369. */
  6370. camera: TCamera;
  6371. /**
  6372. * Update the current camera state depending on the inputs that have been used this frame.
  6373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6374. */
  6375. checkInputs: () => void;
  6376. /**
  6377. * Instantiate a new Camera Input Manager.
  6378. * @param camera Defines the camera the input manager blongs to
  6379. */
  6380. constructor(camera: TCamera);
  6381. /**
  6382. * Add an input method to a camera
  6383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6384. * @param input camera input method
  6385. */
  6386. add(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Remove a specific input method from a camera
  6389. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6390. * @param inputToRemove camera input method
  6391. */
  6392. remove(inputToRemove: ICameraInput<TCamera>): void;
  6393. /**
  6394. * Remove a specific input type from a camera
  6395. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6396. * @param inputType the type of the input to remove
  6397. */
  6398. removeByType(inputType: string): void;
  6399. private _addCheckInputs;
  6400. /**
  6401. * Attach the input controls to the currently attached dom element to listen the events from.
  6402. * @param input Defines the input to attach
  6403. */
  6404. attachInput(input: ICameraInput<TCamera>): void;
  6405. /**
  6406. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6407. * @param element Defines the dom element to collect the events from
  6408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6409. */
  6410. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6411. /**
  6412. * Detach the current manager inputs controls from a specific dom element.
  6413. * @param element Defines the dom element to collect the events from
  6414. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6415. */
  6416. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6417. /**
  6418. * Rebuild the dynamic inputCheck function from the current list of
  6419. * defined inputs in the manager.
  6420. */
  6421. rebuildInputCheck(): void;
  6422. /**
  6423. * Remove all attached input methods from a camera
  6424. */
  6425. clear(): void;
  6426. /**
  6427. * Serialize the current input manager attached to a camera.
  6428. * This ensures than once parsed,
  6429. * the input associated to the camera will be identical to the current ones
  6430. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6431. */
  6432. serialize(serializedCamera: any): void;
  6433. /**
  6434. * Parses an input manager serialized JSON to restore the previous list of inputs
  6435. * and states associated to a camera.
  6436. * @param parsedCamera Defines the JSON to parse
  6437. */
  6438. parse(parsedCamera: any): void;
  6439. }
  6440. }
  6441. declare module "babylonjs/Meshes/buffer" {
  6442. import { Nullable, DataArray } from "babylonjs/types";
  6443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6444. /**
  6445. * Class used to store data that will be store in GPU memory
  6446. */
  6447. export class Buffer {
  6448. private _engine;
  6449. private _buffer;
  6450. /** @hidden */
  6451. _data: Nullable<DataArray>;
  6452. private _updatable;
  6453. private _instanced;
  6454. private _divisor;
  6455. /**
  6456. * Gets the byte stride.
  6457. */
  6458. readonly byteStride: number;
  6459. /**
  6460. * Constructor
  6461. * @param engine the engine
  6462. * @param data the data to use for this buffer
  6463. * @param updatable whether the data is updatable
  6464. * @param stride the stride (optional)
  6465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param useBytes set to true if the stride in in bytes (optional)
  6468. * @param divisor sets an optional divisor for instances (1 by default)
  6469. */
  6470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6471. /**
  6472. * Create a new VertexBuffer based on the current buffer
  6473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6474. * @param offset defines offset in the buffer (0 by default)
  6475. * @param size defines the size in floats of attributes (position is 3 for instance)
  6476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6477. * @param instanced defines if the vertex buffer contains indexed data
  6478. * @param useBytes defines if the offset and stride are in bytes *
  6479. * @param divisor sets an optional divisor for instances (1 by default)
  6480. * @returns the new vertex buffer
  6481. */
  6482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6483. /**
  6484. * Gets a boolean indicating if the Buffer is updatable?
  6485. * @returns true if the buffer is updatable
  6486. */
  6487. isUpdatable(): boolean;
  6488. /**
  6489. * Gets current buffer's data
  6490. * @returns a DataArray or null
  6491. */
  6492. getData(): Nullable<DataArray>;
  6493. /**
  6494. * Gets underlying native buffer
  6495. * @returns underlying native buffer
  6496. */
  6497. getBuffer(): Nullable<DataBuffer>;
  6498. /**
  6499. * Gets the stride in float32 units (i.e. byte stride / 4).
  6500. * May not be an integer if the byte stride is not divisible by 4.
  6501. * @returns the stride in float32 units
  6502. * @deprecated Please use byteStride instead.
  6503. */
  6504. getStrideSize(): number;
  6505. /**
  6506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6507. * @param data defines the data to store
  6508. */
  6509. create(data?: Nullable<DataArray>): void;
  6510. /** @hidden */
  6511. _rebuild(): void;
  6512. /**
  6513. * Update current buffer data
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates the data directly.
  6519. * @param data the new data
  6520. * @param offset the new offset
  6521. * @param vertexCount the vertex count (optional)
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6525. /**
  6526. * Release all resources
  6527. */
  6528. dispose(): void;
  6529. }
  6530. /**
  6531. * Specialized buffer used to store vertex data
  6532. */
  6533. export class VertexBuffer {
  6534. /** @hidden */
  6535. _buffer: Buffer;
  6536. private _kind;
  6537. private _size;
  6538. private _ownsBuffer;
  6539. private _instanced;
  6540. private _instanceDivisor;
  6541. /**
  6542. * The byte type.
  6543. */
  6544. static readonly BYTE: number;
  6545. /**
  6546. * The unsigned byte type.
  6547. */
  6548. static readonly UNSIGNED_BYTE: number;
  6549. /**
  6550. * The short type.
  6551. */
  6552. static readonly SHORT: number;
  6553. /**
  6554. * The unsigned short type.
  6555. */
  6556. static readonly UNSIGNED_SHORT: number;
  6557. /**
  6558. * The integer type.
  6559. */
  6560. static readonly INT: number;
  6561. /**
  6562. * The unsigned integer type.
  6563. */
  6564. static readonly UNSIGNED_INT: number;
  6565. /**
  6566. * The float type.
  6567. */
  6568. static readonly FLOAT: number;
  6569. /**
  6570. * Gets or sets the instance divisor when in instanced mode
  6571. */
  6572. get instanceDivisor(): number;
  6573. set instanceDivisor(value: number);
  6574. /**
  6575. * Gets the byte stride.
  6576. */
  6577. readonly byteStride: number;
  6578. /**
  6579. * Gets the byte offset.
  6580. */
  6581. readonly byteOffset: number;
  6582. /**
  6583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6584. */
  6585. readonly normalized: boolean;
  6586. /**
  6587. * Gets the data type of each component in the array.
  6588. */
  6589. readonly type: number;
  6590. /**
  6591. * Constructor
  6592. * @param engine the engine
  6593. * @param data the data to use for this vertex buffer
  6594. * @param kind the vertex buffer kind
  6595. * @param updatable whether the data is updatable
  6596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6597. * @param stride the stride (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param offset the offset of the data (optional)
  6600. * @param size the number of components (optional)
  6601. * @param type the type of the component (optional)
  6602. * @param normalized whether the data contains normalized data (optional)
  6603. * @param useBytes set to true if stride and offset are in bytes (optional)
  6604. * @param divisor defines the instance divisor to use (1 by default)
  6605. */
  6606. 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);
  6607. /** @hidden */
  6608. _rebuild(): void;
  6609. /**
  6610. * Returns the kind of the VertexBuffer (string)
  6611. * @returns a string
  6612. */
  6613. getKind(): string;
  6614. /**
  6615. * Gets a boolean indicating if the VertexBuffer is updatable?
  6616. * @returns true if the buffer is updatable
  6617. */
  6618. isUpdatable(): boolean;
  6619. /**
  6620. * Gets current buffer's data
  6621. * @returns a DataArray or null
  6622. */
  6623. getData(): Nullable<DataArray>;
  6624. /**
  6625. * Gets underlying native buffer
  6626. * @returns underlying native buffer
  6627. */
  6628. getBuffer(): Nullable<DataBuffer>;
  6629. /**
  6630. * Gets the stride in float32 units (i.e. byte stride / 4).
  6631. * May not be an integer if the byte stride is not divisible by 4.
  6632. * @returns the stride in float32 units
  6633. * @deprecated Please use byteStride instead.
  6634. */
  6635. getStrideSize(): number;
  6636. /**
  6637. * Returns the offset as a multiple of the type byte length.
  6638. * @returns the offset in bytes
  6639. * @deprecated Please use byteOffset instead.
  6640. */
  6641. getOffset(): number;
  6642. /**
  6643. * Returns the number of components per vertex attribute (integer)
  6644. * @returns the size in float
  6645. */
  6646. getSize(): number;
  6647. /**
  6648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6649. * @returns true if this buffer is instanced
  6650. */
  6651. getIsInstanced(): boolean;
  6652. /**
  6653. * Returns the instancing divisor, zero for non-instanced (integer).
  6654. * @returns a number
  6655. */
  6656. getInstanceDivisor(): number;
  6657. /**
  6658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6659. * @param data defines the data to store
  6660. */
  6661. create(data?: DataArray): void;
  6662. /**
  6663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6664. * This function will create a new buffer if the current one is not updatable
  6665. * @param data defines the data to store
  6666. */
  6667. update(data: DataArray): void;
  6668. /**
  6669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6670. * Returns the directly updated WebGLBuffer.
  6671. * @param data the new data
  6672. * @param offset the new offset
  6673. * @param useBytes set to true if the offset is in bytes
  6674. */
  6675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6676. /**
  6677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6678. */
  6679. dispose(): void;
  6680. /**
  6681. * Enumerates each value of this vertex buffer as numbers.
  6682. * @param count the number of values to enumerate
  6683. * @param callback the callback function called for each value
  6684. */
  6685. forEach(count: number, callback: (value: number, index: number) => void): void;
  6686. /**
  6687. * Positions
  6688. */
  6689. static readonly PositionKind: string;
  6690. /**
  6691. * Normals
  6692. */
  6693. static readonly NormalKind: string;
  6694. /**
  6695. * Tangents
  6696. */
  6697. static readonly TangentKind: string;
  6698. /**
  6699. * Texture coordinates
  6700. */
  6701. static readonly UVKind: string;
  6702. /**
  6703. * Texture coordinates 2
  6704. */
  6705. static readonly UV2Kind: string;
  6706. /**
  6707. * Texture coordinates 3
  6708. */
  6709. static readonly UV3Kind: string;
  6710. /**
  6711. * Texture coordinates 4
  6712. */
  6713. static readonly UV4Kind: string;
  6714. /**
  6715. * Texture coordinates 5
  6716. */
  6717. static readonly UV5Kind: string;
  6718. /**
  6719. * Texture coordinates 6
  6720. */
  6721. static readonly UV6Kind: string;
  6722. /**
  6723. * Colors
  6724. */
  6725. static readonly ColorKind: string;
  6726. /**
  6727. * Matrix indices (for bones)
  6728. */
  6729. static readonly MatricesIndicesKind: string;
  6730. /**
  6731. * Matrix weights (for bones)
  6732. */
  6733. static readonly MatricesWeightsKind: string;
  6734. /**
  6735. * Additional matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesExtraKind: string;
  6738. /**
  6739. * Additional matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsExtraKind: string;
  6742. /**
  6743. * Deduces the stride given a kind.
  6744. * @param kind The kind string to deduce
  6745. * @returns The deduced stride
  6746. */
  6747. static DeduceStride(kind: string): number;
  6748. /**
  6749. * Gets the byte length of the given type.
  6750. * @param type the type
  6751. * @returns the number of bytes
  6752. */
  6753. static GetTypeByteLength(type: number): number;
  6754. /**
  6755. * Enumerates each value of the given parameters as numbers.
  6756. * @param data the data to enumerate
  6757. * @param byteOffset the byte offset of the data
  6758. * @param byteStride the byte stride of the data
  6759. * @param componentCount the number of components per element
  6760. * @param componentType the type of the component
  6761. * @param count the number of values to enumerate
  6762. * @param normalized whether the data is normalized
  6763. * @param callback the callback function called for each value
  6764. */
  6765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6766. private static _GetFloatValue;
  6767. }
  6768. }
  6769. declare module "babylonjs/Collisions/intersectionInfo" {
  6770. import { Nullable } from "babylonjs/types";
  6771. /**
  6772. * @hidden
  6773. */
  6774. export class IntersectionInfo {
  6775. bu: Nullable<number>;
  6776. bv: Nullable<number>;
  6777. distance: number;
  6778. faceId: number;
  6779. subMeshId: number;
  6780. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6781. }
  6782. }
  6783. declare module "babylonjs/Culling/boundingSphere" {
  6784. import { DeepImmutable } from "babylonjs/types";
  6785. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6786. import { Plane } from "babylonjs/Maths/math.plane";
  6787. /**
  6788. * Class used to store bounding sphere information
  6789. */
  6790. export class BoundingSphere {
  6791. /**
  6792. * Gets the center of the bounding sphere in local space
  6793. */
  6794. readonly center: Vector3;
  6795. /**
  6796. * Radius of the bounding sphere in local space
  6797. */
  6798. radius: number;
  6799. /**
  6800. * Gets the center of the bounding sphere in world space
  6801. */
  6802. readonly centerWorld: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in world space
  6805. */
  6806. radiusWorld: number;
  6807. /**
  6808. * Gets the minimum vector in local space
  6809. */
  6810. readonly minimum: Vector3;
  6811. /**
  6812. * Gets the maximum vector in local space
  6813. */
  6814. readonly maximum: Vector3;
  6815. private _worldMatrix;
  6816. private static readonly TmpVector3;
  6817. /**
  6818. * Creates a new bounding sphere
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6824. /**
  6825. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6826. * @param min defines the new minimum vector (in local space)
  6827. * @param max defines the new maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Scale the current bounding sphere by applying a scale factor
  6833. * @param factor defines the scale factor to apply
  6834. * @returns the current bounding box
  6835. */
  6836. scale(factor: number): BoundingSphere;
  6837. /**
  6838. * Gets the world matrix of the bounding box
  6839. * @returns a matrix
  6840. */
  6841. getWorldMatrix(): DeepImmutable<Matrix>;
  6842. /** @hidden */
  6843. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Tests if the bounding sphere is intersecting the frustum planes
  6846. * @param frustumPlanes defines the frustum planes to test
  6847. * @returns true if there is an intersection
  6848. */
  6849. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6850. /**
  6851. * Tests if the bounding sphere center is in between the frustum planes.
  6852. * Used for optimistic fast inclusion.
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if the sphere center is in between the frustum planes
  6855. */
  6856. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if a point is inside the bounding sphere
  6859. * @param point defines the point to test
  6860. * @returns true if the point is inside the bounding sphere
  6861. */
  6862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Checks if two sphere intersct
  6865. * @param sphere0 sphere 0
  6866. * @param sphere1 sphere 1
  6867. * @returns true if the speres intersect
  6868. */
  6869. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingBox" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6876. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6877. import { Plane } from "babylonjs/Maths/math.plane";
  6878. /**
  6879. * Class used to store bounding box information
  6880. */
  6881. export class BoundingBox implements ICullable {
  6882. /**
  6883. * Gets the 8 vectors representing the bounding box in local space
  6884. */
  6885. readonly vectors: Vector3[];
  6886. /**
  6887. * Gets the center of the bounding box in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Gets the center of the bounding box in world space
  6892. */
  6893. readonly centerWorld: Vector3;
  6894. /**
  6895. * Gets the extend size in local space
  6896. */
  6897. readonly extendSize: Vector3;
  6898. /**
  6899. * Gets the extend size in world space
  6900. */
  6901. readonly extendSizeWorld: Vector3;
  6902. /**
  6903. * Gets the OBB (object bounding box) directions
  6904. */
  6905. readonly directions: Vector3[];
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in world space
  6908. */
  6909. readonly vectorsWorld: Vector3[];
  6910. /**
  6911. * Gets the minimum vector in world space
  6912. */
  6913. readonly minimumWorld: Vector3;
  6914. /**
  6915. * Gets the maximum vector in world space
  6916. */
  6917. readonly maximumWorld: Vector3;
  6918. /**
  6919. * Gets the minimum vector in local space
  6920. */
  6921. readonly minimum: Vector3;
  6922. /**
  6923. * Gets the maximum vector in local space
  6924. */
  6925. readonly maximum: Vector3;
  6926. private _worldMatrix;
  6927. private static readonly TmpVector3;
  6928. /**
  6929. * @hidden
  6930. */
  6931. _tag: number;
  6932. /**
  6933. * Creates a new bounding box
  6934. * @param min defines the minimum vector (in local space)
  6935. * @param max defines the maximum vector (in local space)
  6936. * @param worldMatrix defines the new world matrix
  6937. */
  6938. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6939. /**
  6940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6941. * @param min defines the new minimum vector (in local space)
  6942. * @param max defines the new maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Scale the current bounding box by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding box
  6950. */
  6951. scale(factor: number): BoundingBox;
  6952. /**
  6953. * Gets the world matrix of the bounding box
  6954. * @returns a matrix
  6955. */
  6956. getWorldMatrix(): DeepImmutable<Matrix>;
  6957. /** @hidden */
  6958. _update(world: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Tests if the bounding box is intersecting the frustum planes
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @returns true if there is an intersection
  6963. */
  6964. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. /**
  6966. * Tests if the bounding box is entirely inside the frustum planes
  6967. * @param frustumPlanes defines the frustum planes to test
  6968. * @returns true if there is an inclusion
  6969. */
  6970. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6971. /**
  6972. * Tests if a point is inside the bounding box
  6973. * @param point defines the point to test
  6974. * @returns true if the point is inside the bounding box
  6975. */
  6976. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6977. /**
  6978. * Tests if the bounding box intersects with a bounding sphere
  6979. * @param sphere defines the sphere to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6983. /**
  6984. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6985. * @param min defines the min vector to use
  6986. * @param max defines the max vector to use
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if two bounding boxes are intersections
  6992. * @param box0 defines the first box to test
  6993. * @param box1 defines the second box to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6997. /**
  6998. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6999. * @param minPoint defines the minimum vector of the bounding box
  7000. * @param maxPoint defines the maximum vector of the bounding box
  7001. * @param sphereCenter defines the sphere center
  7002. * @param sphereRadius defines the sphere radius
  7003. * @returns true if there is an intersection
  7004. */
  7005. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7006. /**
  7007. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @return true if there is an inclusion
  7011. */
  7012. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an intersection
  7018. */
  7019. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. }
  7021. }
  7022. declare module "babylonjs/Collisions/collider" {
  7023. import { Nullable, IndicesArray } from "babylonjs/types";
  7024. import { Vector3 } from "babylonjs/Maths/math.vector";
  7025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7026. import { Plane } from "babylonjs/Maths/math.plane";
  7027. /** @hidden */
  7028. export class Collider {
  7029. /** Define if a collision was found */
  7030. collisionFound: boolean;
  7031. /**
  7032. * Define last intersection point in local space
  7033. */
  7034. intersectionPoint: Vector3;
  7035. /**
  7036. * Define last collided mesh
  7037. */
  7038. collidedMesh: Nullable<AbstractMesh>;
  7039. private _collisionPoint;
  7040. private _planeIntersectionPoint;
  7041. private _tempVector;
  7042. private _tempVector2;
  7043. private _tempVector3;
  7044. private _tempVector4;
  7045. private _edge;
  7046. private _baseToVertex;
  7047. private _destinationPoint;
  7048. private _slidePlaneNormal;
  7049. private _displacementVector;
  7050. /** @hidden */
  7051. _radius: Vector3;
  7052. /** @hidden */
  7053. _retry: number;
  7054. private _velocity;
  7055. private _basePoint;
  7056. private _epsilon;
  7057. /** @hidden */
  7058. _velocityWorldLength: number;
  7059. /** @hidden */
  7060. _basePointWorld: Vector3;
  7061. private _velocityWorld;
  7062. private _normalizedVelocity;
  7063. /** @hidden */
  7064. _initialVelocity: Vector3;
  7065. /** @hidden */
  7066. _initialPosition: Vector3;
  7067. private _nearestDistance;
  7068. private _collisionMask;
  7069. get collisionMask(): number;
  7070. set collisionMask(mask: number);
  7071. /**
  7072. * Gets the plane normal used to compute the sliding response (in local space)
  7073. */
  7074. get slidePlaneNormal(): Vector3;
  7075. /** @hidden */
  7076. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7077. /** @hidden */
  7078. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */
  7080. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7081. /** @hidden */
  7082. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7083. /** @hidden */
  7084. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7085. /** @hidden */
  7086. _getResponse(pos: Vector3, vel: Vector3): void;
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingInfo" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7092. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7093. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7094. import { Plane } from "babylonjs/Maths/math.plane";
  7095. import { Collider } from "babylonjs/Collisions/collider";
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. get minimum(): Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. get maximum(): Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. get isLocked(): boolean;
  7155. set isLocked(value: boolean);
  7156. /**
  7157. * Updates the bounding sphere and box
  7158. * @param world world matrix to be used to update
  7159. */
  7160. update(world: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7163. * @param center New center of the bounding info
  7164. * @param extend New extend of the bounding info
  7165. * @returns the current bounding info
  7166. */
  7167. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7168. /**
  7169. * Scale the current bounding info by applying a scale factor
  7170. * @param factor defines the scale factor to apply
  7171. * @returns the current bounding info
  7172. */
  7173. scale(factor: number): BoundingInfo;
  7174. /**
  7175. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7176. * @param frustumPlanes defines the frustum to test
  7177. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7178. * @returns true if the bounding info is in the frustum planes
  7179. */
  7180. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7181. /**
  7182. * Gets the world distance between the min and max points of the bounding box
  7183. */
  7184. get diagonalLength(): number;
  7185. /**
  7186. * Checks if a cullable object (mesh...) is in the camera frustum
  7187. * Unlike isInFrustum this cheks the full bounding box
  7188. * @param frustumPlanes Camera near/planes
  7189. * @returns true if the object is in frustum otherwise false
  7190. */
  7191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /** @hidden */
  7193. _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module "babylonjs/Maths/math.functions" {
  7212. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7214. /**
  7215. * Extracts minimum and maximum values from a list of indexed positions
  7216. * @param positions defines the positions to use
  7217. * @param indices defines the indices to the positions
  7218. * @param indexStart defines the start index
  7219. * @param indexCount defines the end index
  7220. * @param bias defines bias value to add to the result
  7221. * @return minimum and maximum values
  7222. */
  7223. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7224. minimum: Vector3;
  7225. maximum: Vector3;
  7226. };
  7227. /**
  7228. * Extracts minimum and maximum values from a list of positions
  7229. * @param positions defines the positions to use
  7230. * @param start defines the start index in the positions array
  7231. * @param count defines the number of positions to handle
  7232. * @param bias defines bias value to add to the result
  7233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7234. * @return minimum and maximum values
  7235. */
  7236. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7237. minimum: Vector3;
  7238. maximum: Vector3;
  7239. };
  7240. }
  7241. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7243. /** @hidden */
  7244. export class WebGLDataBuffer extends DataBuffer {
  7245. private _buffer;
  7246. constructor(resource: WebGLBuffer);
  7247. get underlyingResource(): any;
  7248. }
  7249. }
  7250. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. import { Nullable } from "babylonjs/types";
  7253. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7254. /** @hidden */
  7255. export class WebGLPipelineContext implements IPipelineContext {
  7256. engine: ThinEngine;
  7257. program: Nullable<WebGLProgram>;
  7258. context?: WebGLRenderingContext;
  7259. vertexShader?: WebGLShader;
  7260. fragmentShader?: WebGLShader;
  7261. isParallelCompiled: boolean;
  7262. onCompiled?: () => void;
  7263. transformFeedback?: WebGLTransformFeedback | null;
  7264. vertexCompilationError: Nullable<string>;
  7265. fragmentCompilationError: Nullable<string>;
  7266. programLinkError: Nullable<string>;
  7267. programValidationError: Nullable<string>;
  7268. get isAsync(): boolean;
  7269. get isReady(): boolean;
  7270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7271. _getVertexShaderCode(): string | null;
  7272. _getFragmentShaderCode(): string | null;
  7273. }
  7274. }
  7275. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7276. import { FloatArray, Nullable } from "babylonjs/types";
  7277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7279. module "babylonjs/Engines/thinEngine" {
  7280. interface ThinEngine {
  7281. /**
  7282. * Create an uniform buffer
  7283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7284. * @param elements defines the content of the uniform buffer
  7285. * @returns the webGL uniform buffer
  7286. */
  7287. createUniformBuffer(elements: FloatArray): DataBuffer;
  7288. /**
  7289. * Create a dynamic uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Update an existing uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param uniformBuffer defines the target uniform buffer
  7299. * @param elements defines the content to update
  7300. * @param offset defines the offset in the uniform buffer where update should start
  7301. * @param count defines the size of the data to update
  7302. */
  7303. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7304. /**
  7305. * Bind an uniform buffer to the current webGL context
  7306. * @param buffer defines the buffer to bind
  7307. */
  7308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7309. /**
  7310. * Bind a buffer to the current webGL context at a given location
  7311. * @param buffer defines the buffer to bind
  7312. * @param location defines the index where to bind the buffer
  7313. */
  7314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7315. /**
  7316. * Bind a specific block at a given index in a specific shader program
  7317. * @param pipelineContext defines the pipeline context to use
  7318. * @param blockName defines the block name
  7319. * @param index defines the index where to bind the block
  7320. */
  7321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7322. }
  7323. }
  7324. }
  7325. declare module "babylonjs/Materials/uniformBuffer" {
  7326. import { Nullable, FloatArray } from "babylonjs/types";
  7327. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7328. import { Engine } from "babylonjs/Engines/engine";
  7329. import { Effect } from "babylonjs/Materials/effect";
  7330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7332. import { Color3 } from "babylonjs/Maths/math.color";
  7333. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7334. /**
  7335. * Uniform buffer objects.
  7336. *
  7337. * Handles blocks of uniform on the GPU.
  7338. *
  7339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7340. *
  7341. * For more information, please refer to :
  7342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7343. */
  7344. export class UniformBuffer {
  7345. private _engine;
  7346. private _buffer;
  7347. private _data;
  7348. private _bufferData;
  7349. private _dynamic?;
  7350. private _uniformLocations;
  7351. private _uniformSizes;
  7352. private _uniformLocationPointer;
  7353. private _needSync;
  7354. private _noUBO;
  7355. private _currentEffect;
  7356. /** @hidden */
  7357. _alreadyBound: boolean;
  7358. private static _MAX_UNIFORM_SIZE;
  7359. private static _tempBuffer;
  7360. /**
  7361. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7362. * This is dynamic to allow compat with webgl 1 and 2.
  7363. * You will need to pass the name of the uniform as well as the value.
  7364. */
  7365. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7366. /**
  7367. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7368. * This is dynamic to allow compat with webgl 1 and 2.
  7369. * You will need to pass the name of the uniform as well as the value.
  7370. */
  7371. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7372. /**
  7373. * Lambda to Update a single float in a uniform buffer.
  7374. * This is dynamic to allow compat with webgl 1 and 2.
  7375. * You will need to pass the name of the uniform as well as the value.
  7376. */
  7377. updateFloat: (name: string, x: number) => void;
  7378. /**
  7379. * Lambda to Update a vec2 of float in a uniform buffer.
  7380. * This is dynamic to allow compat with webgl 1 and 2.
  7381. * You will need to pass the name of the uniform as well as the value.
  7382. */
  7383. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7384. /**
  7385. * Lambda to Update a vec3 of float in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7390. /**
  7391. * Lambda to Update a vec4 of float in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7396. /**
  7397. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateMatrix: (name: string, mat: Matrix) => void;
  7402. /**
  7403. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateVector3: (name: string, vector: Vector3) => void;
  7408. /**
  7409. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateVector4: (name: string, vector: Vector4) => void;
  7414. /**
  7415. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7426. /**
  7427. * Instantiates a new Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. * @param engine Define the engine the buffer is associated with
  7436. * @param data Define the data contained in the buffer
  7437. * @param dynamic Define if the buffer is updatable
  7438. */
  7439. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7440. /**
  7441. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7442. * or just falling back on setUniformXXX calls.
  7443. */
  7444. get useUbo(): boolean;
  7445. /**
  7446. * Indicates if the WebGL underlying uniform buffer is in sync
  7447. * with the javascript cache data.
  7448. */
  7449. get isSync(): boolean;
  7450. /**
  7451. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7452. * Also, a dynamic UniformBuffer will disable cache verification and always
  7453. * update the underlying WebGL uniform buffer to the GPU.
  7454. * @returns if Dynamic, otherwise false
  7455. */
  7456. isDynamic(): boolean;
  7457. /**
  7458. * The data cache on JS side.
  7459. * @returns the underlying data as a float array
  7460. */
  7461. getData(): Float32Array;
  7462. /**
  7463. * The underlying WebGL Uniform buffer.
  7464. * @returns the webgl buffer
  7465. */
  7466. getBuffer(): Nullable<DataBuffer>;
  7467. /**
  7468. * std140 layout specifies how to align data within an UBO structure.
  7469. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7470. * for specs.
  7471. */
  7472. private _fillAlignment;
  7473. /**
  7474. * Adds an uniform in the buffer.
  7475. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7476. * for the layout to be correct !
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param size Data size, or data directly.
  7479. */
  7480. addUniform(name: string, size: number | number[]): void;
  7481. /**
  7482. * Adds a Matrix 4x4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param mat A 4x4 matrix.
  7485. */
  7486. addMatrix(name: string, mat: Matrix): void;
  7487. /**
  7488. * Adds a vec2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param x Define the x component value of the vec2
  7491. * @param y Define the y component value of the vec2
  7492. */
  7493. addFloat2(name: string, x: number, y: number): void;
  7494. /**
  7495. * Adds a vec3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec3
  7498. * @param y Define the y component value of the vec3
  7499. * @param z Define the z component value of the vec3
  7500. */
  7501. addFloat3(name: string, x: number, y: number, z: 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 color Define the vec3 from a Color
  7506. */
  7507. addColor3(name: string, color: Color3): void;
  7508. /**
  7509. * Adds a vec4 to the uniform buffer.
  7510. * @param name Name of the uniform, as used in the uniform block in the shader.
  7511. * @param color Define the rgb components from a Color
  7512. * @param alpha Define the a component of the vec4
  7513. */
  7514. addColor4(name: string, color: Color3, alpha: number): void;
  7515. /**
  7516. * Adds a vec3 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param vector Define the vec3 components from a Vector
  7519. */
  7520. addVector3(name: string, vector: Vector3): void;
  7521. /**
  7522. * Adds a Matrix 3x3 to the uniform buffer.
  7523. * @param name Name of the uniform, as used in the uniform block in the shader.
  7524. */
  7525. addMatrix3x3(name: string): void;
  7526. /**
  7527. * Adds a Matrix 2x2 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. */
  7530. addMatrix2x2(name: string): void;
  7531. /**
  7532. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7533. */
  7534. create(): void;
  7535. /** @hidden */
  7536. _rebuild(): void;
  7537. /**
  7538. * Updates the WebGL Uniform Buffer on the GPU.
  7539. * If the `dynamic` flag is set to true, no cache comparison is done.
  7540. * Otherwise, the buffer will be updated only if the cache differs.
  7541. */
  7542. update(): void;
  7543. /**
  7544. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7546. * @param data Define the flattened data
  7547. * @param size Define the size of the data.
  7548. */
  7549. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7550. private _valueCache;
  7551. private _cacheMatrix;
  7552. private _updateMatrix3x3ForUniform;
  7553. private _updateMatrix3x3ForEffect;
  7554. private _updateMatrix2x2ForEffect;
  7555. private _updateMatrix2x2ForUniform;
  7556. private _updateFloatForEffect;
  7557. private _updateFloatForUniform;
  7558. private _updateFloat2ForEffect;
  7559. private _updateFloat2ForUniform;
  7560. private _updateFloat3ForEffect;
  7561. private _updateFloat3ForUniform;
  7562. private _updateFloat4ForEffect;
  7563. private _updateFloat4ForUniform;
  7564. private _updateMatrixForEffect;
  7565. private _updateMatrixForUniform;
  7566. private _updateVector3ForEffect;
  7567. private _updateVector3ForUniform;
  7568. private _updateVector4ForEffect;
  7569. private _updateVector4ForUniform;
  7570. private _updateColor3ForEffect;
  7571. private _updateColor3ForUniform;
  7572. private _updateColor4ForEffect;
  7573. private _updateColor4ForUniform;
  7574. /**
  7575. * Sets a sampler uniform on the effect.
  7576. * @param name Define the name of the sampler.
  7577. * @param texture Define the texture to set in the sampler
  7578. */
  7579. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7580. /**
  7581. * Directly updates the value of the uniform in the cache AND on the GPU.
  7582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7583. * @param data Define the flattened data
  7584. */
  7585. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7586. /**
  7587. * Binds this uniform buffer to an effect.
  7588. * @param effect Define the effect to bind the buffer to
  7589. * @param name Name of the uniform block in the shader.
  7590. */
  7591. bindToEffect(effect: Effect, name: string): void;
  7592. /**
  7593. * Disposes the uniform buffer.
  7594. */
  7595. dispose(): void;
  7596. }
  7597. }
  7598. declare module "babylonjs/Misc/iInspectable" {
  7599. /**
  7600. * Enum that determines the text-wrapping mode to use.
  7601. */
  7602. export enum InspectableType {
  7603. /**
  7604. * Checkbox for booleans
  7605. */
  7606. Checkbox = 0,
  7607. /**
  7608. * Sliders for numbers
  7609. */
  7610. Slider = 1,
  7611. /**
  7612. * Vector3
  7613. */
  7614. Vector3 = 2,
  7615. /**
  7616. * Quaternions
  7617. */
  7618. Quaternion = 3,
  7619. /**
  7620. * Color3
  7621. */
  7622. Color3 = 4,
  7623. /**
  7624. * String
  7625. */
  7626. String = 5
  7627. }
  7628. /**
  7629. * Interface used to define custom inspectable properties.
  7630. * This interface is used by the inspector to display custom property grids
  7631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7632. */
  7633. export interface IInspectable {
  7634. /**
  7635. * Gets the label to display
  7636. */
  7637. label: string;
  7638. /**
  7639. * Gets the name of the property to edit
  7640. */
  7641. propertyName: string;
  7642. /**
  7643. * Gets the type of the editor to use
  7644. */
  7645. type: InspectableType;
  7646. /**
  7647. * Gets the minimum value of the property when using in "slider" mode
  7648. */
  7649. min?: number;
  7650. /**
  7651. * Gets the maximum value of the property when using in "slider" mode
  7652. */
  7653. max?: number;
  7654. /**
  7655. * Gets the setp to use when using in "slider" mode
  7656. */
  7657. step?: number;
  7658. }
  7659. }
  7660. declare module "babylonjs/Misc/timingTools" {
  7661. /**
  7662. * Class used to provide helper for timing
  7663. */
  7664. export class TimingTools {
  7665. /**
  7666. * Polyfill for setImmediate
  7667. * @param action defines the action to execute after the current execution block
  7668. */
  7669. static SetImmediate(action: () => void): void;
  7670. }
  7671. }
  7672. declare module "babylonjs/Misc/instantiationTools" {
  7673. /**
  7674. * Class used to enable instatition of objects by class name
  7675. */
  7676. export class InstantiationTools {
  7677. /**
  7678. * Use this object to register external classes like custom textures or material
  7679. * to allow the laoders to instantiate them
  7680. */
  7681. static RegisteredExternalClasses: {
  7682. [key: string]: Object;
  7683. };
  7684. /**
  7685. * Tries to instantiate a new object from a given class name
  7686. * @param className defines the class name to instantiate
  7687. * @returns the new object or null if the system was not able to do the instantiation
  7688. */
  7689. static Instantiate(className: string): any;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7693. /**
  7694. * Define options used to create a depth texture
  7695. */
  7696. export class DepthTextureCreationOptions {
  7697. /** Specifies whether or not a stencil should be allocated in the texture */
  7698. generateStencil?: boolean;
  7699. /** Specifies whether or not bilinear filtering is enable on the texture */
  7700. bilinearFiltering?: boolean;
  7701. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7702. comparisonFunction?: number;
  7703. /** Specifies if the created texture is a cube texture */
  7704. isCube?: boolean;
  7705. }
  7706. }
  7707. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7709. import { Nullable } from "babylonjs/types";
  7710. import { Scene } from "babylonjs/scene";
  7711. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7712. module "babylonjs/Engines/thinEngine" {
  7713. interface ThinEngine {
  7714. /**
  7715. * Creates a depth stencil cube texture.
  7716. * This is only available in WebGL 2.
  7717. * @param size The size of face edge in the cube texture.
  7718. * @param options The options defining the cube texture.
  7719. * @returns The cube texture
  7720. */
  7721. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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;
  7739. /**
  7740. * Creates a cube texture
  7741. * @param rootUrl defines the url where the files to load is located
  7742. * @param scene defines the current scene
  7743. * @param files defines the list of files to load (1 per face)
  7744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7745. * @param onLoad defines an optional callback raised when the texture is loaded
  7746. * @param onError defines an optional callback raised if there is an issue to load the texture
  7747. * @param format defines the format of the data
  7748. * @param forcedExtension defines the extension to use to pick the right loader
  7749. * @returns the cube texture as an InternalTexture
  7750. */
  7751. 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;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @returns the cube texture as an InternalTexture
  7766. */
  7767. 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;
  7768. /** @hidden */
  7769. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7770. /** @hidden */
  7771. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7772. /** @hidden */
  7773. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7774. /** @hidden */
  7775. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7776. /**
  7777. * @hidden
  7778. */
  7779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7780. }
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7784. import { Nullable } from "babylonjs/types";
  7785. import { Scene } from "babylonjs/scene";
  7786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7788. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7789. import { Observable } from "babylonjs/Misc/observable";
  7790. /**
  7791. * Class for creating a cube texture
  7792. */
  7793. export class CubeTexture extends BaseTexture {
  7794. private _delayedOnLoad;
  7795. /**
  7796. * Observable triggered once the texture has been loaded.
  7797. */
  7798. onLoadObservable: Observable<CubeTexture>;
  7799. /**
  7800. * The url of the texture
  7801. */
  7802. url: string;
  7803. /**
  7804. * Gets or sets the center of the bounding box associated with the cube texture.
  7805. * It must define where the camera used to render the texture was set
  7806. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7807. */
  7808. boundingBoxPosition: Vector3;
  7809. private _boundingBoxSize;
  7810. /**
  7811. * Gets or sets the size of the bounding box associated with the cube texture
  7812. * When defined, the cubemap will switch to local mode
  7813. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7814. * @example https://www.babylonjs-playground.com/#RNASML
  7815. */
  7816. set boundingBoxSize(value: Vector3);
  7817. /**
  7818. * Returns the bounding box size
  7819. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7820. */
  7821. get boundingBoxSize(): Vector3;
  7822. protected _rotationY: number;
  7823. /**
  7824. * Sets texture matrix rotation angle around Y axis in radians.
  7825. */
  7826. set rotationY(value: number);
  7827. /**
  7828. * Gets texture matrix rotation angle around Y axis radians.
  7829. */
  7830. get rotationY(): number;
  7831. /**
  7832. * Are mip maps generated for this texture or not.
  7833. */
  7834. get noMipmap(): boolean;
  7835. private _noMipmap;
  7836. private _files;
  7837. protected _forcedExtension: Nullable<string>;
  7838. private _extensions;
  7839. private _textureMatrix;
  7840. private _format;
  7841. private _createPolynomials;
  7842. /** @hidden */
  7843. _prefiltered: boolean;
  7844. /**
  7845. * Creates a cube texture from an array of image urls
  7846. * @param files defines an array of image urls
  7847. * @param scene defines the hosting scene
  7848. * @param noMipmap specifies if mip maps are not used
  7849. * @returns a cube texture
  7850. */
  7851. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7852. /**
  7853. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7854. * @param url defines the url of the prefiltered texture
  7855. * @param scene defines the scene the texture is attached to
  7856. * @param forcedExtension defines the extension of the file if different from the url
  7857. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7858. * @return the prefiltered texture
  7859. */
  7860. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7861. /**
  7862. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7863. * as prefiltered data.
  7864. * @param rootUrl defines the url of the texture or the root name of the six images
  7865. * @param scene defines the scene the texture is attached to
  7866. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7867. * @param noMipmap defines if mipmaps should be created or not
  7868. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7869. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7870. * @param onError defines a callback triggered in case of error during load
  7871. * @param format defines the internal format to use for the texture once loaded
  7872. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7873. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7874. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7875. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7876. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7877. * @return the cube texture
  7878. */
  7879. constructor(rootUrl: string, scene: Scene, 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);
  7880. /**
  7881. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7882. */
  7883. get isPrefiltered(): boolean;
  7884. /**
  7885. * Get the current class name of the texture useful for serialization or dynamic coding.
  7886. * @returns "CubeTexture"
  7887. */
  7888. getClassName(): string;
  7889. /**
  7890. * Update the url (and optional buffer) of this texture if url was null during construction.
  7891. * @param url the url of the texture
  7892. * @param forcedExtension defines the extension to use
  7893. * @param onLoad callback called when the texture is loaded (defaults to null)
  7894. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7895. */
  7896. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7897. /**
  7898. * Delays loading of the cube texture
  7899. * @param forcedExtension defines the extension to use
  7900. */
  7901. delayLoad(forcedExtension?: string): void;
  7902. /**
  7903. * Returns the reflection texture matrix
  7904. * @returns the reflection texture matrix
  7905. */
  7906. getReflectionTextureMatrix(): Matrix;
  7907. /**
  7908. * Sets the reflection texture matrix
  7909. * @param value Reflection texture matrix
  7910. */
  7911. setReflectionTextureMatrix(value: Matrix): void;
  7912. /**
  7913. * Parses text to create a cube texture
  7914. * @param parsedTexture define the serialized text to read from
  7915. * @param scene defines the hosting scene
  7916. * @param rootUrl defines the root url of the cube texture
  7917. * @returns a cube texture
  7918. */
  7919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7920. /**
  7921. * Makes a clone, or deep copy, of the cube texture
  7922. * @returns a new cube texture
  7923. */
  7924. clone(): CubeTexture;
  7925. }
  7926. }
  7927. declare module "babylonjs/Materials/materialDefines" {
  7928. /**
  7929. * Manages the defines for the Material
  7930. */
  7931. export class MaterialDefines {
  7932. /** @hidden */
  7933. protected _keys: string[];
  7934. private _isDirty;
  7935. /** @hidden */
  7936. _renderId: number;
  7937. /** @hidden */
  7938. _areLightsDirty: boolean;
  7939. /** @hidden */
  7940. _areLightsDisposed: boolean;
  7941. /** @hidden */
  7942. _areAttributesDirty: boolean;
  7943. /** @hidden */
  7944. _areTexturesDirty: boolean;
  7945. /** @hidden */
  7946. _areFresnelDirty: boolean;
  7947. /** @hidden */
  7948. _areMiscDirty: boolean;
  7949. /** @hidden */
  7950. _areImageProcessingDirty: boolean;
  7951. /** @hidden */
  7952. _normals: boolean;
  7953. /** @hidden */
  7954. _uvs: boolean;
  7955. /** @hidden */
  7956. _needNormals: boolean;
  7957. /** @hidden */
  7958. _needUVs: boolean;
  7959. [id: string]: any;
  7960. /**
  7961. * Specifies if the material needs to be re-calculated
  7962. */
  7963. get isDirty(): boolean;
  7964. /**
  7965. * Marks the material to indicate that it has been re-calculated
  7966. */
  7967. markAsProcessed(): void;
  7968. /**
  7969. * Marks the material to indicate that it needs to be re-calculated
  7970. */
  7971. markAsUnprocessed(): void;
  7972. /**
  7973. * Marks the material to indicate all of its defines need to be re-calculated
  7974. */
  7975. markAllAsDirty(): void;
  7976. /**
  7977. * Marks the material to indicate that image processing needs to be re-calculated
  7978. */
  7979. markAsImageProcessingDirty(): void;
  7980. /**
  7981. * Marks the material to indicate the lights need to be re-calculated
  7982. * @param disposed Defines whether the light is dirty due to dispose or not
  7983. */
  7984. markAsLightDirty(disposed?: boolean): void;
  7985. /**
  7986. * Marks the attribute state as changed
  7987. */
  7988. markAsAttributesDirty(): void;
  7989. /**
  7990. * Marks the texture state as changed
  7991. */
  7992. markAsTexturesDirty(): void;
  7993. /**
  7994. * Marks the fresnel state as changed
  7995. */
  7996. markAsFresnelDirty(): void;
  7997. /**
  7998. * Marks the misc state as changed
  7999. */
  8000. markAsMiscDirty(): void;
  8001. /**
  8002. * Rebuilds the material defines
  8003. */
  8004. rebuild(): void;
  8005. /**
  8006. * Specifies if two material defines are equal
  8007. * @param other - A material define instance to compare to
  8008. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8009. */
  8010. isEqual(other: MaterialDefines): boolean;
  8011. /**
  8012. * Clones this instance's defines to another instance
  8013. * @param other - material defines to clone values to
  8014. */
  8015. cloneTo(other: MaterialDefines): void;
  8016. /**
  8017. * Resets the material define values
  8018. */
  8019. reset(): void;
  8020. /**
  8021. * Converts the material define values to a string
  8022. * @returns - String of material define information
  8023. */
  8024. toString(): string;
  8025. }
  8026. }
  8027. declare module "babylonjs/Materials/colorCurves" {
  8028. import { Effect } from "babylonjs/Materials/effect";
  8029. /**
  8030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8032. * 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;
  8033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8034. */
  8035. export class ColorCurves {
  8036. private _dirty;
  8037. private _tempColor;
  8038. private _globalCurve;
  8039. private _highlightsCurve;
  8040. private _midtonesCurve;
  8041. private _shadowsCurve;
  8042. private _positiveCurve;
  8043. private _negativeCurve;
  8044. private _globalHue;
  8045. private _globalDensity;
  8046. private _globalSaturation;
  8047. private _globalExposure;
  8048. /**
  8049. * Gets the global Hue value.
  8050. * 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).
  8051. */
  8052. get globalHue(): number;
  8053. /**
  8054. * Sets the global Hue value.
  8055. * 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).
  8056. */
  8057. set globalHue(value: number);
  8058. /**
  8059. * Gets the global Density value.
  8060. * 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.
  8061. * Values less than zero provide a filter of opposite hue.
  8062. */
  8063. get globalDensity(): number;
  8064. /**
  8065. * Sets the global Density value.
  8066. * 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.
  8067. * Values less than zero provide a filter of opposite hue.
  8068. */
  8069. set globalDensity(value: number);
  8070. /**
  8071. * Gets the global Saturation value.
  8072. * 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.
  8073. */
  8074. get globalSaturation(): number;
  8075. /**
  8076. * Sets the global Saturation value.
  8077. * 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.
  8078. */
  8079. set globalSaturation(value: number);
  8080. /**
  8081. * Gets the global Exposure value.
  8082. * 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.
  8083. */
  8084. get globalExposure(): number;
  8085. /**
  8086. * Sets the global Exposure value.
  8087. * 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.
  8088. */
  8089. set globalExposure(value: number);
  8090. private _highlightsHue;
  8091. private _highlightsDensity;
  8092. private _highlightsSaturation;
  8093. private _highlightsExposure;
  8094. /**
  8095. * Gets the highlights Hue value.
  8096. * 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).
  8097. */
  8098. get highlightsHue(): number;
  8099. /**
  8100. * Sets the highlights Hue value.
  8101. * 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).
  8102. */
  8103. set highlightsHue(value: number);
  8104. /**
  8105. * Gets the highlights Density value.
  8106. * 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.
  8107. * Values less than zero provide a filter of opposite hue.
  8108. */
  8109. get highlightsDensity(): number;
  8110. /**
  8111. * Sets the highlights Density value.
  8112. * 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.
  8113. * Values less than zero provide a filter of opposite hue.
  8114. */
  8115. set highlightsDensity(value: number);
  8116. /**
  8117. * Gets the highlights Saturation value.
  8118. * 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.
  8119. */
  8120. get highlightsSaturation(): number;
  8121. /**
  8122. * Sets the highlights Saturation value.
  8123. * 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.
  8124. */
  8125. set highlightsSaturation(value: number);
  8126. /**
  8127. * Gets the highlights Exposure value.
  8128. * 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.
  8129. */
  8130. get highlightsExposure(): number;
  8131. /**
  8132. * Sets the highlights Exposure value.
  8133. * 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.
  8134. */
  8135. set highlightsExposure(value: number);
  8136. private _midtonesHue;
  8137. private _midtonesDensity;
  8138. private _midtonesSaturation;
  8139. private _midtonesExposure;
  8140. /**
  8141. * Gets the midtones Hue value.
  8142. * 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).
  8143. */
  8144. get midtonesHue(): number;
  8145. /**
  8146. * Sets the midtones Hue value.
  8147. * 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).
  8148. */
  8149. set midtonesHue(value: number);
  8150. /**
  8151. * Gets the midtones Density value.
  8152. * 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.
  8153. * Values less than zero provide a filter of opposite hue.
  8154. */
  8155. get midtonesDensity(): number;
  8156. /**
  8157. * Sets the midtones Density value.
  8158. * 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.
  8159. * Values less than zero provide a filter of opposite hue.
  8160. */
  8161. set midtonesDensity(value: number);
  8162. /**
  8163. * Gets the midtones Saturation value.
  8164. * 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.
  8165. */
  8166. get midtonesSaturation(): number;
  8167. /**
  8168. * Sets the midtones Saturation value.
  8169. * 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.
  8170. */
  8171. set midtonesSaturation(value: number);
  8172. /**
  8173. * Gets the midtones Exposure value.
  8174. * 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.
  8175. */
  8176. get midtonesExposure(): number;
  8177. /**
  8178. * Sets the midtones Exposure value.
  8179. * 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.
  8180. */
  8181. set midtonesExposure(value: number);
  8182. private _shadowsHue;
  8183. private _shadowsDensity;
  8184. private _shadowsSaturation;
  8185. private _shadowsExposure;
  8186. /**
  8187. * Gets the shadows Hue value.
  8188. * 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).
  8189. */
  8190. get shadowsHue(): number;
  8191. /**
  8192. * Sets the shadows Hue value.
  8193. * 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).
  8194. */
  8195. set shadowsHue(value: number);
  8196. /**
  8197. * Gets the shadows Density value.
  8198. * 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.
  8199. * Values less than zero provide a filter of opposite hue.
  8200. */
  8201. get shadowsDensity(): number;
  8202. /**
  8203. * Sets the shadows Density value.
  8204. * 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.
  8205. * Values less than zero provide a filter of opposite hue.
  8206. */
  8207. set shadowsDensity(value: number);
  8208. /**
  8209. * Gets the shadows Saturation value.
  8210. * 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.
  8211. */
  8212. get shadowsSaturation(): number;
  8213. /**
  8214. * Sets the shadows Saturation value.
  8215. * 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.
  8216. */
  8217. set shadowsSaturation(value: number);
  8218. /**
  8219. * Gets the shadows Exposure value.
  8220. * 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.
  8221. */
  8222. get shadowsExposure(): number;
  8223. /**
  8224. * Sets the shadows Exposure value.
  8225. * 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.
  8226. */
  8227. set shadowsExposure(value: number);
  8228. /**
  8229. * Returns the class name
  8230. * @returns The class name
  8231. */
  8232. getClassName(): string;
  8233. /**
  8234. * Binds the color curves to the shader.
  8235. * @param colorCurves The color curve to bind
  8236. * @param effect The effect to bind to
  8237. * @param positiveUniform The positive uniform shader parameter
  8238. * @param neutralUniform The neutral uniform shader parameter
  8239. * @param negativeUniform The negative uniform shader parameter
  8240. */
  8241. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8242. /**
  8243. * Prepare the list of uniforms associated with the ColorCurves effects.
  8244. * @param uniformsList The list of uniforms used in the effect
  8245. */
  8246. static PrepareUniforms(uniformsList: string[]): void;
  8247. /**
  8248. * Returns color grading data based on a hue, density, saturation and exposure value.
  8249. * @param filterHue The hue of the color filter.
  8250. * @param filterDensity The density of the color filter.
  8251. * @param saturation The saturation.
  8252. * @param exposure The exposure.
  8253. * @param result The result data container.
  8254. */
  8255. private getColorGradingDataToRef;
  8256. /**
  8257. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8258. * @param value The input slider value in range [-100,100].
  8259. * @returns Adjusted value.
  8260. */
  8261. private static applyColorGradingSliderNonlinear;
  8262. /**
  8263. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8264. * @param hue The hue (H) input.
  8265. * @param saturation The saturation (S) input.
  8266. * @param brightness The brightness (B) input.
  8267. * @result An RGBA color represented as Vector4.
  8268. */
  8269. private static fromHSBToRef;
  8270. /**
  8271. * Returns a value clamped between min and max
  8272. * @param value The value to clamp
  8273. * @param min The minimum of value
  8274. * @param max The maximum of value
  8275. * @returns The clamped value.
  8276. */
  8277. private static clamp;
  8278. /**
  8279. * Clones the current color curve instance.
  8280. * @return The cloned curves
  8281. */
  8282. clone(): ColorCurves;
  8283. /**
  8284. * Serializes the current color curve instance to a json representation.
  8285. * @return a JSON representation
  8286. */
  8287. serialize(): any;
  8288. /**
  8289. * Parses the color curve from a json representation.
  8290. * @param source the JSON source to parse
  8291. * @return The parsed curves
  8292. */
  8293. static Parse(source: any): ColorCurves;
  8294. }
  8295. }
  8296. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8297. import { Observable } from "babylonjs/Misc/observable";
  8298. import { Nullable } from "babylonjs/types";
  8299. import { Color4 } from "babylonjs/Maths/math.color";
  8300. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8301. import { Effect } from "babylonjs/Materials/effect";
  8302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8303. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8304. /**
  8305. * Interface to follow in your material defines to integrate easily the
  8306. * Image proccessing functions.
  8307. * @hidden
  8308. */
  8309. export interface IImageProcessingConfigurationDefines {
  8310. IMAGEPROCESSING: boolean;
  8311. VIGNETTE: boolean;
  8312. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8313. VIGNETTEBLENDMODEOPAQUE: boolean;
  8314. TONEMAPPING: boolean;
  8315. TONEMAPPING_ACES: boolean;
  8316. CONTRAST: boolean;
  8317. EXPOSURE: boolean;
  8318. COLORCURVES: boolean;
  8319. COLORGRADING: boolean;
  8320. COLORGRADING3D: boolean;
  8321. SAMPLER3DGREENDEPTH: boolean;
  8322. SAMPLER3DBGRMAP: boolean;
  8323. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8324. }
  8325. /**
  8326. * @hidden
  8327. */
  8328. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8329. IMAGEPROCESSING: boolean;
  8330. VIGNETTE: boolean;
  8331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8332. VIGNETTEBLENDMODEOPAQUE: boolean;
  8333. TONEMAPPING: boolean;
  8334. TONEMAPPING_ACES: boolean;
  8335. CONTRAST: boolean;
  8336. COLORCURVES: boolean;
  8337. COLORGRADING: boolean;
  8338. COLORGRADING3D: boolean;
  8339. SAMPLER3DGREENDEPTH: boolean;
  8340. SAMPLER3DBGRMAP: boolean;
  8341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8342. EXPOSURE: boolean;
  8343. constructor();
  8344. }
  8345. /**
  8346. * This groups together the common properties used for image processing either in direct forward pass
  8347. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8348. * or not.
  8349. */
  8350. export class ImageProcessingConfiguration {
  8351. /**
  8352. * Default tone mapping applied in BabylonJS.
  8353. */
  8354. static readonly TONEMAPPING_STANDARD: number;
  8355. /**
  8356. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8357. * to other engines rendering to increase portability.
  8358. */
  8359. static readonly TONEMAPPING_ACES: number;
  8360. /**
  8361. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8362. */
  8363. colorCurves: Nullable<ColorCurves>;
  8364. private _colorCurvesEnabled;
  8365. /**
  8366. * Gets wether the color curves effect is enabled.
  8367. */
  8368. get colorCurvesEnabled(): boolean;
  8369. /**
  8370. * Sets wether the color curves effect is enabled.
  8371. */
  8372. set colorCurvesEnabled(value: boolean);
  8373. private _colorGradingTexture;
  8374. /**
  8375. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8376. */
  8377. get colorGradingTexture(): Nullable<BaseTexture>;
  8378. /**
  8379. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8380. */
  8381. set colorGradingTexture(value: Nullable<BaseTexture>);
  8382. private _colorGradingEnabled;
  8383. /**
  8384. * Gets wether the color grading effect is enabled.
  8385. */
  8386. get colorGradingEnabled(): boolean;
  8387. /**
  8388. * Sets wether the color grading effect is enabled.
  8389. */
  8390. set colorGradingEnabled(value: boolean);
  8391. private _colorGradingWithGreenDepth;
  8392. /**
  8393. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8394. */
  8395. get colorGradingWithGreenDepth(): boolean;
  8396. /**
  8397. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8398. */
  8399. set colorGradingWithGreenDepth(value: boolean);
  8400. private _colorGradingBGR;
  8401. /**
  8402. * Gets wether the color grading texture contains BGR values.
  8403. */
  8404. get colorGradingBGR(): boolean;
  8405. /**
  8406. * Sets wether the color grading texture contains BGR values.
  8407. */
  8408. set colorGradingBGR(value: boolean);
  8409. /** @hidden */
  8410. _exposure: number;
  8411. /**
  8412. * Gets the Exposure used in the effect.
  8413. */
  8414. get exposure(): number;
  8415. /**
  8416. * Sets the Exposure used in the effect.
  8417. */
  8418. set exposure(value: number);
  8419. private _toneMappingEnabled;
  8420. /**
  8421. * Gets wether the tone mapping effect is enabled.
  8422. */
  8423. get toneMappingEnabled(): boolean;
  8424. /**
  8425. * Sets wether the tone mapping effect is enabled.
  8426. */
  8427. set toneMappingEnabled(value: boolean);
  8428. private _toneMappingType;
  8429. /**
  8430. * Gets the type of tone mapping effect.
  8431. */
  8432. get toneMappingType(): number;
  8433. /**
  8434. * Sets the type of tone mapping effect used in BabylonJS.
  8435. */
  8436. set toneMappingType(value: number);
  8437. protected _contrast: number;
  8438. /**
  8439. * Gets the contrast used in the effect.
  8440. */
  8441. get contrast(): number;
  8442. /**
  8443. * Sets the contrast used in the effect.
  8444. */
  8445. set contrast(value: number);
  8446. /**
  8447. * Vignette stretch size.
  8448. */
  8449. vignetteStretch: number;
  8450. /**
  8451. * Vignette centre X Offset.
  8452. */
  8453. vignetteCentreX: number;
  8454. /**
  8455. * Vignette centre Y Offset.
  8456. */
  8457. vignetteCentreY: number;
  8458. /**
  8459. * Vignette weight or intensity of the vignette effect.
  8460. */
  8461. vignetteWeight: number;
  8462. /**
  8463. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8464. * if vignetteEnabled is set to true.
  8465. */
  8466. vignetteColor: Color4;
  8467. /**
  8468. * Camera field of view used by the Vignette effect.
  8469. */
  8470. vignetteCameraFov: number;
  8471. private _vignetteBlendMode;
  8472. /**
  8473. * Gets the vignette blend mode allowing different kind of effect.
  8474. */
  8475. get vignetteBlendMode(): number;
  8476. /**
  8477. * Sets the vignette blend mode allowing different kind of effect.
  8478. */
  8479. set vignetteBlendMode(value: number);
  8480. private _vignetteEnabled;
  8481. /**
  8482. * Gets wether the vignette effect is enabled.
  8483. */
  8484. get vignetteEnabled(): boolean;
  8485. /**
  8486. * Sets wether the vignette effect is enabled.
  8487. */
  8488. set vignetteEnabled(value: boolean);
  8489. private _applyByPostProcess;
  8490. /**
  8491. * Gets wether the image processing is applied through a post process or not.
  8492. */
  8493. get applyByPostProcess(): boolean;
  8494. /**
  8495. * Sets wether the image processing is applied through a post process or not.
  8496. */
  8497. set applyByPostProcess(value: boolean);
  8498. private _isEnabled;
  8499. /**
  8500. * Gets wether the image processing is enabled or not.
  8501. */
  8502. get isEnabled(): boolean;
  8503. /**
  8504. * Sets wether the image processing is enabled or not.
  8505. */
  8506. set isEnabled(value: boolean);
  8507. /**
  8508. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8509. */
  8510. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8511. /**
  8512. * Method called each time the image processing information changes requires to recompile the effect.
  8513. */
  8514. protected _updateParameters(): void;
  8515. /**
  8516. * Gets the current class name.
  8517. * @return "ImageProcessingConfiguration"
  8518. */
  8519. getClassName(): string;
  8520. /**
  8521. * Prepare the list of uniforms associated with the Image Processing effects.
  8522. * @param uniforms The list of uniforms used in the effect
  8523. * @param defines the list of defines currently in use
  8524. */
  8525. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8526. /**
  8527. * Prepare the list of samplers associated with the Image Processing effects.
  8528. * @param samplersList The list of uniforms used in the effect
  8529. * @param defines the list of defines currently in use
  8530. */
  8531. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8532. /**
  8533. * Prepare the list of defines associated to the shader.
  8534. * @param defines the list of defines to complete
  8535. * @param forPostProcess Define if we are currently in post process mode or not
  8536. */
  8537. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8538. /**
  8539. * Returns true if all the image processing information are ready.
  8540. * @returns True if ready, otherwise, false
  8541. */
  8542. isReady(): boolean;
  8543. /**
  8544. * Binds the image processing to the shader.
  8545. * @param effect The effect to bind to
  8546. * @param overrideAspectRatio Override the aspect ratio of the effect
  8547. */
  8548. bind(effect: Effect, overrideAspectRatio?: number): void;
  8549. /**
  8550. * Clones the current image processing instance.
  8551. * @return The cloned image processing
  8552. */
  8553. clone(): ImageProcessingConfiguration;
  8554. /**
  8555. * Serializes the current image processing instance to a json representation.
  8556. * @return a JSON representation
  8557. */
  8558. serialize(): any;
  8559. /**
  8560. * Parses the image processing from a json representation.
  8561. * @param source the JSON source to parse
  8562. * @return The parsed image processing
  8563. */
  8564. static Parse(source: any): ImageProcessingConfiguration;
  8565. private static _VIGNETTEMODE_MULTIPLY;
  8566. private static _VIGNETTEMODE_OPAQUE;
  8567. /**
  8568. * Used to apply the vignette as a mix with the pixel color.
  8569. */
  8570. static get VIGNETTEMODE_MULTIPLY(): number;
  8571. /**
  8572. * Used to apply the vignette as a replacement of the pixel color.
  8573. */
  8574. static get VIGNETTEMODE_OPAQUE(): number;
  8575. }
  8576. }
  8577. declare module "babylonjs/Shaders/postprocess.vertex" {
  8578. /** @hidden */
  8579. export var postprocessVertexShader: {
  8580. name: string;
  8581. shader: string;
  8582. };
  8583. }
  8584. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8586. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8587. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8588. module "babylonjs/Engines/thinEngine" {
  8589. interface ThinEngine {
  8590. /**
  8591. * Creates a new render target texture
  8592. * @param size defines the size of the texture
  8593. * @param options defines the options used to create the texture
  8594. * @returns a new render target texture stored in an InternalTexture
  8595. */
  8596. createRenderTargetTexture(size: number | {
  8597. width: number;
  8598. height: number;
  8599. layers?: number;
  8600. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8601. /**
  8602. * Creates a depth stencil texture.
  8603. * This is only available in WebGL 2 or with the depth texture extension available.
  8604. * @param size The size of face edge in the texture.
  8605. * @param options The options defining the texture.
  8606. * @returns The texture
  8607. */
  8608. createDepthStencilTexture(size: number | {
  8609. width: number;
  8610. height: number;
  8611. layers?: number;
  8612. }, options: DepthTextureCreationOptions): InternalTexture;
  8613. /** @hidden */
  8614. _createDepthStencilTexture(size: number | {
  8615. width: number;
  8616. height: number;
  8617. layers?: number;
  8618. }, options: DepthTextureCreationOptions): InternalTexture;
  8619. }
  8620. }
  8621. }
  8622. declare module "babylonjs/Maths/math.axis" {
  8623. import { Vector3 } from "babylonjs/Maths/math.vector";
  8624. /** Defines supported spaces */
  8625. export enum Space {
  8626. /** Local (object) space */
  8627. LOCAL = 0,
  8628. /** World space */
  8629. WORLD = 1,
  8630. /** Bone space */
  8631. BONE = 2
  8632. }
  8633. /** Defines the 3 main axes */
  8634. export class Axis {
  8635. /** X axis */
  8636. static X: Vector3;
  8637. /** Y axis */
  8638. static Y: Vector3;
  8639. /** Z axis */
  8640. static Z: Vector3;
  8641. }
  8642. }
  8643. declare module "babylonjs/Cameras/targetCamera" {
  8644. import { Nullable } from "babylonjs/types";
  8645. import { Camera } from "babylonjs/Cameras/camera";
  8646. import { Scene } from "babylonjs/scene";
  8647. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8648. /**
  8649. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8650. * This is the base of the follow, arc rotate cameras and Free camera
  8651. * @see http://doc.babylonjs.com/features/cameras
  8652. */
  8653. export class TargetCamera extends Camera {
  8654. private static _RigCamTransformMatrix;
  8655. private static _TargetTransformMatrix;
  8656. private static _TargetFocalPoint;
  8657. /**
  8658. * Define the current direction the camera is moving to
  8659. */
  8660. cameraDirection: Vector3;
  8661. /**
  8662. * Define the current rotation the camera is rotating to
  8663. */
  8664. cameraRotation: Vector2;
  8665. /**
  8666. * When set, the up vector of the camera will be updated by the rotation of the camera
  8667. */
  8668. updateUpVectorFromRotation: boolean;
  8669. private _tmpQuaternion;
  8670. /**
  8671. * Define the current rotation of the camera
  8672. */
  8673. rotation: Vector3;
  8674. /**
  8675. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8676. */
  8677. rotationQuaternion: Quaternion;
  8678. /**
  8679. * Define the current speed of the camera
  8680. */
  8681. speed: number;
  8682. /**
  8683. * Add constraint to the camera to prevent it to move freely in all directions and
  8684. * around all axis.
  8685. */
  8686. noRotationConstraint: boolean;
  8687. /**
  8688. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8689. * panning
  8690. */
  8691. invertRotation: boolean;
  8692. /**
  8693. * Speed multiplier for inverse camera panning
  8694. */
  8695. inverseRotationSpeed: number;
  8696. /**
  8697. * Define the current target of the camera as an object or a position.
  8698. */
  8699. lockedTarget: any;
  8700. /** @hidden */
  8701. _currentTarget: Vector3;
  8702. /** @hidden */
  8703. _initialFocalDistance: number;
  8704. /** @hidden */
  8705. _viewMatrix: Matrix;
  8706. /** @hidden */
  8707. _camMatrix: Matrix;
  8708. /** @hidden */
  8709. _cameraTransformMatrix: Matrix;
  8710. /** @hidden */
  8711. _cameraRotationMatrix: Matrix;
  8712. /** @hidden */
  8713. _referencePoint: Vector3;
  8714. /** @hidden */
  8715. _transformedReferencePoint: Vector3;
  8716. protected _globalCurrentTarget: Vector3;
  8717. protected _globalCurrentUpVector: Vector3;
  8718. /** @hidden */
  8719. _reset: () => void;
  8720. private _defaultUp;
  8721. /**
  8722. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8723. * This is the base of the follow, arc rotate cameras and Free camera
  8724. * @see http://doc.babylonjs.com/features/cameras
  8725. * @param name Defines the name of the camera in the scene
  8726. * @param position Defines the start position of the camera in the scene
  8727. * @param scene Defines the scene the camera belongs to
  8728. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8729. */
  8730. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8731. /**
  8732. * Gets the position in front of the camera at a given distance.
  8733. * @param distance The distance from the camera we want the position to be
  8734. * @returns the position
  8735. */
  8736. getFrontPosition(distance: number): Vector3;
  8737. /** @hidden */
  8738. _getLockedTargetPosition(): Nullable<Vector3>;
  8739. private _storedPosition;
  8740. private _storedRotation;
  8741. private _storedRotationQuaternion;
  8742. /**
  8743. * Store current camera state of the camera (fov, position, rotation, etc..)
  8744. * @returns the camera
  8745. */
  8746. storeState(): Camera;
  8747. /**
  8748. * Restored camera state. You must call storeState() first
  8749. * @returns whether it was successful or not
  8750. * @hidden
  8751. */
  8752. _restoreStateValues(): boolean;
  8753. /** @hidden */
  8754. _initCache(): void;
  8755. /** @hidden */
  8756. _updateCache(ignoreParentClass?: boolean): void;
  8757. /** @hidden */
  8758. _isSynchronizedViewMatrix(): boolean;
  8759. /** @hidden */
  8760. _computeLocalCameraSpeed(): number;
  8761. /**
  8762. * Defines the target the camera should look at.
  8763. * @param target Defines the new target as a Vector or a mesh
  8764. */
  8765. setTarget(target: Vector3): void;
  8766. /**
  8767. * Return the current target position of the camera. This value is expressed in local space.
  8768. * @returns the target position
  8769. */
  8770. getTarget(): Vector3;
  8771. /** @hidden */
  8772. _decideIfNeedsToMove(): boolean;
  8773. /** @hidden */
  8774. _updatePosition(): void;
  8775. /** @hidden */
  8776. _checkInputs(): void;
  8777. protected _updateCameraRotationMatrix(): void;
  8778. /**
  8779. * 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)
  8780. * @returns the current camera
  8781. */
  8782. private _rotateUpVectorWithCameraRotationMatrix;
  8783. private _cachedRotationZ;
  8784. private _cachedQuaternionRotationZ;
  8785. /** @hidden */
  8786. _getViewMatrix(): Matrix;
  8787. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8788. /**
  8789. * @hidden
  8790. */
  8791. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8792. /**
  8793. * @hidden
  8794. */
  8795. _updateRigCameras(): void;
  8796. private _getRigCamPositionAndTarget;
  8797. /**
  8798. * Gets the current object class name.
  8799. * @return the class name
  8800. */
  8801. getClassName(): string;
  8802. }
  8803. }
  8804. declare module "babylonjs/Events/keyboardEvents" {
  8805. /**
  8806. * Gather the list of keyboard event types as constants.
  8807. */
  8808. export class KeyboardEventTypes {
  8809. /**
  8810. * The keydown event is fired when a key becomes active (pressed).
  8811. */
  8812. static readonly KEYDOWN: number;
  8813. /**
  8814. * The keyup event is fired when a key has been released.
  8815. */
  8816. static readonly KEYUP: number;
  8817. }
  8818. /**
  8819. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8820. */
  8821. export class KeyboardInfo {
  8822. /**
  8823. * Defines the type of event (KeyboardEventTypes)
  8824. */
  8825. type: number;
  8826. /**
  8827. * Defines the related dom event
  8828. */
  8829. event: KeyboardEvent;
  8830. /**
  8831. * Instantiates a new keyboard info.
  8832. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8833. * @param type Defines the type of event (KeyboardEventTypes)
  8834. * @param event Defines the related dom event
  8835. */
  8836. constructor(
  8837. /**
  8838. * Defines the type of event (KeyboardEventTypes)
  8839. */
  8840. type: number,
  8841. /**
  8842. * Defines the related dom event
  8843. */
  8844. event: KeyboardEvent);
  8845. }
  8846. /**
  8847. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8848. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8849. */
  8850. export class KeyboardInfoPre extends KeyboardInfo {
  8851. /**
  8852. * Defines the type of event (KeyboardEventTypes)
  8853. */
  8854. type: number;
  8855. /**
  8856. * Defines the related dom event
  8857. */
  8858. event: KeyboardEvent;
  8859. /**
  8860. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8861. */
  8862. skipOnPointerObservable: boolean;
  8863. /**
  8864. * Instantiates a new keyboard pre info.
  8865. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8866. * @param type Defines the type of event (KeyboardEventTypes)
  8867. * @param event Defines the related dom event
  8868. */
  8869. constructor(
  8870. /**
  8871. * Defines the type of event (KeyboardEventTypes)
  8872. */
  8873. type: number,
  8874. /**
  8875. * Defines the related dom event
  8876. */
  8877. event: KeyboardEvent);
  8878. }
  8879. }
  8880. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8881. import { Nullable } from "babylonjs/types";
  8882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8883. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8884. /**
  8885. * Manage the keyboard inputs to control the movement of a free camera.
  8886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8887. */
  8888. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8889. /**
  8890. * Defines the camera the input is attached to.
  8891. */
  8892. camera: FreeCamera;
  8893. /**
  8894. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8895. */
  8896. keysUp: number[];
  8897. /**
  8898. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8899. */
  8900. keysUpward: number[];
  8901. /**
  8902. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8903. */
  8904. keysDown: number[];
  8905. /**
  8906. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8907. */
  8908. keysDownward: number[];
  8909. /**
  8910. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8911. */
  8912. keysLeft: number[];
  8913. /**
  8914. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8915. */
  8916. keysRight: number[];
  8917. private _keys;
  8918. private _onCanvasBlurObserver;
  8919. private _onKeyboardObserver;
  8920. private _engine;
  8921. private _scene;
  8922. /**
  8923. * Attach the input controls to a specific dom element to get the input from.
  8924. * @param element Defines the element the controls should be listened from
  8925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8926. */
  8927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8928. /**
  8929. * Detach the current controls from the specified dom element.
  8930. * @param element Defines the element to stop listening the inputs from
  8931. */
  8932. detachControl(element: Nullable<HTMLElement>): void;
  8933. /**
  8934. * Update the current camera state depending on the inputs that have been used this frame.
  8935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8936. */
  8937. checkInputs(): void;
  8938. /**
  8939. * Gets the class name of the current intput.
  8940. * @returns the class name
  8941. */
  8942. getClassName(): string;
  8943. /** @hidden */
  8944. _onLostFocus(): void;
  8945. /**
  8946. * Get the friendly name associated with the input class.
  8947. * @returns the input friendly name
  8948. */
  8949. getSimpleName(): string;
  8950. }
  8951. }
  8952. declare module "babylonjs/Lights/shadowLight" {
  8953. import { Camera } from "babylonjs/Cameras/camera";
  8954. import { Scene } from "babylonjs/scene";
  8955. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8957. import { Light } from "babylonjs/Lights/light";
  8958. /**
  8959. * Interface describing all the common properties and methods a shadow light needs to implement.
  8960. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8961. * as well as binding the different shadow properties to the effects.
  8962. */
  8963. export interface IShadowLight extends Light {
  8964. /**
  8965. * The light id in the scene (used in scene.findLighById for instance)
  8966. */
  8967. id: string;
  8968. /**
  8969. * The position the shdow will be casted from.
  8970. */
  8971. position: Vector3;
  8972. /**
  8973. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8974. */
  8975. direction: Vector3;
  8976. /**
  8977. * The transformed position. Position of the light in world space taking parenting in account.
  8978. */
  8979. transformedPosition: Vector3;
  8980. /**
  8981. * The transformed direction. Direction of the light in world space taking parenting in account.
  8982. */
  8983. transformedDirection: Vector3;
  8984. /**
  8985. * The friendly name of the light in the scene.
  8986. */
  8987. name: string;
  8988. /**
  8989. * Defines the shadow projection clipping minimum z value.
  8990. */
  8991. shadowMinZ: number;
  8992. /**
  8993. * Defines the shadow projection clipping maximum z value.
  8994. */
  8995. shadowMaxZ: number;
  8996. /**
  8997. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8998. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8999. */
  9000. computeTransformedInformation(): boolean;
  9001. /**
  9002. * Gets the scene the light belongs to.
  9003. * @returns The scene
  9004. */
  9005. getScene(): Scene;
  9006. /**
  9007. * Callback defining a custom Projection Matrix Builder.
  9008. * This can be used to override the default projection matrix computation.
  9009. */
  9010. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9011. /**
  9012. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9013. * @param matrix The materix to updated with the projection information
  9014. * @param viewMatrix The transform matrix of the light
  9015. * @param renderList The list of mesh to render in the map
  9016. * @returns The current light
  9017. */
  9018. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9019. /**
  9020. * Gets the current depth scale used in ESM.
  9021. * @returns The scale
  9022. */
  9023. getDepthScale(): number;
  9024. /**
  9025. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9026. * @returns true if a cube texture needs to be use
  9027. */
  9028. needCube(): boolean;
  9029. /**
  9030. * Detects if the projection matrix requires to be recomputed this frame.
  9031. * @returns true if it requires to be recomputed otherwise, false.
  9032. */
  9033. needProjectionMatrixCompute(): boolean;
  9034. /**
  9035. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9036. */
  9037. forceProjectionMatrixCompute(): void;
  9038. /**
  9039. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9040. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9041. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9042. */
  9043. getShadowDirection(faceIndex?: number): Vector3;
  9044. /**
  9045. * Gets the minZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the min for
  9047. * @returns the depth min z
  9048. */
  9049. getDepthMinZ(activeCamera: Camera): number;
  9050. /**
  9051. * Gets the maxZ used for shadow according to both the scene and the light.
  9052. * @param activeCamera The camera we are returning the max for
  9053. * @returns the depth max z
  9054. */
  9055. getDepthMaxZ(activeCamera: Camera): number;
  9056. }
  9057. /**
  9058. * Base implementation IShadowLight
  9059. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9060. */
  9061. export abstract class ShadowLight extends Light implements IShadowLight {
  9062. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9063. protected _position: Vector3;
  9064. protected _setPosition(value: Vector3): void;
  9065. /**
  9066. * Sets the position the shadow will be casted from. Also use as the light position for both
  9067. * point and spot lights.
  9068. */
  9069. get position(): Vector3;
  9070. /**
  9071. * Sets the position the shadow will be casted from. Also use as the light position for both
  9072. * point and spot lights.
  9073. */
  9074. set position(value: Vector3);
  9075. protected _direction: Vector3;
  9076. protected _setDirection(value: Vector3): void;
  9077. /**
  9078. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9079. * Also use as the light direction on spot and directional lights.
  9080. */
  9081. get direction(): Vector3;
  9082. /**
  9083. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9084. * Also use as the light direction on spot and directional lights.
  9085. */
  9086. set direction(value: Vector3);
  9087. protected _shadowMinZ: number;
  9088. /**
  9089. * Gets the shadow projection clipping minimum z value.
  9090. */
  9091. get shadowMinZ(): number;
  9092. /**
  9093. * Sets the shadow projection clipping minimum z value.
  9094. */
  9095. set shadowMinZ(value: number);
  9096. protected _shadowMaxZ: number;
  9097. /**
  9098. * Sets the shadow projection clipping maximum z value.
  9099. */
  9100. get shadowMaxZ(): number;
  9101. /**
  9102. * Gets the shadow projection clipping maximum z value.
  9103. */
  9104. set shadowMaxZ(value: number);
  9105. /**
  9106. * Callback defining a custom Projection Matrix Builder.
  9107. * This can be used to override the default projection matrix computation.
  9108. */
  9109. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9110. /**
  9111. * The transformed position. Position of the light in world space taking parenting in account.
  9112. */
  9113. transformedPosition: Vector3;
  9114. /**
  9115. * The transformed direction. Direction of the light in world space taking parenting in account.
  9116. */
  9117. transformedDirection: Vector3;
  9118. private _needProjectionMatrixCompute;
  9119. /**
  9120. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9121. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9122. */
  9123. computeTransformedInformation(): boolean;
  9124. /**
  9125. * Return the depth scale used for the shadow map.
  9126. * @returns the depth scale.
  9127. */
  9128. getDepthScale(): number;
  9129. /**
  9130. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9131. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9132. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9133. */
  9134. getShadowDirection(faceIndex?: number): Vector3;
  9135. /**
  9136. * Returns the ShadowLight absolute position in the World.
  9137. * @returns the position vector in world space
  9138. */
  9139. getAbsolutePosition(): Vector3;
  9140. /**
  9141. * Sets the ShadowLight direction toward the passed target.
  9142. * @param target The point to target in local space
  9143. * @returns the updated ShadowLight direction
  9144. */
  9145. setDirectionToTarget(target: Vector3): Vector3;
  9146. /**
  9147. * Returns the light rotation in euler definition.
  9148. * @returns the x y z rotation in local space.
  9149. */
  9150. getRotation(): Vector3;
  9151. /**
  9152. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9153. * @returns true if a cube texture needs to be use
  9154. */
  9155. needCube(): boolean;
  9156. /**
  9157. * Detects if the projection matrix requires to be recomputed this frame.
  9158. * @returns true if it requires to be recomputed otherwise, false.
  9159. */
  9160. needProjectionMatrixCompute(): boolean;
  9161. /**
  9162. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9163. */
  9164. forceProjectionMatrixCompute(): void;
  9165. /** @hidden */
  9166. _initCache(): void;
  9167. /** @hidden */
  9168. _isSynchronized(): boolean;
  9169. /**
  9170. * Computes the world matrix of the node
  9171. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9172. * @returns the world matrix
  9173. */
  9174. computeWorldMatrix(force?: boolean): Matrix;
  9175. /**
  9176. * Gets the minZ used for shadow according to both the scene and the light.
  9177. * @param activeCamera The camera we are returning the min for
  9178. * @returns the depth min z
  9179. */
  9180. getDepthMinZ(activeCamera: Camera): number;
  9181. /**
  9182. * Gets the maxZ used for shadow according to both the scene and the light.
  9183. * @param activeCamera The camera we are returning the max for
  9184. * @returns the depth max z
  9185. */
  9186. getDepthMaxZ(activeCamera: Camera): number;
  9187. /**
  9188. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9189. * @param matrix The materix to updated with the projection information
  9190. * @param viewMatrix The transform matrix of the light
  9191. * @param renderList The list of mesh to render in the map
  9192. * @returns The current light
  9193. */
  9194. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9195. }
  9196. }
  9197. declare module "babylonjs/Materials/effectFallbacks" {
  9198. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9199. import { Effect } from "babylonjs/Materials/effect";
  9200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9201. /**
  9202. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9203. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9204. */
  9205. export class EffectFallbacks implements IEffectFallbacks {
  9206. private _defines;
  9207. private _currentRank;
  9208. private _maxRank;
  9209. private _mesh;
  9210. /**
  9211. * Removes the fallback from the bound mesh.
  9212. */
  9213. unBindMesh(): void;
  9214. /**
  9215. * Adds a fallback on the specified property.
  9216. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9217. * @param define The name of the define in the shader
  9218. */
  9219. addFallback(rank: number, define: string): void;
  9220. /**
  9221. * Sets the mesh to use CPU skinning when needing to fallback.
  9222. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9223. * @param mesh The mesh to use the fallbacks.
  9224. */
  9225. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9226. /**
  9227. * Checks to see if more fallbacks are still availible.
  9228. */
  9229. get hasMoreFallbacks(): boolean;
  9230. /**
  9231. * Removes the defines that should be removed when falling back.
  9232. * @param currentDefines defines the current define statements for the shader.
  9233. * @param effect defines the current effect we try to compile
  9234. * @returns The resulting defines with defines of the current rank removed.
  9235. */
  9236. reduce(currentDefines: string, effect: Effect): string;
  9237. }
  9238. }
  9239. declare module "babylonjs/Materials/materialHelper" {
  9240. import { Nullable } from "babylonjs/types";
  9241. import { Scene } from "babylonjs/scene";
  9242. import { Engine } from "babylonjs/Engines/engine";
  9243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9244. import { Light } from "babylonjs/Lights/light";
  9245. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9246. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9248. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9249. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9250. /**
  9251. * "Static Class" containing the most commonly used helper while dealing with material for
  9252. * rendering purpose.
  9253. *
  9254. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9255. *
  9256. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9257. */
  9258. export class MaterialHelper {
  9259. /**
  9260. * Bind the current view position to an effect.
  9261. * @param effect The effect to be bound
  9262. * @param scene The scene the eyes position is used from
  9263. * @param variableName name of the shader variable that will hold the eye position
  9264. */
  9265. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9266. /**
  9267. * Helps preparing the defines values about the UVs in used in the effect.
  9268. * UVs are shared as much as we can accross channels in the shaders.
  9269. * @param texture The texture we are preparing the UVs for
  9270. * @param defines The defines to update
  9271. * @param key The channel key "diffuse", "specular"... used in the shader
  9272. */
  9273. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9274. /**
  9275. * Binds a texture matrix value to its corrsponding uniform
  9276. * @param texture The texture to bind the matrix for
  9277. * @param uniformBuffer The uniform buffer receivin the data
  9278. * @param key The channel key "diffuse", "specular"... used in the shader
  9279. */
  9280. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9281. /**
  9282. * Gets the current status of the fog (should it be enabled?)
  9283. * @param mesh defines the mesh to evaluate for fog support
  9284. * @param scene defines the hosting scene
  9285. * @returns true if fog must be enabled
  9286. */
  9287. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9288. /**
  9289. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9290. * @param mesh defines the current mesh
  9291. * @param scene defines the current scene
  9292. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9293. * @param pointsCloud defines if point cloud rendering has to be turned on
  9294. * @param fogEnabled defines if fog has to be turned on
  9295. * @param alphaTest defines if alpha testing has to be turned on
  9296. * @param defines defines the current list of defines
  9297. */
  9298. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9299. /**
  9300. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9301. * @param scene defines the current scene
  9302. * @param engine defines the current engine
  9303. * @param defines specifies the list of active defines
  9304. * @param useInstances defines if instances have to be turned on
  9305. * @param useClipPlane defines if clip plane have to be turned on
  9306. */
  9307. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9308. /**
  9309. * Prepares the defines for bones
  9310. * @param mesh The mesh containing the geometry data we will draw
  9311. * @param defines The defines to update
  9312. */
  9313. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9314. /**
  9315. * Prepares the defines for morph targets
  9316. * @param mesh The mesh containing the geometry data we will draw
  9317. * @param defines The defines to update
  9318. */
  9319. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9320. /**
  9321. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9322. * @param mesh The mesh containing the geometry data we will draw
  9323. * @param defines The defines to update
  9324. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9325. * @param useBones Precise whether bones should be used or not (override mesh info)
  9326. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9327. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9328. * @returns false if defines are considered not dirty and have not been checked
  9329. */
  9330. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9331. /**
  9332. * Prepares the defines related to multiview
  9333. * @param scene The scene we are intending to draw
  9334. * @param defines The defines to update
  9335. */
  9336. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9337. /**
  9338. * Prepares the defines related to the light information passed in parameter
  9339. * @param scene The scene we are intending to draw
  9340. * @param mesh The mesh the effect is compiling for
  9341. * @param light The light the effect is compiling for
  9342. * @param lightIndex The index of the light
  9343. * @param defines The defines to update
  9344. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9345. * @param state Defines the current state regarding what is needed (normals, etc...)
  9346. */
  9347. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9348. needNormals: boolean;
  9349. needRebuild: boolean;
  9350. shadowEnabled: boolean;
  9351. specularEnabled: boolean;
  9352. lightmapMode: boolean;
  9353. }): void;
  9354. /**
  9355. * Prepares the defines related to the light information passed in parameter
  9356. * @param scene The scene we are intending to draw
  9357. * @param mesh The mesh the effect is compiling for
  9358. * @param defines The defines to update
  9359. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9360. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9361. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9362. * @returns true if normals will be required for the rest of the effect
  9363. */
  9364. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9365. /**
  9366. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9367. * @param lightIndex defines the light index
  9368. * @param uniformsList The uniform list
  9369. * @param samplersList The sampler list
  9370. * @param projectedLightTexture defines if projected texture must be used
  9371. * @param uniformBuffersList defines an optional list of uniform buffers
  9372. */
  9373. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9374. /**
  9375. * Prepares the uniforms and samplers list to be used in the effect
  9376. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9377. * @param samplersList The sampler list
  9378. * @param defines The defines helping in the list generation
  9379. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9380. */
  9381. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9382. /**
  9383. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9384. * @param defines The defines to update while falling back
  9385. * @param fallbacks The authorized effect fallbacks
  9386. * @param maxSimultaneousLights The maximum number of lights allowed
  9387. * @param rank the current rank of the Effect
  9388. * @returns The newly affected rank
  9389. */
  9390. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9391. private static _TmpMorphInfluencers;
  9392. /**
  9393. * Prepares the list of attributes required for morph targets according to the effect defines.
  9394. * @param attribs The current list of supported attribs
  9395. * @param mesh The mesh to prepare the morph targets attributes for
  9396. * @param influencers The number of influencers
  9397. */
  9398. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9399. /**
  9400. * Prepares the list of attributes required for morph targets according to the effect defines.
  9401. * @param attribs The current list of supported attribs
  9402. * @param mesh The mesh to prepare the morph targets attributes for
  9403. * @param defines The current Defines of the effect
  9404. */
  9405. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9406. /**
  9407. * Prepares the list of attributes required for bones according to the effect defines.
  9408. * @param attribs The current list of supported attribs
  9409. * @param mesh The mesh to prepare the bones attributes for
  9410. * @param defines The current Defines of the effect
  9411. * @param fallbacks The current efffect fallback strategy
  9412. */
  9413. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9414. /**
  9415. * Check and prepare the list of attributes required for instances according to the effect defines.
  9416. * @param attribs The current list of supported attribs
  9417. * @param defines The current MaterialDefines of the effect
  9418. */
  9419. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9420. /**
  9421. * Add the list of attributes required for instances to the attribs array.
  9422. * @param attribs The current list of supported attribs
  9423. */
  9424. static PushAttributesForInstances(attribs: string[]): void;
  9425. /**
  9426. * Binds the light information to the effect.
  9427. * @param light The light containing the generator
  9428. * @param effect The effect we are binding the data to
  9429. * @param lightIndex The light index in the effect used to render
  9430. */
  9431. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9432. /**
  9433. * Binds the lights information from the scene to the effect for the given mesh.
  9434. * @param light Light to bind
  9435. * @param lightIndex Light index
  9436. * @param scene The scene where the light belongs to
  9437. * @param effect The effect we are binding the data to
  9438. * @param useSpecular Defines if specular is supported
  9439. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9440. */
  9441. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9442. /**
  9443. * Binds the lights information from the scene to the effect for the given mesh.
  9444. * @param scene The scene the lights belongs to
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. * @param defines The generated defines for the effect
  9448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9449. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9450. */
  9451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9452. private static _tempFogColor;
  9453. /**
  9454. * Binds the fog information from the scene to the effect for the given mesh.
  9455. * @param scene The scene the lights belongs to
  9456. * @param mesh The mesh we are binding the information to render
  9457. * @param effect The effect we are binding the data to
  9458. * @param linearSpace Defines if the fog effect is applied in linear space
  9459. */
  9460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9461. /**
  9462. * Binds the bones information from the mesh to the effect.
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. */
  9466. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9467. /**
  9468. * Binds the morph targets information from the mesh to the effect.
  9469. * @param abstractMesh The mesh we are binding the information to render
  9470. * @param effect The effect we are binding the data to
  9471. */
  9472. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9473. /**
  9474. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9475. * @param defines The generated defines used in the effect
  9476. * @param effect The effect we are binding the data to
  9477. * @param scene The scene we are willing to render with logarithmic scale for
  9478. */
  9479. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9480. /**
  9481. * Binds the clip plane information from the scene to the effect.
  9482. * @param scene The scene the clip plane information are extracted from
  9483. * @param effect The effect we are binding the data to
  9484. */
  9485. static BindClipPlane(effect: Effect, scene: Scene): void;
  9486. }
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9489. /** @hidden */
  9490. export var packingFunctions: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9496. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9497. /** @hidden */
  9498. export var shadowMapFragmentDeclaration: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9504. /** @hidden */
  9505. export var clipPlaneFragmentDeclaration: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9511. /** @hidden */
  9512. export var clipPlaneFragment: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9518. /** @hidden */
  9519. export var shadowMapFragment: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9528. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9529. /** @hidden */
  9530. export var shadowMapPixelShader: {
  9531. name: string;
  9532. shader: string;
  9533. };
  9534. }
  9535. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9536. /** @hidden */
  9537. export var bonesDeclaration: {
  9538. name: string;
  9539. shader: string;
  9540. };
  9541. }
  9542. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9543. /** @hidden */
  9544. export var morphTargetsVertexGlobalDeclaration: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9550. /** @hidden */
  9551. export var morphTargetsVertexDeclaration: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9557. /** @hidden */
  9558. export var instancesDeclaration: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9564. /** @hidden */
  9565. export var helperFunctions: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9571. /** @hidden */
  9572. export var shadowMapVertexDeclaration: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9578. /** @hidden */
  9579. export var clipPlaneVertexDeclaration: {
  9580. name: string;
  9581. shader: string;
  9582. };
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9585. /** @hidden */
  9586. export var morphTargetsVertex: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9592. /** @hidden */
  9593. export var instancesVertex: {
  9594. name: string;
  9595. shader: string;
  9596. };
  9597. }
  9598. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9599. /** @hidden */
  9600. export var bonesVertex: {
  9601. name: string;
  9602. shader: string;
  9603. };
  9604. }
  9605. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9606. /** @hidden */
  9607. export var shadowMapVertexNormalBias: {
  9608. name: string;
  9609. shader: string;
  9610. };
  9611. }
  9612. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9613. /** @hidden */
  9614. export var shadowMapVertexMetric: {
  9615. name: string;
  9616. shader: string;
  9617. };
  9618. }
  9619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9620. /** @hidden */
  9621. export var clipPlaneVertex: {
  9622. name: string;
  9623. shader: string;
  9624. };
  9625. }
  9626. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9627. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9632. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9633. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9637. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9638. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9639. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9640. /** @hidden */
  9641. export var shadowMapVertexShader: {
  9642. name: string;
  9643. shader: string;
  9644. };
  9645. }
  9646. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9647. /** @hidden */
  9648. export var depthBoxBlurPixelShader: {
  9649. name: string;
  9650. shader: string;
  9651. };
  9652. }
  9653. declare module "babylonjs/Culling/ray" {
  9654. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9657. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9658. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9659. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9660. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9661. import { Plane } from "babylonjs/Maths/math.plane";
  9662. /**
  9663. * Class representing a ray with position and direction
  9664. */
  9665. export class Ray {
  9666. /** origin point */
  9667. origin: Vector3;
  9668. /** direction */
  9669. direction: Vector3;
  9670. /** length of the ray */
  9671. length: number;
  9672. private static readonly TmpVector3;
  9673. private _tmpRay;
  9674. /**
  9675. * Creates a new ray
  9676. * @param origin origin point
  9677. * @param direction direction
  9678. * @param length length of the ray
  9679. */
  9680. constructor(
  9681. /** origin point */
  9682. origin: Vector3,
  9683. /** direction */
  9684. direction: Vector3,
  9685. /** length of the ray */
  9686. length?: number);
  9687. /**
  9688. * Checks if the ray intersects a box
  9689. * This does not account for the ray lenght by design to improve perfs.
  9690. * @param minimum bound of the box
  9691. * @param maximum bound of the box
  9692. * @param intersectionTreshold extra extend to be added to the box in all direction
  9693. * @returns if the box was hit
  9694. */
  9695. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9696. /**
  9697. * Checks if the ray intersects a box
  9698. * This does not account for the ray lenght by design to improve perfs.
  9699. * @param box the bounding box to check
  9700. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9701. * @returns if the box was hit
  9702. */
  9703. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9704. /**
  9705. * If the ray hits a sphere
  9706. * @param sphere the bounding sphere to check
  9707. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9708. * @returns true if it hits the sphere
  9709. */
  9710. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9711. /**
  9712. * If the ray hits a triange
  9713. * @param vertex0 triangle vertex
  9714. * @param vertex1 triangle vertex
  9715. * @param vertex2 triangle vertex
  9716. * @returns intersection information if hit
  9717. */
  9718. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9719. /**
  9720. * Checks if ray intersects a plane
  9721. * @param plane the plane to check
  9722. * @returns the distance away it was hit
  9723. */
  9724. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9725. /**
  9726. * Calculate the intercept of a ray on a given axis
  9727. * @param axis to check 'x' | 'y' | 'z'
  9728. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9729. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9730. */
  9731. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9732. /**
  9733. * Checks if ray intersects a mesh
  9734. * @param mesh the mesh to check
  9735. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9736. * @returns picking info of the intersecton
  9737. */
  9738. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9739. /**
  9740. * Checks if ray intersects a mesh
  9741. * @param meshes the meshes to check
  9742. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9743. * @param results array to store result in
  9744. * @returns Array of picking infos
  9745. */
  9746. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9747. private _comparePickingInfo;
  9748. private static smallnum;
  9749. private static rayl;
  9750. /**
  9751. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9752. * @param sega the first point of the segment to test the intersection against
  9753. * @param segb the second point of the segment to test the intersection against
  9754. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9755. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9756. */
  9757. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9758. /**
  9759. * Update the ray from viewport position
  9760. * @param x position
  9761. * @param y y position
  9762. * @param viewportWidth viewport width
  9763. * @param viewportHeight viewport height
  9764. * @param world world matrix
  9765. * @param view view matrix
  9766. * @param projection projection matrix
  9767. * @returns this ray updated
  9768. */
  9769. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9770. /**
  9771. * Creates a ray with origin and direction of 0,0,0
  9772. * @returns the new ray
  9773. */
  9774. static Zero(): Ray;
  9775. /**
  9776. * Creates a new ray from screen space and viewport
  9777. * @param x position
  9778. * @param y y position
  9779. * @param viewportWidth viewport width
  9780. * @param viewportHeight viewport height
  9781. * @param world world matrix
  9782. * @param view view matrix
  9783. * @param projection projection matrix
  9784. * @returns new ray
  9785. */
  9786. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9787. /**
  9788. * 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
  9789. * transformed to the given world matrix.
  9790. * @param origin The origin point
  9791. * @param end The end point
  9792. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9793. * @returns the new ray
  9794. */
  9795. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9796. /**
  9797. * Transforms a ray by a matrix
  9798. * @param ray ray to transform
  9799. * @param matrix matrix to apply
  9800. * @returns the resulting new ray
  9801. */
  9802. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9803. /**
  9804. * Transforms a ray by a matrix
  9805. * @param ray ray to transform
  9806. * @param matrix matrix to apply
  9807. * @param result ray to store result in
  9808. */
  9809. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9810. /**
  9811. * Unproject a ray from screen space to object space
  9812. * @param sourceX defines the screen space x coordinate to use
  9813. * @param sourceY defines the screen space y coordinate to use
  9814. * @param viewportWidth defines the current width of the viewport
  9815. * @param viewportHeight defines the current height of the viewport
  9816. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9817. * @param view defines the view matrix to use
  9818. * @param projection defines the projection matrix to use
  9819. */
  9820. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9821. }
  9822. /**
  9823. * Type used to define predicate used to select faces when a mesh intersection is detected
  9824. */
  9825. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9826. module "babylonjs/scene" {
  9827. interface Scene {
  9828. /** @hidden */
  9829. _tempPickingRay: Nullable<Ray>;
  9830. /** @hidden */
  9831. _cachedRayForTransform: Ray;
  9832. /** @hidden */
  9833. _pickWithRayInverseMatrix: Matrix;
  9834. /** @hidden */
  9835. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9836. /** @hidden */
  9837. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9838. }
  9839. }
  9840. }
  9841. declare module "babylonjs/sceneComponent" {
  9842. import { Scene } from "babylonjs/scene";
  9843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9845. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9846. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9847. import { Nullable } from "babylonjs/types";
  9848. import { Camera } from "babylonjs/Cameras/camera";
  9849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9850. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9851. import { AbstractScene } from "babylonjs/abstractScene";
  9852. import { Mesh } from "babylonjs/Meshes/mesh";
  9853. /**
  9854. * Groups all the scene component constants in one place to ease maintenance.
  9855. * @hidden
  9856. */
  9857. export class SceneComponentConstants {
  9858. static readonly NAME_EFFECTLAYER: string;
  9859. static readonly NAME_LAYER: string;
  9860. static readonly NAME_LENSFLARESYSTEM: string;
  9861. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9862. static readonly NAME_PARTICLESYSTEM: string;
  9863. static readonly NAME_GAMEPAD: string;
  9864. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9865. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9866. static readonly NAME_DEPTHRENDERER: string;
  9867. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9868. static readonly NAME_SPRITE: string;
  9869. static readonly NAME_OUTLINERENDERER: string;
  9870. static readonly NAME_PROCEDURALTEXTURE: string;
  9871. static readonly NAME_SHADOWGENERATOR: string;
  9872. static readonly NAME_OCTREE: string;
  9873. static readonly NAME_PHYSICSENGINE: string;
  9874. static readonly NAME_AUDIO: string;
  9875. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9876. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9877. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9878. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9879. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9880. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9881. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9882. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9883. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9884. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9885. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9886. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9887. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9888. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9889. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9890. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9891. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9892. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9893. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9894. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9895. static readonly STEP_AFTERRENDER_AUDIO: number;
  9896. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9897. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9898. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9899. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9900. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9901. static readonly STEP_POINTERMOVE_SPRITE: number;
  9902. static readonly STEP_POINTERDOWN_SPRITE: number;
  9903. static readonly STEP_POINTERUP_SPRITE: number;
  9904. }
  9905. /**
  9906. * This represents a scene component.
  9907. *
  9908. * This is used to decouple the dependency the scene is having on the different workloads like
  9909. * layers, post processes...
  9910. */
  9911. export interface ISceneComponent {
  9912. /**
  9913. * The name of the component. Each component must have a unique name.
  9914. */
  9915. name: string;
  9916. /**
  9917. * The scene the component belongs to.
  9918. */
  9919. scene: Scene;
  9920. /**
  9921. * Register the component to one instance of a scene.
  9922. */
  9923. register(): void;
  9924. /**
  9925. * Rebuilds the elements related to this component in case of
  9926. * context lost for instance.
  9927. */
  9928. rebuild(): void;
  9929. /**
  9930. * Disposes the component and the associated ressources.
  9931. */
  9932. dispose(): void;
  9933. }
  9934. /**
  9935. * This represents a SERIALIZABLE scene component.
  9936. *
  9937. * This extends Scene Component to add Serialization methods on top.
  9938. */
  9939. export interface ISceneSerializableComponent extends ISceneComponent {
  9940. /**
  9941. * Adds all the elements from the container to the scene
  9942. * @param container the container holding the elements
  9943. */
  9944. addFromContainer(container: AbstractScene): void;
  9945. /**
  9946. * Removes all the elements in the container from the scene
  9947. * @param container contains the elements to remove
  9948. * @param dispose if the removed element should be disposed (default: false)
  9949. */
  9950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9951. /**
  9952. * Serializes the component data to the specified json object
  9953. * @param serializationObject The object to serialize to
  9954. */
  9955. serialize(serializationObject: any): void;
  9956. }
  9957. /**
  9958. * Strong typing of a Mesh related stage step action
  9959. */
  9960. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9961. /**
  9962. * Strong typing of a Evaluate Sub Mesh related stage step action
  9963. */
  9964. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9965. /**
  9966. * Strong typing of a Active Mesh related stage step action
  9967. */
  9968. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9969. /**
  9970. * Strong typing of a Camera related stage step action
  9971. */
  9972. export type CameraStageAction = (camera: Camera) => void;
  9973. /**
  9974. * Strong typing of a Camera Frame buffer related stage step action
  9975. */
  9976. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9977. /**
  9978. * Strong typing of a Render Target related stage step action
  9979. */
  9980. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9981. /**
  9982. * Strong typing of a RenderingGroup related stage step action
  9983. */
  9984. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9985. /**
  9986. * Strong typing of a Mesh Render related stage step action
  9987. */
  9988. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9989. /**
  9990. * Strong typing of a simple stage step action
  9991. */
  9992. export type SimpleStageAction = () => void;
  9993. /**
  9994. * Strong typing of a render target action.
  9995. */
  9996. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9997. /**
  9998. * Strong typing of a pointer move action.
  9999. */
  10000. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10001. /**
  10002. * Strong typing of a pointer up/down action.
  10003. */
  10004. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10005. /**
  10006. * Representation of a stage in the scene (Basically a list of ordered steps)
  10007. * @hidden
  10008. */
  10009. export class Stage<T extends Function> extends Array<{
  10010. index: number;
  10011. component: ISceneComponent;
  10012. action: T;
  10013. }> {
  10014. /**
  10015. * Hide ctor from the rest of the world.
  10016. * @param items The items to add.
  10017. */
  10018. private constructor();
  10019. /**
  10020. * Creates a new Stage.
  10021. * @returns A new instance of a Stage
  10022. */
  10023. static Create<T extends Function>(): Stage<T>;
  10024. /**
  10025. * Registers a step in an ordered way in the targeted stage.
  10026. * @param index Defines the position to register the step in
  10027. * @param component Defines the component attached to the step
  10028. * @param action Defines the action to launch during the step
  10029. */
  10030. registerStep(index: number, component: ISceneComponent, action: T): void;
  10031. /**
  10032. * Clears all the steps from the stage.
  10033. */
  10034. clear(): void;
  10035. }
  10036. }
  10037. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10038. import { Nullable } from "babylonjs/types";
  10039. import { Observable } from "babylonjs/Misc/observable";
  10040. import { Scene } from "babylonjs/scene";
  10041. import { Sprite } from "babylonjs/Sprites/sprite";
  10042. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10043. import { Ray } from "babylonjs/Culling/ray";
  10044. import { Camera } from "babylonjs/Cameras/camera";
  10045. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10046. import { ISceneComponent } from "babylonjs/sceneComponent";
  10047. module "babylonjs/scene" {
  10048. interface Scene {
  10049. /** @hidden */
  10050. _pointerOverSprite: Nullable<Sprite>;
  10051. /** @hidden */
  10052. _pickedDownSprite: Nullable<Sprite>;
  10053. /** @hidden */
  10054. _tempSpritePickingRay: Nullable<Ray>;
  10055. /**
  10056. * All of the sprite managers added to this scene
  10057. * @see http://doc.babylonjs.com/babylon101/sprites
  10058. */
  10059. spriteManagers: Array<ISpriteManager>;
  10060. /**
  10061. * An event triggered when sprites rendering is about to start
  10062. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10063. */
  10064. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10065. /**
  10066. * An event triggered when sprites rendering is done
  10067. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10068. */
  10069. onAfterSpritesRenderingObservable: Observable<Scene>;
  10070. /** @hidden */
  10071. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10072. /** Launch a ray to try to pick a sprite in the scene
  10073. * @param x position on screen
  10074. * @param y position on screen
  10075. * @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
  10076. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10077. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10078. * @returns a PickingInfo
  10079. */
  10080. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10081. /** Use the given ray to pick a sprite in the scene
  10082. * @param ray The ray (in world space) to use to pick meshes
  10083. * @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
  10084. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10085. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10086. * @returns a PickingInfo
  10087. */
  10088. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10089. /** @hidden */
  10090. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10091. /** Launch a ray to try to pick sprites in the scene
  10092. * @param x position on screen
  10093. * @param y position on screen
  10094. * @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
  10095. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10096. * @returns a PickingInfo array
  10097. */
  10098. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10099. /** Use the given ray to pick sprites in the scene
  10100. * @param ray The ray (in world space) to use to pick meshes
  10101. * @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
  10102. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10103. * @returns a PickingInfo array
  10104. */
  10105. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10106. /**
  10107. * Force the sprite under the pointer
  10108. * @param sprite defines the sprite to use
  10109. */
  10110. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10111. /**
  10112. * Gets the sprite under the pointer
  10113. * @returns a Sprite or null if no sprite is under the pointer
  10114. */
  10115. getPointerOverSprite(): Nullable<Sprite>;
  10116. }
  10117. }
  10118. /**
  10119. * Defines the sprite scene component responsible to manage sprites
  10120. * in a given scene.
  10121. */
  10122. export class SpriteSceneComponent implements ISceneComponent {
  10123. /**
  10124. * The component name helpfull to identify the component in the list of scene components.
  10125. */
  10126. readonly name: string;
  10127. /**
  10128. * The scene the component belongs to.
  10129. */
  10130. scene: Scene;
  10131. /** @hidden */
  10132. private _spritePredicate;
  10133. /**
  10134. * Creates a new instance of the component for the given scene
  10135. * @param scene Defines the scene to register the component in
  10136. */
  10137. constructor(scene: Scene);
  10138. /**
  10139. * Registers the component in a given scene
  10140. */
  10141. register(): void;
  10142. /**
  10143. * Rebuilds the elements related to this component in case of
  10144. * context lost for instance.
  10145. */
  10146. rebuild(): void;
  10147. /**
  10148. * Disposes the component and the associated ressources.
  10149. */
  10150. dispose(): void;
  10151. private _pickSpriteButKeepRay;
  10152. private _pointerMove;
  10153. private _pointerDown;
  10154. private _pointerUp;
  10155. }
  10156. }
  10157. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10158. /** @hidden */
  10159. export var fogFragmentDeclaration: {
  10160. name: string;
  10161. shader: string;
  10162. };
  10163. }
  10164. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10165. /** @hidden */
  10166. export var fogFragment: {
  10167. name: string;
  10168. shader: string;
  10169. };
  10170. }
  10171. declare module "babylonjs/Shaders/sprites.fragment" {
  10172. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10173. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10174. /** @hidden */
  10175. export var spritesPixelShader: {
  10176. name: string;
  10177. shader: string;
  10178. };
  10179. }
  10180. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10181. /** @hidden */
  10182. export var fogVertexDeclaration: {
  10183. name: string;
  10184. shader: string;
  10185. };
  10186. }
  10187. declare module "babylonjs/Shaders/sprites.vertex" {
  10188. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10189. /** @hidden */
  10190. export var spritesVertexShader: {
  10191. name: string;
  10192. shader: string;
  10193. };
  10194. }
  10195. declare module "babylonjs/Sprites/spriteManager" {
  10196. import { IDisposable, Scene } from "babylonjs/scene";
  10197. import { Nullable } from "babylonjs/types";
  10198. import { Observable } from "babylonjs/Misc/observable";
  10199. import { Sprite } from "babylonjs/Sprites/sprite";
  10200. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10201. import { Camera } from "babylonjs/Cameras/camera";
  10202. import { Texture } from "babylonjs/Materials/Textures/texture";
  10203. import "babylonjs/Shaders/sprites.fragment";
  10204. import "babylonjs/Shaders/sprites.vertex";
  10205. import { Ray } from "babylonjs/Culling/ray";
  10206. /**
  10207. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10208. */
  10209. export interface ISpriteManager extends IDisposable {
  10210. /**
  10211. * Restricts the camera to viewing objects with the same layerMask.
  10212. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10213. */
  10214. layerMask: number;
  10215. /**
  10216. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10217. */
  10218. isPickable: boolean;
  10219. /**
  10220. * Specifies the rendering group id for this mesh (0 by default)
  10221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10222. */
  10223. renderingGroupId: number;
  10224. /**
  10225. * Defines the list of sprites managed by the manager.
  10226. */
  10227. sprites: Array<Sprite>;
  10228. /**
  10229. * Tests the intersection of a sprite with a specific ray.
  10230. * @param ray The ray we are sending to test the collision
  10231. * @param camera The camera space we are sending rays in
  10232. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10233. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10234. * @returns picking info or null.
  10235. */
  10236. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10237. /**
  10238. * Intersects the sprites with a ray
  10239. * @param ray defines the ray to intersect with
  10240. * @param camera defines the current active camera
  10241. * @param predicate defines a predicate used to select candidate sprites
  10242. * @returns null if no hit or a PickingInfo array
  10243. */
  10244. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10245. /**
  10246. * Renders the list of sprites on screen.
  10247. */
  10248. render(): void;
  10249. }
  10250. /**
  10251. * Class used to manage multiple sprites on the same spritesheet
  10252. * @see http://doc.babylonjs.com/babylon101/sprites
  10253. */
  10254. export class SpriteManager implements ISpriteManager {
  10255. /** defines the manager's name */
  10256. name: string;
  10257. /** Gets the list of sprites */
  10258. sprites: Sprite[];
  10259. /** Gets or sets the rendering group id (0 by default) */
  10260. renderingGroupId: number;
  10261. /** Gets or sets camera layer mask */
  10262. layerMask: number;
  10263. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10264. fogEnabled: boolean;
  10265. /** Gets or sets a boolean indicating if the sprites are pickable */
  10266. isPickable: boolean;
  10267. /** Defines the default width of a cell in the spritesheet */
  10268. cellWidth: number;
  10269. /** Defines the default height of a cell in the spritesheet */
  10270. cellHeight: number;
  10271. /** Associative array from JSON sprite data file */
  10272. private _cellData;
  10273. /** Array of sprite names from JSON sprite data file */
  10274. private _spriteMap;
  10275. /** True when packed cell data from JSON file is ready*/
  10276. private _packedAndReady;
  10277. private _textureContent;
  10278. /**
  10279. * An event triggered when the manager is disposed.
  10280. */
  10281. onDisposeObservable: Observable<SpriteManager>;
  10282. private _onDisposeObserver;
  10283. /**
  10284. * Callback called when the manager is disposed
  10285. */
  10286. set onDispose(callback: () => void);
  10287. private _capacity;
  10288. private _fromPacked;
  10289. private _spriteTexture;
  10290. private _epsilon;
  10291. private _scene;
  10292. private _vertexData;
  10293. private _buffer;
  10294. private _vertexBuffers;
  10295. private _indexBuffer;
  10296. private _effectBase;
  10297. private _effectFog;
  10298. /**
  10299. * Gets or sets the spritesheet texture
  10300. */
  10301. get texture(): Texture;
  10302. set texture(value: Texture);
  10303. private _blendMode;
  10304. /**
  10305. * Blend mode use to render the particle, it can be any of
  10306. * the static Constants.ALPHA_x properties provided in this class.
  10307. * Default value is Constants.ALPHA_COMBINE
  10308. */
  10309. get blendMode(): number;
  10310. set blendMode(blendMode: number);
  10311. /** Disables writing to the depth buffer when rendering the sprites.
  10312. * It can be handy to disable depth writing when using textures without alpha channel
  10313. * and setting some specific blend modes.
  10314. */
  10315. disableDepthWrite: boolean;
  10316. /**
  10317. * Creates a new sprite manager
  10318. * @param name defines the manager's name
  10319. * @param imgUrl defines the sprite sheet url
  10320. * @param capacity defines the maximum allowed number of sprites
  10321. * @param cellSize defines the size of a sprite cell
  10322. * @param scene defines the hosting scene
  10323. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10324. * @param samplingMode defines the smapling mode to use with spritesheet
  10325. * @param fromPacked set to false; do not alter
  10326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10327. */
  10328. constructor(
  10329. /** defines the manager's name */
  10330. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10331. private _makePacked;
  10332. private _appendSpriteVertex;
  10333. private _checkTextureAlpha;
  10334. /**
  10335. * Intersects the sprites with a ray
  10336. * @param ray defines the ray to intersect with
  10337. * @param camera defines the current active camera
  10338. * @param predicate defines a predicate used to select candidate sprites
  10339. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10340. * @returns null if no hit or a PickingInfo
  10341. */
  10342. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10343. /**
  10344. * Intersects the sprites with a ray
  10345. * @param ray defines the ray to intersect with
  10346. * @param camera defines the current active camera
  10347. * @param predicate defines a predicate used to select candidate sprites
  10348. * @returns null if no hit or a PickingInfo array
  10349. */
  10350. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10351. /**
  10352. * Render all child sprites
  10353. */
  10354. render(): void;
  10355. /**
  10356. * Release associated resources
  10357. */
  10358. dispose(): void;
  10359. }
  10360. }
  10361. declare module "babylonjs/Misc/gradients" {
  10362. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10363. /** Interface used by value gradients (color, factor, ...) */
  10364. export interface IValueGradient {
  10365. /**
  10366. * Gets or sets the gradient value (between 0 and 1)
  10367. */
  10368. gradient: number;
  10369. }
  10370. /** Class used to store color4 gradient */
  10371. export class ColorGradient implements IValueGradient {
  10372. /**
  10373. * Gets or sets the gradient value (between 0 and 1)
  10374. */
  10375. gradient: number;
  10376. /**
  10377. * Gets or sets first associated color
  10378. */
  10379. color1: Color4;
  10380. /**
  10381. * Gets or sets second associated color
  10382. */
  10383. color2?: Color4 | undefined;
  10384. /**
  10385. * Creates a new color4 gradient
  10386. * @param gradient gets or sets the gradient value (between 0 and 1)
  10387. * @param color1 gets or sets first associated color
  10388. * @param color2 gets or sets first second color
  10389. */
  10390. constructor(
  10391. /**
  10392. * Gets or sets the gradient value (between 0 and 1)
  10393. */
  10394. gradient: number,
  10395. /**
  10396. * Gets or sets first associated color
  10397. */
  10398. color1: Color4,
  10399. /**
  10400. * Gets or sets second associated color
  10401. */
  10402. color2?: Color4 | undefined);
  10403. /**
  10404. * Will get a color picked randomly between color1 and color2.
  10405. * If color2 is undefined then color1 will be used
  10406. * @param result defines the target Color4 to store the result in
  10407. */
  10408. getColorToRef(result: Color4): void;
  10409. }
  10410. /** Class used to store color 3 gradient */
  10411. export class Color3Gradient implements IValueGradient {
  10412. /**
  10413. * Gets or sets the gradient value (between 0 and 1)
  10414. */
  10415. gradient: number;
  10416. /**
  10417. * Gets or sets the associated color
  10418. */
  10419. color: Color3;
  10420. /**
  10421. * Creates a new color3 gradient
  10422. * @param gradient gets or sets the gradient value (between 0 and 1)
  10423. * @param color gets or sets associated color
  10424. */
  10425. constructor(
  10426. /**
  10427. * Gets or sets the gradient value (between 0 and 1)
  10428. */
  10429. gradient: number,
  10430. /**
  10431. * Gets or sets the associated color
  10432. */
  10433. color: Color3);
  10434. }
  10435. /** Class used to store factor gradient */
  10436. export class FactorGradient implements IValueGradient {
  10437. /**
  10438. * Gets or sets the gradient value (between 0 and 1)
  10439. */
  10440. gradient: number;
  10441. /**
  10442. * Gets or sets first associated factor
  10443. */
  10444. factor1: number;
  10445. /**
  10446. * Gets or sets second associated factor
  10447. */
  10448. factor2?: number | undefined;
  10449. /**
  10450. * Creates a new factor gradient
  10451. * @param gradient gets or sets the gradient value (between 0 and 1)
  10452. * @param factor1 gets or sets first associated factor
  10453. * @param factor2 gets or sets second associated factor
  10454. */
  10455. constructor(
  10456. /**
  10457. * Gets or sets the gradient value (between 0 and 1)
  10458. */
  10459. gradient: number,
  10460. /**
  10461. * Gets or sets first associated factor
  10462. */
  10463. factor1: number,
  10464. /**
  10465. * Gets or sets second associated factor
  10466. */
  10467. factor2?: number | undefined);
  10468. /**
  10469. * Will get a number picked randomly between factor1 and factor2.
  10470. * If factor2 is undefined then factor1 will be used
  10471. * @returns the picked number
  10472. */
  10473. getFactor(): number;
  10474. }
  10475. /**
  10476. * Helper used to simplify some generic gradient tasks
  10477. */
  10478. export class GradientHelper {
  10479. /**
  10480. * Gets the current gradient from an array of IValueGradient
  10481. * @param ratio defines the current ratio to get
  10482. * @param gradients defines the array of IValueGradient
  10483. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10484. */
  10485. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10486. }
  10487. }
  10488. declare module "babylonjs/Maths/math.size" {
  10489. /**
  10490. * Interface for the size containing width and height
  10491. */
  10492. export interface ISize {
  10493. /**
  10494. * Width
  10495. */
  10496. width: number;
  10497. /**
  10498. * Heighht
  10499. */
  10500. height: number;
  10501. }
  10502. /**
  10503. * Size containing widht and height
  10504. */
  10505. export class Size implements ISize {
  10506. /**
  10507. * Width
  10508. */
  10509. width: number;
  10510. /**
  10511. * Height
  10512. */
  10513. height: number;
  10514. /**
  10515. * Creates a Size object from the given width and height (floats).
  10516. * @param width width of the new size
  10517. * @param height height of the new size
  10518. */
  10519. constructor(width: number, height: number);
  10520. /**
  10521. * Returns a string with the Size width and height
  10522. * @returns a string with the Size width and height
  10523. */
  10524. toString(): string;
  10525. /**
  10526. * "Size"
  10527. * @returns the string "Size"
  10528. */
  10529. getClassName(): string;
  10530. /**
  10531. * Returns the Size hash code.
  10532. * @returns a hash code for a unique width and height
  10533. */
  10534. getHashCode(): number;
  10535. /**
  10536. * Updates the current size from the given one.
  10537. * @param src the given size
  10538. */
  10539. copyFrom(src: Size): void;
  10540. /**
  10541. * Updates in place the current Size from the given floats.
  10542. * @param width width of the new size
  10543. * @param height height of the new size
  10544. * @returns the updated Size.
  10545. */
  10546. copyFromFloats(width: number, height: number): Size;
  10547. /**
  10548. * Updates in place the current Size from the given floats.
  10549. * @param width width to set
  10550. * @param height height to set
  10551. * @returns the updated Size.
  10552. */
  10553. set(width: number, height: number): Size;
  10554. /**
  10555. * Multiplies the width and height by numbers
  10556. * @param w factor to multiple the width by
  10557. * @param h factor to multiple the height by
  10558. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10559. */
  10560. multiplyByFloats(w: number, h: number): Size;
  10561. /**
  10562. * Clones the size
  10563. * @returns a new Size copied from the given one.
  10564. */
  10565. clone(): Size;
  10566. /**
  10567. * True if the current Size and the given one width and height are strictly equal.
  10568. * @param other the other size to compare against
  10569. * @returns True if the current Size and the given one width and height are strictly equal.
  10570. */
  10571. equals(other: Size): boolean;
  10572. /**
  10573. * The surface of the Size : width * height (float).
  10574. */
  10575. get surface(): number;
  10576. /**
  10577. * Create a new size of zero
  10578. * @returns a new Size set to (0.0, 0.0)
  10579. */
  10580. static Zero(): Size;
  10581. /**
  10582. * Sums the width and height of two sizes
  10583. * @param otherSize size to add to this size
  10584. * @returns a new Size set as the addition result of the current Size and the given one.
  10585. */
  10586. add(otherSize: Size): Size;
  10587. /**
  10588. * Subtracts the width and height of two
  10589. * @param otherSize size to subtract to this size
  10590. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10591. */
  10592. subtract(otherSize: Size): Size;
  10593. /**
  10594. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10595. * @param start starting size to lerp between
  10596. * @param end end size to lerp between
  10597. * @param amount amount to lerp between the start and end values
  10598. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10599. */
  10600. static Lerp(start: Size, end: Size, amount: number): Size;
  10601. }
  10602. }
  10603. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10605. import { Nullable } from "babylonjs/types";
  10606. module "babylonjs/Engines/thinEngine" {
  10607. interface ThinEngine {
  10608. /**
  10609. * Creates a dynamic texture
  10610. * @param width defines the width of the texture
  10611. * @param height defines the height of the texture
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10614. * @returns the dynamic texture inside an InternalTexture
  10615. */
  10616. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10617. /**
  10618. * Update the content of a dynamic texture
  10619. * @param texture defines the texture to update
  10620. * @param canvas defines the canvas containing the source
  10621. * @param invertY defines if data must be stored with Y axis inverted
  10622. * @param premulAlpha defines if alpha is stored as premultiplied
  10623. * @param format defines the format of the data
  10624. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10625. */
  10626. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10627. }
  10628. }
  10629. }
  10630. declare module "babylonjs/Misc/canvasGenerator" {
  10631. /**
  10632. * Helper class used to generate a canvas to manipulate images
  10633. */
  10634. export class CanvasGenerator {
  10635. /**
  10636. * Create a new canvas (or offscreen canvas depending on the context)
  10637. * @param width defines the expected width
  10638. * @param height defines the expected height
  10639. * @return a new canvas or offscreen canvas
  10640. */
  10641. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10642. }
  10643. }
  10644. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10645. import { Scene } from "babylonjs/scene";
  10646. import { Texture } from "babylonjs/Materials/Textures/texture";
  10647. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10648. /**
  10649. * A class extending Texture allowing drawing on a texture
  10650. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10651. */
  10652. export class DynamicTexture extends Texture {
  10653. private _generateMipMaps;
  10654. private _canvas;
  10655. private _context;
  10656. private _engine;
  10657. /**
  10658. * Creates a DynamicTexture
  10659. * @param name defines the name of the texture
  10660. * @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
  10661. * @param scene defines the scene where you want the texture
  10662. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10663. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10664. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10665. */
  10666. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10667. /**
  10668. * Get the current class name of the texture useful for serialization or dynamic coding.
  10669. * @returns "DynamicTexture"
  10670. */
  10671. getClassName(): string;
  10672. /**
  10673. * Gets the current state of canRescale
  10674. */
  10675. get canRescale(): boolean;
  10676. private _recreate;
  10677. /**
  10678. * Scales the texture
  10679. * @param ratio the scale factor to apply to both width and height
  10680. */
  10681. scale(ratio: number): void;
  10682. /**
  10683. * Resizes the texture
  10684. * @param width the new width
  10685. * @param height the new height
  10686. */
  10687. scaleTo(width: number, height: number): void;
  10688. /**
  10689. * Gets the context of the canvas used by the texture
  10690. * @returns the canvas context of the dynamic texture
  10691. */
  10692. getContext(): CanvasRenderingContext2D;
  10693. /**
  10694. * Clears the texture
  10695. */
  10696. clear(): void;
  10697. /**
  10698. * Updates the texture
  10699. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10700. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10701. */
  10702. update(invertY?: boolean, premulAlpha?: boolean): void;
  10703. /**
  10704. * Draws text onto the texture
  10705. * @param text defines the text to be drawn
  10706. * @param x defines the placement of the text from the left
  10707. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10708. * @param font defines the font to be used with font-style, font-size, font-name
  10709. * @param color defines the color used for the text
  10710. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10711. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10712. * @param update defines whether texture is immediately update (default is true)
  10713. */
  10714. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10715. /**
  10716. * Clones the texture
  10717. * @returns the clone of the texture.
  10718. */
  10719. clone(): DynamicTexture;
  10720. /**
  10721. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10722. * @returns a serialized dynamic texture object
  10723. */
  10724. serialize(): any;
  10725. /** @hidden */
  10726. _rebuild(): void;
  10727. }
  10728. }
  10729. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10730. import { Nullable } from "babylonjs/types";
  10731. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10732. import { Scene } from "babylonjs/scene";
  10733. module "babylonjs/Engines/thinEngine" {
  10734. interface ThinEngine {
  10735. /**
  10736. * Creates a raw texture
  10737. * @param data defines the data to store in the texture
  10738. * @param width defines the width of the texture
  10739. * @param height defines the height of the texture
  10740. * @param format defines the format of the data
  10741. * @param generateMipMaps defines if the engine should generate the mip levels
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10744. * @param compression defines the compression used (null by default)
  10745. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10746. * @returns the raw texture inside an InternalTexture
  10747. */
  10748. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10749. /**
  10750. * Update a raw texture
  10751. * @param texture defines the texture to update
  10752. * @param data defines the data to store in the texture
  10753. * @param format defines the format of the data
  10754. * @param invertY defines if data must be stored with Y axis inverted
  10755. */
  10756. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10757. /**
  10758. * Update a raw texture
  10759. * @param texture defines the texture to update
  10760. * @param data defines the data to store in the texture
  10761. * @param format defines the format of the data
  10762. * @param invertY defines if data must be stored with Y axis inverted
  10763. * @param compression defines the compression used (null by default)
  10764. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10765. */
  10766. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10767. /**
  10768. * Creates a new raw cube texture
  10769. * @param data defines the array of data to use to create each face
  10770. * @param size defines the size of the textures
  10771. * @param format defines the format of the data
  10772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10773. * @param generateMipMaps defines if the engine should generate the mip levels
  10774. * @param invertY defines if data must be stored with Y axis inverted
  10775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10776. * @param compression defines the compression used (null by default)
  10777. * @returns the cube texture as an InternalTexture
  10778. */
  10779. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10780. /**
  10781. * Update a raw cube texture
  10782. * @param texture defines the texture to udpdate
  10783. * @param data defines the data to store
  10784. * @param format defines the data format
  10785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10786. * @param invertY defines if data must be stored with Y axis inverted
  10787. */
  10788. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10789. /**
  10790. * Update a raw cube texture
  10791. * @param texture defines the texture to udpdate
  10792. * @param data defines the data to store
  10793. * @param format defines the data format
  10794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10795. * @param invertY defines if data must be stored with Y axis inverted
  10796. * @param compression defines the compression used (null by default)
  10797. */
  10798. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10799. /**
  10800. * Update a raw cube texture
  10801. * @param texture defines the texture to udpdate
  10802. * @param data defines the data to store
  10803. * @param format defines the data format
  10804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10805. * @param invertY defines if data must be stored with Y axis inverted
  10806. * @param compression defines the compression used (null by default)
  10807. * @param level defines which level of the texture to update
  10808. */
  10809. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10810. /**
  10811. * Creates a new raw cube texture from a specified url
  10812. * @param url defines the url where the data is located
  10813. * @param scene defines the current scene
  10814. * @param size defines the size of the textures
  10815. * @param format defines the format of the data
  10816. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10817. * @param noMipmap defines if the engine should avoid generating the mip levels
  10818. * @param callback defines a callback used to extract texture data from loaded data
  10819. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10820. * @param onLoad defines a callback called when texture is loaded
  10821. * @param onError defines a callback called if there is an error
  10822. * @returns the cube texture as an InternalTexture
  10823. */
  10824. createRawCubeTextureFromUrl(url: string, scene: 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;
  10825. /**
  10826. * Creates a new raw cube texture from a specified url
  10827. * @param url defines the url where the data is located
  10828. * @param scene defines the current scene
  10829. * @param size defines the size of the textures
  10830. * @param format defines the format of the data
  10831. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10832. * @param noMipmap defines if the engine should avoid generating the mip levels
  10833. * @param callback defines a callback used to extract texture data from loaded data
  10834. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10835. * @param onLoad defines a callback called when texture is loaded
  10836. * @param onError defines a callback called if there is an error
  10837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10838. * @param invertY defines if data must be stored with Y axis inverted
  10839. * @returns the cube texture as an InternalTexture
  10840. */
  10841. createRawCubeTextureFromUrl(url: string, scene: 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;
  10842. /**
  10843. * Creates a new raw 3D texture
  10844. * @param data defines the data used to create the texture
  10845. * @param width defines the width of the texture
  10846. * @param height defines the height of the texture
  10847. * @param depth defines the depth of the texture
  10848. * @param format defines the format of the texture
  10849. * @param generateMipMaps defines if the engine must generate mip levels
  10850. * @param invertY defines if data must be stored with Y axis inverted
  10851. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10852. * @param compression defines the compressed used (can be null)
  10853. * @param textureType defines the compressed used (can be null)
  10854. * @returns a new raw 3D texture (stored in an InternalTexture)
  10855. */
  10856. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10857. /**
  10858. * Update a raw 3D texture
  10859. * @param texture defines the texture to update
  10860. * @param data defines the data to store
  10861. * @param format defines the data format
  10862. * @param invertY defines if data must be stored with Y axis inverted
  10863. */
  10864. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10865. /**
  10866. * Update a raw 3D texture
  10867. * @param texture defines the texture to update
  10868. * @param data defines the data to store
  10869. * @param format defines the data format
  10870. * @param invertY defines if data must be stored with Y axis inverted
  10871. * @param compression defines the used compression (can be null)
  10872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10873. */
  10874. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10875. /**
  10876. * Creates a new raw 2D array texture
  10877. * @param data defines the data used to create the texture
  10878. * @param width defines the width of the texture
  10879. * @param height defines the height of the texture
  10880. * @param depth defines the number of layers of the texture
  10881. * @param format defines the format of the texture
  10882. * @param generateMipMaps defines if the engine must generate mip levels
  10883. * @param invertY defines if data must be stored with Y axis inverted
  10884. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10885. * @param compression defines the compressed used (can be null)
  10886. * @param textureType defines the compressed used (can be null)
  10887. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10888. */
  10889. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10890. /**
  10891. * Update a raw 2D array texture
  10892. * @param texture defines the texture to update
  10893. * @param data defines the data to store
  10894. * @param format defines the data format
  10895. * @param invertY defines if data must be stored with Y axis inverted
  10896. */
  10897. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10898. /**
  10899. * Update a raw 2D array texture
  10900. * @param texture defines the texture to update
  10901. * @param data defines the data to store
  10902. * @param format defines the data format
  10903. * @param invertY defines if data must be stored with Y axis inverted
  10904. * @param compression defines the used compression (can be null)
  10905. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10906. */
  10907. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10908. }
  10909. }
  10910. }
  10911. declare module "babylonjs/Materials/Textures/rawTexture" {
  10912. import { Scene } from "babylonjs/scene";
  10913. import { Texture } from "babylonjs/Materials/Textures/texture";
  10914. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10915. /**
  10916. * Raw texture can help creating a texture directly from an array of data.
  10917. * This can be super useful if you either get the data from an uncompressed source or
  10918. * if you wish to create your texture pixel by pixel.
  10919. */
  10920. export class RawTexture extends Texture {
  10921. /**
  10922. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10923. */
  10924. format: number;
  10925. private _engine;
  10926. /**
  10927. * Instantiates a new RawTexture.
  10928. * Raw texture can help creating a texture directly from an array of data.
  10929. * This can be super useful if you either get the data from an uncompressed source or
  10930. * if you wish to create your texture pixel by pixel.
  10931. * @param data define the array of data to use to create the texture
  10932. * @param width define the width of the texture
  10933. * @param height define the height of the texture
  10934. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10935. * @param scene define the scene the texture belongs to
  10936. * @param generateMipMaps define whether mip maps should be generated or not
  10937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10939. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10940. */
  10941. constructor(data: ArrayBufferView, width: number, height: number,
  10942. /**
  10943. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10944. */
  10945. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10946. /**
  10947. * Updates the texture underlying data.
  10948. * @param data Define the new data of the texture
  10949. */
  10950. update(data: ArrayBufferView): void;
  10951. /**
  10952. * Creates a luminance texture from some data.
  10953. * @param data Define the texture data
  10954. * @param width Define the width of the texture
  10955. * @param height Define the height of the texture
  10956. * @param scene Define the scene the texture belongs to
  10957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10960. * @returns the luminance texture
  10961. */
  10962. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10963. /**
  10964. * Creates a luminance alpha texture from some data.
  10965. * @param data Define the texture data
  10966. * @param width Define the width of the texture
  10967. * @param height Define the height of the texture
  10968. * @param scene Define the scene the texture belongs to
  10969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10972. * @returns the luminance alpha texture
  10973. */
  10974. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10975. /**
  10976. * Creates an alpha texture from some data.
  10977. * @param data Define the texture data
  10978. * @param width Define the width of the texture
  10979. * @param height Define the height of the texture
  10980. * @param scene Define the scene the texture belongs to
  10981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10984. * @returns the alpha texture
  10985. */
  10986. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10987. /**
  10988. * Creates a RGB texture from some data.
  10989. * @param data Define the texture data
  10990. * @param width Define the width of the texture
  10991. * @param height Define the height of the texture
  10992. * @param scene Define the scene the texture belongs to
  10993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10997. * @returns the RGB alpha texture
  10998. */
  10999. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11000. /**
  11001. * Creates a RGBA texture from some data.
  11002. * @param data Define the texture data
  11003. * @param width Define the width of the texture
  11004. * @param height Define the height of the texture
  11005. * @param scene Define the scene the texture belongs to
  11006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11010. * @returns the RGBA texture
  11011. */
  11012. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11013. /**
  11014. * Creates a R texture from some data.
  11015. * @param data Define the texture data
  11016. * @param width Define the width of the texture
  11017. * @param height Define the height of the texture
  11018. * @param scene Define the scene the texture belongs to
  11019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11023. * @returns the R texture
  11024. */
  11025. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11026. }
  11027. }
  11028. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11029. import { Scene } from "babylonjs/scene";
  11030. import { ISceneComponent } from "babylonjs/sceneComponent";
  11031. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11032. module "babylonjs/abstractScene" {
  11033. interface AbstractScene {
  11034. /**
  11035. * The list of procedural textures added to the scene
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11037. */
  11038. proceduralTextures: Array<ProceduralTexture>;
  11039. }
  11040. }
  11041. /**
  11042. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11043. * in a given scene.
  11044. */
  11045. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11046. /**
  11047. * The component name helpfull to identify the component in the list of scene components.
  11048. */
  11049. readonly name: string;
  11050. /**
  11051. * The scene the component belongs to.
  11052. */
  11053. scene: Scene;
  11054. /**
  11055. * Creates a new instance of the component for the given scene
  11056. * @param scene Defines the scene to register the component in
  11057. */
  11058. constructor(scene: Scene);
  11059. /**
  11060. * Registers the component in a given scene
  11061. */
  11062. register(): void;
  11063. /**
  11064. * Rebuilds the elements related to this component in case of
  11065. * context lost for instance.
  11066. */
  11067. rebuild(): void;
  11068. /**
  11069. * Disposes the component and the associated ressources.
  11070. */
  11071. dispose(): void;
  11072. private _beforeClear;
  11073. }
  11074. }
  11075. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11077. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11078. module "babylonjs/Engines/thinEngine" {
  11079. interface ThinEngine {
  11080. /**
  11081. * Creates a new render target cube texture
  11082. * @param size defines the size of the texture
  11083. * @param options defines the options used to create the texture
  11084. * @returns a new render target cube texture stored in an InternalTexture
  11085. */
  11086. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11087. }
  11088. }
  11089. }
  11090. declare module "babylonjs/Shaders/procedural.vertex" {
  11091. /** @hidden */
  11092. export var proceduralVertexShader: {
  11093. name: string;
  11094. shader: string;
  11095. };
  11096. }
  11097. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11098. import { Observable } from "babylonjs/Misc/observable";
  11099. import { Nullable } from "babylonjs/types";
  11100. import { Scene } from "babylonjs/scene";
  11101. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11102. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11103. import { Effect } from "babylonjs/Materials/effect";
  11104. import { Texture } from "babylonjs/Materials/Textures/texture";
  11105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11106. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11107. import "babylonjs/Shaders/procedural.vertex";
  11108. /**
  11109. * 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.
  11110. * This is the base class of any Procedural texture and contains most of the shareable code.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11112. */
  11113. export class ProceduralTexture extends Texture {
  11114. isCube: boolean;
  11115. /**
  11116. * Define if the texture is enabled or not (disabled texture will not render)
  11117. */
  11118. isEnabled: boolean;
  11119. /**
  11120. * Define if the texture must be cleared before rendering (default is true)
  11121. */
  11122. autoClear: boolean;
  11123. /**
  11124. * Callback called when the texture is generated
  11125. */
  11126. onGenerated: () => void;
  11127. /**
  11128. * Event raised when the texture is generated
  11129. */
  11130. onGeneratedObservable: Observable<ProceduralTexture>;
  11131. /** @hidden */
  11132. _generateMipMaps: boolean;
  11133. /** @hidden **/
  11134. _effect: Effect;
  11135. /** @hidden */
  11136. _textures: {
  11137. [key: string]: Texture;
  11138. };
  11139. /** @hidden */
  11140. protected _fallbackTexture: Nullable<Texture>;
  11141. private _size;
  11142. private _currentRefreshId;
  11143. private _frameId;
  11144. private _refreshRate;
  11145. private _vertexBuffers;
  11146. private _indexBuffer;
  11147. private _uniforms;
  11148. private _samplers;
  11149. private _fragment;
  11150. private _floats;
  11151. private _ints;
  11152. private _floatsArrays;
  11153. private _colors3;
  11154. private _colors4;
  11155. private _vectors2;
  11156. private _vectors3;
  11157. private _matrices;
  11158. private _fallbackTextureUsed;
  11159. private _engine;
  11160. private _cachedDefines;
  11161. private _contentUpdateId;
  11162. private _contentData;
  11163. /**
  11164. * Instantiates a new procedural texture.
  11165. * 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.
  11166. * This is the base class of any Procedural texture and contains most of the shareable code.
  11167. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11168. * @param name Define the name of the texture
  11169. * @param size Define the size of the texture to create
  11170. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11171. * @param scene Define the scene the texture belongs to
  11172. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11173. * @param generateMipMaps Define if the texture should creates mip maps or not
  11174. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11175. */
  11176. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11177. /**
  11178. * The effect that is created when initializing the post process.
  11179. * @returns The created effect corresponding the the postprocess.
  11180. */
  11181. getEffect(): Effect;
  11182. /**
  11183. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11184. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11185. */
  11186. getContent(): Nullable<ArrayBufferView>;
  11187. private _createIndexBuffer;
  11188. /** @hidden */
  11189. _rebuild(): void;
  11190. /**
  11191. * Resets the texture in order to recreate its associated resources.
  11192. * This can be called in case of context loss
  11193. */
  11194. reset(): void;
  11195. protected _getDefines(): string;
  11196. /**
  11197. * Is the texture ready to be used ? (rendered at least once)
  11198. * @returns true if ready, otherwise, false.
  11199. */
  11200. isReady(): boolean;
  11201. /**
  11202. * Resets the refresh counter of the texture and start bak from scratch.
  11203. * Could be useful to regenerate the texture if it is setup to render only once.
  11204. */
  11205. resetRefreshCounter(): void;
  11206. /**
  11207. * Set the fragment shader to use in order to render the texture.
  11208. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11209. */
  11210. setFragment(fragment: any): void;
  11211. /**
  11212. * Define the refresh rate of the texture or the rendering frequency.
  11213. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11214. */
  11215. get refreshRate(): number;
  11216. set refreshRate(value: number);
  11217. /** @hidden */
  11218. _shouldRender(): boolean;
  11219. /**
  11220. * Get the size the texture is rendering at.
  11221. * @returns the size (texture is always squared)
  11222. */
  11223. getRenderSize(): number;
  11224. /**
  11225. * Resize the texture to new value.
  11226. * @param size Define the new size the texture should have
  11227. * @param generateMipMaps Define whether the new texture should create mip maps
  11228. */
  11229. resize(size: number, generateMipMaps: boolean): void;
  11230. private _checkUniform;
  11231. /**
  11232. * Set a texture in the shader program used to render.
  11233. * @param name Define the name of the uniform samplers as defined in the shader
  11234. * @param texture Define the texture to bind to this sampler
  11235. * @return the texture itself allowing "fluent" like uniform updates
  11236. */
  11237. setTexture(name: string, texture: Texture): ProceduralTexture;
  11238. /**
  11239. * Set a float in the shader.
  11240. * @param name Define the name of the uniform as defined in the shader
  11241. * @param value Define the value to give to the uniform
  11242. * @return the texture itself allowing "fluent" like uniform updates
  11243. */
  11244. setFloat(name: string, value: number): ProceduralTexture;
  11245. /**
  11246. * Set a int in the shader.
  11247. * @param name Define the name of the uniform as defined in the shader
  11248. * @param value Define the value to give to the uniform
  11249. * @return the texture itself allowing "fluent" like uniform updates
  11250. */
  11251. setInt(name: string, value: number): ProceduralTexture;
  11252. /**
  11253. * Set an array of floats in the shader.
  11254. * @param name Define the name of the uniform as defined in the shader
  11255. * @param value Define the value to give to the uniform
  11256. * @return the texture itself allowing "fluent" like uniform updates
  11257. */
  11258. setFloats(name: string, value: number[]): ProceduralTexture;
  11259. /**
  11260. * Set a vec3 in the shader from a Color3.
  11261. * @param name Define the name of the uniform as defined in the shader
  11262. * @param value Define the value to give to the uniform
  11263. * @return the texture itself allowing "fluent" like uniform updates
  11264. */
  11265. setColor3(name: string, value: Color3): ProceduralTexture;
  11266. /**
  11267. * Set a vec4 in the shader from a Color4.
  11268. * @param name Define the name of the uniform as defined in the shader
  11269. * @param value Define the value to give to the uniform
  11270. * @return the texture itself allowing "fluent" like uniform updates
  11271. */
  11272. setColor4(name: string, value: Color4): ProceduralTexture;
  11273. /**
  11274. * Set a vec2 in the shader from a Vector2.
  11275. * @param name Define the name of the uniform as defined in the shader
  11276. * @param value Define the value to give to the uniform
  11277. * @return the texture itself allowing "fluent" like uniform updates
  11278. */
  11279. setVector2(name: string, value: Vector2): ProceduralTexture;
  11280. /**
  11281. * Set a vec3 in the shader from a Vector3.
  11282. * @param name Define the name of the uniform as defined in the shader
  11283. * @param value Define the value to give to the uniform
  11284. * @return the texture itself allowing "fluent" like uniform updates
  11285. */
  11286. setVector3(name: string, value: Vector3): ProceduralTexture;
  11287. /**
  11288. * Set a mat4 in the shader from a MAtrix.
  11289. * @param name Define the name of the uniform as defined in the shader
  11290. * @param value Define the value to give to the uniform
  11291. * @return the texture itself allowing "fluent" like uniform updates
  11292. */
  11293. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11294. /**
  11295. * Render the texture to its associated render target.
  11296. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11297. */
  11298. render(useCameraPostProcess?: boolean): void;
  11299. /**
  11300. * Clone the texture.
  11301. * @returns the cloned texture
  11302. */
  11303. clone(): ProceduralTexture;
  11304. /**
  11305. * Dispose the texture and release its asoociated resources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. }
  11310. declare module "babylonjs/Particles/baseParticleSystem" {
  11311. import { Nullable } from "babylonjs/types";
  11312. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11314. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11315. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11316. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11317. import { Scene } from "babylonjs/scene";
  11318. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11319. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11320. import { Texture } from "babylonjs/Materials/Textures/texture";
  11321. import { Color4 } from "babylonjs/Maths/math.color";
  11322. import { Animation } from "babylonjs/Animations/animation";
  11323. /**
  11324. * This represents the base class for particle system in Babylon.
  11325. * 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.
  11326. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11327. * @example https://doc.babylonjs.com/babylon101/particles
  11328. */
  11329. export class BaseParticleSystem {
  11330. /**
  11331. * Source color is added to the destination color without alpha affecting the result
  11332. */
  11333. static BLENDMODE_ONEONE: number;
  11334. /**
  11335. * Blend current color and particle color using particle’s alpha
  11336. */
  11337. static BLENDMODE_STANDARD: number;
  11338. /**
  11339. * Add current color and particle color multiplied by particle’s alpha
  11340. */
  11341. static BLENDMODE_ADD: number;
  11342. /**
  11343. * Multiply current color with particle color
  11344. */
  11345. static BLENDMODE_MULTIPLY: number;
  11346. /**
  11347. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11348. */
  11349. static BLENDMODE_MULTIPLYADD: number;
  11350. /**
  11351. * List of animations used by the particle system.
  11352. */
  11353. animations: Animation[];
  11354. /**
  11355. * Gets or sets the unique id of the particle system
  11356. */
  11357. uniqueId: number;
  11358. /**
  11359. * The id of the Particle system.
  11360. */
  11361. id: string;
  11362. /**
  11363. * The friendly name of the Particle system.
  11364. */
  11365. name: string;
  11366. /**
  11367. * Snippet ID if the particle system was created from the snippet server
  11368. */
  11369. snippetId: string;
  11370. /**
  11371. * The rendering group used by the Particle system to chose when to render.
  11372. */
  11373. renderingGroupId: number;
  11374. /**
  11375. * The emitter represents the Mesh or position we are attaching the particle system to.
  11376. */
  11377. emitter: Nullable<AbstractMesh | Vector3>;
  11378. /**
  11379. * The maximum number of particles to emit per frame
  11380. */
  11381. emitRate: number;
  11382. /**
  11383. * If you want to launch only a few particles at once, that can be done, as well.
  11384. */
  11385. manualEmitCount: number;
  11386. /**
  11387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11388. */
  11389. updateSpeed: number;
  11390. /**
  11391. * The amount of time the particle system is running (depends of the overall update speed).
  11392. */
  11393. targetStopDuration: number;
  11394. /**
  11395. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11396. */
  11397. disposeOnStop: boolean;
  11398. /**
  11399. * Minimum power of emitting particles.
  11400. */
  11401. minEmitPower: number;
  11402. /**
  11403. * Maximum power of emitting particles.
  11404. */
  11405. maxEmitPower: number;
  11406. /**
  11407. * Minimum life time of emitting particles.
  11408. */
  11409. minLifeTime: number;
  11410. /**
  11411. * Maximum life time of emitting particles.
  11412. */
  11413. maxLifeTime: number;
  11414. /**
  11415. * Minimum Size of emitting particles.
  11416. */
  11417. minSize: number;
  11418. /**
  11419. * Maximum Size of emitting particles.
  11420. */
  11421. maxSize: number;
  11422. /**
  11423. * Minimum scale of emitting particles on X axis.
  11424. */
  11425. minScaleX: number;
  11426. /**
  11427. * Maximum scale of emitting particles on X axis.
  11428. */
  11429. maxScaleX: number;
  11430. /**
  11431. * Minimum scale of emitting particles on Y axis.
  11432. */
  11433. minScaleY: number;
  11434. /**
  11435. * Maximum scale of emitting particles on Y axis.
  11436. */
  11437. maxScaleY: number;
  11438. /**
  11439. * Gets or sets the minimal initial rotation in radians.
  11440. */
  11441. minInitialRotation: number;
  11442. /**
  11443. * Gets or sets the maximal initial rotation in radians.
  11444. */
  11445. maxInitialRotation: number;
  11446. /**
  11447. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11448. */
  11449. minAngularSpeed: number;
  11450. /**
  11451. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11452. */
  11453. maxAngularSpeed: number;
  11454. /**
  11455. * The texture used to render each particle. (this can be a spritesheet)
  11456. */
  11457. particleTexture: Nullable<Texture>;
  11458. /**
  11459. * The layer mask we are rendering the particles through.
  11460. */
  11461. layerMask: number;
  11462. /**
  11463. * This can help using your own shader to render the particle system.
  11464. * The according effect will be created
  11465. */
  11466. customShader: any;
  11467. /**
  11468. * By default particle system starts as soon as they are created. This prevents the
  11469. * automatic start to happen and let you decide when to start emitting particles.
  11470. */
  11471. preventAutoStart: boolean;
  11472. private _noiseTexture;
  11473. /**
  11474. * Gets or sets a texture used to add random noise to particle positions
  11475. */
  11476. get noiseTexture(): Nullable<ProceduralTexture>;
  11477. set noiseTexture(value: Nullable<ProceduralTexture>);
  11478. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11479. noiseStrength: Vector3;
  11480. /**
  11481. * Callback triggered when the particle animation is ending.
  11482. */
  11483. onAnimationEnd: Nullable<() => void>;
  11484. /**
  11485. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11486. */
  11487. blendMode: number;
  11488. /**
  11489. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11490. * to override the particles.
  11491. */
  11492. forceDepthWrite: boolean;
  11493. /** 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 */
  11494. preWarmCycles: number;
  11495. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11496. preWarmStepOffset: number;
  11497. /**
  11498. * 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)
  11499. */
  11500. spriteCellChangeSpeed: number;
  11501. /**
  11502. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11503. */
  11504. startSpriteCellID: number;
  11505. /**
  11506. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11507. */
  11508. endSpriteCellID: number;
  11509. /**
  11510. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11511. */
  11512. spriteCellWidth: number;
  11513. /**
  11514. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11515. */
  11516. spriteCellHeight: number;
  11517. /**
  11518. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11519. */
  11520. spriteRandomStartCell: boolean;
  11521. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11522. translationPivot: Vector2;
  11523. /** @hidden */
  11524. protected _isAnimationSheetEnabled: boolean;
  11525. /**
  11526. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11527. */
  11528. beginAnimationOnStart: boolean;
  11529. /**
  11530. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11531. */
  11532. beginAnimationFrom: number;
  11533. /**
  11534. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11535. */
  11536. beginAnimationTo: number;
  11537. /**
  11538. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11539. */
  11540. beginAnimationLoop: boolean;
  11541. /**
  11542. * Gets or sets a world offset applied to all particles
  11543. */
  11544. worldOffset: Vector3;
  11545. /**
  11546. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11547. */
  11548. get isAnimationSheetEnabled(): boolean;
  11549. set isAnimationSheetEnabled(value: boolean);
  11550. /**
  11551. * Get hosting scene
  11552. * @returns the scene
  11553. */
  11554. getScene(): Scene;
  11555. /**
  11556. * You can use gravity if you want to give an orientation to your particles.
  11557. */
  11558. gravity: Vector3;
  11559. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11560. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11561. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11562. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11563. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11564. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11565. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11566. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11567. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11568. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11569. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11570. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11571. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11572. /**
  11573. * Defines the delay in milliseconds before starting the system (0 by default)
  11574. */
  11575. startDelay: number;
  11576. /**
  11577. * Gets the current list of drag gradients.
  11578. * You must use addDragGradient and removeDragGradient to udpate this list
  11579. * @returns the list of drag gradients
  11580. */
  11581. getDragGradients(): Nullable<Array<FactorGradient>>;
  11582. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11583. limitVelocityDamping: number;
  11584. /**
  11585. * Gets the current list of limit velocity gradients.
  11586. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11587. * @returns the list of limit velocity gradients
  11588. */
  11589. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11590. /**
  11591. * Gets the current list of color gradients.
  11592. * You must use addColorGradient and removeColorGradient to udpate this list
  11593. * @returns the list of color gradients
  11594. */
  11595. getColorGradients(): Nullable<Array<ColorGradient>>;
  11596. /**
  11597. * Gets the current list of size gradients.
  11598. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11599. * @returns the list of size gradients
  11600. */
  11601. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11602. /**
  11603. * Gets the current list of color remap gradients.
  11604. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11605. * @returns the list of color remap gradients
  11606. */
  11607. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11608. /**
  11609. * Gets the current list of alpha remap gradients.
  11610. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11611. * @returns the list of alpha remap gradients
  11612. */
  11613. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11614. /**
  11615. * Gets the current list of life time gradients.
  11616. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11617. * @returns the list of life time gradients
  11618. */
  11619. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11620. /**
  11621. * Gets the current list of angular speed gradients.
  11622. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11623. * @returns the list of angular speed gradients
  11624. */
  11625. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11626. /**
  11627. * Gets the current list of velocity gradients.
  11628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11629. * @returns the list of velocity gradients
  11630. */
  11631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11632. /**
  11633. * Gets the current list of start size gradients.
  11634. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11635. * @returns the list of start size gradients
  11636. */
  11637. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11638. /**
  11639. * Gets the current list of emit rate gradients.
  11640. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11641. * @returns the list of emit rate gradients
  11642. */
  11643. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11644. /**
  11645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11646. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11647. */
  11648. get direction1(): Vector3;
  11649. set direction1(value: Vector3);
  11650. /**
  11651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11653. */
  11654. get direction2(): Vector3;
  11655. set direction2(value: Vector3);
  11656. /**
  11657. * 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.
  11658. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11659. */
  11660. get minEmitBox(): Vector3;
  11661. set minEmitBox(value: Vector3);
  11662. /**
  11663. * 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.
  11664. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11665. */
  11666. get maxEmitBox(): Vector3;
  11667. set maxEmitBox(value: Vector3);
  11668. /**
  11669. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11670. */
  11671. color1: Color4;
  11672. /**
  11673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11674. */
  11675. color2: Color4;
  11676. /**
  11677. * Color the particle will have at the end of its lifetime
  11678. */
  11679. colorDead: Color4;
  11680. /**
  11681. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11682. */
  11683. textureMask: Color4;
  11684. /**
  11685. * The particle emitter type defines the emitter used by the particle system.
  11686. * It can be for example box, sphere, or cone...
  11687. */
  11688. particleEmitterType: IParticleEmitterType;
  11689. /** @hidden */
  11690. _isSubEmitter: boolean;
  11691. /**
  11692. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11693. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11694. */
  11695. billboardMode: number;
  11696. protected _isBillboardBased: boolean;
  11697. /**
  11698. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11699. */
  11700. get isBillboardBased(): boolean;
  11701. set isBillboardBased(value: boolean);
  11702. /**
  11703. * The scene the particle system belongs to.
  11704. */
  11705. protected _scene: Scene;
  11706. /**
  11707. * Local cache of defines for image processing.
  11708. */
  11709. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11710. /**
  11711. * Default configuration related to image processing available in the standard Material.
  11712. */
  11713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11714. /**
  11715. * Gets the image processing configuration used either in this material.
  11716. */
  11717. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11718. /**
  11719. * Sets the Default image processing configuration used either in the this material.
  11720. *
  11721. * If sets to null, the scene one is in use.
  11722. */
  11723. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11724. /**
  11725. * Attaches a new image processing configuration to the Standard Material.
  11726. * @param configuration
  11727. */
  11728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11729. /** @hidden */
  11730. protected _reset(): void;
  11731. /** @hidden */
  11732. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11733. /**
  11734. * Instantiates a particle system.
  11735. * 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.
  11736. * @param name The name of the particle system
  11737. */
  11738. constructor(name: string);
  11739. /**
  11740. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11743. * @returns the emitter
  11744. */
  11745. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11746. /**
  11747. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11748. * @param radius The radius of the hemisphere to emit from
  11749. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11750. * @returns the emitter
  11751. */
  11752. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11753. /**
  11754. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11755. * @param radius The radius of the sphere to emit from
  11756. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11757. * @returns the emitter
  11758. */
  11759. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11760. /**
  11761. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11762. * @param radius The radius of the sphere to emit from
  11763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11765. * @returns the emitter
  11766. */
  11767. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11768. /**
  11769. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11770. * @param radius The radius of the emission cylinder
  11771. * @param height The height of the emission cylinder
  11772. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11773. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11774. * @returns the emitter
  11775. */
  11776. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11777. /**
  11778. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11779. * @param radius The radius of the cylinder to emit from
  11780. * @param height The height of the emission cylinder
  11781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11784. * @returns the emitter
  11785. */
  11786. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11787. /**
  11788. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11789. * @param radius The radius of the cone to emit from
  11790. * @param angle The base angle of the cone
  11791. * @returns the emitter
  11792. */
  11793. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11794. /**
  11795. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11798. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11799. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11800. * @returns the emitter
  11801. */
  11802. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11803. }
  11804. }
  11805. declare module "babylonjs/Particles/subEmitter" {
  11806. import { Scene } from "babylonjs/scene";
  11807. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11808. /**
  11809. * Type of sub emitter
  11810. */
  11811. export enum SubEmitterType {
  11812. /**
  11813. * Attached to the particle over it's lifetime
  11814. */
  11815. ATTACHED = 0,
  11816. /**
  11817. * Created when the particle dies
  11818. */
  11819. END = 1
  11820. }
  11821. /**
  11822. * Sub emitter class used to emit particles from an existing particle
  11823. */
  11824. export class SubEmitter {
  11825. /**
  11826. * the particle system to be used by the sub emitter
  11827. */
  11828. particleSystem: ParticleSystem;
  11829. /**
  11830. * Type of the submitter (Default: END)
  11831. */
  11832. type: SubEmitterType;
  11833. /**
  11834. * 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)
  11835. * Note: This only is supported when using an emitter of type Mesh
  11836. */
  11837. inheritDirection: boolean;
  11838. /**
  11839. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11840. */
  11841. inheritedVelocityAmount: number;
  11842. /**
  11843. * Creates a sub emitter
  11844. * @param particleSystem the particle system to be used by the sub emitter
  11845. */
  11846. constructor(
  11847. /**
  11848. * the particle system to be used by the sub emitter
  11849. */
  11850. particleSystem: ParticleSystem);
  11851. /**
  11852. * Clones the sub emitter
  11853. * @returns the cloned sub emitter
  11854. */
  11855. clone(): SubEmitter;
  11856. /**
  11857. * Serialize current object to a JSON object
  11858. * @returns the serialized object
  11859. */
  11860. serialize(): any;
  11861. /** @hidden */
  11862. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11863. /**
  11864. * Creates a new SubEmitter from a serialized JSON version
  11865. * @param serializationObject defines the JSON object to read from
  11866. * @param scene defines the hosting scene
  11867. * @param rootUrl defines the rootUrl for data loading
  11868. * @returns a new SubEmitter
  11869. */
  11870. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11871. /** Release associated resources */
  11872. dispose(): void;
  11873. }
  11874. }
  11875. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11876. /** @hidden */
  11877. export var imageProcessingDeclaration: {
  11878. name: string;
  11879. shader: string;
  11880. };
  11881. }
  11882. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11883. /** @hidden */
  11884. export var imageProcessingFunctions: {
  11885. name: string;
  11886. shader: string;
  11887. };
  11888. }
  11889. declare module "babylonjs/Shaders/particles.fragment" {
  11890. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11893. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11894. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11895. /** @hidden */
  11896. export var particlesPixelShader: {
  11897. name: string;
  11898. shader: string;
  11899. };
  11900. }
  11901. declare module "babylonjs/Shaders/particles.vertex" {
  11902. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11904. /** @hidden */
  11905. export var particlesVertexShader: {
  11906. name: string;
  11907. shader: string;
  11908. };
  11909. }
  11910. declare module "babylonjs/Particles/particleSystem" {
  11911. import { Nullable } from "babylonjs/types";
  11912. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11913. import { Observable } from "babylonjs/Misc/observable";
  11914. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11915. import { Effect } from "babylonjs/Materials/effect";
  11916. import { Scene, IDisposable } from "babylonjs/scene";
  11917. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11918. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11919. import { Particle } from "babylonjs/Particles/particle";
  11920. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11922. import "babylonjs/Shaders/particles.fragment";
  11923. import "babylonjs/Shaders/particles.vertex";
  11924. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11925. /**
  11926. * This represents a particle system in Babylon.
  11927. * 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.
  11928. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11929. * @example https://doc.babylonjs.com/babylon101/particles
  11930. */
  11931. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11932. /**
  11933. * Billboard mode will only apply to Y axis
  11934. */
  11935. static readonly BILLBOARDMODE_Y: number;
  11936. /**
  11937. * Billboard mode will apply to all axes
  11938. */
  11939. static readonly BILLBOARDMODE_ALL: number;
  11940. /**
  11941. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11942. */
  11943. static readonly BILLBOARDMODE_STRETCHED: number;
  11944. /**
  11945. * This function can be defined to provide custom update for active particles.
  11946. * This function will be called instead of regular update (age, position, color, etc.).
  11947. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11948. */
  11949. updateFunction: (particles: Particle[]) => void;
  11950. private _emitterWorldMatrix;
  11951. /**
  11952. * This function can be defined to specify initial direction for every new particle.
  11953. * It by default use the emitterType defined function
  11954. */
  11955. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11956. /**
  11957. * This function can be defined to specify initial position for every new particle.
  11958. * It by default use the emitterType defined function
  11959. */
  11960. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11961. /**
  11962. * @hidden
  11963. */
  11964. _inheritedVelocityOffset: Vector3;
  11965. /**
  11966. * An event triggered when the system is disposed
  11967. */
  11968. onDisposeObservable: Observable<ParticleSystem>;
  11969. private _onDisposeObserver;
  11970. /**
  11971. * Sets a callback that will be triggered when the system is disposed
  11972. */
  11973. set onDispose(callback: () => void);
  11974. private _particles;
  11975. private _epsilon;
  11976. private _capacity;
  11977. private _stockParticles;
  11978. private _newPartsExcess;
  11979. private _vertexData;
  11980. private _vertexBuffer;
  11981. private _vertexBuffers;
  11982. private _spriteBuffer;
  11983. private _indexBuffer;
  11984. private _effect;
  11985. private _customEffect;
  11986. private _cachedDefines;
  11987. private _scaledColorStep;
  11988. private _colorDiff;
  11989. private _scaledDirection;
  11990. private _scaledGravity;
  11991. private _currentRenderId;
  11992. private _alive;
  11993. private _useInstancing;
  11994. private _started;
  11995. private _stopped;
  11996. private _actualFrame;
  11997. private _scaledUpdateSpeed;
  11998. private _vertexBufferSize;
  11999. /** @hidden */
  12000. _currentEmitRateGradient: Nullable<FactorGradient>;
  12001. /** @hidden */
  12002. _currentEmitRate1: number;
  12003. /** @hidden */
  12004. _currentEmitRate2: number;
  12005. /** @hidden */
  12006. _currentStartSizeGradient: Nullable<FactorGradient>;
  12007. /** @hidden */
  12008. _currentStartSize1: number;
  12009. /** @hidden */
  12010. _currentStartSize2: number;
  12011. private readonly _rawTextureWidth;
  12012. private _rampGradientsTexture;
  12013. private _useRampGradients;
  12014. /** Gets or sets a boolean indicating that ramp gradients must be used
  12015. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12016. */
  12017. get useRampGradients(): boolean;
  12018. set useRampGradients(value: boolean);
  12019. /**
  12020. * 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.
  12021. * 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: [])
  12022. */
  12023. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12024. private _subEmitters;
  12025. /**
  12026. * @hidden
  12027. * If the particle systems emitter should be disposed when the particle system is disposed
  12028. */
  12029. _disposeEmitterOnDispose: boolean;
  12030. /**
  12031. * The current active Sub-systems, this property is used by the root particle system only.
  12032. */
  12033. activeSubSystems: Array<ParticleSystem>;
  12034. /**
  12035. * Specifies if the particles are updated in emitter local space or world space
  12036. */
  12037. isLocal: boolean;
  12038. private _rootParticleSystem;
  12039. /**
  12040. * Gets the current list of active particles
  12041. */
  12042. get particles(): Particle[];
  12043. /**
  12044. * Gets the number of particles active at the same time.
  12045. * @returns The number of active particles.
  12046. */
  12047. getActiveCount(): number;
  12048. /**
  12049. * Returns the string "ParticleSystem"
  12050. * @returns a string containing the class name
  12051. */
  12052. getClassName(): string;
  12053. /**
  12054. * Gets a boolean indicating that the system is stopping
  12055. * @returns true if the system is currently stopping
  12056. */
  12057. isStopping(): boolean;
  12058. /**
  12059. * Instantiates a particle system.
  12060. * 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.
  12061. * @param name The name of the particle system
  12062. * @param capacity The max number of particles alive at the same time
  12063. * @param scene The scene the particle system belongs to
  12064. * @param customEffect a custom effect used to change the way particles are rendered by default
  12065. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12066. * @param epsilon Offset used to render the particles
  12067. */
  12068. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12069. private _addFactorGradient;
  12070. private _removeFactorGradient;
  12071. /**
  12072. * Adds a new life time gradient
  12073. * @param gradient defines the gradient to use (between 0 and 1)
  12074. * @param factor defines the life time factor to affect to the specified gradient
  12075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12076. * @returns the current particle system
  12077. */
  12078. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12079. /**
  12080. * Remove a specific life time gradient
  12081. * @param gradient defines the gradient to remove
  12082. * @returns the current particle system
  12083. */
  12084. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12085. /**
  12086. * Adds a new size gradient
  12087. * @param gradient defines the gradient to use (between 0 and 1)
  12088. * @param factor defines the size factor to affect to the specified gradient
  12089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12090. * @returns the current particle system
  12091. */
  12092. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12093. /**
  12094. * Remove a specific size gradient
  12095. * @param gradient defines the gradient to remove
  12096. * @returns the current particle system
  12097. */
  12098. removeSizeGradient(gradient: number): IParticleSystem;
  12099. /**
  12100. * Adds a new color remap gradient
  12101. * @param gradient defines the gradient to use (between 0 and 1)
  12102. * @param min defines the color remap minimal range
  12103. * @param max defines the color remap maximal range
  12104. * @returns the current particle system
  12105. */
  12106. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12107. /**
  12108. * Remove a specific color remap gradient
  12109. * @param gradient defines the gradient to remove
  12110. * @returns the current particle system
  12111. */
  12112. removeColorRemapGradient(gradient: number): IParticleSystem;
  12113. /**
  12114. * Adds a new alpha remap gradient
  12115. * @param gradient defines the gradient to use (between 0 and 1)
  12116. * @param min defines the alpha remap minimal range
  12117. * @param max defines the alpha remap maximal range
  12118. * @returns the current particle system
  12119. */
  12120. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12121. /**
  12122. * Remove a specific alpha remap gradient
  12123. * @param gradient defines the gradient to remove
  12124. * @returns the current particle system
  12125. */
  12126. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12127. /**
  12128. * Adds a new angular speed gradient
  12129. * @param gradient defines the gradient to use (between 0 and 1)
  12130. * @param factor defines the angular speed to affect to the specified gradient
  12131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12132. * @returns the current particle system
  12133. */
  12134. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12135. /**
  12136. * Remove a specific angular speed gradient
  12137. * @param gradient defines the gradient to remove
  12138. * @returns the current particle system
  12139. */
  12140. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12141. /**
  12142. * Adds a new velocity gradient
  12143. * @param gradient defines the gradient to use (between 0 and 1)
  12144. * @param factor defines the velocity to affect to the specified gradient
  12145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12146. * @returns the current particle system
  12147. */
  12148. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12149. /**
  12150. * Remove a specific velocity gradient
  12151. * @param gradient defines the gradient to remove
  12152. * @returns the current particle system
  12153. */
  12154. removeVelocityGradient(gradient: number): IParticleSystem;
  12155. /**
  12156. * Adds a new limit velocity gradient
  12157. * @param gradient defines the gradient to use (between 0 and 1)
  12158. * @param factor defines the limit velocity value to affect to the specified gradient
  12159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12160. * @returns the current particle system
  12161. */
  12162. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12163. /**
  12164. * Remove a specific limit velocity gradient
  12165. * @param gradient defines the gradient to remove
  12166. * @returns the current particle system
  12167. */
  12168. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12169. /**
  12170. * Adds a new drag gradient
  12171. * @param gradient defines the gradient to use (between 0 and 1)
  12172. * @param factor defines the drag value to affect to the specified gradient
  12173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12174. * @returns the current particle system
  12175. */
  12176. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12177. /**
  12178. * Remove a specific drag gradient
  12179. * @param gradient defines the gradient to remove
  12180. * @returns the current particle system
  12181. */
  12182. removeDragGradient(gradient: number): IParticleSystem;
  12183. /**
  12184. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12185. * @param gradient defines the gradient to use (between 0 and 1)
  12186. * @param factor defines the emit rate value to affect to the specified gradient
  12187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12188. * @returns the current particle system
  12189. */
  12190. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12191. /**
  12192. * Remove a specific emit rate gradient
  12193. * @param gradient defines the gradient to remove
  12194. * @returns the current particle system
  12195. */
  12196. removeEmitRateGradient(gradient: number): IParticleSystem;
  12197. /**
  12198. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12199. * @param gradient defines the gradient to use (between 0 and 1)
  12200. * @param factor defines the start size value to affect to the specified gradient
  12201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12202. * @returns the current particle system
  12203. */
  12204. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12205. /**
  12206. * Remove a specific start size gradient
  12207. * @param gradient defines the gradient to remove
  12208. * @returns the current particle system
  12209. */
  12210. removeStartSizeGradient(gradient: number): IParticleSystem;
  12211. private _createRampGradientTexture;
  12212. /**
  12213. * Gets the current list of ramp gradients.
  12214. * You must use addRampGradient and removeRampGradient to udpate this list
  12215. * @returns the list of ramp gradients
  12216. */
  12217. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12218. /** Force the system to rebuild all gradients that need to be resync */
  12219. forceRefreshGradients(): void;
  12220. private _syncRampGradientTexture;
  12221. /**
  12222. * Adds a new ramp gradient used to remap particle colors
  12223. * @param gradient defines the gradient to use (between 0 and 1)
  12224. * @param color defines the color to affect to the specified gradient
  12225. * @returns the current particle system
  12226. */
  12227. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12228. /**
  12229. * Remove a specific ramp gradient
  12230. * @param gradient defines the gradient to remove
  12231. * @returns the current particle system
  12232. */
  12233. removeRampGradient(gradient: number): ParticleSystem;
  12234. /**
  12235. * Adds a new color gradient
  12236. * @param gradient defines the gradient to use (between 0 and 1)
  12237. * @param color1 defines the color to affect to the specified gradient
  12238. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12239. * @returns this particle system
  12240. */
  12241. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12242. /**
  12243. * Remove a specific color gradient
  12244. * @param gradient defines the gradient to remove
  12245. * @returns this particle system
  12246. */
  12247. removeColorGradient(gradient: number): IParticleSystem;
  12248. private _fetchR;
  12249. protected _reset(): void;
  12250. private _resetEffect;
  12251. private _createVertexBuffers;
  12252. private _createIndexBuffer;
  12253. /**
  12254. * Gets the maximum number of particles active at the same time.
  12255. * @returns The max number of active particles.
  12256. */
  12257. getCapacity(): number;
  12258. /**
  12259. * Gets whether there are still active particles in the system.
  12260. * @returns True if it is alive, otherwise false.
  12261. */
  12262. isAlive(): boolean;
  12263. /**
  12264. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12265. * @returns True if it has been started, otherwise false.
  12266. */
  12267. isStarted(): boolean;
  12268. private _prepareSubEmitterInternalArray;
  12269. /**
  12270. * Starts the particle system and begins to emit
  12271. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12272. */
  12273. start(delay?: number): void;
  12274. /**
  12275. * Stops the particle system.
  12276. * @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.
  12277. */
  12278. stop(stopSubEmitters?: boolean): void;
  12279. /**
  12280. * Remove all active particles
  12281. */
  12282. reset(): void;
  12283. /**
  12284. * @hidden (for internal use only)
  12285. */
  12286. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12287. /**
  12288. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12289. * Its lifetime will start back at 0.
  12290. */
  12291. recycleParticle: (particle: Particle) => void;
  12292. private _stopSubEmitters;
  12293. private _createParticle;
  12294. private _removeFromRoot;
  12295. private _emitFromParticle;
  12296. private _update;
  12297. /** @hidden */
  12298. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12299. /** @hidden */
  12300. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12301. /** @hidden */
  12302. private _getEffect;
  12303. /**
  12304. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12305. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12306. */
  12307. animate(preWarmOnly?: boolean): void;
  12308. private _appendParticleVertices;
  12309. /**
  12310. * Rebuilds the particle system.
  12311. */
  12312. rebuild(): void;
  12313. /**
  12314. * Is this system ready to be used/rendered
  12315. * @return true if the system is ready
  12316. */
  12317. isReady(): boolean;
  12318. private _render;
  12319. /**
  12320. * Renders the particle system in its current state.
  12321. * @returns the current number of particles
  12322. */
  12323. render(): number;
  12324. /**
  12325. * Disposes the particle system and free the associated resources
  12326. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12327. */
  12328. dispose(disposeTexture?: boolean): void;
  12329. /**
  12330. * Clones the particle system.
  12331. * @param name The name of the cloned object
  12332. * @param newEmitter The new emitter to use
  12333. * @returns the cloned particle system
  12334. */
  12335. clone(name: string, newEmitter: any): ParticleSystem;
  12336. /**
  12337. * Serializes the particle system to a JSON object
  12338. * @param serializeTexture defines if the texture must be serialized as well
  12339. * @returns the JSON object
  12340. */
  12341. serialize(serializeTexture?: boolean): any;
  12342. /** @hidden */
  12343. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12344. /** @hidden */
  12345. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12346. /**
  12347. * Parses a JSON object to create a particle system.
  12348. * @param parsedParticleSystem The JSON object to parse
  12349. * @param scene The scene to create the particle system in
  12350. * @param rootUrl The root url to use to load external dependencies like texture
  12351. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12352. * @returns the Parsed particle system
  12353. */
  12354. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12355. }
  12356. }
  12357. declare module "babylonjs/Particles/particle" {
  12358. import { Nullable } from "babylonjs/types";
  12359. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12360. import { Color4 } from "babylonjs/Maths/math.color";
  12361. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12362. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12363. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12364. /**
  12365. * A particle represents one of the element emitted by a particle system.
  12366. * This is mainly define by its coordinates, direction, velocity and age.
  12367. */
  12368. export class Particle {
  12369. /**
  12370. * The particle system the particle belongs to.
  12371. */
  12372. particleSystem: ParticleSystem;
  12373. private static _Count;
  12374. /**
  12375. * Unique ID of the particle
  12376. */
  12377. id: number;
  12378. /**
  12379. * The world position of the particle in the scene.
  12380. */
  12381. position: Vector3;
  12382. /**
  12383. * The world direction of the particle in the scene.
  12384. */
  12385. direction: Vector3;
  12386. /**
  12387. * The color of the particle.
  12388. */
  12389. color: Color4;
  12390. /**
  12391. * The color change of the particle per step.
  12392. */
  12393. colorStep: Color4;
  12394. /**
  12395. * Defines how long will the life of the particle be.
  12396. */
  12397. lifeTime: number;
  12398. /**
  12399. * The current age of the particle.
  12400. */
  12401. age: number;
  12402. /**
  12403. * The current size of the particle.
  12404. */
  12405. size: number;
  12406. /**
  12407. * The current scale of the particle.
  12408. */
  12409. scale: Vector2;
  12410. /**
  12411. * The current angle of the particle.
  12412. */
  12413. angle: number;
  12414. /**
  12415. * Defines how fast is the angle changing.
  12416. */
  12417. angularSpeed: number;
  12418. /**
  12419. * Defines the cell index used by the particle to be rendered from a sprite.
  12420. */
  12421. cellIndex: number;
  12422. /**
  12423. * The information required to support color remapping
  12424. */
  12425. remapData: Vector4;
  12426. /** @hidden */
  12427. _randomCellOffset?: number;
  12428. /** @hidden */
  12429. _initialDirection: Nullable<Vector3>;
  12430. /** @hidden */
  12431. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12432. /** @hidden */
  12433. _initialStartSpriteCellID: number;
  12434. /** @hidden */
  12435. _initialEndSpriteCellID: number;
  12436. /** @hidden */
  12437. _currentColorGradient: Nullable<ColorGradient>;
  12438. /** @hidden */
  12439. _currentColor1: Color4;
  12440. /** @hidden */
  12441. _currentColor2: Color4;
  12442. /** @hidden */
  12443. _currentSizeGradient: Nullable<FactorGradient>;
  12444. /** @hidden */
  12445. _currentSize1: number;
  12446. /** @hidden */
  12447. _currentSize2: number;
  12448. /** @hidden */
  12449. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12450. /** @hidden */
  12451. _currentAngularSpeed1: number;
  12452. /** @hidden */
  12453. _currentAngularSpeed2: number;
  12454. /** @hidden */
  12455. _currentVelocityGradient: Nullable<FactorGradient>;
  12456. /** @hidden */
  12457. _currentVelocity1: number;
  12458. /** @hidden */
  12459. _currentVelocity2: number;
  12460. /** @hidden */
  12461. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12462. /** @hidden */
  12463. _currentLimitVelocity1: number;
  12464. /** @hidden */
  12465. _currentLimitVelocity2: number;
  12466. /** @hidden */
  12467. _currentDragGradient: Nullable<FactorGradient>;
  12468. /** @hidden */
  12469. _currentDrag1: number;
  12470. /** @hidden */
  12471. _currentDrag2: number;
  12472. /** @hidden */
  12473. _randomNoiseCoordinates1: Vector3;
  12474. /** @hidden */
  12475. _randomNoiseCoordinates2: Vector3;
  12476. /** @hidden */
  12477. _localPosition?: Vector3;
  12478. /**
  12479. * Creates a new instance Particle
  12480. * @param particleSystem the particle system the particle belongs to
  12481. */
  12482. constructor(
  12483. /**
  12484. * The particle system the particle belongs to.
  12485. */
  12486. particleSystem: ParticleSystem);
  12487. private updateCellInfoFromSystem;
  12488. /**
  12489. * Defines how the sprite cell index is updated for the particle
  12490. */
  12491. updateCellIndex(): void;
  12492. /** @hidden */
  12493. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12494. /** @hidden */
  12495. _inheritParticleInfoToSubEmitters(): void;
  12496. /** @hidden */
  12497. _reset(): void;
  12498. /**
  12499. * Copy the properties of particle to another one.
  12500. * @param other the particle to copy the information to.
  12501. */
  12502. copyTo(other: Particle): void;
  12503. }
  12504. }
  12505. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12507. import { Effect } from "babylonjs/Materials/effect";
  12508. import { Particle } from "babylonjs/Particles/particle";
  12509. import { Scene } from "babylonjs/scene";
  12510. /**
  12511. * Particle emitter represents a volume emitting particles.
  12512. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12513. */
  12514. export interface IParticleEmitterType {
  12515. /**
  12516. * Called by the particle System when the direction is computed for the created particle.
  12517. * @param worldMatrix is the world matrix of the particle system
  12518. * @param directionToUpdate is the direction vector to update with the result
  12519. * @param particle is the particle we are computed the direction for
  12520. * @param isLocal defines if the direction should be set in local space
  12521. */
  12522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12523. /**
  12524. * Called by the particle System when the position is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param positionToUpdate is the position vector to update with the result
  12527. * @param particle is the particle we are computed the position for
  12528. * @param isLocal defines if the position should be set in local space
  12529. */
  12530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12531. /**
  12532. * Clones the current emitter and returns a copy of it
  12533. * @returns the new emitter
  12534. */
  12535. clone(): IParticleEmitterType;
  12536. /**
  12537. * Called by the GPUParticleSystem to setup the update shader
  12538. * @param effect defines the update shader
  12539. */
  12540. applyToShader(effect: Effect): void;
  12541. /**
  12542. * Returns a string to use to update the GPU particles update shader
  12543. * @returns the effect defines string
  12544. */
  12545. getEffectDefines(): string;
  12546. /**
  12547. * Returns a string representing the class name
  12548. * @returns a string containing the class name
  12549. */
  12550. getClassName(): string;
  12551. /**
  12552. * Serializes the particle system to a JSON object.
  12553. * @returns the JSON object
  12554. */
  12555. serialize(): any;
  12556. /**
  12557. * Parse properties from a JSON object
  12558. * @param serializationObject defines the JSON object
  12559. * @param scene defines the hosting scene
  12560. */
  12561. parse(serializationObject: any, scene: Scene): void;
  12562. }
  12563. }
  12564. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12565. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12566. import { Effect } from "babylonjs/Materials/effect";
  12567. import { Particle } from "babylonjs/Particles/particle";
  12568. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12569. /**
  12570. * Particle emitter emitting particles from the inside of a box.
  12571. * It emits the particles randomly between 2 given directions.
  12572. */
  12573. export class BoxParticleEmitter implements IParticleEmitterType {
  12574. /**
  12575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12576. */
  12577. direction1: Vector3;
  12578. /**
  12579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12580. */
  12581. direction2: Vector3;
  12582. /**
  12583. * 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.
  12584. */
  12585. minEmitBox: Vector3;
  12586. /**
  12587. * 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.
  12588. */
  12589. maxEmitBox: Vector3;
  12590. /**
  12591. * Creates a new instance BoxParticleEmitter
  12592. */
  12593. constructor();
  12594. /**
  12595. * Called by the particle System when the direction is computed for the created particle.
  12596. * @param worldMatrix is the world matrix of the particle system
  12597. * @param directionToUpdate is the direction vector to update with the result
  12598. * @param particle is the particle we are computed the direction for
  12599. * @param isLocal defines if the direction should be set in local space
  12600. */
  12601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12602. /**
  12603. * Called by the particle System when the position is computed for the created particle.
  12604. * @param worldMatrix is the world matrix of the particle system
  12605. * @param positionToUpdate is the position vector to update with the result
  12606. * @param particle is the particle we are computed the position for
  12607. * @param isLocal defines if the position should be set in local space
  12608. */
  12609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12610. /**
  12611. * Clones the current emitter and returns a copy of it
  12612. * @returns the new emitter
  12613. */
  12614. clone(): BoxParticleEmitter;
  12615. /**
  12616. * Called by the GPUParticleSystem to setup the update shader
  12617. * @param effect defines the update shader
  12618. */
  12619. applyToShader(effect: Effect): void;
  12620. /**
  12621. * Returns a string to use to update the GPU particles update shader
  12622. * @returns a string containng the defines string
  12623. */
  12624. getEffectDefines(): string;
  12625. /**
  12626. * Returns the string "BoxParticleEmitter"
  12627. * @returns a string containing the class name
  12628. */
  12629. getClassName(): string;
  12630. /**
  12631. * Serializes the particle system to a JSON object.
  12632. * @returns the JSON object
  12633. */
  12634. serialize(): any;
  12635. /**
  12636. * Parse properties from a JSON object
  12637. * @param serializationObject defines the JSON object
  12638. */
  12639. parse(serializationObject: any): void;
  12640. }
  12641. }
  12642. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12643. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12644. import { Effect } from "babylonjs/Materials/effect";
  12645. import { Particle } from "babylonjs/Particles/particle";
  12646. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12647. /**
  12648. * Particle emitter emitting particles from the inside of a cone.
  12649. * It emits the particles alongside the cone volume from the base to the particle.
  12650. * The emission direction might be randomized.
  12651. */
  12652. export class ConeParticleEmitter implements IParticleEmitterType {
  12653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12654. directionRandomizer: number;
  12655. private _radius;
  12656. private _angle;
  12657. private _height;
  12658. /**
  12659. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12660. */
  12661. radiusRange: number;
  12662. /**
  12663. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12664. */
  12665. heightRange: number;
  12666. /**
  12667. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12668. */
  12669. emitFromSpawnPointOnly: boolean;
  12670. /**
  12671. * Gets or sets the radius of the emission cone
  12672. */
  12673. get radius(): number;
  12674. set radius(value: number);
  12675. /**
  12676. * Gets or sets the angle of the emission cone
  12677. */
  12678. get angle(): number;
  12679. set angle(value: number);
  12680. private _buildHeight;
  12681. /**
  12682. * Creates a new instance ConeParticleEmitter
  12683. * @param radius the radius of the emission cone (1 by default)
  12684. * @param angle the cone base angle (PI by default)
  12685. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12686. */
  12687. constructor(radius?: number, angle?: number,
  12688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12689. directionRandomizer?: number);
  12690. /**
  12691. * Called by the particle System when the direction is computed for the created particle.
  12692. * @param worldMatrix is the world matrix of the particle system
  12693. * @param directionToUpdate is the direction vector to update with the result
  12694. * @param particle is the particle we are computed the direction for
  12695. * @param isLocal defines if the direction should be set in local space
  12696. */
  12697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12698. /**
  12699. * Called by the particle System when the position is computed for the created particle.
  12700. * @param worldMatrix is the world matrix of the particle system
  12701. * @param positionToUpdate is the position vector to update with the result
  12702. * @param particle is the particle we are computed the position for
  12703. * @param isLocal defines if the position should be set in local space
  12704. */
  12705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12706. /**
  12707. * Clones the current emitter and returns a copy of it
  12708. * @returns the new emitter
  12709. */
  12710. clone(): ConeParticleEmitter;
  12711. /**
  12712. * Called by the GPUParticleSystem to setup the update shader
  12713. * @param effect defines the update shader
  12714. */
  12715. applyToShader(effect: Effect): void;
  12716. /**
  12717. * Returns a string to use to update the GPU particles update shader
  12718. * @returns a string containng the defines string
  12719. */
  12720. getEffectDefines(): string;
  12721. /**
  12722. * Returns the string "ConeParticleEmitter"
  12723. * @returns a string containing the class name
  12724. */
  12725. getClassName(): string;
  12726. /**
  12727. * Serializes the particle system to a JSON object.
  12728. * @returns the JSON object
  12729. */
  12730. serialize(): any;
  12731. /**
  12732. * Parse properties from a JSON object
  12733. * @param serializationObject defines the JSON object
  12734. */
  12735. parse(serializationObject: any): void;
  12736. }
  12737. }
  12738. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12740. import { Effect } from "babylonjs/Materials/effect";
  12741. import { Particle } from "babylonjs/Particles/particle";
  12742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12743. /**
  12744. * Particle emitter emitting particles from the inside of a cylinder.
  12745. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12746. */
  12747. export class CylinderParticleEmitter implements IParticleEmitterType {
  12748. /**
  12749. * The radius of the emission cylinder.
  12750. */
  12751. radius: number;
  12752. /**
  12753. * The height of the emission cylinder.
  12754. */
  12755. height: number;
  12756. /**
  12757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12758. */
  12759. radiusRange: number;
  12760. /**
  12761. * How much to randomize the particle direction [0-1].
  12762. */
  12763. directionRandomizer: number;
  12764. /**
  12765. * Creates a new instance CylinderParticleEmitter
  12766. * @param radius the radius of the emission cylinder (1 by default)
  12767. * @param height the height of the emission cylinder (1 by default)
  12768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12770. */
  12771. constructor(
  12772. /**
  12773. * The radius of the emission cylinder.
  12774. */
  12775. radius?: number,
  12776. /**
  12777. * The height of the emission cylinder.
  12778. */
  12779. height?: number,
  12780. /**
  12781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12782. */
  12783. radiusRange?: number,
  12784. /**
  12785. * How much to randomize the particle direction [0-1].
  12786. */
  12787. directionRandomizer?: number);
  12788. /**
  12789. * Called by the particle System when the direction is computed for the created particle.
  12790. * @param worldMatrix is the world matrix of the particle system
  12791. * @param directionToUpdate is the direction vector to update with the result
  12792. * @param particle is the particle we are computed the direction for
  12793. * @param isLocal defines if the direction should be set in local space
  12794. */
  12795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12796. /**
  12797. * Called by the particle System when the position is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param positionToUpdate is the position vector to update with the result
  12800. * @param particle is the particle we are computed the position for
  12801. * @param isLocal defines if the position should be set in local space
  12802. */
  12803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Clones the current emitter and returns a copy of it
  12806. * @returns the new emitter
  12807. */
  12808. clone(): CylinderParticleEmitter;
  12809. /**
  12810. * Called by the GPUParticleSystem to setup the update shader
  12811. * @param effect defines the update shader
  12812. */
  12813. applyToShader(effect: Effect): void;
  12814. /**
  12815. * Returns a string to use to update the GPU particles update shader
  12816. * @returns a string containng the defines string
  12817. */
  12818. getEffectDefines(): string;
  12819. /**
  12820. * Returns the string "CylinderParticleEmitter"
  12821. * @returns a string containing the class name
  12822. */
  12823. getClassName(): string;
  12824. /**
  12825. * Serializes the particle system to a JSON object.
  12826. * @returns the JSON object
  12827. */
  12828. serialize(): any;
  12829. /**
  12830. * Parse properties from a JSON object
  12831. * @param serializationObject defines the JSON object
  12832. */
  12833. parse(serializationObject: any): void;
  12834. }
  12835. /**
  12836. * Particle emitter emitting particles from the inside of a cylinder.
  12837. * It emits the particles randomly between two vectors.
  12838. */
  12839. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12840. /**
  12841. * The min limit of the emission direction.
  12842. */
  12843. direction1: Vector3;
  12844. /**
  12845. * The max limit of the emission direction.
  12846. */
  12847. direction2: Vector3;
  12848. /**
  12849. * Creates a new instance CylinderDirectedParticleEmitter
  12850. * @param radius the radius of the emission cylinder (1 by default)
  12851. * @param height the height of the emission cylinder (1 by default)
  12852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12853. * @param direction1 the min limit of the emission direction (up vector by default)
  12854. * @param direction2 the max limit of the emission direction (up vector by default)
  12855. */
  12856. constructor(radius?: number, height?: number, radiusRange?: number,
  12857. /**
  12858. * The min limit of the emission direction.
  12859. */
  12860. direction1?: Vector3,
  12861. /**
  12862. * The max limit of the emission direction.
  12863. */
  12864. direction2?: Vector3);
  12865. /**
  12866. * Called by the particle System when the direction is computed for the created particle.
  12867. * @param worldMatrix is the world matrix of the particle system
  12868. * @param directionToUpdate is the direction vector to update with the result
  12869. * @param particle is the particle we are computed the direction for
  12870. */
  12871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12872. /**
  12873. * Clones the current emitter and returns a copy of it
  12874. * @returns the new emitter
  12875. */
  12876. clone(): CylinderDirectedParticleEmitter;
  12877. /**
  12878. * Called by the GPUParticleSystem to setup the update shader
  12879. * @param effect defines the update shader
  12880. */
  12881. applyToShader(effect: Effect): void;
  12882. /**
  12883. * Returns a string to use to update the GPU particles update shader
  12884. * @returns a string containng the defines string
  12885. */
  12886. getEffectDefines(): string;
  12887. /**
  12888. * Returns the string "CylinderDirectedParticleEmitter"
  12889. * @returns a string containing the class name
  12890. */
  12891. getClassName(): string;
  12892. /**
  12893. * Serializes the particle system to a JSON object.
  12894. * @returns the JSON object
  12895. */
  12896. serialize(): any;
  12897. /**
  12898. * Parse properties from a JSON object
  12899. * @param serializationObject defines the JSON object
  12900. */
  12901. parse(serializationObject: any): void;
  12902. }
  12903. }
  12904. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12905. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12906. import { Effect } from "babylonjs/Materials/effect";
  12907. import { Particle } from "babylonjs/Particles/particle";
  12908. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12909. /**
  12910. * Particle emitter emitting particles from the inside of a hemisphere.
  12911. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12912. */
  12913. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12914. /**
  12915. * The radius of the emission hemisphere.
  12916. */
  12917. radius: number;
  12918. /**
  12919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12920. */
  12921. radiusRange: number;
  12922. /**
  12923. * How much to randomize the particle direction [0-1].
  12924. */
  12925. directionRandomizer: number;
  12926. /**
  12927. * Creates a new instance HemisphericParticleEmitter
  12928. * @param radius the radius of the emission hemisphere (1 by default)
  12929. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12930. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12931. */
  12932. constructor(
  12933. /**
  12934. * The radius of the emission hemisphere.
  12935. */
  12936. radius?: number,
  12937. /**
  12938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12939. */
  12940. radiusRange?: number,
  12941. /**
  12942. * How much to randomize the particle direction [0-1].
  12943. */
  12944. directionRandomizer?: number);
  12945. /**
  12946. * Called by the particle System when the direction is computed for the created particle.
  12947. * @param worldMatrix is the world matrix of the particle system
  12948. * @param directionToUpdate is the direction vector to update with the result
  12949. * @param particle is the particle we are computed the direction for
  12950. * @param isLocal defines if the direction should be set in local space
  12951. */
  12952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12953. /**
  12954. * Called by the particle System when the position is computed for the created particle.
  12955. * @param worldMatrix is the world matrix of the particle system
  12956. * @param positionToUpdate is the position vector to update with the result
  12957. * @param particle is the particle we are computed the position for
  12958. * @param isLocal defines if the position should be set in local space
  12959. */
  12960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12961. /**
  12962. * Clones the current emitter and returns a copy of it
  12963. * @returns the new emitter
  12964. */
  12965. clone(): HemisphericParticleEmitter;
  12966. /**
  12967. * Called by the GPUParticleSystem to setup the update shader
  12968. * @param effect defines the update shader
  12969. */
  12970. applyToShader(effect: Effect): void;
  12971. /**
  12972. * Returns a string to use to update the GPU particles update shader
  12973. * @returns a string containng the defines string
  12974. */
  12975. getEffectDefines(): string;
  12976. /**
  12977. * Returns the string "HemisphericParticleEmitter"
  12978. * @returns a string containing the class name
  12979. */
  12980. getClassName(): string;
  12981. /**
  12982. * Serializes the particle system to a JSON object.
  12983. * @returns the JSON object
  12984. */
  12985. serialize(): any;
  12986. /**
  12987. * Parse properties from a JSON object
  12988. * @param serializationObject defines the JSON object
  12989. */
  12990. parse(serializationObject: any): void;
  12991. }
  12992. }
  12993. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12995. import { Effect } from "babylonjs/Materials/effect";
  12996. import { Particle } from "babylonjs/Particles/particle";
  12997. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12998. /**
  12999. * Particle emitter emitting particles from a point.
  13000. * It emits the particles randomly between 2 given directions.
  13001. */
  13002. export class PointParticleEmitter implements IParticleEmitterType {
  13003. /**
  13004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13005. */
  13006. direction1: Vector3;
  13007. /**
  13008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13009. */
  13010. direction2: Vector3;
  13011. /**
  13012. * Creates a new instance PointParticleEmitter
  13013. */
  13014. constructor();
  13015. /**
  13016. * Called by the particle System when the direction is computed for the created particle.
  13017. * @param worldMatrix is the world matrix of the particle system
  13018. * @param directionToUpdate is the direction vector to update with the result
  13019. * @param particle is the particle we are computed the direction for
  13020. * @param isLocal defines if the direction should be set in local space
  13021. */
  13022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13023. /**
  13024. * Called by the particle System when the position is computed for the created particle.
  13025. * @param worldMatrix is the world matrix of the particle system
  13026. * @param positionToUpdate is the position vector to update with the result
  13027. * @param particle is the particle we are computed the position for
  13028. * @param isLocal defines if the position should be set in local space
  13029. */
  13030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): PointParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "PointParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. */
  13060. parse(serializationObject: any): void;
  13061. }
  13062. }
  13063. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13065. import { Effect } from "babylonjs/Materials/effect";
  13066. import { Particle } from "babylonjs/Particles/particle";
  13067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13068. /**
  13069. * Particle emitter emitting particles from the inside of a sphere.
  13070. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13071. */
  13072. export class SphereParticleEmitter implements IParticleEmitterType {
  13073. /**
  13074. * The radius of the emission sphere.
  13075. */
  13076. radius: number;
  13077. /**
  13078. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13079. */
  13080. radiusRange: number;
  13081. /**
  13082. * How much to randomize the particle direction [0-1].
  13083. */
  13084. directionRandomizer: number;
  13085. /**
  13086. * Creates a new instance SphereParticleEmitter
  13087. * @param radius the radius of the emission sphere (1 by default)
  13088. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13089. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13090. */
  13091. constructor(
  13092. /**
  13093. * The radius of the emission sphere.
  13094. */
  13095. radius?: number,
  13096. /**
  13097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13098. */
  13099. radiusRange?: number,
  13100. /**
  13101. * How much to randomize the particle direction [0-1].
  13102. */
  13103. directionRandomizer?: number);
  13104. /**
  13105. * Called by the particle System when the direction is computed for the created particle.
  13106. * @param worldMatrix is the world matrix of the particle system
  13107. * @param directionToUpdate is the direction vector to update with the result
  13108. * @param particle is the particle we are computed the direction for
  13109. * @param isLocal defines if the direction should be set in local space
  13110. */
  13111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13112. /**
  13113. * Called by the particle System when the position is computed for the created particle.
  13114. * @param worldMatrix is the world matrix of the particle system
  13115. * @param positionToUpdate is the position vector to update with the result
  13116. * @param particle is the particle we are computed the position for
  13117. * @param isLocal defines if the position should be set in local space
  13118. */
  13119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13120. /**
  13121. * Clones the current emitter and returns a copy of it
  13122. * @returns the new emitter
  13123. */
  13124. clone(): SphereParticleEmitter;
  13125. /**
  13126. * Called by the GPUParticleSystem to setup the update shader
  13127. * @param effect defines the update shader
  13128. */
  13129. applyToShader(effect: Effect): void;
  13130. /**
  13131. * Returns a string to use to update the GPU particles update shader
  13132. * @returns a string containng the defines string
  13133. */
  13134. getEffectDefines(): string;
  13135. /**
  13136. * Returns the string "SphereParticleEmitter"
  13137. * @returns a string containing the class name
  13138. */
  13139. getClassName(): string;
  13140. /**
  13141. * Serializes the particle system to a JSON object.
  13142. * @returns the JSON object
  13143. */
  13144. serialize(): any;
  13145. /**
  13146. * Parse properties from a JSON object
  13147. * @param serializationObject defines the JSON object
  13148. */
  13149. parse(serializationObject: any): void;
  13150. }
  13151. /**
  13152. * Particle emitter emitting particles from the inside of a sphere.
  13153. * It emits the particles randomly between two vectors.
  13154. */
  13155. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13156. /**
  13157. * The min limit of the emission direction.
  13158. */
  13159. direction1: Vector3;
  13160. /**
  13161. * The max limit of the emission direction.
  13162. */
  13163. direction2: Vector3;
  13164. /**
  13165. * Creates a new instance SphereDirectedParticleEmitter
  13166. * @param radius the radius of the emission sphere (1 by default)
  13167. * @param direction1 the min limit of the emission direction (up vector by default)
  13168. * @param direction2 the max limit of the emission direction (up vector by default)
  13169. */
  13170. constructor(radius?: number,
  13171. /**
  13172. * The min limit of the emission direction.
  13173. */
  13174. direction1?: Vector3,
  13175. /**
  13176. * The max limit of the emission direction.
  13177. */
  13178. direction2?: Vector3);
  13179. /**
  13180. * Called by the particle System when the direction is computed for the created particle.
  13181. * @param worldMatrix is the world matrix of the particle system
  13182. * @param directionToUpdate is the direction vector to update with the result
  13183. * @param particle is the particle we are computed the direction for
  13184. */
  13185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13186. /**
  13187. * Clones the current emitter and returns a copy of it
  13188. * @returns the new emitter
  13189. */
  13190. clone(): SphereDirectedParticleEmitter;
  13191. /**
  13192. * Called by the GPUParticleSystem to setup the update shader
  13193. * @param effect defines the update shader
  13194. */
  13195. applyToShader(effect: Effect): void;
  13196. /**
  13197. * Returns a string to use to update the GPU particles update shader
  13198. * @returns a string containng the defines string
  13199. */
  13200. getEffectDefines(): string;
  13201. /**
  13202. * Returns the string "SphereDirectedParticleEmitter"
  13203. * @returns a string containing the class name
  13204. */
  13205. getClassName(): string;
  13206. /**
  13207. * Serializes the particle system to a JSON object.
  13208. * @returns the JSON object
  13209. */
  13210. serialize(): any;
  13211. /**
  13212. * Parse properties from a JSON object
  13213. * @param serializationObject defines the JSON object
  13214. */
  13215. parse(serializationObject: any): void;
  13216. }
  13217. }
  13218. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13220. import { Effect } from "babylonjs/Materials/effect";
  13221. import { Particle } from "babylonjs/Particles/particle";
  13222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13223. import { Nullable } from "babylonjs/types";
  13224. /**
  13225. * Particle emitter emitting particles from a custom list of positions.
  13226. */
  13227. export class CustomParticleEmitter implements IParticleEmitterType {
  13228. /**
  13229. * Gets or sets the position generator that will create the inital position of each particle.
  13230. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13231. */
  13232. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13233. /**
  13234. * Gets or sets the destination generator that will create the final destination of each particle.
  13235. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13236. */
  13237. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13238. /**
  13239. * Creates a new instance CustomParticleEmitter
  13240. */
  13241. constructor();
  13242. /**
  13243. * Called by the particle System when the direction is computed for the created particle.
  13244. * @param worldMatrix is the world matrix of the particle system
  13245. * @param directionToUpdate is the direction vector to update with the result
  13246. * @param particle is the particle we are computed the direction for
  13247. * @param isLocal defines if the direction should be set in local space
  13248. */
  13249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13250. /**
  13251. * Called by the particle System when the position is computed for the created particle.
  13252. * @param worldMatrix is the world matrix of the particle system
  13253. * @param positionToUpdate is the position vector to update with the result
  13254. * @param particle is the particle we are computed the position for
  13255. * @param isLocal defines if the position should be set in local space
  13256. */
  13257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13258. /**
  13259. * Clones the current emitter and returns a copy of it
  13260. * @returns the new emitter
  13261. */
  13262. clone(): CustomParticleEmitter;
  13263. /**
  13264. * Called by the GPUParticleSystem to setup the update shader
  13265. * @param effect defines the update shader
  13266. */
  13267. applyToShader(effect: Effect): void;
  13268. /**
  13269. * Returns a string to use to update the GPU particles update shader
  13270. * @returns a string containng the defines string
  13271. */
  13272. getEffectDefines(): string;
  13273. /**
  13274. * Returns the string "PointParticleEmitter"
  13275. * @returns a string containing the class name
  13276. */
  13277. getClassName(): string;
  13278. /**
  13279. * Serializes the particle system to a JSON object.
  13280. * @returns the JSON object
  13281. */
  13282. serialize(): any;
  13283. /**
  13284. * Parse properties from a JSON object
  13285. * @param serializationObject defines the JSON object
  13286. */
  13287. parse(serializationObject: any): void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13292. import { Effect } from "babylonjs/Materials/effect";
  13293. import { Particle } from "babylonjs/Particles/particle";
  13294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13295. import { Nullable } from "babylonjs/types";
  13296. import { Scene } from "babylonjs/scene";
  13297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13298. /**
  13299. * Particle emitter emitting particles from the inside of a box.
  13300. * It emits the particles randomly between 2 given directions.
  13301. */
  13302. export class MeshParticleEmitter implements IParticleEmitterType {
  13303. private _indices;
  13304. private _positions;
  13305. private _normals;
  13306. private _storedNormal;
  13307. private _mesh;
  13308. /**
  13309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13310. */
  13311. direction1: Vector3;
  13312. /**
  13313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13314. */
  13315. direction2: Vector3;
  13316. /**
  13317. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13318. */
  13319. useMeshNormalsForDirection: boolean;
  13320. /** Defines the mesh to use as source */
  13321. get mesh(): Nullable<AbstractMesh>;
  13322. set mesh(value: Nullable<AbstractMesh>);
  13323. /**
  13324. * Creates a new instance MeshParticleEmitter
  13325. * @param mesh defines the mesh to use as source
  13326. */
  13327. constructor(mesh?: Nullable<AbstractMesh>);
  13328. /**
  13329. * Called by the particle System when the direction is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param directionToUpdate is the direction vector to update with the result
  13332. * @param particle is the particle we are computed the direction for
  13333. * @param isLocal defines if the direction should be set in local space
  13334. */
  13335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Called by the particle System when the position is computed for the created particle.
  13338. * @param worldMatrix is the world matrix of the particle system
  13339. * @param positionToUpdate is the position vector to update with the result
  13340. * @param particle is the particle we are computed the position for
  13341. * @param isLocal defines if the position should be set in local space
  13342. */
  13343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13344. /**
  13345. * Clones the current emitter and returns a copy of it
  13346. * @returns the new emitter
  13347. */
  13348. clone(): MeshParticleEmitter;
  13349. /**
  13350. * Called by the GPUParticleSystem to setup the update shader
  13351. * @param effect defines the update shader
  13352. */
  13353. applyToShader(effect: Effect): void;
  13354. /**
  13355. * Returns a string to use to update the GPU particles update shader
  13356. * @returns a string containng the defines string
  13357. */
  13358. getEffectDefines(): string;
  13359. /**
  13360. * Returns the string "BoxParticleEmitter"
  13361. * @returns a string containing the class name
  13362. */
  13363. getClassName(): string;
  13364. /**
  13365. * Serializes the particle system to a JSON object.
  13366. * @returns the JSON object
  13367. */
  13368. serialize(): any;
  13369. /**
  13370. * Parse properties from a JSON object
  13371. * @param serializationObject defines the JSON object
  13372. * @param scene defines the hosting scene
  13373. */
  13374. parse(serializationObject: any, scene: Scene): void;
  13375. }
  13376. }
  13377. declare module "babylonjs/Particles/EmitterTypes/index" {
  13378. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13379. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13380. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13381. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13382. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13383. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13384. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13385. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13386. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13387. }
  13388. declare module "babylonjs/Particles/IParticleSystem" {
  13389. import { Nullable } from "babylonjs/types";
  13390. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13391. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13394. import { Texture } from "babylonjs/Materials/Textures/texture";
  13395. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13396. import { Scene } from "babylonjs/scene";
  13397. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13398. import { Animation } from "babylonjs/Animations/animation";
  13399. /**
  13400. * Interface representing a particle system in Babylon.js.
  13401. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13402. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13403. */
  13404. export interface IParticleSystem {
  13405. /**
  13406. * List of animations used by the particle system.
  13407. */
  13408. animations: Animation[];
  13409. /**
  13410. * The id of the Particle system.
  13411. */
  13412. id: string;
  13413. /**
  13414. * The name of the Particle system.
  13415. */
  13416. name: string;
  13417. /**
  13418. * The emitter represents the Mesh or position we are attaching the particle system to.
  13419. */
  13420. emitter: Nullable<AbstractMesh | Vector3>;
  13421. /**
  13422. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13423. */
  13424. isBillboardBased: boolean;
  13425. /**
  13426. * The rendering group used by the Particle system to chose when to render.
  13427. */
  13428. renderingGroupId: number;
  13429. /**
  13430. * The layer mask we are rendering the particles through.
  13431. */
  13432. layerMask: number;
  13433. /**
  13434. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13435. */
  13436. updateSpeed: number;
  13437. /**
  13438. * The amount of time the particle system is running (depends of the overall update speed).
  13439. */
  13440. targetStopDuration: number;
  13441. /**
  13442. * The texture used to render each particle. (this can be a spritesheet)
  13443. */
  13444. particleTexture: Nullable<Texture>;
  13445. /**
  13446. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13447. */
  13448. blendMode: number;
  13449. /**
  13450. * Minimum life time of emitting particles.
  13451. */
  13452. minLifeTime: number;
  13453. /**
  13454. * Maximum life time of emitting particles.
  13455. */
  13456. maxLifeTime: number;
  13457. /**
  13458. * Minimum Size of emitting particles.
  13459. */
  13460. minSize: number;
  13461. /**
  13462. * Maximum Size of emitting particles.
  13463. */
  13464. maxSize: number;
  13465. /**
  13466. * Minimum scale of emitting particles on X axis.
  13467. */
  13468. minScaleX: number;
  13469. /**
  13470. * Maximum scale of emitting particles on X axis.
  13471. */
  13472. maxScaleX: number;
  13473. /**
  13474. * Minimum scale of emitting particles on Y axis.
  13475. */
  13476. minScaleY: number;
  13477. /**
  13478. * Maximum scale of emitting particles on Y axis.
  13479. */
  13480. maxScaleY: number;
  13481. /**
  13482. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13483. */
  13484. color1: Color4;
  13485. /**
  13486. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13487. */
  13488. color2: Color4;
  13489. /**
  13490. * Color the particle will have at the end of its lifetime.
  13491. */
  13492. colorDead: Color4;
  13493. /**
  13494. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13495. */
  13496. emitRate: number;
  13497. /**
  13498. * You can use gravity if you want to give an orientation to your particles.
  13499. */
  13500. gravity: Vector3;
  13501. /**
  13502. * Minimum power of emitting particles.
  13503. */
  13504. minEmitPower: number;
  13505. /**
  13506. * Maximum power of emitting particles.
  13507. */
  13508. maxEmitPower: number;
  13509. /**
  13510. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13511. */
  13512. minAngularSpeed: number;
  13513. /**
  13514. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13515. */
  13516. maxAngularSpeed: number;
  13517. /**
  13518. * Gets or sets the minimal initial rotation in radians.
  13519. */
  13520. minInitialRotation: number;
  13521. /**
  13522. * Gets or sets the maximal initial rotation in radians.
  13523. */
  13524. maxInitialRotation: number;
  13525. /**
  13526. * The particle emitter type defines the emitter used by the particle system.
  13527. * It can be for example box, sphere, or cone...
  13528. */
  13529. particleEmitterType: Nullable<IParticleEmitterType>;
  13530. /**
  13531. * Defines the delay in milliseconds before starting the system (0 by default)
  13532. */
  13533. startDelay: number;
  13534. /**
  13535. * 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
  13536. */
  13537. preWarmCycles: number;
  13538. /**
  13539. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13540. */
  13541. preWarmStepOffset: number;
  13542. /**
  13543. * 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)
  13544. */
  13545. spriteCellChangeSpeed: number;
  13546. /**
  13547. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13548. */
  13549. startSpriteCellID: number;
  13550. /**
  13551. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13552. */
  13553. endSpriteCellID: number;
  13554. /**
  13555. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13556. */
  13557. spriteCellWidth: number;
  13558. /**
  13559. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13560. */
  13561. spriteCellHeight: number;
  13562. /**
  13563. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13564. */
  13565. spriteRandomStartCell: boolean;
  13566. /**
  13567. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13568. */
  13569. isAnimationSheetEnabled: boolean;
  13570. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13571. translationPivot: Vector2;
  13572. /**
  13573. * Gets or sets a texture used to add random noise to particle positions
  13574. */
  13575. noiseTexture: Nullable<BaseTexture>;
  13576. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13577. noiseStrength: Vector3;
  13578. /**
  13579. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13580. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13581. */
  13582. billboardMode: number;
  13583. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13584. limitVelocityDamping: number;
  13585. /**
  13586. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13587. */
  13588. beginAnimationOnStart: boolean;
  13589. /**
  13590. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13591. */
  13592. beginAnimationFrom: number;
  13593. /**
  13594. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13595. */
  13596. beginAnimationTo: number;
  13597. /**
  13598. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13599. */
  13600. beginAnimationLoop: boolean;
  13601. /**
  13602. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13603. */
  13604. disposeOnStop: boolean;
  13605. /**
  13606. * Specifies if the particles are updated in emitter local space or world space
  13607. */
  13608. isLocal: boolean;
  13609. /** Snippet ID if the particle system was created from the snippet server */
  13610. snippetId: string;
  13611. /**
  13612. * Gets the maximum number of particles active at the same time.
  13613. * @returns The max number of active particles.
  13614. */
  13615. getCapacity(): number;
  13616. /**
  13617. * Gets the number of particles active at the same time.
  13618. * @returns The number of active particles.
  13619. */
  13620. getActiveCount(): number;
  13621. /**
  13622. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13623. * @returns True if it has been started, otherwise false.
  13624. */
  13625. isStarted(): boolean;
  13626. /**
  13627. * Animates the particle system for this frame.
  13628. */
  13629. animate(): void;
  13630. /**
  13631. * Renders the particle system in its current state.
  13632. * @returns the current number of particles
  13633. */
  13634. render(): number;
  13635. /**
  13636. * Dispose the particle system and frees its associated resources.
  13637. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13638. */
  13639. dispose(disposeTexture?: boolean): void;
  13640. /**
  13641. * Clones the particle system.
  13642. * @param name The name of the cloned object
  13643. * @param newEmitter The new emitter to use
  13644. * @returns the cloned particle system
  13645. */
  13646. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13647. /**
  13648. * Serializes the particle system to a JSON object
  13649. * @param serializeTexture defines if the texture must be serialized as well
  13650. * @returns the JSON object
  13651. */
  13652. serialize(serializeTexture: boolean): any;
  13653. /**
  13654. * Rebuild the particle system
  13655. */
  13656. rebuild(): void;
  13657. /** Force the system to rebuild all gradients that need to be resync */
  13658. forceRefreshGradients(): void;
  13659. /**
  13660. * Starts the particle system and begins to emit
  13661. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13662. */
  13663. start(delay?: number): void;
  13664. /**
  13665. * Stops the particle system.
  13666. */
  13667. stop(): void;
  13668. /**
  13669. * Remove all active particles
  13670. */
  13671. reset(): void;
  13672. /**
  13673. * Gets a boolean indicating that the system is stopping
  13674. * @returns true if the system is currently stopping
  13675. */
  13676. isStopping(): boolean;
  13677. /**
  13678. * Is this system ready to be used/rendered
  13679. * @return true if the system is ready
  13680. */
  13681. isReady(): boolean;
  13682. /**
  13683. * Returns the string "ParticleSystem"
  13684. * @returns a string containing the class name
  13685. */
  13686. getClassName(): string;
  13687. /**
  13688. * Adds a new color gradient
  13689. * @param gradient defines the gradient to use (between 0 and 1)
  13690. * @param color1 defines the color to affect to the specified gradient
  13691. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13692. * @returns the current particle system
  13693. */
  13694. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13695. /**
  13696. * Remove a specific color gradient
  13697. * @param gradient defines the gradient to remove
  13698. * @returns the current particle system
  13699. */
  13700. removeColorGradient(gradient: number): IParticleSystem;
  13701. /**
  13702. * Adds a new size gradient
  13703. * @param gradient defines the gradient to use (between 0 and 1)
  13704. * @param factor defines the size factor to affect to the specified gradient
  13705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13706. * @returns the current particle system
  13707. */
  13708. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13709. /**
  13710. * Remove a specific size gradient
  13711. * @param gradient defines the gradient to remove
  13712. * @returns the current particle system
  13713. */
  13714. removeSizeGradient(gradient: number): IParticleSystem;
  13715. /**
  13716. * Gets the current list of color gradients.
  13717. * You must use addColorGradient and removeColorGradient to udpate this list
  13718. * @returns the list of color gradients
  13719. */
  13720. getColorGradients(): Nullable<Array<ColorGradient>>;
  13721. /**
  13722. * Gets the current list of size gradients.
  13723. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13724. * @returns the list of size gradients
  13725. */
  13726. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13727. /**
  13728. * Gets the current list of angular speed gradients.
  13729. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13730. * @returns the list of angular speed gradients
  13731. */
  13732. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13733. /**
  13734. * Adds a new angular speed gradient
  13735. * @param gradient defines the gradient to use (between 0 and 1)
  13736. * @param factor defines the angular speed to affect to the specified gradient
  13737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13738. * @returns the current particle system
  13739. */
  13740. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13741. /**
  13742. * Remove a specific angular speed gradient
  13743. * @param gradient defines the gradient to remove
  13744. * @returns the current particle system
  13745. */
  13746. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13747. /**
  13748. * Gets the current list of velocity gradients.
  13749. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13750. * @returns the list of velocity gradients
  13751. */
  13752. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13753. /**
  13754. * Adds a new velocity gradient
  13755. * @param gradient defines the gradient to use (between 0 and 1)
  13756. * @param factor defines the velocity to affect to the specified gradient
  13757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13758. * @returns the current particle system
  13759. */
  13760. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13761. /**
  13762. * Remove a specific velocity gradient
  13763. * @param gradient defines the gradient to remove
  13764. * @returns the current particle system
  13765. */
  13766. removeVelocityGradient(gradient: number): IParticleSystem;
  13767. /**
  13768. * Gets the current list of limit velocity gradients.
  13769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13770. * @returns the list of limit velocity gradients
  13771. */
  13772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13773. /**
  13774. * Adds a new limit velocity gradient
  13775. * @param gradient defines the gradient to use (between 0 and 1)
  13776. * @param factor defines the limit velocity to affect to the specified gradient
  13777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13778. * @returns the current particle system
  13779. */
  13780. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13781. /**
  13782. * Remove a specific limit velocity gradient
  13783. * @param gradient defines the gradient to remove
  13784. * @returns the current particle system
  13785. */
  13786. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13787. /**
  13788. * Adds a new drag gradient
  13789. * @param gradient defines the gradient to use (between 0 and 1)
  13790. * @param factor defines the drag to affect to the specified gradient
  13791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13792. * @returns the current particle system
  13793. */
  13794. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13795. /**
  13796. * Remove a specific drag gradient
  13797. * @param gradient defines the gradient to remove
  13798. * @returns the current particle system
  13799. */
  13800. removeDragGradient(gradient: number): IParticleSystem;
  13801. /**
  13802. * Gets the current list of drag gradients.
  13803. * You must use addDragGradient and removeDragGradient to udpate this list
  13804. * @returns the list of drag gradients
  13805. */
  13806. getDragGradients(): Nullable<Array<FactorGradient>>;
  13807. /**
  13808. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13809. * @param gradient defines the gradient to use (between 0 and 1)
  13810. * @param factor defines the emit rate to affect to the specified gradient
  13811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13812. * @returns the current particle system
  13813. */
  13814. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13815. /**
  13816. * Remove a specific emit rate gradient
  13817. * @param gradient defines the gradient to remove
  13818. * @returns the current particle system
  13819. */
  13820. removeEmitRateGradient(gradient: number): IParticleSystem;
  13821. /**
  13822. * Gets the current list of emit rate gradients.
  13823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13824. * @returns the list of emit rate gradients
  13825. */
  13826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13827. /**
  13828. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13829. * @param gradient defines the gradient to use (between 0 and 1)
  13830. * @param factor defines the start size to affect to the specified gradient
  13831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13832. * @returns the current particle system
  13833. */
  13834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13835. /**
  13836. * Remove a specific start size gradient
  13837. * @param gradient defines the gradient to remove
  13838. * @returns the current particle system
  13839. */
  13840. removeStartSizeGradient(gradient: number): IParticleSystem;
  13841. /**
  13842. * Gets the current list of start size gradients.
  13843. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13844. * @returns the list of start size gradients
  13845. */
  13846. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13847. /**
  13848. * Adds a new life time gradient
  13849. * @param gradient defines the gradient to use (between 0 and 1)
  13850. * @param factor defines the life time factor to affect to the specified gradient
  13851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13852. * @returns the current particle system
  13853. */
  13854. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13855. /**
  13856. * Remove a specific life time gradient
  13857. * @param gradient defines the gradient to remove
  13858. * @returns the current particle system
  13859. */
  13860. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13861. /**
  13862. * Gets the current list of life time gradients.
  13863. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13864. * @returns the list of life time gradients
  13865. */
  13866. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13867. /**
  13868. * Gets the current list of color gradients.
  13869. * You must use addColorGradient and removeColorGradient to udpate this list
  13870. * @returns the list of color gradients
  13871. */
  13872. getColorGradients(): Nullable<Array<ColorGradient>>;
  13873. /**
  13874. * Adds a new ramp gradient used to remap particle colors
  13875. * @param gradient defines the gradient to use (between 0 and 1)
  13876. * @param color defines the color to affect to the specified gradient
  13877. * @returns the current particle system
  13878. */
  13879. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13880. /**
  13881. * Gets the current list of ramp gradients.
  13882. * You must use addRampGradient and removeRampGradient to udpate this list
  13883. * @returns the list of ramp gradients
  13884. */
  13885. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13886. /** Gets or sets a boolean indicating that ramp gradients must be used
  13887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13888. */
  13889. useRampGradients: boolean;
  13890. /**
  13891. * Adds a new color remap gradient
  13892. * @param gradient defines the gradient to use (between 0 and 1)
  13893. * @param min defines the color remap minimal range
  13894. * @param max defines the color remap maximal range
  13895. * @returns the current particle system
  13896. */
  13897. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13898. /**
  13899. * Gets the current list of color remap gradients.
  13900. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13901. * @returns the list of color remap gradients
  13902. */
  13903. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13904. /**
  13905. * Adds a new alpha remap gradient
  13906. * @param gradient defines the gradient to use (between 0 and 1)
  13907. * @param min defines the alpha remap minimal range
  13908. * @param max defines the alpha remap maximal range
  13909. * @returns the current particle system
  13910. */
  13911. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13912. /**
  13913. * Gets the current list of alpha remap gradients.
  13914. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13915. * @returns the list of alpha remap gradients
  13916. */
  13917. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13918. /**
  13919. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13920. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13921. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13922. * @returns the emitter
  13923. */
  13924. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13925. /**
  13926. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13927. * @param radius The radius of the hemisphere to emit from
  13928. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13929. * @returns the emitter
  13930. */
  13931. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13932. /**
  13933. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13934. * @param radius The radius of the sphere to emit from
  13935. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13936. * @returns the emitter
  13937. */
  13938. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13939. /**
  13940. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13941. * @param radius The radius of the sphere to emit from
  13942. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13943. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13944. * @returns the emitter
  13945. */
  13946. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13947. /**
  13948. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13949. * @param radius The radius of the emission cylinder
  13950. * @param height The height of the emission cylinder
  13951. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13952. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13953. * @returns the emitter
  13954. */
  13955. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13956. /**
  13957. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13958. * @param radius The radius of the cylinder to emit from
  13959. * @param height The height of the emission cylinder
  13960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13961. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13962. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13963. * @returns the emitter
  13964. */
  13965. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13966. /**
  13967. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13968. * @param radius The radius of the cone to emit from
  13969. * @param angle The base angle of the cone
  13970. * @returns the emitter
  13971. */
  13972. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13973. /**
  13974. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13975. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13976. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13977. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13978. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13979. * @returns the emitter
  13980. */
  13981. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13982. /**
  13983. * Get hosting scene
  13984. * @returns the scene
  13985. */
  13986. getScene(): Scene;
  13987. }
  13988. }
  13989. declare module "babylonjs/Meshes/transformNode" {
  13990. import { DeepImmutable } from "babylonjs/types";
  13991. import { Observable } from "babylonjs/Misc/observable";
  13992. import { Nullable } from "babylonjs/types";
  13993. import { Camera } from "babylonjs/Cameras/camera";
  13994. import { Scene } from "babylonjs/scene";
  13995. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13996. import { Node } from "babylonjs/node";
  13997. import { Bone } from "babylonjs/Bones/bone";
  13998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13999. import { Space } from "babylonjs/Maths/math.axis";
  14000. /**
  14001. * 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.
  14002. * @see https://doc.babylonjs.com/how_to/transformnode
  14003. */
  14004. export class TransformNode extends Node {
  14005. /**
  14006. * Object will not rotate to face the camera
  14007. */
  14008. static BILLBOARDMODE_NONE: number;
  14009. /**
  14010. * Object will rotate to face the camera but only on the x axis
  14011. */
  14012. static BILLBOARDMODE_X: number;
  14013. /**
  14014. * Object will rotate to face the camera but only on the y axis
  14015. */
  14016. static BILLBOARDMODE_Y: number;
  14017. /**
  14018. * Object will rotate to face the camera but only on the z axis
  14019. */
  14020. static BILLBOARDMODE_Z: number;
  14021. /**
  14022. * Object will rotate to face the camera
  14023. */
  14024. static BILLBOARDMODE_ALL: number;
  14025. /**
  14026. * Object will rotate to face the camera's position instead of orientation
  14027. */
  14028. static BILLBOARDMODE_USE_POSITION: number;
  14029. private _forward;
  14030. private _forwardInverted;
  14031. private _up;
  14032. private _right;
  14033. private _rightInverted;
  14034. private _position;
  14035. private _rotation;
  14036. private _rotationQuaternion;
  14037. protected _scaling: Vector3;
  14038. protected _isDirty: boolean;
  14039. private _transformToBoneReferal;
  14040. private _isAbsoluteSynced;
  14041. private _billboardMode;
  14042. /**
  14043. * Gets or sets the billboard mode. Default is 0.
  14044. *
  14045. * | Value | Type | Description |
  14046. * | --- | --- | --- |
  14047. * | 0 | BILLBOARDMODE_NONE | |
  14048. * | 1 | BILLBOARDMODE_X | |
  14049. * | 2 | BILLBOARDMODE_Y | |
  14050. * | 4 | BILLBOARDMODE_Z | |
  14051. * | 7 | BILLBOARDMODE_ALL | |
  14052. *
  14053. */
  14054. get billboardMode(): number;
  14055. set billboardMode(value: number);
  14056. private _preserveParentRotationForBillboard;
  14057. /**
  14058. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14059. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14060. */
  14061. get preserveParentRotationForBillboard(): boolean;
  14062. set preserveParentRotationForBillboard(value: boolean);
  14063. /**
  14064. * 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
  14065. */
  14066. scalingDeterminant: number;
  14067. private _infiniteDistance;
  14068. /**
  14069. * Gets or sets the distance of the object to max, often used by skybox
  14070. */
  14071. get infiniteDistance(): boolean;
  14072. set infiniteDistance(value: boolean);
  14073. /**
  14074. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14075. * By default the system will update normals to compensate
  14076. */
  14077. ignoreNonUniformScaling: boolean;
  14078. /**
  14079. * 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
  14080. */
  14081. reIntegrateRotationIntoRotationQuaternion: boolean;
  14082. /** @hidden */
  14083. _poseMatrix: Nullable<Matrix>;
  14084. /** @hidden */
  14085. _localMatrix: Matrix;
  14086. private _usePivotMatrix;
  14087. private _absolutePosition;
  14088. private _absoluteScaling;
  14089. private _absoluteRotationQuaternion;
  14090. private _pivotMatrix;
  14091. private _pivotMatrixInverse;
  14092. protected _postMultiplyPivotMatrix: boolean;
  14093. protected _isWorldMatrixFrozen: boolean;
  14094. /** @hidden */
  14095. _indexInSceneTransformNodesArray: number;
  14096. /**
  14097. * An event triggered after the world matrix is updated
  14098. */
  14099. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14100. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14101. /**
  14102. * Gets a string identifying the name of the class
  14103. * @returns "TransformNode" string
  14104. */
  14105. getClassName(): string;
  14106. /**
  14107. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14108. */
  14109. get position(): Vector3;
  14110. set position(newPosition: Vector3);
  14111. /**
  14112. * 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)).
  14113. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14114. */
  14115. get rotation(): Vector3;
  14116. set rotation(newRotation: Vector3);
  14117. /**
  14118. * 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)).
  14119. */
  14120. get scaling(): Vector3;
  14121. set scaling(newScaling: Vector3);
  14122. /**
  14123. * 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).
  14124. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14125. */
  14126. get rotationQuaternion(): Nullable<Quaternion>;
  14127. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14128. /**
  14129. * The forward direction of that transform in world space.
  14130. */
  14131. get forward(): Vector3;
  14132. /**
  14133. * The up direction of that transform in world space.
  14134. */
  14135. get up(): Vector3;
  14136. /**
  14137. * The right direction of that transform in world space.
  14138. */
  14139. get right(): Vector3;
  14140. /**
  14141. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14142. * @param matrix the matrix to copy the pose from
  14143. * @returns this TransformNode.
  14144. */
  14145. updatePoseMatrix(matrix: Matrix): TransformNode;
  14146. /**
  14147. * Returns the mesh Pose matrix.
  14148. * @returns the pose matrix
  14149. */
  14150. getPoseMatrix(): Matrix;
  14151. /** @hidden */
  14152. _isSynchronized(): boolean;
  14153. /** @hidden */
  14154. _initCache(): void;
  14155. /**
  14156. * Flag the transform node as dirty (Forcing it to update everything)
  14157. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14158. * @returns this transform node
  14159. */
  14160. markAsDirty(property: string): TransformNode;
  14161. /**
  14162. * Returns the current mesh absolute position.
  14163. * Returns a Vector3.
  14164. */
  14165. get absolutePosition(): Vector3;
  14166. /**
  14167. * Returns the current mesh absolute scaling.
  14168. * Returns a Vector3.
  14169. */
  14170. get absoluteScaling(): Vector3;
  14171. /**
  14172. * Returns the current mesh absolute rotation.
  14173. * Returns a Quaternion.
  14174. */
  14175. get absoluteRotationQuaternion(): Quaternion;
  14176. /**
  14177. * Sets a new matrix to apply before all other transformation
  14178. * @param matrix defines the transform matrix
  14179. * @returns the current TransformNode
  14180. */
  14181. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14182. /**
  14183. * Sets a new pivot matrix to the current node
  14184. * @param matrix defines the new pivot matrix to use
  14185. * @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
  14186. * @returns the current TransformNode
  14187. */
  14188. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14189. /**
  14190. * Returns the mesh pivot matrix.
  14191. * Default : Identity.
  14192. * @returns the matrix
  14193. */
  14194. getPivotMatrix(): Matrix;
  14195. /**
  14196. * Instantiate (when possible) or clone that node with its hierarchy
  14197. * @param newParent defines the new parent to use for the instance (or clone)
  14198. * @param options defines options to configure how copy is done
  14199. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14200. * @returns an instance (or a clone) of the current node with its hiearchy
  14201. */
  14202. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14203. doNotInstantiate: boolean;
  14204. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14205. /**
  14206. * Prevents the World matrix to be computed any longer
  14207. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14208. * @returns the TransformNode.
  14209. */
  14210. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14211. /**
  14212. * Allows back the World matrix computation.
  14213. * @returns the TransformNode.
  14214. */
  14215. unfreezeWorldMatrix(): this;
  14216. /**
  14217. * True if the World matrix has been frozen.
  14218. */
  14219. get isWorldMatrixFrozen(): boolean;
  14220. /**
  14221. * Retuns the mesh absolute position in the World.
  14222. * @returns a Vector3.
  14223. */
  14224. getAbsolutePosition(): Vector3;
  14225. /**
  14226. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14227. * @param absolutePosition the absolute position to set
  14228. * @returns the TransformNode.
  14229. */
  14230. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14231. /**
  14232. * Sets the mesh position in its local space.
  14233. * @param vector3 the position to set in localspace
  14234. * @returns the TransformNode.
  14235. */
  14236. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14237. /**
  14238. * Returns the mesh position in the local space from the current World matrix values.
  14239. * @returns a new Vector3.
  14240. */
  14241. getPositionExpressedInLocalSpace(): Vector3;
  14242. /**
  14243. * Translates the mesh along the passed Vector3 in its local space.
  14244. * @param vector3 the distance to translate in localspace
  14245. * @returns the TransformNode.
  14246. */
  14247. locallyTranslate(vector3: Vector3): TransformNode;
  14248. private static _lookAtVectorCache;
  14249. /**
  14250. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14251. * @param targetPoint the position (must be in same space as current mesh) to look at
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @param space the choosen space of the target
  14256. * @returns the TransformNode.
  14257. */
  14258. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14259. /**
  14260. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14261. * This Vector3 is expressed in the World space.
  14262. * @param localAxis axis to rotate
  14263. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14264. */
  14265. getDirection(localAxis: Vector3): Vector3;
  14266. /**
  14267. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14268. * localAxis is expressed in the mesh local space.
  14269. * result is computed in the Wordl space from the mesh World matrix.
  14270. * @param localAxis axis to rotate
  14271. * @param result the resulting transformnode
  14272. * @returns this TransformNode.
  14273. */
  14274. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14275. /**
  14276. * Sets this transform node rotation to the given local axis.
  14277. * @param localAxis the axis in local space
  14278. * @param yawCor optional yaw (y-axis) correction in radians
  14279. * @param pitchCor optional pitch (x-axis) correction in radians
  14280. * @param rollCor optional roll (z-axis) correction in radians
  14281. * @returns this TransformNode
  14282. */
  14283. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14284. /**
  14285. * Sets a new pivot point to the current node
  14286. * @param point defines the new pivot point to use
  14287. * @param space defines if the point is in world or local space (local by default)
  14288. * @returns the current TransformNode
  14289. */
  14290. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14291. /**
  14292. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14293. * @returns the pivot point
  14294. */
  14295. getPivotPoint(): Vector3;
  14296. /**
  14297. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14298. * @param result the vector3 to store the result
  14299. * @returns this TransformNode.
  14300. */
  14301. getPivotPointToRef(result: Vector3): TransformNode;
  14302. /**
  14303. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14304. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14305. */
  14306. getAbsolutePivotPoint(): Vector3;
  14307. /**
  14308. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14309. * @param result vector3 to store the result
  14310. * @returns this TransformNode.
  14311. */
  14312. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14313. /**
  14314. * Defines the passed node as the parent of the current node.
  14315. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14316. * @see https://doc.babylonjs.com/how_to/parenting
  14317. * @param node the node ot set as the parent
  14318. * @returns this TransformNode.
  14319. */
  14320. setParent(node: Nullable<Node>): TransformNode;
  14321. private _nonUniformScaling;
  14322. /**
  14323. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14324. */
  14325. get nonUniformScaling(): boolean;
  14326. /** @hidden */
  14327. _updateNonUniformScalingState(value: boolean): boolean;
  14328. /**
  14329. * Attach the current TransformNode to another TransformNode associated with a bone
  14330. * @param bone Bone affecting the TransformNode
  14331. * @param affectedTransformNode TransformNode associated with the bone
  14332. * @returns this object
  14333. */
  14334. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14335. /**
  14336. * Detach the transform node if its associated with a bone
  14337. * @returns this object
  14338. */
  14339. detachFromBone(): TransformNode;
  14340. private static _rotationAxisCache;
  14341. /**
  14342. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14343. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14344. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14345. * The passed axis is also normalized.
  14346. * @param axis the axis to rotate around
  14347. * @param amount the amount to rotate in radians
  14348. * @param space Space to rotate in (Default: local)
  14349. * @returns the TransformNode.
  14350. */
  14351. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14352. /**
  14353. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14354. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14355. * The passed axis is also normalized. .
  14356. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14357. * @param point the point to rotate around
  14358. * @param axis the axis to rotate around
  14359. * @param amount the amount to rotate in radians
  14360. * @returns the TransformNode
  14361. */
  14362. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14363. /**
  14364. * Translates the mesh along the axis vector for the passed distance in the given space.
  14365. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14366. * @param axis the axis to translate in
  14367. * @param distance the distance to translate
  14368. * @param space Space to rotate in (Default: local)
  14369. * @returns the TransformNode.
  14370. */
  14371. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14372. /**
  14373. * Adds a rotation step to the mesh current rotation.
  14374. * x, y, z are Euler angles expressed in radians.
  14375. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14376. * This means this rotation is made in the mesh local space only.
  14377. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14378. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14379. * ```javascript
  14380. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14381. * ```
  14382. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14383. * 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.
  14384. * @param x Rotation to add
  14385. * @param y Rotation to add
  14386. * @param z Rotation to add
  14387. * @returns the TransformNode.
  14388. */
  14389. addRotation(x: number, y: number, z: number): TransformNode;
  14390. /**
  14391. * @hidden
  14392. */
  14393. protected _getEffectiveParent(): Nullable<Node>;
  14394. /**
  14395. * Computes the world matrix of the node
  14396. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14397. * @returns the world matrix
  14398. */
  14399. computeWorldMatrix(force?: boolean): Matrix;
  14400. /**
  14401. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14402. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14403. */
  14404. resetLocalMatrix(independentOfChildren?: boolean): void;
  14405. protected _afterComputeWorldMatrix(): void;
  14406. /**
  14407. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14408. * @param func callback function to add
  14409. *
  14410. * @returns the TransformNode.
  14411. */
  14412. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14413. /**
  14414. * Removes a registered callback function.
  14415. * @param func callback function to remove
  14416. * @returns the TransformNode.
  14417. */
  14418. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14419. /**
  14420. * Gets the position of the current mesh in camera space
  14421. * @param camera defines the camera to use
  14422. * @returns a position
  14423. */
  14424. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14425. /**
  14426. * Returns the distance from the mesh to the active camera
  14427. * @param camera defines the camera to use
  14428. * @returns the distance
  14429. */
  14430. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14431. /**
  14432. * Clone the current transform node
  14433. * @param name Name of the new clone
  14434. * @param newParent New parent for the clone
  14435. * @param doNotCloneChildren Do not clone children hierarchy
  14436. * @returns the new transform node
  14437. */
  14438. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14439. /**
  14440. * Serializes the objects information.
  14441. * @param currentSerializationObject defines the object to serialize in
  14442. * @returns the serialized object
  14443. */
  14444. serialize(currentSerializationObject?: any): any;
  14445. /**
  14446. * Returns a new TransformNode object parsed from the source provided.
  14447. * @param parsedTransformNode is the source.
  14448. * @param scene the scne the object belongs to
  14449. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14450. * @returns a new TransformNode object parsed from the source provided.
  14451. */
  14452. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14453. /**
  14454. * Get all child-transformNodes of this node
  14455. * @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
  14456. * @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
  14457. * @returns an array of TransformNode
  14458. */
  14459. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14460. /**
  14461. * Releases resources associated with this transform node.
  14462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14464. */
  14465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14466. /**
  14467. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14468. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14469. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14470. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14471. * @returns the current mesh
  14472. */
  14473. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14474. private _syncAbsoluteScalingAndRotation;
  14475. }
  14476. }
  14477. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14478. /**
  14479. * Class used to override all child animations of a given target
  14480. */
  14481. export class AnimationPropertiesOverride {
  14482. /**
  14483. * Gets or sets a value indicating if animation blending must be used
  14484. */
  14485. enableBlending: boolean;
  14486. /**
  14487. * Gets or sets the blending speed to use when enableBlending is true
  14488. */
  14489. blendingSpeed: number;
  14490. /**
  14491. * Gets or sets the default loop mode to use
  14492. */
  14493. loopMode: number;
  14494. }
  14495. }
  14496. declare module "babylonjs/Bones/bone" {
  14497. import { Skeleton } from "babylonjs/Bones/skeleton";
  14498. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14499. import { Nullable } from "babylonjs/types";
  14500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14502. import { Node } from "babylonjs/node";
  14503. import { Space } from "babylonjs/Maths/math.axis";
  14504. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14505. /**
  14506. * Class used to store bone information
  14507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14508. */
  14509. export class Bone extends Node {
  14510. /**
  14511. * defines the bone name
  14512. */
  14513. name: string;
  14514. private static _tmpVecs;
  14515. private static _tmpQuat;
  14516. private static _tmpMats;
  14517. /**
  14518. * Gets the list of child bones
  14519. */
  14520. children: Bone[];
  14521. /** Gets the animations associated with this bone */
  14522. animations: import("babylonjs/Animations/animation").Animation[];
  14523. /**
  14524. * Gets or sets bone length
  14525. */
  14526. length: number;
  14527. /**
  14528. * @hidden Internal only
  14529. * Set this value to map this bone to a different index in the transform matrices
  14530. * Set this value to -1 to exclude the bone from the transform matrices
  14531. */
  14532. _index: Nullable<number>;
  14533. private _skeleton;
  14534. private _localMatrix;
  14535. private _restPose;
  14536. private _baseMatrix;
  14537. private _absoluteTransform;
  14538. private _invertedAbsoluteTransform;
  14539. private _parent;
  14540. private _scalingDeterminant;
  14541. private _worldTransform;
  14542. private _localScaling;
  14543. private _localRotation;
  14544. private _localPosition;
  14545. private _needToDecompose;
  14546. private _needToCompose;
  14547. /** @hidden */
  14548. _linkedTransformNode: Nullable<TransformNode>;
  14549. /** @hidden */
  14550. _waitingTransformNodeId: Nullable<string>;
  14551. /** @hidden */
  14552. get _matrix(): Matrix;
  14553. /** @hidden */
  14554. set _matrix(value: Matrix);
  14555. /**
  14556. * Create a new bone
  14557. * @param name defines the bone name
  14558. * @param skeleton defines the parent skeleton
  14559. * @param parentBone defines the parent (can be null if the bone is the root)
  14560. * @param localMatrix defines the local matrix
  14561. * @param restPose defines the rest pose matrix
  14562. * @param baseMatrix defines the base matrix
  14563. * @param index defines index of the bone in the hiearchy
  14564. */
  14565. constructor(
  14566. /**
  14567. * defines the bone name
  14568. */
  14569. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14570. /**
  14571. * Gets the current object class name.
  14572. * @return the class name
  14573. */
  14574. getClassName(): string;
  14575. /**
  14576. * Gets the parent skeleton
  14577. * @returns a skeleton
  14578. */
  14579. getSkeleton(): Skeleton;
  14580. /**
  14581. * Gets parent bone
  14582. * @returns a bone or null if the bone is the root of the bone hierarchy
  14583. */
  14584. getParent(): Nullable<Bone>;
  14585. /**
  14586. * Returns an array containing the root bones
  14587. * @returns an array containing the root bones
  14588. */
  14589. getChildren(): Array<Bone>;
  14590. /**
  14591. * Gets the node index in matrix array generated for rendering
  14592. * @returns the node index
  14593. */
  14594. getIndex(): number;
  14595. /**
  14596. * Sets the parent bone
  14597. * @param parent defines the parent (can be null if the bone is the root)
  14598. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14599. */
  14600. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14601. /**
  14602. * Gets the local matrix
  14603. * @returns a matrix
  14604. */
  14605. getLocalMatrix(): Matrix;
  14606. /**
  14607. * Gets the base matrix (initial matrix which remains unchanged)
  14608. * @returns a matrix
  14609. */
  14610. getBaseMatrix(): Matrix;
  14611. /**
  14612. * Gets the rest pose matrix
  14613. * @returns a matrix
  14614. */
  14615. getRestPose(): Matrix;
  14616. /**
  14617. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14618. */
  14619. getWorldMatrix(): Matrix;
  14620. /**
  14621. * Sets the local matrix to rest pose matrix
  14622. */
  14623. returnToRest(): void;
  14624. /**
  14625. * Gets the inverse of the absolute transform matrix.
  14626. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14627. * @returns a matrix
  14628. */
  14629. getInvertedAbsoluteTransform(): Matrix;
  14630. /**
  14631. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14632. * @returns a matrix
  14633. */
  14634. getAbsoluteTransform(): Matrix;
  14635. /**
  14636. * Links with the given transform node.
  14637. * The local matrix of this bone is copied from the transform node every frame.
  14638. * @param transformNode defines the transform node to link to
  14639. */
  14640. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14641. /**
  14642. * Gets the node used to drive the bone's transformation
  14643. * @returns a transform node or null
  14644. */
  14645. getTransformNode(): Nullable<TransformNode>;
  14646. /** Gets or sets current position (in local space) */
  14647. get position(): Vector3;
  14648. set position(newPosition: Vector3);
  14649. /** Gets or sets current rotation (in local space) */
  14650. get rotation(): Vector3;
  14651. set rotation(newRotation: Vector3);
  14652. /** Gets or sets current rotation quaternion (in local space) */
  14653. get rotationQuaternion(): Quaternion;
  14654. set rotationQuaternion(newRotation: Quaternion);
  14655. /** Gets or sets current scaling (in local space) */
  14656. get scaling(): Vector3;
  14657. set scaling(newScaling: Vector3);
  14658. /**
  14659. * Gets the animation properties override
  14660. */
  14661. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14662. private _decompose;
  14663. private _compose;
  14664. /**
  14665. * Update the base and local matrices
  14666. * @param matrix defines the new base or local matrix
  14667. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14668. * @param updateLocalMatrix defines if the local matrix should be updated
  14669. */
  14670. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14671. /** @hidden */
  14672. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14673. /**
  14674. * Flag the bone as dirty (Forcing it to update everything)
  14675. */
  14676. markAsDirty(): void;
  14677. /** @hidden */
  14678. _markAsDirtyAndCompose(): void;
  14679. private _markAsDirtyAndDecompose;
  14680. /**
  14681. * Translate the bone in local or world space
  14682. * @param vec The amount to translate the bone
  14683. * @param space The space that the translation is in
  14684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14685. */
  14686. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14687. /**
  14688. * Set the postion of the bone in local or world space
  14689. * @param position The position to set the bone
  14690. * @param space The space that the position is in
  14691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14692. */
  14693. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14694. /**
  14695. * Set the absolute position of the bone (world space)
  14696. * @param position The position to set the bone
  14697. * @param mesh The mesh that this bone is attached to
  14698. */
  14699. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14700. /**
  14701. * Scale the bone on the x, y and z axes (in local space)
  14702. * @param x The amount to scale the bone on the x axis
  14703. * @param y The amount to scale the bone on the y axis
  14704. * @param z The amount to scale the bone on the z axis
  14705. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14706. */
  14707. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14708. /**
  14709. * Set the bone scaling in local space
  14710. * @param scale defines the scaling vector
  14711. */
  14712. setScale(scale: Vector3): void;
  14713. /**
  14714. * Gets the current scaling in local space
  14715. * @returns the current scaling vector
  14716. */
  14717. getScale(): Vector3;
  14718. /**
  14719. * Gets the current scaling in local space and stores it in a target vector
  14720. * @param result defines the target vector
  14721. */
  14722. getScaleToRef(result: Vector3): void;
  14723. /**
  14724. * Set the yaw, pitch, and roll of the bone in local or world space
  14725. * @param yaw The rotation of the bone on the y axis
  14726. * @param pitch The rotation of the bone on the x axis
  14727. * @param roll The rotation of the bone on the z axis
  14728. * @param space The space that the axes of rotation are in
  14729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14730. */
  14731. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14732. /**
  14733. * Add a rotation to the bone on an axis in local or world space
  14734. * @param axis The axis to rotate the bone on
  14735. * @param amount The amount to rotate the bone
  14736. * @param space The space that the axis is in
  14737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14738. */
  14739. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14740. /**
  14741. * Set the rotation of the bone to a particular axis angle in local or world space
  14742. * @param axis The axis to rotate the bone on
  14743. * @param angle The angle that the bone should be rotated to
  14744. * @param space The space that the axis is in
  14745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14746. */
  14747. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14748. /**
  14749. * Set the euler rotation of the bone in local of world space
  14750. * @param rotation The euler rotation that the bone should be set to
  14751. * @param space The space that the rotation is in
  14752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14753. */
  14754. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14755. /**
  14756. * Set the quaternion rotation of the bone in local of world space
  14757. * @param quat The quaternion rotation that the bone should be set to
  14758. * @param space The space that the rotation is in
  14759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14760. */
  14761. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14762. /**
  14763. * Set the rotation matrix of the bone in local of world space
  14764. * @param rotMat The rotation matrix that the bone should be set to
  14765. * @param space The space that the rotation is in
  14766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14767. */
  14768. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14769. private _rotateWithMatrix;
  14770. private _getNegativeRotationToRef;
  14771. /**
  14772. * Get the position of the bone in local or world space
  14773. * @param space The space that the returned position is in
  14774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14775. * @returns The position of the bone
  14776. */
  14777. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14778. /**
  14779. * Copy the position of the bone to a vector3 in local or world space
  14780. * @param space The space that the returned position is in
  14781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14782. * @param result The vector3 to copy the position to
  14783. */
  14784. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14785. /**
  14786. * Get the absolute position of the bone (world space)
  14787. * @param mesh The mesh that this bone is attached to
  14788. * @returns The absolute position of the bone
  14789. */
  14790. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14791. /**
  14792. * Copy the absolute position of the bone (world space) to the result param
  14793. * @param mesh The mesh that this bone is attached to
  14794. * @param result The vector3 to copy the absolute position to
  14795. */
  14796. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14797. /**
  14798. * Compute the absolute transforms of this bone and its children
  14799. */
  14800. computeAbsoluteTransforms(): void;
  14801. /**
  14802. * Get the world direction from an axis that is in the local space of the bone
  14803. * @param localAxis The local direction that is used to compute the world direction
  14804. * @param mesh The mesh that this bone is attached to
  14805. * @returns The world direction
  14806. */
  14807. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14808. /**
  14809. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14810. * @param localAxis The local direction that is used to compute the world direction
  14811. * @param mesh The mesh that this bone is attached to
  14812. * @param result The vector3 that the world direction will be copied to
  14813. */
  14814. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14815. /**
  14816. * Get the euler rotation of the bone in local or world space
  14817. * @param space The space that the rotation should be in
  14818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14819. * @returns The euler rotation
  14820. */
  14821. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14822. /**
  14823. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14824. * @param space The space that the rotation should be in
  14825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14826. * @param result The vector3 that the rotation should be copied to
  14827. */
  14828. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14829. /**
  14830. * Get the quaternion rotation of the bone in either local or world space
  14831. * @param space The space that the rotation should be in
  14832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14833. * @returns The quaternion rotation
  14834. */
  14835. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14836. /**
  14837. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14838. * @param space The space that the rotation should be in
  14839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14840. * @param result The quaternion that the rotation should be copied to
  14841. */
  14842. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14843. /**
  14844. * Get the rotation matrix of the bone in local or world space
  14845. * @param space The space that the rotation should be in
  14846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14847. * @returns The rotation matrix
  14848. */
  14849. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14850. /**
  14851. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14852. * @param space The space that the rotation should be in
  14853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14854. * @param result The quaternion that the rotation should be copied to
  14855. */
  14856. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14857. /**
  14858. * Get the world position of a point that is in the local space of the bone
  14859. * @param position The local position
  14860. * @param mesh The mesh that this bone is attached to
  14861. * @returns The world position
  14862. */
  14863. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14864. /**
  14865. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14866. * @param position The local position
  14867. * @param mesh The mesh that this bone is attached to
  14868. * @param result The vector3 that the world position should be copied to
  14869. */
  14870. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14871. /**
  14872. * Get the local position of a point that is in world space
  14873. * @param position The world position
  14874. * @param mesh The mesh that this bone is attached to
  14875. * @returns The local position
  14876. */
  14877. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14878. /**
  14879. * Get the local position of a point that is in world space and copy it to the result param
  14880. * @param position The world position
  14881. * @param mesh The mesh that this bone is attached to
  14882. * @param result The vector3 that the local position should be copied to
  14883. */
  14884. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14885. }
  14886. }
  14887. declare module "babylonjs/Animations/runtimeAnimation" {
  14888. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14889. import { Animatable } from "babylonjs/Animations/animatable";
  14890. import { Scene } from "babylonjs/scene";
  14891. /**
  14892. * Defines a runtime animation
  14893. */
  14894. export class RuntimeAnimation {
  14895. private _events;
  14896. /**
  14897. * The current frame of the runtime animation
  14898. */
  14899. private _currentFrame;
  14900. /**
  14901. * The animation used by the runtime animation
  14902. */
  14903. private _animation;
  14904. /**
  14905. * The target of the runtime animation
  14906. */
  14907. private _target;
  14908. /**
  14909. * The initiating animatable
  14910. */
  14911. private _host;
  14912. /**
  14913. * The original value of the runtime animation
  14914. */
  14915. private _originalValue;
  14916. /**
  14917. * The original blend value of the runtime animation
  14918. */
  14919. private _originalBlendValue;
  14920. /**
  14921. * The offsets cache of the runtime animation
  14922. */
  14923. private _offsetsCache;
  14924. /**
  14925. * The high limits cache of the runtime animation
  14926. */
  14927. private _highLimitsCache;
  14928. /**
  14929. * Specifies if the runtime animation has been stopped
  14930. */
  14931. private _stopped;
  14932. /**
  14933. * The blending factor of the runtime animation
  14934. */
  14935. private _blendingFactor;
  14936. /**
  14937. * The BabylonJS scene
  14938. */
  14939. private _scene;
  14940. /**
  14941. * The current value of the runtime animation
  14942. */
  14943. private _currentValue;
  14944. /** @hidden */
  14945. _animationState: _IAnimationState;
  14946. /**
  14947. * The active target of the runtime animation
  14948. */
  14949. private _activeTargets;
  14950. private _currentActiveTarget;
  14951. private _directTarget;
  14952. /**
  14953. * The target path of the runtime animation
  14954. */
  14955. private _targetPath;
  14956. /**
  14957. * The weight of the runtime animation
  14958. */
  14959. private _weight;
  14960. /**
  14961. * The ratio offset of the runtime animation
  14962. */
  14963. private _ratioOffset;
  14964. /**
  14965. * The previous delay of the runtime animation
  14966. */
  14967. private _previousDelay;
  14968. /**
  14969. * The previous ratio of the runtime animation
  14970. */
  14971. private _previousRatio;
  14972. private _enableBlending;
  14973. private _keys;
  14974. private _minFrame;
  14975. private _maxFrame;
  14976. private _minValue;
  14977. private _maxValue;
  14978. private _targetIsArray;
  14979. /**
  14980. * Gets the current frame of the runtime animation
  14981. */
  14982. get currentFrame(): number;
  14983. /**
  14984. * Gets the weight of the runtime animation
  14985. */
  14986. get weight(): number;
  14987. /**
  14988. * Gets the current value of the runtime animation
  14989. */
  14990. get currentValue(): any;
  14991. /**
  14992. * Gets the target path of the runtime animation
  14993. */
  14994. get targetPath(): string;
  14995. /**
  14996. * Gets the actual target of the runtime animation
  14997. */
  14998. get target(): any;
  14999. /**
  15000. * Gets the additive state of the runtime animation
  15001. */
  15002. get isAdditive(): boolean;
  15003. /** @hidden */
  15004. _onLoop: () => void;
  15005. /**
  15006. * Create a new RuntimeAnimation object
  15007. * @param target defines the target of the animation
  15008. * @param animation defines the source animation object
  15009. * @param scene defines the hosting scene
  15010. * @param host defines the initiating Animatable
  15011. */
  15012. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15013. private _preparePath;
  15014. /**
  15015. * Gets the animation from the runtime animation
  15016. */
  15017. get animation(): Animation;
  15018. /**
  15019. * Resets the runtime animation to the beginning
  15020. * @param restoreOriginal defines whether to restore the target property to the original value
  15021. */
  15022. reset(restoreOriginal?: boolean): void;
  15023. /**
  15024. * Specifies if the runtime animation is stopped
  15025. * @returns Boolean specifying if the runtime animation is stopped
  15026. */
  15027. isStopped(): boolean;
  15028. /**
  15029. * Disposes of the runtime animation
  15030. */
  15031. dispose(): void;
  15032. /**
  15033. * Apply the interpolated value to the target
  15034. * @param currentValue defines the value computed by the animation
  15035. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15036. */
  15037. setValue(currentValue: any, weight: number): void;
  15038. private _getOriginalValues;
  15039. private _setValue;
  15040. /**
  15041. * Gets the loop pmode of the runtime animation
  15042. * @returns Loop Mode
  15043. */
  15044. private _getCorrectLoopMode;
  15045. /**
  15046. * Move the current animation to a given frame
  15047. * @param frame defines the frame to move to
  15048. */
  15049. goToFrame(frame: number): void;
  15050. /**
  15051. * @hidden Internal use only
  15052. */
  15053. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15054. /**
  15055. * Execute the current animation
  15056. * @param delay defines the delay to add to the current frame
  15057. * @param from defines the lower bound of the animation range
  15058. * @param to defines the upper bound of the animation range
  15059. * @param loop defines if the current animation must loop
  15060. * @param speedRatio defines the current speed ratio
  15061. * @param weight defines the weight of the animation (default is -1 so no weight)
  15062. * @param onLoop optional callback called when animation loops
  15063. * @returns a boolean indicating if the animation is running
  15064. */
  15065. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15066. }
  15067. }
  15068. declare module "babylonjs/Animations/animatable" {
  15069. import { Animation } from "babylonjs/Animations/animation";
  15070. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15071. import { Nullable } from "babylonjs/types";
  15072. import { Observable } from "babylonjs/Misc/observable";
  15073. import { Scene } from "babylonjs/scene";
  15074. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15075. import { Node } from "babylonjs/node";
  15076. /**
  15077. * Class used to store an actual running animation
  15078. */
  15079. export class Animatable {
  15080. /** defines the target object */
  15081. target: any;
  15082. /** defines the starting frame number (default is 0) */
  15083. fromFrame: number;
  15084. /** defines the ending frame number (default is 100) */
  15085. toFrame: number;
  15086. /** defines if the animation must loop (default is false) */
  15087. loopAnimation: boolean;
  15088. /** defines a callback to call when animation ends if it is not looping */
  15089. onAnimationEnd?: (() => void) | null | undefined;
  15090. /** defines a callback to call when animation loops */
  15091. onAnimationLoop?: (() => void) | null | undefined;
  15092. /** defines whether the animation should be evaluated additively */
  15093. isAdditive: boolean;
  15094. private _localDelayOffset;
  15095. private _pausedDelay;
  15096. private _runtimeAnimations;
  15097. private _paused;
  15098. private _scene;
  15099. private _speedRatio;
  15100. private _weight;
  15101. private _syncRoot;
  15102. /**
  15103. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15104. * This will only apply for non looping animation (default is true)
  15105. */
  15106. disposeOnEnd: boolean;
  15107. /**
  15108. * Gets a boolean indicating if the animation has started
  15109. */
  15110. animationStarted: boolean;
  15111. /**
  15112. * Observer raised when the animation ends
  15113. */
  15114. onAnimationEndObservable: Observable<Animatable>;
  15115. /**
  15116. * Observer raised when the animation loops
  15117. */
  15118. onAnimationLoopObservable: Observable<Animatable>;
  15119. /**
  15120. * Gets the root Animatable used to synchronize and normalize animations
  15121. */
  15122. get syncRoot(): Nullable<Animatable>;
  15123. /**
  15124. * Gets the current frame of the first RuntimeAnimation
  15125. * Used to synchronize Animatables
  15126. */
  15127. get masterFrame(): number;
  15128. /**
  15129. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15130. */
  15131. get weight(): number;
  15132. set weight(value: number);
  15133. /**
  15134. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15135. */
  15136. get speedRatio(): number;
  15137. set speedRatio(value: number);
  15138. /**
  15139. * Creates a new Animatable
  15140. * @param scene defines the hosting scene
  15141. * @param target defines the target object
  15142. * @param fromFrame defines the starting frame number (default is 0)
  15143. * @param toFrame defines the ending frame number (default is 100)
  15144. * @param loopAnimation defines if the animation must loop (default is false)
  15145. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15146. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15147. * @param animations defines a group of animation to add to the new Animatable
  15148. * @param onAnimationLoop defines a callback to call when animation loops
  15149. * @param isAdditive defines whether the animation should be evaluated additively
  15150. */
  15151. constructor(scene: Scene,
  15152. /** defines the target object */
  15153. target: any,
  15154. /** defines the starting frame number (default is 0) */
  15155. fromFrame?: number,
  15156. /** defines the ending frame number (default is 100) */
  15157. toFrame?: number,
  15158. /** defines if the animation must loop (default is false) */
  15159. loopAnimation?: boolean, speedRatio?: number,
  15160. /** defines a callback to call when animation ends if it is not looping */
  15161. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15162. /** defines a callback to call when animation loops */
  15163. onAnimationLoop?: (() => void) | null | undefined,
  15164. /** defines whether the animation should be evaluated additively */
  15165. isAdditive?: boolean);
  15166. /**
  15167. * Synchronize and normalize current Animatable with a source Animatable
  15168. * This is useful when using animation weights and when animations are not of the same length
  15169. * @param root defines the root Animatable to synchronize with
  15170. * @returns the current Animatable
  15171. */
  15172. syncWith(root: Animatable): Animatable;
  15173. /**
  15174. * Gets the list of runtime animations
  15175. * @returns an array of RuntimeAnimation
  15176. */
  15177. getAnimations(): RuntimeAnimation[];
  15178. /**
  15179. * Adds more animations to the current animatable
  15180. * @param target defines the target of the animations
  15181. * @param animations defines the new animations to add
  15182. */
  15183. appendAnimations(target: any, animations: Animation[]): void;
  15184. /**
  15185. * Gets the source animation for a specific property
  15186. * @param property defines the propertyu to look for
  15187. * @returns null or the source animation for the given property
  15188. */
  15189. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15190. /**
  15191. * Gets the runtime animation for a specific property
  15192. * @param property defines the propertyu to look for
  15193. * @returns null or the runtime animation for the given property
  15194. */
  15195. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15196. /**
  15197. * Resets the animatable to its original state
  15198. */
  15199. reset(): void;
  15200. /**
  15201. * Allows the animatable to blend with current running animations
  15202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15203. * @param blendingSpeed defines the blending speed to use
  15204. */
  15205. enableBlending(blendingSpeed: number): void;
  15206. /**
  15207. * Disable animation blending
  15208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15209. */
  15210. disableBlending(): void;
  15211. /**
  15212. * Jump directly to a given frame
  15213. * @param frame defines the frame to jump to
  15214. */
  15215. goToFrame(frame: number): void;
  15216. /**
  15217. * Pause the animation
  15218. */
  15219. pause(): void;
  15220. /**
  15221. * Restart the animation
  15222. */
  15223. restart(): void;
  15224. private _raiseOnAnimationEnd;
  15225. /**
  15226. * Stop and delete the current animation
  15227. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15228. * @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)
  15229. */
  15230. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15231. /**
  15232. * Wait asynchronously for the animation to end
  15233. * @returns a promise which will be fullfilled when the animation ends
  15234. */
  15235. waitAsync(): Promise<Animatable>;
  15236. /** @hidden */
  15237. _animate(delay: number): boolean;
  15238. }
  15239. module "babylonjs/scene" {
  15240. interface Scene {
  15241. /** @hidden */
  15242. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15243. /** @hidden */
  15244. _processLateAnimationBindingsForMatrices(holder: {
  15245. totalWeight: number;
  15246. totalAdditiveWeight: number;
  15247. animations: RuntimeAnimation[];
  15248. additiveAnimations: RuntimeAnimation[];
  15249. originalValue: Matrix;
  15250. }): any;
  15251. /** @hidden */
  15252. _processLateAnimationBindingsForQuaternions(holder: {
  15253. totalWeight: number;
  15254. totalAdditiveWeight: number;
  15255. animations: RuntimeAnimation[];
  15256. additiveAnimations: RuntimeAnimation[];
  15257. originalValue: Quaternion;
  15258. }, refQuaternion: Quaternion): Quaternion;
  15259. /** @hidden */
  15260. _processLateAnimationBindings(): void;
  15261. /**
  15262. * Will start the animation sequence of a given target
  15263. * @param target defines the target
  15264. * @param from defines from which frame should animation start
  15265. * @param to defines until which frame should animation run.
  15266. * @param weight defines the weight to apply to the animation (1.0 by default)
  15267. * @param loop defines if the animation loops
  15268. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15269. * @param onAnimationEnd defines the function to be executed when the animation ends
  15270. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15271. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15272. * @param onAnimationLoop defines the callback to call when an animation loops
  15273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15274. * @returns the animatable object created for this animation
  15275. */
  15276. 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;
  15277. /**
  15278. * Will start the animation sequence of a given target
  15279. * @param target defines the target
  15280. * @param from defines from which frame should animation start
  15281. * @param to defines until which frame should animation run.
  15282. * @param loop defines if the animation loops
  15283. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15284. * @param onAnimationEnd defines the function to be executed when the animation ends
  15285. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15286. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15287. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15288. * @param onAnimationLoop defines the callback to call when an animation loops
  15289. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15290. * @returns the animatable object created for this animation
  15291. */
  15292. 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;
  15293. /**
  15294. * Will start the animation sequence of a given target and its hierarchy
  15295. * @param target defines the target
  15296. * @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.
  15297. * @param from defines from which frame should animation start
  15298. * @param to defines until which frame should animation run.
  15299. * @param loop defines if the animation loops
  15300. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15301. * @param onAnimationEnd defines the function to be executed when the animation ends
  15302. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15303. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15304. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15305. * @param onAnimationLoop defines the callback to call when an animation loops
  15306. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15307. * @returns the list of created animatables
  15308. */
  15309. 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[];
  15310. /**
  15311. * Begin a new animation on a given node
  15312. * @param target defines the target where the animation will take place
  15313. * @param animations defines the list of animations to start
  15314. * @param from defines the initial value
  15315. * @param to defines the final value
  15316. * @param loop defines if you want animation to loop (off by default)
  15317. * @param speedRatio defines the speed ratio to apply to all animations
  15318. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15319. * @param onAnimationLoop defines the callback to call when an animation loops
  15320. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15321. * @returns the list of created animatables
  15322. */
  15323. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15324. /**
  15325. * Begin a new animation on a given node and its hierarchy
  15326. * @param target defines the root node where the animation will take place
  15327. * @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.
  15328. * @param animations defines the list of animations to start
  15329. * @param from defines the initial value
  15330. * @param to defines the final value
  15331. * @param loop defines if you want animation to loop (off by default)
  15332. * @param speedRatio defines the speed ratio to apply to all animations
  15333. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15334. * @param onAnimationLoop defines the callback to call when an animation loops
  15335. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15336. * @returns the list of animatables created for all nodes
  15337. */
  15338. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15339. /**
  15340. * Gets the animatable associated with a specific target
  15341. * @param target defines the target of the animatable
  15342. * @returns the required animatable if found
  15343. */
  15344. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15345. /**
  15346. * Gets all animatables associated with a given target
  15347. * @param target defines the target to look animatables for
  15348. * @returns an array of Animatables
  15349. */
  15350. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15351. /**
  15352. * Stops and removes all animations that have been applied to the scene
  15353. */
  15354. stopAllAnimations(): void;
  15355. /**
  15356. * Gets the current delta time used by animation engine
  15357. */
  15358. deltaTime: number;
  15359. }
  15360. }
  15361. module "babylonjs/Bones/bone" {
  15362. interface Bone {
  15363. /**
  15364. * Copy an animation range from another bone
  15365. * @param source defines the source bone
  15366. * @param rangeName defines the range name to copy
  15367. * @param frameOffset defines the frame offset
  15368. * @param rescaleAsRequired defines if rescaling must be applied if required
  15369. * @param skelDimensionsRatio defines the scaling ratio
  15370. * @returns true if operation was successful
  15371. */
  15372. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15373. }
  15374. }
  15375. }
  15376. declare module "babylonjs/Bones/skeleton" {
  15377. import { Bone } from "babylonjs/Bones/bone";
  15378. import { Observable } from "babylonjs/Misc/observable";
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15380. import { Scene } from "babylonjs/scene";
  15381. import { Nullable } from "babylonjs/types";
  15382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15383. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15384. import { Animatable } from "babylonjs/Animations/animatable";
  15385. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15386. import { Animation } from "babylonjs/Animations/animation";
  15387. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15388. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15389. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15390. /**
  15391. * Class used to handle skinning animations
  15392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15393. */
  15394. export class Skeleton implements IAnimatable {
  15395. /** defines the skeleton name */
  15396. name: string;
  15397. /** defines the skeleton Id */
  15398. id: string;
  15399. /**
  15400. * Defines the list of child bones
  15401. */
  15402. bones: Bone[];
  15403. /**
  15404. * Defines an estimate of the dimension of the skeleton at rest
  15405. */
  15406. dimensionsAtRest: Vector3;
  15407. /**
  15408. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15409. */
  15410. needInitialSkinMatrix: boolean;
  15411. /**
  15412. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15413. */
  15414. overrideMesh: Nullable<AbstractMesh>;
  15415. /**
  15416. * Gets the list of animations attached to this skeleton
  15417. */
  15418. animations: Array<Animation>;
  15419. private _scene;
  15420. private _isDirty;
  15421. private _transformMatrices;
  15422. private _transformMatrixTexture;
  15423. private _meshesWithPoseMatrix;
  15424. private _animatables;
  15425. private _identity;
  15426. private _synchronizedWithMesh;
  15427. private _ranges;
  15428. private _lastAbsoluteTransformsUpdateId;
  15429. private _canUseTextureForBones;
  15430. private _uniqueId;
  15431. /** @hidden */
  15432. _numBonesWithLinkedTransformNode: number;
  15433. /** @hidden */
  15434. _hasWaitingData: Nullable<boolean>;
  15435. /**
  15436. * Specifies if the skeleton should be serialized
  15437. */
  15438. doNotSerialize: boolean;
  15439. private _useTextureToStoreBoneMatrices;
  15440. /**
  15441. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15442. * Please note that this option is not available if the hardware does not support it
  15443. */
  15444. get useTextureToStoreBoneMatrices(): boolean;
  15445. set useTextureToStoreBoneMatrices(value: boolean);
  15446. private _animationPropertiesOverride;
  15447. /**
  15448. * Gets or sets the animation properties override
  15449. */
  15450. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15451. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15452. /**
  15453. * List of inspectable custom properties (used by the Inspector)
  15454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15455. */
  15456. inspectableCustomProperties: IInspectable[];
  15457. /**
  15458. * An observable triggered before computing the skeleton's matrices
  15459. */
  15460. onBeforeComputeObservable: Observable<Skeleton>;
  15461. /**
  15462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15463. */
  15464. get isUsingTextureForMatrices(): boolean;
  15465. /**
  15466. * Gets the unique ID of this skeleton
  15467. */
  15468. get uniqueId(): number;
  15469. /**
  15470. * Creates a new skeleton
  15471. * @param name defines the skeleton name
  15472. * @param id defines the skeleton Id
  15473. * @param scene defines the hosting scene
  15474. */
  15475. constructor(
  15476. /** defines the skeleton name */
  15477. name: string,
  15478. /** defines the skeleton Id */
  15479. id: string, scene: Scene);
  15480. /**
  15481. * Gets the current object class name.
  15482. * @return the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Returns an array containing the root bones
  15487. * @returns an array containing the root bones
  15488. */
  15489. getChildren(): Array<Bone>;
  15490. /**
  15491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15493. * @returns a Float32Array containing matrices data
  15494. */
  15495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15496. /**
  15497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15499. * @returns a raw texture containing the data
  15500. */
  15501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15502. /**
  15503. * Gets the current hosting scene
  15504. * @returns a scene object
  15505. */
  15506. getScene(): Scene;
  15507. /**
  15508. * Gets a string representing the current skeleton data
  15509. * @param fullDetails defines a boolean indicating if we want a verbose version
  15510. * @returns a string representing the current skeleton data
  15511. */
  15512. toString(fullDetails?: boolean): string;
  15513. /**
  15514. * Get bone's index searching by name
  15515. * @param name defines bone's name to search for
  15516. * @return the indice of the bone. Returns -1 if not found
  15517. */
  15518. getBoneIndexByName(name: string): number;
  15519. /**
  15520. * Creater a new animation range
  15521. * @param name defines the name of the range
  15522. * @param from defines the start key
  15523. * @param to defines the end key
  15524. */
  15525. createAnimationRange(name: string, from: number, to: number): void;
  15526. /**
  15527. * Delete a specific animation range
  15528. * @param name defines the name of the range
  15529. * @param deleteFrames defines if frames must be removed as well
  15530. */
  15531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15532. /**
  15533. * Gets a specific animation range
  15534. * @param name defines the name of the range to look for
  15535. * @returns the requested animation range or null if not found
  15536. */
  15537. getAnimationRange(name: string): Nullable<AnimationRange>;
  15538. /**
  15539. * Gets the list of all animation ranges defined on this skeleton
  15540. * @returns an array
  15541. */
  15542. getAnimationRanges(): Nullable<AnimationRange>[];
  15543. /**
  15544. * Copy animation range from a source skeleton.
  15545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15546. * @param source defines the source skeleton
  15547. * @param name defines the name of the range to copy
  15548. * @param rescaleAsRequired defines if rescaling must be applied if required
  15549. * @returns true if operation was successful
  15550. */
  15551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15552. /**
  15553. * Forces the skeleton to go to rest pose
  15554. */
  15555. returnToRest(): void;
  15556. private _getHighestAnimationFrame;
  15557. /**
  15558. * Begin a specific animation range
  15559. * @param name defines the name of the range to start
  15560. * @param loop defines if looping must be turned on (false by default)
  15561. * @param speedRatio defines the speed ratio to apply (1 by default)
  15562. * @param onAnimationEnd defines a callback which will be called when animation will end
  15563. * @returns a new animatable
  15564. */
  15565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15566. /**
  15567. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15568. * @param skeleton defines the Skeleton containing the animation range to convert
  15569. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15570. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15571. * @returns the original skeleton
  15572. */
  15573. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15574. /** @hidden */
  15575. _markAsDirty(): void;
  15576. /** @hidden */
  15577. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15578. /** @hidden */
  15579. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15580. private _computeTransformMatrices;
  15581. /**
  15582. * Build all resources required to render a skeleton
  15583. */
  15584. prepare(): void;
  15585. /**
  15586. * Gets the list of animatables currently running for this skeleton
  15587. * @returns an array of animatables
  15588. */
  15589. getAnimatables(): IAnimatable[];
  15590. /**
  15591. * Clone the current skeleton
  15592. * @param name defines the name of the new skeleton
  15593. * @param id defines the id of the new skeleton
  15594. * @returns the new skeleton
  15595. */
  15596. clone(name: string, id?: string): Skeleton;
  15597. /**
  15598. * Enable animation blending for this skeleton
  15599. * @param blendingSpeed defines the blending speed to apply
  15600. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15601. */
  15602. enableBlending(blendingSpeed?: number): void;
  15603. /**
  15604. * Releases all resources associated with the current skeleton
  15605. */
  15606. dispose(): void;
  15607. /**
  15608. * Serialize the skeleton in a JSON object
  15609. * @returns a JSON object
  15610. */
  15611. serialize(): any;
  15612. /**
  15613. * Creates a new skeleton from serialized data
  15614. * @param parsedSkeleton defines the serialized data
  15615. * @param scene defines the hosting scene
  15616. * @returns a new skeleton
  15617. */
  15618. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15619. /**
  15620. * Compute all node absolute transforms
  15621. * @param forceUpdate defines if computation must be done even if cache is up to date
  15622. */
  15623. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15624. /**
  15625. * Gets the root pose matrix
  15626. * @returns a matrix
  15627. */
  15628. getPoseMatrix(): Nullable<Matrix>;
  15629. /**
  15630. * Sorts bones per internal index
  15631. */
  15632. sortBones(): void;
  15633. private _sortBones;
  15634. }
  15635. }
  15636. declare module "babylonjs/Meshes/instancedMesh" {
  15637. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15638. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15639. import { Camera } from "babylonjs/Cameras/camera";
  15640. import { Node } from "babylonjs/node";
  15641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15642. import { Mesh } from "babylonjs/Meshes/mesh";
  15643. import { Material } from "babylonjs/Materials/material";
  15644. import { Skeleton } from "babylonjs/Bones/skeleton";
  15645. import { Light } from "babylonjs/Lights/light";
  15646. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15647. /**
  15648. * Creates an instance based on a source mesh.
  15649. */
  15650. export class InstancedMesh extends AbstractMesh {
  15651. private _sourceMesh;
  15652. private _currentLOD;
  15653. /** @hidden */
  15654. _indexInSourceMeshInstanceArray: number;
  15655. constructor(name: string, source: Mesh);
  15656. /**
  15657. * Returns the string "InstancedMesh".
  15658. */
  15659. getClassName(): string;
  15660. /** Gets the list of lights affecting that mesh */
  15661. get lightSources(): Light[];
  15662. _resyncLightSources(): void;
  15663. _resyncLightSource(light: Light): void;
  15664. _removeLightSource(light: Light, dispose: boolean): void;
  15665. /**
  15666. * If the source mesh receives shadows
  15667. */
  15668. get receiveShadows(): boolean;
  15669. /**
  15670. * The material of the source mesh
  15671. */
  15672. get material(): Nullable<Material>;
  15673. /**
  15674. * Visibility of the source mesh
  15675. */
  15676. get visibility(): number;
  15677. /**
  15678. * Skeleton of the source mesh
  15679. */
  15680. get skeleton(): Nullable<Skeleton>;
  15681. /**
  15682. * Rendering ground id of the source mesh
  15683. */
  15684. get renderingGroupId(): number;
  15685. set renderingGroupId(value: number);
  15686. /**
  15687. * Returns the total number of vertices (integer).
  15688. */
  15689. getTotalVertices(): number;
  15690. /**
  15691. * Returns a positive integer : the total number of indices in this mesh geometry.
  15692. * @returns the numner of indices or zero if the mesh has no geometry.
  15693. */
  15694. getTotalIndices(): number;
  15695. /**
  15696. * The source mesh of the instance
  15697. */
  15698. get sourceMesh(): Mesh;
  15699. /**
  15700. * Is this node ready to be used/rendered
  15701. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15702. * @return {boolean} is it ready
  15703. */
  15704. isReady(completeCheck?: boolean): boolean;
  15705. /**
  15706. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15707. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15708. * @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.
  15709. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15710. */
  15711. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15712. /**
  15713. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15714. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15715. * The `data` are either a numeric array either a Float32Array.
  15716. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15717. * 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).
  15718. * Note that a new underlying VertexBuffer object is created each call.
  15719. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15720. *
  15721. * Possible `kind` values :
  15722. * - VertexBuffer.PositionKind
  15723. * - VertexBuffer.UVKind
  15724. * - VertexBuffer.UV2Kind
  15725. * - VertexBuffer.UV3Kind
  15726. * - VertexBuffer.UV4Kind
  15727. * - VertexBuffer.UV5Kind
  15728. * - VertexBuffer.UV6Kind
  15729. * - VertexBuffer.ColorKind
  15730. * - VertexBuffer.MatricesIndicesKind
  15731. * - VertexBuffer.MatricesIndicesExtraKind
  15732. * - VertexBuffer.MatricesWeightsKind
  15733. * - VertexBuffer.MatricesWeightsExtraKind
  15734. *
  15735. * Returns the Mesh.
  15736. */
  15737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15738. /**
  15739. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15740. * If the mesh has no geometry, it is simply returned as it is.
  15741. * The `data` are either a numeric array either a Float32Array.
  15742. * No new underlying VertexBuffer object is created.
  15743. * 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.
  15744. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15745. *
  15746. * Possible `kind` values :
  15747. * - VertexBuffer.PositionKind
  15748. * - VertexBuffer.UVKind
  15749. * - VertexBuffer.UV2Kind
  15750. * - VertexBuffer.UV3Kind
  15751. * - VertexBuffer.UV4Kind
  15752. * - VertexBuffer.UV5Kind
  15753. * - VertexBuffer.UV6Kind
  15754. * - VertexBuffer.ColorKind
  15755. * - VertexBuffer.MatricesIndicesKind
  15756. * - VertexBuffer.MatricesIndicesExtraKind
  15757. * - VertexBuffer.MatricesWeightsKind
  15758. * - VertexBuffer.MatricesWeightsExtraKind
  15759. *
  15760. * Returns the Mesh.
  15761. */
  15762. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15763. /**
  15764. * Sets the mesh indices.
  15765. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15766. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15767. * This method creates a new index buffer each call.
  15768. * Returns the Mesh.
  15769. */
  15770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15771. /**
  15772. * Boolean : True if the mesh owns the requested kind of data.
  15773. */
  15774. isVerticesDataPresent(kind: string): boolean;
  15775. /**
  15776. * Returns an array of indices (IndicesArray).
  15777. */
  15778. getIndices(): Nullable<IndicesArray>;
  15779. get _positions(): Nullable<Vector3[]>;
  15780. /**
  15781. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15782. * This means the mesh underlying bounding box and sphere are recomputed.
  15783. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15784. * @returns the current mesh
  15785. */
  15786. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15787. /** @hidden */
  15788. _preActivate(): InstancedMesh;
  15789. /** @hidden */
  15790. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15791. /** @hidden */
  15792. _postActivate(): void;
  15793. getWorldMatrix(): Matrix;
  15794. get isAnInstance(): boolean;
  15795. /**
  15796. * Returns the current associated LOD AbstractMesh.
  15797. */
  15798. getLOD(camera: Camera): AbstractMesh;
  15799. /** @hidden */
  15800. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15801. /** @hidden */
  15802. _syncSubMeshes(): InstancedMesh;
  15803. /** @hidden */
  15804. _generatePointsArray(): boolean;
  15805. /**
  15806. * Creates a new InstancedMesh from the current mesh.
  15807. * - name (string) : the cloned mesh name
  15808. * - newParent (optional Node) : the optional Node to parent the clone to.
  15809. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15810. *
  15811. * Returns the clone.
  15812. */
  15813. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15814. /**
  15815. * Disposes the InstancedMesh.
  15816. * Returns nothing.
  15817. */
  15818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15819. }
  15820. module "babylonjs/Meshes/mesh" {
  15821. interface Mesh {
  15822. /**
  15823. * Register a custom buffer that will be instanced
  15824. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15825. * @param kind defines the buffer kind
  15826. * @param stride defines the stride in floats
  15827. */
  15828. registerInstancedBuffer(kind: string, stride: number): void;
  15829. /** @hidden */
  15830. _userInstancedBuffersStorage: {
  15831. data: {
  15832. [key: string]: Float32Array;
  15833. };
  15834. sizes: {
  15835. [key: string]: number;
  15836. };
  15837. vertexBuffers: {
  15838. [key: string]: Nullable<VertexBuffer>;
  15839. };
  15840. strides: {
  15841. [key: string]: number;
  15842. };
  15843. };
  15844. }
  15845. }
  15846. module "babylonjs/Meshes/abstractMesh" {
  15847. interface AbstractMesh {
  15848. /**
  15849. * Object used to store instanced buffers defined by user
  15850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15851. */
  15852. instancedBuffers: {
  15853. [key: string]: any;
  15854. };
  15855. }
  15856. }
  15857. }
  15858. declare module "babylonjs/Materials/shaderMaterial" {
  15859. import { Nullable } from "babylonjs/types";
  15860. import { Scene } from "babylonjs/scene";
  15861. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15863. import { Mesh } from "babylonjs/Meshes/mesh";
  15864. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15866. import { Effect } from "babylonjs/Materials/effect";
  15867. import { Material } from "babylonjs/Materials/material";
  15868. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15869. /**
  15870. * Defines the options associated with the creation of a shader material.
  15871. */
  15872. export interface IShaderMaterialOptions {
  15873. /**
  15874. * Does the material work in alpha blend mode
  15875. */
  15876. needAlphaBlending: boolean;
  15877. /**
  15878. * Does the material work in alpha test mode
  15879. */
  15880. needAlphaTesting: boolean;
  15881. /**
  15882. * The list of attribute names used in the shader
  15883. */
  15884. attributes: string[];
  15885. /**
  15886. * The list of unifrom names used in the shader
  15887. */
  15888. uniforms: string[];
  15889. /**
  15890. * The list of UBO names used in the shader
  15891. */
  15892. uniformBuffers: string[];
  15893. /**
  15894. * The list of sampler names used in the shader
  15895. */
  15896. samplers: string[];
  15897. /**
  15898. * The list of defines used in the shader
  15899. */
  15900. defines: string[];
  15901. }
  15902. /**
  15903. * 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.
  15904. *
  15905. * This returned material effects how the mesh will look based on the code in the shaders.
  15906. *
  15907. * @see http://doc.babylonjs.com/how_to/shader_material
  15908. */
  15909. export class ShaderMaterial extends Material {
  15910. private _shaderPath;
  15911. private _options;
  15912. private _textures;
  15913. private _textureArrays;
  15914. private _floats;
  15915. private _ints;
  15916. private _floatsArrays;
  15917. private _colors3;
  15918. private _colors3Arrays;
  15919. private _colors4;
  15920. private _colors4Arrays;
  15921. private _vectors2;
  15922. private _vectors3;
  15923. private _vectors4;
  15924. private _matrices;
  15925. private _matrixArrays;
  15926. private _matrices3x3;
  15927. private _matrices2x2;
  15928. private _vectors2Arrays;
  15929. private _vectors3Arrays;
  15930. private _vectors4Arrays;
  15931. private _cachedWorldViewMatrix;
  15932. private _cachedWorldViewProjectionMatrix;
  15933. private _renderId;
  15934. private _multiview;
  15935. private _cachedDefines;
  15936. /**
  15937. * Instantiate a new shader material.
  15938. * 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.
  15939. * This returned material effects how the mesh will look based on the code in the shaders.
  15940. * @see http://doc.babylonjs.com/how_to/shader_material
  15941. * @param name Define the name of the material in the scene
  15942. * @param scene Define the scene the material belongs to
  15943. * @param shaderPath Defines the route to the shader code in one of three ways:
  15944. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15945. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15946. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15947. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15948. * @param options Define the options used to create the shader
  15949. */
  15950. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15951. /**
  15952. * Gets the shader path used to define the shader code
  15953. * It can be modified to trigger a new compilation
  15954. */
  15955. get shaderPath(): any;
  15956. /**
  15957. * Sets the shader path used to define the shader code
  15958. * It can be modified to trigger a new compilation
  15959. */
  15960. set shaderPath(shaderPath: any);
  15961. /**
  15962. * Gets the options used to compile the shader.
  15963. * They can be modified to trigger a new compilation
  15964. */
  15965. get options(): IShaderMaterialOptions;
  15966. /**
  15967. * Gets the current class name of the material e.g. "ShaderMaterial"
  15968. * Mainly use in serialization.
  15969. * @returns the class name
  15970. */
  15971. getClassName(): string;
  15972. /**
  15973. * Specifies if the material will require alpha blending
  15974. * @returns a boolean specifying if alpha blending is needed
  15975. */
  15976. needAlphaBlending(): boolean;
  15977. /**
  15978. * Specifies if this material should be rendered in alpha test mode
  15979. * @returns a boolean specifying if an alpha test is needed.
  15980. */
  15981. needAlphaTesting(): boolean;
  15982. private _checkUniform;
  15983. /**
  15984. * Set a texture in the shader.
  15985. * @param name Define the name of the uniform samplers as defined in the shader
  15986. * @param texture Define the texture to bind to this sampler
  15987. * @return the material itself allowing "fluent" like uniform updates
  15988. */
  15989. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15990. /**
  15991. * Set a texture array in the shader.
  15992. * @param name Define the name of the uniform sampler array as defined in the shader
  15993. * @param textures Define the list of textures to bind to this sampler
  15994. * @return the material itself allowing "fluent" like uniform updates
  15995. */
  15996. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15997. /**
  15998. * Set a float in the shader.
  15999. * @param name Define the name of the uniform as defined in the shader
  16000. * @param value Define the value to give to the uniform
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setFloat(name: string, value: number): ShaderMaterial;
  16004. /**
  16005. * Set a int in the shader.
  16006. * @param name Define the name of the uniform as defined in the shader
  16007. * @param value Define the value to give to the uniform
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setInt(name: string, value: number): ShaderMaterial;
  16011. /**
  16012. * Set an array of floats in the shader.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setFloats(name: string, value: number[]): ShaderMaterial;
  16018. /**
  16019. * Set a vec3 in the shader from a Color3.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setColor3(name: string, value: Color3): ShaderMaterial;
  16025. /**
  16026. * Set a vec3 array in the shader from a Color3 array.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec4 in the shader from a Color4.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setColor4(name: string, value: Color4): ShaderMaterial;
  16039. /**
  16040. * Set a vec4 array in the shader from a Color4 array.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16046. /**
  16047. * Set a vec2 in the shader from a Vector2.
  16048. * @param name Define the name of the uniform as defined in the shader
  16049. * @param value Define the value to give to the uniform
  16050. * @return the material itself allowing "fluent" like uniform updates
  16051. */
  16052. setVector2(name: string, value: Vector2): ShaderMaterial;
  16053. /**
  16054. * Set a vec3 in the shader from a Vector3.
  16055. * @param name Define the name of the uniform as defined in the shader
  16056. * @param value Define the value to give to the uniform
  16057. * @return the material itself allowing "fluent" like uniform updates
  16058. */
  16059. setVector3(name: string, value: Vector3): ShaderMaterial;
  16060. /**
  16061. * Set a vec4 in the shader from a Vector4.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the material itself allowing "fluent" like uniform updates
  16065. */
  16066. setVector4(name: string, value: Vector4): ShaderMaterial;
  16067. /**
  16068. * Set a mat4 in the shader from a Matrix.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the material itself allowing "fluent" like uniform updates
  16072. */
  16073. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16074. /**
  16075. * Set a float32Array in the shader from a matrix array.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the material itself allowing "fluent" like uniform updates
  16079. */
  16080. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16081. /**
  16082. * Set a mat3 in the shader from a Float32Array.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the material itself allowing "fluent" like uniform updates
  16086. */
  16087. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16088. /**
  16089. * Set a mat2 in the shader from a Float32Array.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the material itself allowing "fluent" like uniform updates
  16093. */
  16094. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16095. /**
  16096. * Set a vec2 array in the shader from a number array.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the material itself allowing "fluent" like uniform updates
  16100. */
  16101. setArray2(name: string, value: number[]): ShaderMaterial;
  16102. /**
  16103. * Set a vec3 array in the shader from a number array.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the material itself allowing "fluent" like uniform updates
  16107. */
  16108. setArray3(name: string, value: number[]): ShaderMaterial;
  16109. /**
  16110. * Set a vec4 array in the shader from a number array.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the material itself allowing "fluent" like uniform updates
  16114. */
  16115. setArray4(name: string, value: number[]): ShaderMaterial;
  16116. private _checkCache;
  16117. /**
  16118. * Specifies that the submesh is ready to be used
  16119. * @param mesh defines the mesh to check
  16120. * @param subMesh defines which submesh to check
  16121. * @param useInstances specifies that instances should be used
  16122. * @returns a boolean indicating that the submesh is ready or not
  16123. */
  16124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16125. /**
  16126. * Checks if the material is ready to render the requested mesh
  16127. * @param mesh Define the mesh to render
  16128. * @param useInstances Define whether or not the material is used with instances
  16129. * @returns true if ready, otherwise false
  16130. */
  16131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16132. /**
  16133. * Binds the world matrix to the material
  16134. * @param world defines the world transformation matrix
  16135. * @param effectOverride - If provided, use this effect instead of internal effect
  16136. */
  16137. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16138. /**
  16139. * Binds the submesh to this material by preparing the effect and shader to draw
  16140. * @param world defines the world transformation matrix
  16141. * @param mesh defines the mesh containing the submesh
  16142. * @param subMesh defines the submesh to bind the material to
  16143. */
  16144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16145. /**
  16146. * Binds the material to the mesh
  16147. * @param world defines the world transformation matrix
  16148. * @param mesh defines the mesh to bind the material to
  16149. * @param effectOverride - If provided, use this effect instead of internal effect
  16150. */
  16151. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16152. protected _afterBind(mesh?: Mesh): void;
  16153. /**
  16154. * Gets the active textures from the material
  16155. * @returns an array of textures
  16156. */
  16157. getActiveTextures(): BaseTexture[];
  16158. /**
  16159. * Specifies if the material uses a texture
  16160. * @param texture defines the texture to check against the material
  16161. * @returns a boolean specifying if the material uses the texture
  16162. */
  16163. hasTexture(texture: BaseTexture): boolean;
  16164. /**
  16165. * Makes a duplicate of the material, and gives it a new name
  16166. * @param name defines the new name for the duplicated material
  16167. * @returns the cloned material
  16168. */
  16169. clone(name: string): ShaderMaterial;
  16170. /**
  16171. * Disposes the material
  16172. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16173. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16174. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16175. */
  16176. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16177. /**
  16178. * Serializes this material in a JSON representation
  16179. * @returns the serialized material object
  16180. */
  16181. serialize(): any;
  16182. /**
  16183. * Creates a shader material from parsed shader material data
  16184. * @param source defines the JSON represnetation of the material
  16185. * @param scene defines the hosting scene
  16186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16187. * @returns a new material
  16188. */
  16189. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16190. }
  16191. }
  16192. declare module "babylonjs/Shaders/color.fragment" {
  16193. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16194. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16195. /** @hidden */
  16196. export var colorPixelShader: {
  16197. name: string;
  16198. shader: string;
  16199. };
  16200. }
  16201. declare module "babylonjs/Shaders/color.vertex" {
  16202. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16203. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16204. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16205. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16206. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16207. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16208. /** @hidden */
  16209. export var colorVertexShader: {
  16210. name: string;
  16211. shader: string;
  16212. };
  16213. }
  16214. declare module "babylonjs/Meshes/linesMesh" {
  16215. import { Nullable } from "babylonjs/types";
  16216. import { Scene } from "babylonjs/scene";
  16217. import { Color3 } from "babylonjs/Maths/math.color";
  16218. import { Node } from "babylonjs/node";
  16219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16220. import { Mesh } from "babylonjs/Meshes/mesh";
  16221. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16222. import { Effect } from "babylonjs/Materials/effect";
  16223. import { Material } from "babylonjs/Materials/material";
  16224. import "babylonjs/Shaders/color.fragment";
  16225. import "babylonjs/Shaders/color.vertex";
  16226. /**
  16227. * Line mesh
  16228. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16229. */
  16230. export class LinesMesh extends Mesh {
  16231. /**
  16232. * If vertex color should be applied to the mesh
  16233. */
  16234. readonly useVertexColor?: boolean | undefined;
  16235. /**
  16236. * If vertex alpha should be applied to the mesh
  16237. */
  16238. readonly useVertexAlpha?: boolean | undefined;
  16239. /**
  16240. * Color of the line (Default: White)
  16241. */
  16242. color: Color3;
  16243. /**
  16244. * Alpha of the line (Default: 1)
  16245. */
  16246. alpha: number;
  16247. /**
  16248. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16249. * This margin is expressed in world space coordinates, so its value may vary.
  16250. * Default value is 0.1
  16251. */
  16252. intersectionThreshold: number;
  16253. private _colorShader;
  16254. private color4;
  16255. /**
  16256. * Creates a new LinesMesh
  16257. * @param name defines the name
  16258. * @param scene defines the hosting scene
  16259. * @param parent defines the parent mesh if any
  16260. * @param source defines the optional source LinesMesh used to clone data from
  16261. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16262. * When false, achieved by calling a clone(), also passing False.
  16263. * This will make creation of children, recursive.
  16264. * @param useVertexColor defines if this LinesMesh supports vertex color
  16265. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16266. */
  16267. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16268. /**
  16269. * If vertex color should be applied to the mesh
  16270. */
  16271. useVertexColor?: boolean | undefined,
  16272. /**
  16273. * If vertex alpha should be applied to the mesh
  16274. */
  16275. useVertexAlpha?: boolean | undefined);
  16276. private _addClipPlaneDefine;
  16277. private _removeClipPlaneDefine;
  16278. isReady(): boolean;
  16279. /**
  16280. * Returns the string "LineMesh"
  16281. */
  16282. getClassName(): string;
  16283. /**
  16284. * @hidden
  16285. */
  16286. get material(): Material;
  16287. /**
  16288. * @hidden
  16289. */
  16290. set material(value: Material);
  16291. /**
  16292. * @hidden
  16293. */
  16294. get checkCollisions(): boolean;
  16295. /** @hidden */
  16296. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16297. /** @hidden */
  16298. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16299. /**
  16300. * Disposes of the line mesh
  16301. * @param doNotRecurse If children should be disposed
  16302. */
  16303. dispose(doNotRecurse?: boolean): void;
  16304. /**
  16305. * Returns a new LineMesh object cloned from the current one.
  16306. */
  16307. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16308. /**
  16309. * Creates a new InstancedLinesMesh object from the mesh model.
  16310. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16311. * @param name defines the name of the new instance
  16312. * @returns a new InstancedLinesMesh
  16313. */
  16314. createInstance(name: string): InstancedLinesMesh;
  16315. }
  16316. /**
  16317. * Creates an instance based on a source LinesMesh
  16318. */
  16319. export class InstancedLinesMesh extends InstancedMesh {
  16320. /**
  16321. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16322. * This margin is expressed in world space coordinates, so its value may vary.
  16323. * Initilized with the intersectionThreshold value of the source LinesMesh
  16324. */
  16325. intersectionThreshold: number;
  16326. constructor(name: string, source: LinesMesh);
  16327. /**
  16328. * Returns the string "InstancedLinesMesh".
  16329. */
  16330. getClassName(): string;
  16331. }
  16332. }
  16333. declare module "babylonjs/Shaders/line.fragment" {
  16334. /** @hidden */
  16335. export var linePixelShader: {
  16336. name: string;
  16337. shader: string;
  16338. };
  16339. }
  16340. declare module "babylonjs/Shaders/line.vertex" {
  16341. /** @hidden */
  16342. export var lineVertexShader: {
  16343. name: string;
  16344. shader: string;
  16345. };
  16346. }
  16347. declare module "babylonjs/Rendering/edgesRenderer" {
  16348. import { Nullable } from "babylonjs/types";
  16349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16351. import { Vector3 } from "babylonjs/Maths/math.vector";
  16352. import { IDisposable } from "babylonjs/scene";
  16353. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16354. import "babylonjs/Shaders/line.fragment";
  16355. import "babylonjs/Shaders/line.vertex";
  16356. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16357. module "babylonjs/Meshes/abstractMesh" {
  16358. interface AbstractMesh {
  16359. /**
  16360. * Gets the edgesRenderer associated with the mesh
  16361. */
  16362. edgesRenderer: Nullable<EdgesRenderer>;
  16363. }
  16364. }
  16365. module "babylonjs/Meshes/linesMesh" {
  16366. interface LinesMesh {
  16367. /**
  16368. * Enables the edge rendering mode on the mesh.
  16369. * This mode makes the mesh edges visible
  16370. * @param epsilon defines the maximal distance between two angles to detect a face
  16371. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16372. * @returns the currentAbstractMesh
  16373. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16374. */
  16375. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16376. }
  16377. }
  16378. module "babylonjs/Meshes/linesMesh" {
  16379. interface InstancedLinesMesh {
  16380. /**
  16381. * Enables the edge rendering mode on the mesh.
  16382. * This mode makes the mesh edges visible
  16383. * @param epsilon defines the maximal distance between two angles to detect a face
  16384. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16385. * @returns the current InstancedLinesMesh
  16386. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16387. */
  16388. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16389. }
  16390. }
  16391. /**
  16392. * Defines the minimum contract an Edges renderer should follow.
  16393. */
  16394. export interface IEdgesRenderer extends IDisposable {
  16395. /**
  16396. * Gets or sets a boolean indicating if the edgesRenderer is active
  16397. */
  16398. isEnabled: boolean;
  16399. /**
  16400. * Renders the edges of the attached mesh,
  16401. */
  16402. render(): void;
  16403. /**
  16404. * Checks wether or not the edges renderer is ready to render.
  16405. * @return true if ready, otherwise false.
  16406. */
  16407. isReady(): boolean;
  16408. }
  16409. /**
  16410. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16411. */
  16412. export class EdgesRenderer implements IEdgesRenderer {
  16413. /**
  16414. * Define the size of the edges with an orthographic camera
  16415. */
  16416. edgesWidthScalerForOrthographic: number;
  16417. /**
  16418. * Define the size of the edges with a perspective camera
  16419. */
  16420. edgesWidthScalerForPerspective: number;
  16421. protected _source: AbstractMesh;
  16422. protected _linesPositions: number[];
  16423. protected _linesNormals: number[];
  16424. protected _linesIndices: number[];
  16425. protected _epsilon: number;
  16426. protected _indicesCount: number;
  16427. protected _lineShader: ShaderMaterial;
  16428. protected _ib: DataBuffer;
  16429. protected _buffers: {
  16430. [key: string]: Nullable<VertexBuffer>;
  16431. };
  16432. protected _checkVerticesInsteadOfIndices: boolean;
  16433. private _meshRebuildObserver;
  16434. private _meshDisposeObserver;
  16435. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16436. isEnabled: boolean;
  16437. /**
  16438. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16439. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16440. * @param source Mesh used to create edges
  16441. * @param epsilon sum of angles in adjacency to check for edge
  16442. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16443. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16444. */
  16445. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16446. protected _prepareRessources(): void;
  16447. /** @hidden */
  16448. _rebuild(): void;
  16449. /**
  16450. * Releases the required resources for the edges renderer
  16451. */
  16452. dispose(): void;
  16453. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16454. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16455. /**
  16456. * Checks if the pair of p0 and p1 is en edge
  16457. * @param faceIndex
  16458. * @param edge
  16459. * @param faceNormals
  16460. * @param p0
  16461. * @param p1
  16462. * @private
  16463. */
  16464. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16465. /**
  16466. * push line into the position, normal and index buffer
  16467. * @protected
  16468. */
  16469. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16470. /**
  16471. * Generates lines edges from adjacencjes
  16472. * @private
  16473. */
  16474. _generateEdgesLines(): void;
  16475. /**
  16476. * Checks wether or not the edges renderer is ready to render.
  16477. * @return true if ready, otherwise false.
  16478. */
  16479. isReady(): boolean;
  16480. /**
  16481. * Renders the edges of the attached mesh,
  16482. */
  16483. render(): void;
  16484. }
  16485. /**
  16486. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16487. */
  16488. export class LineEdgesRenderer extends EdgesRenderer {
  16489. /**
  16490. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16491. * @param source LineMesh used to generate edges
  16492. * @param epsilon not important (specified angle for edge detection)
  16493. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16494. */
  16495. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16496. /**
  16497. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16498. */
  16499. _generateEdgesLines(): void;
  16500. }
  16501. }
  16502. declare module "babylonjs/Rendering/renderingGroup" {
  16503. import { SmartArray } from "babylonjs/Misc/smartArray";
  16504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16506. import { Nullable } from "babylonjs/types";
  16507. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16508. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16509. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16510. import { Material } from "babylonjs/Materials/material";
  16511. import { Scene } from "babylonjs/scene";
  16512. /**
  16513. * This represents the object necessary to create a rendering group.
  16514. * This is exclusively used and created by the rendering manager.
  16515. * To modify the behavior, you use the available helpers in your scene or meshes.
  16516. * @hidden
  16517. */
  16518. export class RenderingGroup {
  16519. index: number;
  16520. private static _zeroVector;
  16521. private _scene;
  16522. private _opaqueSubMeshes;
  16523. private _transparentSubMeshes;
  16524. private _alphaTestSubMeshes;
  16525. private _depthOnlySubMeshes;
  16526. private _particleSystems;
  16527. private _spriteManagers;
  16528. private _opaqueSortCompareFn;
  16529. private _alphaTestSortCompareFn;
  16530. private _transparentSortCompareFn;
  16531. private _renderOpaque;
  16532. private _renderAlphaTest;
  16533. private _renderTransparent;
  16534. /** @hidden */
  16535. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16536. onBeforeTransparentRendering: () => void;
  16537. /**
  16538. * Set the opaque sort comparison function.
  16539. * If null the sub meshes will be render in the order they were created
  16540. */
  16541. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16542. /**
  16543. * Set the alpha test sort comparison function.
  16544. * If null the sub meshes will be render in the order they were created
  16545. */
  16546. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16547. /**
  16548. * Set the transparent sort comparison function.
  16549. * If null the sub meshes will be render in the order they were created
  16550. */
  16551. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16552. /**
  16553. * Creates a new rendering group.
  16554. * @param index The rendering group index
  16555. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16556. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16557. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16558. */
  16559. 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>);
  16560. /**
  16561. * Render all the sub meshes contained in the group.
  16562. * @param customRenderFunction Used to override the default render behaviour of the group.
  16563. * @returns true if rendered some submeshes.
  16564. */
  16565. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16566. /**
  16567. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16568. * @param subMeshes The submeshes to render
  16569. */
  16570. private renderOpaqueSorted;
  16571. /**
  16572. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16573. * @param subMeshes The submeshes to render
  16574. */
  16575. private renderAlphaTestSorted;
  16576. /**
  16577. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16578. * @param subMeshes The submeshes to render
  16579. */
  16580. private renderTransparentSorted;
  16581. /**
  16582. * Renders the submeshes in a specified order.
  16583. * @param subMeshes The submeshes to sort before render
  16584. * @param sortCompareFn The comparison function use to sort
  16585. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16586. * @param transparent Specifies to activate blending if true
  16587. */
  16588. private static renderSorted;
  16589. /**
  16590. * Renders the submeshes in the order they were dispatched (no sort applied).
  16591. * @param subMeshes The submeshes to render
  16592. */
  16593. private static renderUnsorted;
  16594. /**
  16595. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16596. * are rendered back to front if in the same alpha index.
  16597. *
  16598. * @param a The first submesh
  16599. * @param b The second submesh
  16600. * @returns The result of the comparison
  16601. */
  16602. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16603. /**
  16604. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16605. * are rendered back to front.
  16606. *
  16607. * @param a The first submesh
  16608. * @param b The second submesh
  16609. * @returns The result of the comparison
  16610. */
  16611. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16612. /**
  16613. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16614. * are rendered front to back (prevent overdraw).
  16615. *
  16616. * @param a The first submesh
  16617. * @param b The second submesh
  16618. * @returns The result of the comparison
  16619. */
  16620. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16621. /**
  16622. * Resets the different lists of submeshes to prepare a new frame.
  16623. */
  16624. prepare(): void;
  16625. dispose(): void;
  16626. /**
  16627. * Inserts the submesh in its correct queue depending on its material.
  16628. * @param subMesh The submesh to dispatch
  16629. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16630. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16631. */
  16632. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16633. dispatchSprites(spriteManager: ISpriteManager): void;
  16634. dispatchParticles(particleSystem: IParticleSystem): void;
  16635. private _renderParticles;
  16636. private _renderSprites;
  16637. }
  16638. }
  16639. declare module "babylonjs/Rendering/renderingManager" {
  16640. import { Nullable } from "babylonjs/types";
  16641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16643. import { SmartArray } from "babylonjs/Misc/smartArray";
  16644. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16646. import { Material } from "babylonjs/Materials/material";
  16647. import { Scene } from "babylonjs/scene";
  16648. import { Camera } from "babylonjs/Cameras/camera";
  16649. /**
  16650. * Interface describing the different options available in the rendering manager
  16651. * regarding Auto Clear between groups.
  16652. */
  16653. export interface IRenderingManagerAutoClearSetup {
  16654. /**
  16655. * Defines whether or not autoclear is enable.
  16656. */
  16657. autoClear: boolean;
  16658. /**
  16659. * Defines whether or not to autoclear the depth buffer.
  16660. */
  16661. depth: boolean;
  16662. /**
  16663. * Defines whether or not to autoclear the stencil buffer.
  16664. */
  16665. stencil: boolean;
  16666. }
  16667. /**
  16668. * This class is used by the onRenderingGroupObservable
  16669. */
  16670. export class RenderingGroupInfo {
  16671. /**
  16672. * The Scene that being rendered
  16673. */
  16674. scene: Scene;
  16675. /**
  16676. * The camera currently used for the rendering pass
  16677. */
  16678. camera: Nullable<Camera>;
  16679. /**
  16680. * The ID of the renderingGroup being processed
  16681. */
  16682. renderingGroupId: number;
  16683. }
  16684. /**
  16685. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16686. * It is enable to manage the different groups as well as the different necessary sort functions.
  16687. * This should not be used directly aside of the few static configurations
  16688. */
  16689. export class RenderingManager {
  16690. /**
  16691. * The max id used for rendering groups (not included)
  16692. */
  16693. static MAX_RENDERINGGROUPS: number;
  16694. /**
  16695. * The min id used for rendering groups (included)
  16696. */
  16697. static MIN_RENDERINGGROUPS: number;
  16698. /**
  16699. * Used to globally prevent autoclearing scenes.
  16700. */
  16701. static AUTOCLEAR: boolean;
  16702. /**
  16703. * @hidden
  16704. */
  16705. _useSceneAutoClearSetup: boolean;
  16706. private _scene;
  16707. private _renderingGroups;
  16708. private _depthStencilBufferAlreadyCleaned;
  16709. private _autoClearDepthStencil;
  16710. private _customOpaqueSortCompareFn;
  16711. private _customAlphaTestSortCompareFn;
  16712. private _customTransparentSortCompareFn;
  16713. private _renderingGroupInfo;
  16714. /**
  16715. * Instantiates a new rendering group for a particular scene
  16716. * @param scene Defines the scene the groups belongs to
  16717. */
  16718. constructor(scene: Scene);
  16719. private _clearDepthStencilBuffer;
  16720. /**
  16721. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16722. * @hidden
  16723. */
  16724. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16725. /**
  16726. * Resets the different information of the group to prepare a new frame
  16727. * @hidden
  16728. */
  16729. reset(): void;
  16730. /**
  16731. * Dispose and release the group and its associated resources.
  16732. * @hidden
  16733. */
  16734. dispose(): void;
  16735. /**
  16736. * Clear the info related to rendering groups preventing retention points during dispose.
  16737. */
  16738. freeRenderingGroups(): void;
  16739. private _prepareRenderingGroup;
  16740. /**
  16741. * Add a sprite manager to the rendering manager in order to render it this frame.
  16742. * @param spriteManager Define the sprite manager to render
  16743. */
  16744. dispatchSprites(spriteManager: ISpriteManager): void;
  16745. /**
  16746. * Add a particle system to the rendering manager in order to render it this frame.
  16747. * @param particleSystem Define the particle system to render
  16748. */
  16749. dispatchParticles(particleSystem: IParticleSystem): void;
  16750. /**
  16751. * Add a submesh to the manager in order to render it this frame
  16752. * @param subMesh The submesh to dispatch
  16753. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16754. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16755. */
  16756. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16757. /**
  16758. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16759. * This allowed control for front to back rendering or reversly depending of the special needs.
  16760. *
  16761. * @param renderingGroupId The rendering group id corresponding to its index
  16762. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16763. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16764. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16765. */
  16766. 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;
  16767. /**
  16768. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16769. *
  16770. * @param renderingGroupId The rendering group id corresponding to its index
  16771. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16772. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16773. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16774. */
  16775. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16776. /**
  16777. * Gets the current auto clear configuration for one rendering group of the rendering
  16778. * manager.
  16779. * @param index the rendering group index to get the information for
  16780. * @returns The auto clear setup for the requested rendering group
  16781. */
  16782. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16783. }
  16784. }
  16785. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16786. import { SmartArray } from "babylonjs/Misc/smartArray";
  16787. import { Nullable } from "babylonjs/types";
  16788. import { Scene } from "babylonjs/scene";
  16789. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16792. import { Mesh } from "babylonjs/Meshes/mesh";
  16793. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16794. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16795. import { Effect } from "babylonjs/Materials/effect";
  16796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16798. import "babylonjs/Shaders/shadowMap.fragment";
  16799. import "babylonjs/Shaders/shadowMap.vertex";
  16800. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16801. import { Observable } from "babylonjs/Misc/observable";
  16802. /**
  16803. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16804. */
  16805. export interface ICustomShaderOptions {
  16806. /**
  16807. * Gets or sets the custom shader name to use
  16808. */
  16809. shaderName: string;
  16810. /**
  16811. * The list of attribute names used in the shader
  16812. */
  16813. attributes?: string[];
  16814. /**
  16815. * The list of unifrom names used in the shader
  16816. */
  16817. uniforms?: string[];
  16818. /**
  16819. * The list of sampler names used in the shader
  16820. */
  16821. samplers?: string[];
  16822. /**
  16823. * The list of defines used in the shader
  16824. */
  16825. defines?: string[];
  16826. }
  16827. /**
  16828. * Interface to implement to create a shadow generator compatible with BJS.
  16829. */
  16830. export interface IShadowGenerator {
  16831. /**
  16832. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16833. * @returns The render target texture if present otherwise, null
  16834. */
  16835. getShadowMap(): Nullable<RenderTargetTexture>;
  16836. /**
  16837. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16838. * @param subMesh The submesh we want to render in the shadow map
  16839. * @param useInstances Defines wether will draw in the map using instances
  16840. * @returns true if ready otherwise, false
  16841. */
  16842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16843. /**
  16844. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16845. * @param defines Defines of the material we want to update
  16846. * @param lightIndex Index of the light in the enabled light list of the material
  16847. */
  16848. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16849. /**
  16850. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16851. * defined in the generator but impacting the effect).
  16852. * It implies the unifroms available on the materials are the standard BJS ones.
  16853. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16854. * @param effect The effect we are binfing the information for
  16855. */
  16856. bindShadowLight(lightIndex: string, effect: Effect): void;
  16857. /**
  16858. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16859. * (eq to shadow prjection matrix * light transform matrix)
  16860. * @returns The transform matrix used to create the shadow map
  16861. */
  16862. getTransformMatrix(): Matrix;
  16863. /**
  16864. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16865. * Cube and 2D textures for instance.
  16866. */
  16867. recreateShadowMap(): void;
  16868. /**
  16869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16870. * @param onCompiled Callback triggered at the and of the effects compilation
  16871. * @param options Sets of optional options forcing the compilation with different modes
  16872. */
  16873. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16874. useInstances: boolean;
  16875. }>): void;
  16876. /**
  16877. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16878. * @param options Sets of optional options forcing the compilation with different modes
  16879. * @returns A promise that resolves when the compilation completes
  16880. */
  16881. forceCompilationAsync(options?: Partial<{
  16882. useInstances: boolean;
  16883. }>): Promise<void>;
  16884. /**
  16885. * Serializes the shadow generator setup to a json object.
  16886. * @returns The serialized JSON object
  16887. */
  16888. serialize(): any;
  16889. /**
  16890. * Disposes the Shadow map and related Textures and effects.
  16891. */
  16892. dispose(): void;
  16893. }
  16894. /**
  16895. * Default implementation IShadowGenerator.
  16896. * This is the main object responsible of generating shadows in the framework.
  16897. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16898. */
  16899. export class ShadowGenerator implements IShadowGenerator {
  16900. /**
  16901. * Name of the shadow generator class
  16902. */
  16903. static CLASSNAME: string;
  16904. /**
  16905. * Shadow generator mode None: no filtering applied.
  16906. */
  16907. static readonly FILTER_NONE: number;
  16908. /**
  16909. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16910. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16911. */
  16912. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16913. /**
  16914. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16915. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16916. */
  16917. static readonly FILTER_POISSONSAMPLING: number;
  16918. /**
  16919. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16920. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16921. */
  16922. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16923. /**
  16924. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16925. * edge artifacts on steep falloff.
  16926. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16927. */
  16928. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16929. /**
  16930. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16931. * edge artifacts on steep falloff.
  16932. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16933. */
  16934. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16935. /**
  16936. * Shadow generator mode PCF: Percentage Closer Filtering
  16937. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16938. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16939. */
  16940. static readonly FILTER_PCF: number;
  16941. /**
  16942. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16943. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16944. * Contact Hardening
  16945. */
  16946. static readonly FILTER_PCSS: number;
  16947. /**
  16948. * Reserved for PCF and PCSS
  16949. * Highest Quality.
  16950. *
  16951. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16952. *
  16953. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16954. */
  16955. static readonly QUALITY_HIGH: number;
  16956. /**
  16957. * Reserved for PCF and PCSS
  16958. * Good tradeoff for quality/perf cross devices
  16959. *
  16960. * Execute PCF on a 3*3 kernel.
  16961. *
  16962. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16963. */
  16964. static readonly QUALITY_MEDIUM: number;
  16965. /**
  16966. * Reserved for PCF and PCSS
  16967. * The lowest quality but the fastest.
  16968. *
  16969. * Execute PCF on a 1*1 kernel.
  16970. *
  16971. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16972. */
  16973. static readonly QUALITY_LOW: number;
  16974. /** Gets or sets the custom shader name to use */
  16975. customShaderOptions: ICustomShaderOptions;
  16976. /**
  16977. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16978. */
  16979. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16980. /**
  16981. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16982. */
  16983. onAfterShadowMapRenderObservable: Observable<Effect>;
  16984. /**
  16985. * Observable triggered before a mesh is rendered in the shadow map.
  16986. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16987. */
  16988. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16989. /**
  16990. * Observable triggered after a mesh is rendered in the shadow map.
  16991. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16992. */
  16993. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16994. protected _bias: number;
  16995. /**
  16996. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16997. */
  16998. get bias(): number;
  16999. /**
  17000. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17001. */
  17002. set bias(bias: number);
  17003. protected _normalBias: number;
  17004. /**
  17005. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17006. */
  17007. get normalBias(): number;
  17008. /**
  17009. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17010. */
  17011. set normalBias(normalBias: number);
  17012. protected _blurBoxOffset: number;
  17013. /**
  17014. * Gets the blur box offset: offset applied during the blur pass.
  17015. * Only useful if useKernelBlur = false
  17016. */
  17017. get blurBoxOffset(): number;
  17018. /**
  17019. * Sets the blur box offset: offset applied during the blur pass.
  17020. * Only useful if useKernelBlur = false
  17021. */
  17022. set blurBoxOffset(value: number);
  17023. protected _blurScale: number;
  17024. /**
  17025. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17026. * 2 means half of the size.
  17027. */
  17028. get blurScale(): number;
  17029. /**
  17030. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17031. * 2 means half of the size.
  17032. */
  17033. set blurScale(value: number);
  17034. protected _blurKernel: number;
  17035. /**
  17036. * Gets the blur kernel: kernel size of the blur pass.
  17037. * Only useful if useKernelBlur = true
  17038. */
  17039. get blurKernel(): number;
  17040. /**
  17041. * Sets the blur kernel: kernel size of the blur pass.
  17042. * Only useful if useKernelBlur = true
  17043. */
  17044. set blurKernel(value: number);
  17045. protected _useKernelBlur: boolean;
  17046. /**
  17047. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17048. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17049. */
  17050. get useKernelBlur(): boolean;
  17051. /**
  17052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17054. */
  17055. set useKernelBlur(value: boolean);
  17056. protected _depthScale: number;
  17057. /**
  17058. * Gets the depth scale used in ESM mode.
  17059. */
  17060. get depthScale(): number;
  17061. /**
  17062. * Sets the depth scale used in ESM mode.
  17063. * This can override the scale stored on the light.
  17064. */
  17065. set depthScale(value: number);
  17066. protected _validateFilter(filter: number): number;
  17067. protected _filter: number;
  17068. /**
  17069. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17071. */
  17072. get filter(): number;
  17073. /**
  17074. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17075. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17076. */
  17077. set filter(value: number);
  17078. /**
  17079. * Gets if the current filter is set to Poisson Sampling.
  17080. */
  17081. get usePoissonSampling(): boolean;
  17082. /**
  17083. * Sets the current filter to Poisson Sampling.
  17084. */
  17085. set usePoissonSampling(value: boolean);
  17086. /**
  17087. * Gets if the current filter is set to ESM.
  17088. */
  17089. get useExponentialShadowMap(): boolean;
  17090. /**
  17091. * Sets the current filter is to ESM.
  17092. */
  17093. set useExponentialShadowMap(value: boolean);
  17094. /**
  17095. * Gets if the current filter is set to filtered ESM.
  17096. */
  17097. get useBlurExponentialShadowMap(): boolean;
  17098. /**
  17099. * Gets if the current filter is set to filtered ESM.
  17100. */
  17101. set useBlurExponentialShadowMap(value: boolean);
  17102. /**
  17103. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17104. * exponential to prevent steep falloff artifacts).
  17105. */
  17106. get useCloseExponentialShadowMap(): boolean;
  17107. /**
  17108. * Sets the current filter to "close ESM" (using the inverse of the
  17109. * exponential to prevent steep falloff artifacts).
  17110. */
  17111. set useCloseExponentialShadowMap(value: boolean);
  17112. /**
  17113. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17114. * exponential to prevent steep falloff artifacts).
  17115. */
  17116. get useBlurCloseExponentialShadowMap(): boolean;
  17117. /**
  17118. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17119. * exponential to prevent steep falloff artifacts).
  17120. */
  17121. set useBlurCloseExponentialShadowMap(value: boolean);
  17122. /**
  17123. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17124. */
  17125. get usePercentageCloserFiltering(): boolean;
  17126. /**
  17127. * Sets the current filter to "PCF" (percentage closer filtering).
  17128. */
  17129. set usePercentageCloserFiltering(value: boolean);
  17130. protected _filteringQuality: number;
  17131. /**
  17132. * Gets the PCF or PCSS Quality.
  17133. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17134. */
  17135. get filteringQuality(): number;
  17136. /**
  17137. * Sets the PCF or PCSS Quality.
  17138. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17139. */
  17140. set filteringQuality(filteringQuality: number);
  17141. /**
  17142. * Gets if the current filter is set to "PCSS" (contact hardening).
  17143. */
  17144. get useContactHardeningShadow(): boolean;
  17145. /**
  17146. * Sets the current filter to "PCSS" (contact hardening).
  17147. */
  17148. set useContactHardeningShadow(value: boolean);
  17149. protected _contactHardeningLightSizeUVRatio: number;
  17150. /**
  17151. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17152. * Using a ratio helps keeping shape stability independently of the map size.
  17153. *
  17154. * It does not account for the light projection as it was having too much
  17155. * instability during the light setup or during light position changes.
  17156. *
  17157. * Only valid if useContactHardeningShadow is true.
  17158. */
  17159. get contactHardeningLightSizeUVRatio(): number;
  17160. /**
  17161. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17162. * Using a ratio helps keeping shape stability independently of the map size.
  17163. *
  17164. * It does not account for the light projection as it was having too much
  17165. * instability during the light setup or during light position changes.
  17166. *
  17167. * Only valid if useContactHardeningShadow is true.
  17168. */
  17169. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17170. protected _darkness: number;
  17171. /** Gets or sets the actual darkness of a shadow */
  17172. get darkness(): number;
  17173. set darkness(value: number);
  17174. /**
  17175. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17176. * 0 means strongest and 1 would means no shadow.
  17177. * @returns the darkness.
  17178. */
  17179. getDarkness(): number;
  17180. /**
  17181. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17182. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17183. * @returns the shadow generator allowing fluent coding.
  17184. */
  17185. setDarkness(darkness: number): ShadowGenerator;
  17186. protected _transparencyShadow: boolean;
  17187. /** Gets or sets the ability to have transparent shadow */
  17188. get transparencyShadow(): boolean;
  17189. set transparencyShadow(value: boolean);
  17190. /**
  17191. * Sets the ability to have transparent shadow (boolean).
  17192. * @param transparent True if transparent else False
  17193. * @returns the shadow generator allowing fluent coding
  17194. */
  17195. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17196. protected _shadowMap: Nullable<RenderTargetTexture>;
  17197. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17198. /**
  17199. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17200. * @returns The render target texture if present otherwise, null
  17201. */
  17202. getShadowMap(): Nullable<RenderTargetTexture>;
  17203. /**
  17204. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17205. * @returns The render target texture if the shadow map is present otherwise, null
  17206. */
  17207. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17208. /**
  17209. * Gets the class name of that object
  17210. * @returns "ShadowGenerator"
  17211. */
  17212. getClassName(): string;
  17213. /**
  17214. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17215. * @param mesh Mesh to add
  17216. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17217. * @returns the Shadow Generator itself
  17218. */
  17219. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17220. /**
  17221. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17222. * @param mesh Mesh to remove
  17223. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17224. * @returns the Shadow Generator itself
  17225. */
  17226. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17227. /**
  17228. * Controls the extent to which the shadows fade out at the edge of the frustum
  17229. */
  17230. frustumEdgeFalloff: number;
  17231. protected _light: IShadowLight;
  17232. /**
  17233. * Returns the associated light object.
  17234. * @returns the light generating the shadow
  17235. */
  17236. getLight(): IShadowLight;
  17237. /**
  17238. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17239. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17240. * It might on the other hand introduce peter panning.
  17241. */
  17242. forceBackFacesOnly: boolean;
  17243. protected _scene: Scene;
  17244. protected _lightDirection: Vector3;
  17245. protected _effect: Effect;
  17246. protected _viewMatrix: Matrix;
  17247. protected _projectionMatrix: Matrix;
  17248. protected _transformMatrix: Matrix;
  17249. protected _cachedPosition: Vector3;
  17250. protected _cachedDirection: Vector3;
  17251. protected _cachedDefines: string;
  17252. protected _currentRenderID: number;
  17253. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17254. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17255. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17256. protected _blurPostProcesses: PostProcess[];
  17257. protected _mapSize: number;
  17258. protected _currentFaceIndex: number;
  17259. protected _currentFaceIndexCache: number;
  17260. protected _textureType: number;
  17261. protected _defaultTextureMatrix: Matrix;
  17262. protected _storedUniqueId: Nullable<number>;
  17263. /** @hidden */
  17264. static _SceneComponentInitialization: (scene: Scene) => void;
  17265. /**
  17266. * Creates a ShadowGenerator object.
  17267. * A ShadowGenerator is the required tool to use the shadows.
  17268. * Each light casting shadows needs to use its own ShadowGenerator.
  17269. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17270. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17271. * @param light The light object generating the shadows.
  17272. * @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.
  17273. */
  17274. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17275. protected _initializeGenerator(): void;
  17276. protected _createTargetRenderTexture(): void;
  17277. protected _initializeShadowMap(): void;
  17278. protected _initializeBlurRTTAndPostProcesses(): void;
  17279. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17280. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17281. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17282. protected _applyFilterValues(): void;
  17283. /**
  17284. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17285. * @param onCompiled Callback triggered at the and of the effects compilation
  17286. * @param options Sets of optional options forcing the compilation with different modes
  17287. */
  17288. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17289. useInstances: boolean;
  17290. }>): void;
  17291. /**
  17292. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17293. * @param options Sets of optional options forcing the compilation with different modes
  17294. * @returns A promise that resolves when the compilation completes
  17295. */
  17296. forceCompilationAsync(options?: Partial<{
  17297. useInstances: boolean;
  17298. }>): Promise<void>;
  17299. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17300. private _prepareShadowDefines;
  17301. /**
  17302. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17303. * @param subMesh The submesh we want to render in the shadow map
  17304. * @param useInstances Defines wether will draw in the map using instances
  17305. * @returns true if ready otherwise, false
  17306. */
  17307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17308. /**
  17309. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17310. * @param defines Defines of the material we want to update
  17311. * @param lightIndex Index of the light in the enabled light list of the material
  17312. */
  17313. prepareDefines(defines: any, lightIndex: number): void;
  17314. /**
  17315. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17316. * defined in the generator but impacting the effect).
  17317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17318. * @param effect The effect we are binfing the information for
  17319. */
  17320. bindShadowLight(lightIndex: string, effect: Effect): void;
  17321. /**
  17322. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17323. * (eq to shadow prjection matrix * light transform matrix)
  17324. * @returns The transform matrix used to create the shadow map
  17325. */
  17326. getTransformMatrix(): Matrix;
  17327. /**
  17328. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17329. * Cube and 2D textures for instance.
  17330. */
  17331. recreateShadowMap(): void;
  17332. protected _disposeBlurPostProcesses(): void;
  17333. protected _disposeRTTandPostProcesses(): void;
  17334. /**
  17335. * Disposes the ShadowGenerator.
  17336. * Returns nothing.
  17337. */
  17338. dispose(): void;
  17339. /**
  17340. * Serializes the shadow generator setup to a json object.
  17341. * @returns The serialized JSON object
  17342. */
  17343. serialize(): any;
  17344. /**
  17345. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17346. * @param parsedShadowGenerator The JSON object to parse
  17347. * @param scene The scene to create the shadow map for
  17348. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17349. * @returns The parsed shadow generator
  17350. */
  17351. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17352. }
  17353. }
  17354. declare module "babylonjs/Lights/light" {
  17355. import { Nullable } from "babylonjs/types";
  17356. import { Scene } from "babylonjs/scene";
  17357. import { Vector3 } from "babylonjs/Maths/math.vector";
  17358. import { Color3 } from "babylonjs/Maths/math.color";
  17359. import { Node } from "babylonjs/node";
  17360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17361. import { Effect } from "babylonjs/Materials/effect";
  17362. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17363. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17364. /**
  17365. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17366. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17367. * 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.
  17368. */
  17369. export abstract class Light extends Node {
  17370. /**
  17371. * Falloff Default: light is falling off following the material specification:
  17372. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17373. */
  17374. static readonly FALLOFF_DEFAULT: number;
  17375. /**
  17376. * Falloff Physical: light is falling off following the inverse squared distance law.
  17377. */
  17378. static readonly FALLOFF_PHYSICAL: number;
  17379. /**
  17380. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17381. * to enhance interoperability with other engines.
  17382. */
  17383. static readonly FALLOFF_GLTF: number;
  17384. /**
  17385. * Falloff Standard: light is falling off like in the standard material
  17386. * to enhance interoperability with other materials.
  17387. */
  17388. static readonly FALLOFF_STANDARD: number;
  17389. /**
  17390. * If every light affecting the material is in this lightmapMode,
  17391. * material.lightmapTexture adds or multiplies
  17392. * (depends on material.useLightmapAsShadowmap)
  17393. * after every other light calculations.
  17394. */
  17395. static readonly LIGHTMAP_DEFAULT: number;
  17396. /**
  17397. * material.lightmapTexture as only diffuse lighting from this light
  17398. * adds only specular lighting from this light
  17399. * adds dynamic shadows
  17400. */
  17401. static readonly LIGHTMAP_SPECULAR: number;
  17402. /**
  17403. * material.lightmapTexture as only lighting
  17404. * no light calculation from this light
  17405. * only adds dynamic shadows from this light
  17406. */
  17407. static readonly LIGHTMAP_SHADOWSONLY: number;
  17408. /**
  17409. * Each light type uses the default quantity according to its type:
  17410. * point/spot lights use luminous intensity
  17411. * directional lights use illuminance
  17412. */
  17413. static readonly INTENSITYMODE_AUTOMATIC: number;
  17414. /**
  17415. * lumen (lm)
  17416. */
  17417. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17418. /**
  17419. * candela (lm/sr)
  17420. */
  17421. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17422. /**
  17423. * lux (lm/m^2)
  17424. */
  17425. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17426. /**
  17427. * nit (cd/m^2)
  17428. */
  17429. static readonly INTENSITYMODE_LUMINANCE: number;
  17430. /**
  17431. * Light type const id of the point light.
  17432. */
  17433. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17434. /**
  17435. * Light type const id of the directional light.
  17436. */
  17437. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17438. /**
  17439. * Light type const id of the spot light.
  17440. */
  17441. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17442. /**
  17443. * Light type const id of the hemispheric light.
  17444. */
  17445. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17446. /**
  17447. * Diffuse gives the basic color to an object.
  17448. */
  17449. diffuse: Color3;
  17450. /**
  17451. * Specular produces a highlight color on an object.
  17452. * Note: This is note affecting PBR materials.
  17453. */
  17454. specular: Color3;
  17455. /**
  17456. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17457. * falling off base on range or angle.
  17458. * This can be set to any values in Light.FALLOFF_x.
  17459. *
  17460. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17461. * other types of materials.
  17462. */
  17463. falloffType: number;
  17464. /**
  17465. * Strength of the light.
  17466. * Note: By default it is define in the framework own unit.
  17467. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17468. */
  17469. intensity: number;
  17470. private _range;
  17471. protected _inverseSquaredRange: number;
  17472. /**
  17473. * Defines how far from the source the light is impacting in scene units.
  17474. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17475. */
  17476. get range(): number;
  17477. /**
  17478. * Defines how far from the source the light is impacting in scene units.
  17479. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17480. */
  17481. set range(value: number);
  17482. /**
  17483. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17484. * of light.
  17485. */
  17486. private _photometricScale;
  17487. private _intensityMode;
  17488. /**
  17489. * Gets the photometric scale used to interpret the intensity.
  17490. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17491. */
  17492. get intensityMode(): number;
  17493. /**
  17494. * Sets the photometric scale used to interpret the intensity.
  17495. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17496. */
  17497. set intensityMode(value: number);
  17498. private _radius;
  17499. /**
  17500. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17501. */
  17502. get radius(): number;
  17503. /**
  17504. * sets the light radius used by PBR Materials to simulate soft area lights.
  17505. */
  17506. set radius(value: number);
  17507. private _renderPriority;
  17508. /**
  17509. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17510. * exceeding the number allowed of the materials.
  17511. */
  17512. renderPriority: number;
  17513. private _shadowEnabled;
  17514. /**
  17515. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17516. * the current shadow generator.
  17517. */
  17518. get shadowEnabled(): boolean;
  17519. /**
  17520. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17521. * the current shadow generator.
  17522. */
  17523. set shadowEnabled(value: boolean);
  17524. private _includedOnlyMeshes;
  17525. /**
  17526. * Gets the only meshes impacted by this light.
  17527. */
  17528. get includedOnlyMeshes(): AbstractMesh[];
  17529. /**
  17530. * Sets the only meshes impacted by this light.
  17531. */
  17532. set includedOnlyMeshes(value: AbstractMesh[]);
  17533. private _excludedMeshes;
  17534. /**
  17535. * Gets the meshes not impacted by this light.
  17536. */
  17537. get excludedMeshes(): AbstractMesh[];
  17538. /**
  17539. * Sets the meshes not impacted by this light.
  17540. */
  17541. set excludedMeshes(value: AbstractMesh[]);
  17542. private _excludeWithLayerMask;
  17543. /**
  17544. * Gets the layer id use to find what meshes are not impacted by the light.
  17545. * Inactive if 0
  17546. */
  17547. get excludeWithLayerMask(): number;
  17548. /**
  17549. * Sets the layer id use to find what meshes are not impacted by the light.
  17550. * Inactive if 0
  17551. */
  17552. set excludeWithLayerMask(value: number);
  17553. private _includeOnlyWithLayerMask;
  17554. /**
  17555. * Gets the layer id use to find what meshes are impacted by the light.
  17556. * Inactive if 0
  17557. */
  17558. get includeOnlyWithLayerMask(): number;
  17559. /**
  17560. * Sets the layer id use to find what meshes are impacted by the light.
  17561. * Inactive if 0
  17562. */
  17563. set includeOnlyWithLayerMask(value: number);
  17564. private _lightmapMode;
  17565. /**
  17566. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17567. */
  17568. get lightmapMode(): number;
  17569. /**
  17570. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17571. */
  17572. set lightmapMode(value: number);
  17573. /**
  17574. * Shadow generator associted to the light.
  17575. * @hidden Internal use only.
  17576. */
  17577. _shadowGenerator: Nullable<IShadowGenerator>;
  17578. /**
  17579. * @hidden Internal use only.
  17580. */
  17581. _excludedMeshesIds: string[];
  17582. /**
  17583. * @hidden Internal use only.
  17584. */
  17585. _includedOnlyMeshesIds: string[];
  17586. /**
  17587. * The current light unifom buffer.
  17588. * @hidden Internal use only.
  17589. */
  17590. _uniformBuffer: UniformBuffer;
  17591. /** @hidden */
  17592. _renderId: number;
  17593. /**
  17594. * Creates a Light object in the scene.
  17595. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17596. * @param name The firendly name of the light
  17597. * @param scene The scene the light belongs too
  17598. */
  17599. constructor(name: string, scene: Scene);
  17600. protected abstract _buildUniformLayout(): void;
  17601. /**
  17602. * Sets the passed Effect "effect" with the Light information.
  17603. * @param effect The effect to update
  17604. * @param lightIndex The index of the light in the effect to update
  17605. * @returns The light
  17606. */
  17607. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17608. /**
  17609. * Sets the passed Effect "effect" with the Light textures.
  17610. * @param effect The effect to update
  17611. * @param lightIndex The index of the light in the effect to update
  17612. * @returns The light
  17613. */
  17614. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17615. /**
  17616. * Binds the lights information from the scene to the effect for the given mesh.
  17617. * @param lightIndex Light index
  17618. * @param scene The scene where the light belongs to
  17619. * @param effect The effect we are binding the data to
  17620. * @param useSpecular Defines if specular is supported
  17621. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17622. */
  17623. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17624. /**
  17625. * Sets the passed Effect "effect" with the Light information.
  17626. * @param effect The effect to update
  17627. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17628. * @returns The light
  17629. */
  17630. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17631. /**
  17632. * Returns the string "Light".
  17633. * @returns the class name
  17634. */
  17635. getClassName(): string;
  17636. /** @hidden */
  17637. readonly _isLight: boolean;
  17638. /**
  17639. * Converts the light information to a readable string for debug purpose.
  17640. * @param fullDetails Supports for multiple levels of logging within scene loading
  17641. * @returns the human readable light info
  17642. */
  17643. toString(fullDetails?: boolean): string;
  17644. /** @hidden */
  17645. protected _syncParentEnabledState(): void;
  17646. /**
  17647. * Set the enabled state of this node.
  17648. * @param value - the new enabled state
  17649. */
  17650. setEnabled(value: boolean): void;
  17651. /**
  17652. * Returns the Light associated shadow generator if any.
  17653. * @return the associated shadow generator.
  17654. */
  17655. getShadowGenerator(): Nullable<IShadowGenerator>;
  17656. /**
  17657. * Returns a Vector3, the absolute light position in the World.
  17658. * @returns the world space position of the light
  17659. */
  17660. getAbsolutePosition(): Vector3;
  17661. /**
  17662. * Specifies if the light will affect the passed mesh.
  17663. * @param mesh The mesh to test against the light
  17664. * @return true the mesh is affected otherwise, false.
  17665. */
  17666. canAffectMesh(mesh: AbstractMesh): boolean;
  17667. /**
  17668. * Sort function to order lights for rendering.
  17669. * @param a First Light object to compare to second.
  17670. * @param b Second Light object to compare first.
  17671. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17672. */
  17673. static CompareLightsPriority(a: Light, b: Light): number;
  17674. /**
  17675. * Releases resources associated with this node.
  17676. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17677. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17678. */
  17679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17680. /**
  17681. * Returns the light type ID (integer).
  17682. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17683. */
  17684. getTypeID(): number;
  17685. /**
  17686. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17687. * @returns the scaled intensity in intensity mode unit
  17688. */
  17689. getScaledIntensity(): number;
  17690. /**
  17691. * Returns a new Light object, named "name", from the current one.
  17692. * @param name The name of the cloned light
  17693. * @returns the new created light
  17694. */
  17695. clone(name: string): Nullable<Light>;
  17696. /**
  17697. * Serializes the current light into a Serialization object.
  17698. * @returns the serialized object.
  17699. */
  17700. serialize(): any;
  17701. /**
  17702. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17703. * This new light is named "name" and added to the passed scene.
  17704. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17705. * @param name The friendly name of the light
  17706. * @param scene The scene the new light will belong to
  17707. * @returns the constructor function
  17708. */
  17709. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17710. /**
  17711. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17712. * @param parsedLight The JSON representation of the light
  17713. * @param scene The scene to create the parsed light in
  17714. * @returns the created light after parsing
  17715. */
  17716. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17717. private _hookArrayForExcluded;
  17718. private _hookArrayForIncludedOnly;
  17719. private _resyncMeshes;
  17720. /**
  17721. * Forces the meshes to update their light related information in their rendering used effects
  17722. * @hidden Internal Use Only
  17723. */
  17724. _markMeshesAsLightDirty(): void;
  17725. /**
  17726. * Recomputes the cached photometric scale if needed.
  17727. */
  17728. private _computePhotometricScale;
  17729. /**
  17730. * Returns the Photometric Scale according to the light type and intensity mode.
  17731. */
  17732. private _getPhotometricScale;
  17733. /**
  17734. * Reorder the light in the scene according to their defined priority.
  17735. * @hidden Internal Use Only
  17736. */
  17737. _reorderLightsInScene(): void;
  17738. /**
  17739. * Prepares the list of defines specific to the light type.
  17740. * @param defines the list of defines
  17741. * @param lightIndex defines the index of the light for the effect
  17742. */
  17743. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17744. }
  17745. }
  17746. declare module "babylonjs/Actions/action" {
  17747. import { Observable } from "babylonjs/Misc/observable";
  17748. import { Condition } from "babylonjs/Actions/condition";
  17749. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17750. import { ActionManager } from "babylonjs/Actions/actionManager";
  17751. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17752. /**
  17753. * Interface used to define Action
  17754. */
  17755. export interface IAction {
  17756. /**
  17757. * Trigger for the action
  17758. */
  17759. trigger: number;
  17760. /** Options of the trigger */
  17761. triggerOptions: any;
  17762. /**
  17763. * Gets the trigger parameters
  17764. * @returns the trigger parameters
  17765. */
  17766. getTriggerParameter(): any;
  17767. /**
  17768. * Internal only - executes current action event
  17769. * @hidden
  17770. */
  17771. _executeCurrent(evt?: ActionEvent): void;
  17772. /**
  17773. * Serialize placeholder for child classes
  17774. * @param parent of child
  17775. * @returns the serialized object
  17776. */
  17777. serialize(parent: any): any;
  17778. /**
  17779. * Internal only
  17780. * @hidden
  17781. */
  17782. _prepare(): void;
  17783. /**
  17784. * Internal only - manager for action
  17785. * @hidden
  17786. */
  17787. _actionManager: AbstractActionManager;
  17788. /**
  17789. * Adds action to chain of actions, may be a DoNothingAction
  17790. * @param action defines the next action to execute
  17791. * @returns The action passed in
  17792. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17793. */
  17794. then(action: IAction): IAction;
  17795. }
  17796. /**
  17797. * The action to be carried out following a trigger
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17799. */
  17800. export class Action implements IAction {
  17801. /** the trigger, with or without parameters, for the action */
  17802. triggerOptions: any;
  17803. /**
  17804. * Trigger for the action
  17805. */
  17806. trigger: number;
  17807. /**
  17808. * Internal only - manager for action
  17809. * @hidden
  17810. */
  17811. _actionManager: ActionManager;
  17812. private _nextActiveAction;
  17813. private _child;
  17814. private _condition?;
  17815. private _triggerParameter;
  17816. /**
  17817. * An event triggered prior to action being executed.
  17818. */
  17819. onBeforeExecuteObservable: Observable<Action>;
  17820. /**
  17821. * Creates a new Action
  17822. * @param triggerOptions the trigger, with or without parameters, for the action
  17823. * @param condition an optional determinant of action
  17824. */
  17825. constructor(
  17826. /** the trigger, with or without parameters, for the action */
  17827. triggerOptions: any, condition?: Condition);
  17828. /**
  17829. * Internal only
  17830. * @hidden
  17831. */
  17832. _prepare(): void;
  17833. /**
  17834. * Gets the trigger parameters
  17835. * @returns the trigger parameters
  17836. */
  17837. getTriggerParameter(): any;
  17838. /**
  17839. * Internal only - executes current action event
  17840. * @hidden
  17841. */
  17842. _executeCurrent(evt?: ActionEvent): void;
  17843. /**
  17844. * Execute placeholder for child classes
  17845. * @param evt optional action event
  17846. */
  17847. execute(evt?: ActionEvent): void;
  17848. /**
  17849. * Skips to next active action
  17850. */
  17851. skipToNextActiveAction(): void;
  17852. /**
  17853. * Adds action to chain of actions, may be a DoNothingAction
  17854. * @param action defines the next action to execute
  17855. * @returns The action passed in
  17856. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17857. */
  17858. then(action: Action): Action;
  17859. /**
  17860. * Internal only
  17861. * @hidden
  17862. */
  17863. _getProperty(propertyPath: string): string;
  17864. /**
  17865. * Internal only
  17866. * @hidden
  17867. */
  17868. _getEffectiveTarget(target: any, propertyPath: string): any;
  17869. /**
  17870. * Serialize placeholder for child classes
  17871. * @param parent of child
  17872. * @returns the serialized object
  17873. */
  17874. serialize(parent: any): any;
  17875. /**
  17876. * Internal only called by serialize
  17877. * @hidden
  17878. */
  17879. protected _serialize(serializedAction: any, parent?: any): any;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. static _SerializeValueAsString: (value: any) => string;
  17885. /**
  17886. * Internal only
  17887. * @hidden
  17888. */
  17889. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17890. name: string;
  17891. targetType: string;
  17892. value: string;
  17893. };
  17894. }
  17895. }
  17896. declare module "babylonjs/Actions/condition" {
  17897. import { ActionManager } from "babylonjs/Actions/actionManager";
  17898. /**
  17899. * A Condition applied to an Action
  17900. */
  17901. export class Condition {
  17902. /**
  17903. * Internal only - manager for action
  17904. * @hidden
  17905. */
  17906. _actionManager: ActionManager;
  17907. /**
  17908. * Internal only
  17909. * @hidden
  17910. */
  17911. _evaluationId: number;
  17912. /**
  17913. * Internal only
  17914. * @hidden
  17915. */
  17916. _currentResult: boolean;
  17917. /**
  17918. * Creates a new Condition
  17919. * @param actionManager the manager of the action the condition is applied to
  17920. */
  17921. constructor(actionManager: ActionManager);
  17922. /**
  17923. * Check if the current condition is valid
  17924. * @returns a boolean
  17925. */
  17926. isValid(): boolean;
  17927. /**
  17928. * Internal only
  17929. * @hidden
  17930. */
  17931. _getProperty(propertyPath: string): string;
  17932. /**
  17933. * Internal only
  17934. * @hidden
  17935. */
  17936. _getEffectiveTarget(target: any, propertyPath: string): any;
  17937. /**
  17938. * Serialize placeholder for child classes
  17939. * @returns the serialized object
  17940. */
  17941. serialize(): any;
  17942. /**
  17943. * Internal only
  17944. * @hidden
  17945. */
  17946. protected _serialize(serializedCondition: any): any;
  17947. }
  17948. /**
  17949. * Defines specific conditional operators as extensions of Condition
  17950. */
  17951. export class ValueCondition extends Condition {
  17952. /** path to specify the property of the target the conditional operator uses */
  17953. propertyPath: string;
  17954. /** the value compared by the conditional operator against the current value of the property */
  17955. value: any;
  17956. /** the conditional operator, default ValueCondition.IsEqual */
  17957. operator: number;
  17958. /**
  17959. * Internal only
  17960. * @hidden
  17961. */
  17962. private static _IsEqual;
  17963. /**
  17964. * Internal only
  17965. * @hidden
  17966. */
  17967. private static _IsDifferent;
  17968. /**
  17969. * Internal only
  17970. * @hidden
  17971. */
  17972. private static _IsGreater;
  17973. /**
  17974. * Internal only
  17975. * @hidden
  17976. */
  17977. private static _IsLesser;
  17978. /**
  17979. * returns the number for IsEqual
  17980. */
  17981. static get IsEqual(): number;
  17982. /**
  17983. * Returns the number for IsDifferent
  17984. */
  17985. static get IsDifferent(): number;
  17986. /**
  17987. * Returns the number for IsGreater
  17988. */
  17989. static get IsGreater(): number;
  17990. /**
  17991. * Returns the number for IsLesser
  17992. */
  17993. static get IsLesser(): number;
  17994. /**
  17995. * Internal only The action manager for the condition
  17996. * @hidden
  17997. */
  17998. _actionManager: ActionManager;
  17999. /**
  18000. * Internal only
  18001. * @hidden
  18002. */
  18003. private _target;
  18004. /**
  18005. * Internal only
  18006. * @hidden
  18007. */
  18008. private _effectiveTarget;
  18009. /**
  18010. * Internal only
  18011. * @hidden
  18012. */
  18013. private _property;
  18014. /**
  18015. * Creates a new ValueCondition
  18016. * @param actionManager manager for the action the condition applies to
  18017. * @param target for the action
  18018. * @param propertyPath path to specify the property of the target the conditional operator uses
  18019. * @param value the value compared by the conditional operator against the current value of the property
  18020. * @param operator the conditional operator, default ValueCondition.IsEqual
  18021. */
  18022. constructor(actionManager: ActionManager, target: any,
  18023. /** path to specify the property of the target the conditional operator uses */
  18024. propertyPath: string,
  18025. /** the value compared by the conditional operator against the current value of the property */
  18026. value: any,
  18027. /** the conditional operator, default ValueCondition.IsEqual */
  18028. operator?: number);
  18029. /**
  18030. * Compares the given value with the property value for the specified conditional operator
  18031. * @returns the result of the comparison
  18032. */
  18033. isValid(): boolean;
  18034. /**
  18035. * Serialize the ValueCondition into a JSON compatible object
  18036. * @returns serialization object
  18037. */
  18038. serialize(): any;
  18039. /**
  18040. * Gets the name of the conditional operator for the ValueCondition
  18041. * @param operator the conditional operator
  18042. * @returns the name
  18043. */
  18044. static GetOperatorName(operator: number): string;
  18045. }
  18046. /**
  18047. * Defines a predicate condition as an extension of Condition
  18048. */
  18049. export class PredicateCondition extends Condition {
  18050. /** defines the predicate function used to validate the condition */
  18051. predicate: () => boolean;
  18052. /**
  18053. * Internal only - manager for action
  18054. * @hidden
  18055. */
  18056. _actionManager: ActionManager;
  18057. /**
  18058. * Creates a new PredicateCondition
  18059. * @param actionManager manager for the action the condition applies to
  18060. * @param predicate defines the predicate function used to validate the condition
  18061. */
  18062. constructor(actionManager: ActionManager,
  18063. /** defines the predicate function used to validate the condition */
  18064. predicate: () => boolean);
  18065. /**
  18066. * @returns the validity of the predicate condition
  18067. */
  18068. isValid(): boolean;
  18069. }
  18070. /**
  18071. * Defines a state condition as an extension of Condition
  18072. */
  18073. export class StateCondition extends Condition {
  18074. /** Value to compare with target state */
  18075. value: string;
  18076. /**
  18077. * Internal only - manager for action
  18078. * @hidden
  18079. */
  18080. _actionManager: ActionManager;
  18081. /**
  18082. * Internal only
  18083. * @hidden
  18084. */
  18085. private _target;
  18086. /**
  18087. * Creates a new StateCondition
  18088. * @param actionManager manager for the action the condition applies to
  18089. * @param target of the condition
  18090. * @param value to compare with target state
  18091. */
  18092. constructor(actionManager: ActionManager, target: any,
  18093. /** Value to compare with target state */
  18094. value: string);
  18095. /**
  18096. * Gets a boolean indicating if the current condition is met
  18097. * @returns the validity of the state
  18098. */
  18099. isValid(): boolean;
  18100. /**
  18101. * Serialize the StateCondition into a JSON compatible object
  18102. * @returns serialization object
  18103. */
  18104. serialize(): any;
  18105. }
  18106. }
  18107. declare module "babylonjs/Actions/directActions" {
  18108. import { Action } from "babylonjs/Actions/action";
  18109. import { Condition } from "babylonjs/Actions/condition";
  18110. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18111. /**
  18112. * This defines an action responsible to toggle a boolean once triggered.
  18113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18114. */
  18115. export class SwitchBooleanAction extends Action {
  18116. /**
  18117. * The path to the boolean property in the target object
  18118. */
  18119. propertyPath: string;
  18120. private _target;
  18121. private _effectiveTarget;
  18122. private _property;
  18123. /**
  18124. * Instantiate the action
  18125. * @param triggerOptions defines the trigger options
  18126. * @param target defines the object containing the boolean
  18127. * @param propertyPath defines the path to the boolean property in the target object
  18128. * @param condition defines the trigger related conditions
  18129. */
  18130. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18131. /** @hidden */
  18132. _prepare(): void;
  18133. /**
  18134. * Execute the action toggle the boolean value.
  18135. */
  18136. execute(): void;
  18137. /**
  18138. * Serializes the actions and its related information.
  18139. * @param parent defines the object to serialize in
  18140. * @returns the serialized object
  18141. */
  18142. serialize(parent: any): any;
  18143. }
  18144. /**
  18145. * This defines an action responsible to set a the state field of the target
  18146. * to a desired value once triggered.
  18147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18148. */
  18149. export class SetStateAction extends Action {
  18150. /**
  18151. * The value to store in the state field.
  18152. */
  18153. value: string;
  18154. private _target;
  18155. /**
  18156. * Instantiate the action
  18157. * @param triggerOptions defines the trigger options
  18158. * @param target defines the object containing the state property
  18159. * @param value defines the value to store in the state field
  18160. * @param condition defines the trigger related conditions
  18161. */
  18162. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18163. /**
  18164. * Execute the action and store the value on the target state property.
  18165. */
  18166. execute(): void;
  18167. /**
  18168. * Serializes the actions and its related information.
  18169. * @param parent defines the object to serialize in
  18170. * @returns the serialized object
  18171. */
  18172. serialize(parent: any): any;
  18173. }
  18174. /**
  18175. * This defines an action responsible to set a property of the target
  18176. * to a desired value once triggered.
  18177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18178. */
  18179. export class SetValueAction extends Action {
  18180. /**
  18181. * The path of the property to set in the target.
  18182. */
  18183. propertyPath: string;
  18184. /**
  18185. * The value to set in the property
  18186. */
  18187. value: any;
  18188. private _target;
  18189. private _effectiveTarget;
  18190. private _property;
  18191. /**
  18192. * Instantiate the action
  18193. * @param triggerOptions defines the trigger options
  18194. * @param target defines the object containing the property
  18195. * @param propertyPath defines the path of the property to set in the target
  18196. * @param value defines the value to set in the property
  18197. * @param condition defines the trigger related conditions
  18198. */
  18199. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18200. /** @hidden */
  18201. _prepare(): void;
  18202. /**
  18203. * Execute the action and set the targetted property to the desired value.
  18204. */
  18205. execute(): void;
  18206. /**
  18207. * Serializes the actions and its related information.
  18208. * @param parent defines the object to serialize in
  18209. * @returns the serialized object
  18210. */
  18211. serialize(parent: any): any;
  18212. }
  18213. /**
  18214. * This defines an action responsible to increment the target value
  18215. * to a desired value once triggered.
  18216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18217. */
  18218. export class IncrementValueAction extends Action {
  18219. /**
  18220. * The path of the property to increment in the target.
  18221. */
  18222. propertyPath: string;
  18223. /**
  18224. * The value we should increment the property by.
  18225. */
  18226. value: any;
  18227. private _target;
  18228. private _effectiveTarget;
  18229. private _property;
  18230. /**
  18231. * Instantiate the action
  18232. * @param triggerOptions defines the trigger options
  18233. * @param target defines the object containing the property
  18234. * @param propertyPath defines the path of the property to increment in the target
  18235. * @param value defines the value value we should increment the property by
  18236. * @param condition defines the trigger related conditions
  18237. */
  18238. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18239. /** @hidden */
  18240. _prepare(): void;
  18241. /**
  18242. * Execute the action and increment the target of the value amount.
  18243. */
  18244. execute(): void;
  18245. /**
  18246. * Serializes the actions and its related information.
  18247. * @param parent defines the object to serialize in
  18248. * @returns the serialized object
  18249. */
  18250. serialize(parent: any): any;
  18251. }
  18252. /**
  18253. * This defines an action responsible to start an animation once triggered.
  18254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18255. */
  18256. export class PlayAnimationAction extends Action {
  18257. /**
  18258. * Where the animation should start (animation frame)
  18259. */
  18260. from: number;
  18261. /**
  18262. * Where the animation should stop (animation frame)
  18263. */
  18264. to: number;
  18265. /**
  18266. * Define if the animation should loop or stop after the first play.
  18267. */
  18268. loop?: boolean;
  18269. private _target;
  18270. /**
  18271. * Instantiate the action
  18272. * @param triggerOptions defines the trigger options
  18273. * @param target defines the target animation or animation name
  18274. * @param from defines from where the animation should start (animation frame)
  18275. * @param end defines where the animation should stop (animation frame)
  18276. * @param loop defines if the animation should loop or stop after the first play
  18277. * @param condition defines the trigger related conditions
  18278. */
  18279. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18280. /** @hidden */
  18281. _prepare(): void;
  18282. /**
  18283. * Execute the action and play the animation.
  18284. */
  18285. execute(): void;
  18286. /**
  18287. * Serializes the actions and its related information.
  18288. * @param parent defines the object to serialize in
  18289. * @returns the serialized object
  18290. */
  18291. serialize(parent: any): any;
  18292. }
  18293. /**
  18294. * This defines an action responsible to stop an animation once triggered.
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18296. */
  18297. export class StopAnimationAction extends Action {
  18298. private _target;
  18299. /**
  18300. * Instantiate the action
  18301. * @param triggerOptions defines the trigger options
  18302. * @param target defines the target animation or animation name
  18303. * @param condition defines the trigger related conditions
  18304. */
  18305. constructor(triggerOptions: any, target: any, condition?: Condition);
  18306. /** @hidden */
  18307. _prepare(): void;
  18308. /**
  18309. * Execute the action and stop the animation.
  18310. */
  18311. execute(): void;
  18312. /**
  18313. * Serializes the actions and its related information.
  18314. * @param parent defines the object to serialize in
  18315. * @returns the serialized object
  18316. */
  18317. serialize(parent: any): any;
  18318. }
  18319. /**
  18320. * This defines an action responsible that does nothing once triggered.
  18321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18322. */
  18323. export class DoNothingAction extends Action {
  18324. /**
  18325. * Instantiate the action
  18326. * @param triggerOptions defines the trigger options
  18327. * @param condition defines the trigger related conditions
  18328. */
  18329. constructor(triggerOptions?: any, condition?: Condition);
  18330. /**
  18331. * Execute the action and do nothing.
  18332. */
  18333. execute(): void;
  18334. /**
  18335. * Serializes the actions and its related information.
  18336. * @param parent defines the object to serialize in
  18337. * @returns the serialized object
  18338. */
  18339. serialize(parent: any): any;
  18340. }
  18341. /**
  18342. * This defines an action responsible to trigger several actions once triggered.
  18343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18344. */
  18345. export class CombineAction extends Action {
  18346. /**
  18347. * The list of aggregated animations to run.
  18348. */
  18349. children: Action[];
  18350. /**
  18351. * Instantiate the action
  18352. * @param triggerOptions defines the trigger options
  18353. * @param children defines the list of aggregated animations to run
  18354. * @param condition defines the trigger related conditions
  18355. */
  18356. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18357. /** @hidden */
  18358. _prepare(): void;
  18359. /**
  18360. * Execute the action and executes all the aggregated actions.
  18361. */
  18362. execute(evt: ActionEvent): void;
  18363. /**
  18364. * Serializes the actions and its related information.
  18365. * @param parent defines the object to serialize in
  18366. * @returns the serialized object
  18367. */
  18368. serialize(parent: any): any;
  18369. }
  18370. /**
  18371. * This defines an action responsible to run code (external event) once triggered.
  18372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18373. */
  18374. export class ExecuteCodeAction extends Action {
  18375. /**
  18376. * The callback function to run.
  18377. */
  18378. func: (evt: ActionEvent) => void;
  18379. /**
  18380. * Instantiate the action
  18381. * @param triggerOptions defines the trigger options
  18382. * @param func defines the callback function to run
  18383. * @param condition defines the trigger related conditions
  18384. */
  18385. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18386. /**
  18387. * Execute the action and run the attached code.
  18388. */
  18389. execute(evt: ActionEvent): void;
  18390. }
  18391. /**
  18392. * This defines an action responsible to set the parent property of the target once triggered.
  18393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18394. */
  18395. export class SetParentAction extends Action {
  18396. private _parent;
  18397. private _target;
  18398. /**
  18399. * Instantiate the action
  18400. * @param triggerOptions defines the trigger options
  18401. * @param target defines the target containing the parent property
  18402. * @param parent defines from where the animation should start (animation frame)
  18403. * @param condition defines the trigger related conditions
  18404. */
  18405. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18406. /** @hidden */
  18407. _prepare(): void;
  18408. /**
  18409. * Execute the action and set the parent property.
  18410. */
  18411. execute(): void;
  18412. /**
  18413. * Serializes the actions and its related information.
  18414. * @param parent defines the object to serialize in
  18415. * @returns the serialized object
  18416. */
  18417. serialize(parent: any): any;
  18418. }
  18419. }
  18420. declare module "babylonjs/Actions/actionManager" {
  18421. import { Nullable } from "babylonjs/types";
  18422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18423. import { Scene } from "babylonjs/scene";
  18424. import { IAction } from "babylonjs/Actions/action";
  18425. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18426. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18427. /**
  18428. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18429. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18431. */
  18432. export class ActionManager extends AbstractActionManager {
  18433. /**
  18434. * Nothing
  18435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18436. */
  18437. static readonly NothingTrigger: number;
  18438. /**
  18439. * On pick
  18440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18441. */
  18442. static readonly OnPickTrigger: number;
  18443. /**
  18444. * On left pick
  18445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18446. */
  18447. static readonly OnLeftPickTrigger: number;
  18448. /**
  18449. * On right pick
  18450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18451. */
  18452. static readonly OnRightPickTrigger: number;
  18453. /**
  18454. * On center pick
  18455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18456. */
  18457. static readonly OnCenterPickTrigger: number;
  18458. /**
  18459. * On pick down
  18460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18461. */
  18462. static readonly OnPickDownTrigger: number;
  18463. /**
  18464. * On double pick
  18465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18466. */
  18467. static readonly OnDoublePickTrigger: number;
  18468. /**
  18469. * On pick up
  18470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18471. */
  18472. static readonly OnPickUpTrigger: number;
  18473. /**
  18474. * On pick out.
  18475. * This trigger will only be raised if you also declared a OnPickDown
  18476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18477. */
  18478. static readonly OnPickOutTrigger: number;
  18479. /**
  18480. * On long press
  18481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18482. */
  18483. static readonly OnLongPressTrigger: number;
  18484. /**
  18485. * On pointer over
  18486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18487. */
  18488. static readonly OnPointerOverTrigger: number;
  18489. /**
  18490. * On pointer out
  18491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18492. */
  18493. static readonly OnPointerOutTrigger: number;
  18494. /**
  18495. * On every frame
  18496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18497. */
  18498. static readonly OnEveryFrameTrigger: number;
  18499. /**
  18500. * On intersection enter
  18501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18502. */
  18503. static readonly OnIntersectionEnterTrigger: number;
  18504. /**
  18505. * On intersection exit
  18506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18507. */
  18508. static readonly OnIntersectionExitTrigger: number;
  18509. /**
  18510. * On key down
  18511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18512. */
  18513. static readonly OnKeyDownTrigger: number;
  18514. /**
  18515. * On key up
  18516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18517. */
  18518. static readonly OnKeyUpTrigger: number;
  18519. private _scene;
  18520. /**
  18521. * Creates a new action manager
  18522. * @param scene defines the hosting scene
  18523. */
  18524. constructor(scene: Scene);
  18525. /**
  18526. * Releases all associated resources
  18527. */
  18528. dispose(): void;
  18529. /**
  18530. * Gets hosting scene
  18531. * @returns the hosting scene
  18532. */
  18533. getScene(): Scene;
  18534. /**
  18535. * Does this action manager handles actions of any of the given triggers
  18536. * @param triggers defines the triggers to be tested
  18537. * @return a boolean indicating whether one (or more) of the triggers is handled
  18538. */
  18539. hasSpecificTriggers(triggers: number[]): boolean;
  18540. /**
  18541. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18542. * speed.
  18543. * @param triggerA defines the trigger to be tested
  18544. * @param triggerB defines the trigger to be tested
  18545. * @return a boolean indicating whether one (or more) of the triggers is handled
  18546. */
  18547. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18548. /**
  18549. * Does this action manager handles actions of a given trigger
  18550. * @param trigger defines the trigger to be tested
  18551. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18552. * @return whether the trigger is handled
  18553. */
  18554. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18555. /**
  18556. * Does this action manager has pointer triggers
  18557. */
  18558. get hasPointerTriggers(): boolean;
  18559. /**
  18560. * Does this action manager has pick triggers
  18561. */
  18562. get hasPickTriggers(): boolean;
  18563. /**
  18564. * Registers an action to this action manager
  18565. * @param action defines the action to be registered
  18566. * @return the action amended (prepared) after registration
  18567. */
  18568. registerAction(action: IAction): Nullable<IAction>;
  18569. /**
  18570. * Unregisters an action to this action manager
  18571. * @param action defines the action to be unregistered
  18572. * @return a boolean indicating whether the action has been unregistered
  18573. */
  18574. unregisterAction(action: IAction): Boolean;
  18575. /**
  18576. * Process a specific trigger
  18577. * @param trigger defines the trigger to process
  18578. * @param evt defines the event details to be processed
  18579. */
  18580. processTrigger(trigger: number, evt?: IActionEvent): void;
  18581. /** @hidden */
  18582. _getEffectiveTarget(target: any, propertyPath: string): any;
  18583. /** @hidden */
  18584. _getProperty(propertyPath: string): string;
  18585. /**
  18586. * Serialize this manager to a JSON object
  18587. * @param name defines the property name to store this manager
  18588. * @returns a JSON representation of this manager
  18589. */
  18590. serialize(name: string): any;
  18591. /**
  18592. * Creates a new ActionManager from a JSON data
  18593. * @param parsedActions defines the JSON data to read from
  18594. * @param object defines the hosting mesh
  18595. * @param scene defines the hosting scene
  18596. */
  18597. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18598. /**
  18599. * Get a trigger name by index
  18600. * @param trigger defines the trigger index
  18601. * @returns a trigger name
  18602. */
  18603. static GetTriggerName(trigger: number): string;
  18604. }
  18605. }
  18606. declare module "babylonjs/Sprites/sprite" {
  18607. import { Vector3 } from "babylonjs/Maths/math.vector";
  18608. import { Nullable } from "babylonjs/types";
  18609. import { ActionManager } from "babylonjs/Actions/actionManager";
  18610. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18611. import { Color4 } from "babylonjs/Maths/math.color";
  18612. import { Observable } from "babylonjs/Misc/observable";
  18613. /**
  18614. * Class used to represent a sprite
  18615. * @see http://doc.babylonjs.com/babylon101/sprites
  18616. */
  18617. export class Sprite {
  18618. /** defines the name */
  18619. name: string;
  18620. /** Gets or sets the current world position */
  18621. position: Vector3;
  18622. /** Gets or sets the main color */
  18623. color: Color4;
  18624. /** Gets or sets the width */
  18625. width: number;
  18626. /** Gets or sets the height */
  18627. height: number;
  18628. /** Gets or sets rotation angle */
  18629. angle: number;
  18630. /** Gets or sets the cell index in the sprite sheet */
  18631. cellIndex: number;
  18632. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18633. cellRef: string;
  18634. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18635. invertU: number;
  18636. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18637. invertV: number;
  18638. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18639. disposeWhenFinishedAnimating: boolean;
  18640. /** Gets the list of attached animations */
  18641. animations: Animation[];
  18642. /** Gets or sets a boolean indicating if the sprite can be picked */
  18643. isPickable: boolean;
  18644. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18645. useAlphaForPicking: boolean;
  18646. /** @hidden */
  18647. _xOffset: number;
  18648. /** @hidden */
  18649. _yOffset: number;
  18650. /** @hidden */
  18651. _xSize: number;
  18652. /** @hidden */
  18653. _ySize: number;
  18654. /**
  18655. * Gets or sets the associated action manager
  18656. */
  18657. actionManager: Nullable<ActionManager>;
  18658. /**
  18659. * An event triggered when the control has been disposed
  18660. */
  18661. onDisposeObservable: Observable<Sprite>;
  18662. private _animationStarted;
  18663. private _loopAnimation;
  18664. private _fromIndex;
  18665. private _toIndex;
  18666. private _delay;
  18667. private _direction;
  18668. private _manager;
  18669. private _time;
  18670. private _onAnimationEnd;
  18671. /**
  18672. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18673. */
  18674. isVisible: boolean;
  18675. /**
  18676. * Gets or sets the sprite size
  18677. */
  18678. get size(): number;
  18679. set size(value: number);
  18680. /**
  18681. * Creates a new Sprite
  18682. * @param name defines the name
  18683. * @param manager defines the manager
  18684. */
  18685. constructor(
  18686. /** defines the name */
  18687. name: string, manager: ISpriteManager);
  18688. /**
  18689. * Starts an animation
  18690. * @param from defines the initial key
  18691. * @param to defines the end key
  18692. * @param loop defines if the animation must loop
  18693. * @param delay defines the start delay (in ms)
  18694. * @param onAnimationEnd defines a callback to call when animation ends
  18695. */
  18696. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18697. /** Stops current animation (if any) */
  18698. stopAnimation(): void;
  18699. /** @hidden */
  18700. _animate(deltaTime: number): void;
  18701. /** Release associated resources */
  18702. dispose(): void;
  18703. }
  18704. }
  18705. declare module "babylonjs/Collisions/pickingInfo" {
  18706. import { Nullable } from "babylonjs/types";
  18707. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18709. import { Sprite } from "babylonjs/Sprites/sprite";
  18710. import { Ray } from "babylonjs/Culling/ray";
  18711. /**
  18712. * Information about the result of picking within a scene
  18713. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18714. */
  18715. export class PickingInfo {
  18716. /** @hidden */
  18717. _pickingUnavailable: boolean;
  18718. /**
  18719. * If the pick collided with an object
  18720. */
  18721. hit: boolean;
  18722. /**
  18723. * Distance away where the pick collided
  18724. */
  18725. distance: number;
  18726. /**
  18727. * The location of pick collision
  18728. */
  18729. pickedPoint: Nullable<Vector3>;
  18730. /**
  18731. * The mesh corresponding the the pick collision
  18732. */
  18733. pickedMesh: Nullable<AbstractMesh>;
  18734. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18735. bu: number;
  18736. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18737. bv: number;
  18738. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18739. faceId: number;
  18740. /** Id of the the submesh that was picked */
  18741. subMeshId: number;
  18742. /** If a sprite was picked, this will be the sprite the pick collided with */
  18743. pickedSprite: Nullable<Sprite>;
  18744. /**
  18745. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18746. */
  18747. originMesh: Nullable<AbstractMesh>;
  18748. /**
  18749. * The ray that was used to perform the picking.
  18750. */
  18751. ray: Nullable<Ray>;
  18752. /**
  18753. * Gets the normal correspodning to the face the pick collided with
  18754. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18755. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18756. * @returns The normal correspodning to the face the pick collided with
  18757. */
  18758. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18759. /**
  18760. * Gets the texture coordinates of where the pick occured
  18761. * @returns the vector containing the coordnates of the texture
  18762. */
  18763. getTextureCoordinates(): Nullable<Vector2>;
  18764. }
  18765. }
  18766. declare module "babylonjs/Events/pointerEvents" {
  18767. import { Nullable } from "babylonjs/types";
  18768. import { Vector2 } from "babylonjs/Maths/math.vector";
  18769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18770. import { Ray } from "babylonjs/Culling/ray";
  18771. /**
  18772. * Gather the list of pointer event types as constants.
  18773. */
  18774. export class PointerEventTypes {
  18775. /**
  18776. * 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.
  18777. */
  18778. static readonly POINTERDOWN: number;
  18779. /**
  18780. * The pointerup event is fired when a pointer is no longer active.
  18781. */
  18782. static readonly POINTERUP: number;
  18783. /**
  18784. * The pointermove event is fired when a pointer changes coordinates.
  18785. */
  18786. static readonly POINTERMOVE: number;
  18787. /**
  18788. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18789. */
  18790. static readonly POINTERWHEEL: number;
  18791. /**
  18792. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18793. */
  18794. static readonly POINTERPICK: number;
  18795. /**
  18796. * The pointertap event is fired when a the object has been touched and released without drag.
  18797. */
  18798. static readonly POINTERTAP: number;
  18799. /**
  18800. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18801. */
  18802. static readonly POINTERDOUBLETAP: number;
  18803. }
  18804. /**
  18805. * Base class of pointer info types.
  18806. */
  18807. export class PointerInfoBase {
  18808. /**
  18809. * Defines the type of event (PointerEventTypes)
  18810. */
  18811. type: number;
  18812. /**
  18813. * Defines the related dom event
  18814. */
  18815. event: PointerEvent | MouseWheelEvent;
  18816. /**
  18817. * Instantiates the base class of pointers info.
  18818. * @param type Defines the type of event (PointerEventTypes)
  18819. * @param event Defines the related dom event
  18820. */
  18821. constructor(
  18822. /**
  18823. * Defines the type of event (PointerEventTypes)
  18824. */
  18825. type: number,
  18826. /**
  18827. * Defines the related dom event
  18828. */
  18829. event: PointerEvent | MouseWheelEvent);
  18830. }
  18831. /**
  18832. * This class is used to store pointer related info for the onPrePointerObservable event.
  18833. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18834. */
  18835. export class PointerInfoPre extends PointerInfoBase {
  18836. /**
  18837. * Ray from a pointer if availible (eg. 6dof controller)
  18838. */
  18839. ray: Nullable<Ray>;
  18840. /**
  18841. * Defines the local position of the pointer on the canvas.
  18842. */
  18843. localPosition: Vector2;
  18844. /**
  18845. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18846. */
  18847. skipOnPointerObservable: boolean;
  18848. /**
  18849. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18850. * @param type Defines the type of event (PointerEventTypes)
  18851. * @param event Defines the related dom event
  18852. * @param localX Defines the local x coordinates of the pointer when the event occured
  18853. * @param localY Defines the local y coordinates of the pointer when the event occured
  18854. */
  18855. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18856. }
  18857. /**
  18858. * This type contains all the data related to a pointer event in Babylon.js.
  18859. * 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.
  18860. */
  18861. export class PointerInfo extends PointerInfoBase {
  18862. /**
  18863. * Defines the picking info associated to the info (if any)\
  18864. */
  18865. pickInfo: Nullable<PickingInfo>;
  18866. /**
  18867. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18868. * @param type Defines the type of event (PointerEventTypes)
  18869. * @param event Defines the related dom event
  18870. * @param pickInfo Defines the picking info associated to the info (if any)\
  18871. */
  18872. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18873. /**
  18874. * Defines the picking info associated to the info (if any)\
  18875. */
  18876. pickInfo: Nullable<PickingInfo>);
  18877. }
  18878. /**
  18879. * Data relating to a touch event on the screen.
  18880. */
  18881. export interface PointerTouch {
  18882. /**
  18883. * X coordinate of touch.
  18884. */
  18885. x: number;
  18886. /**
  18887. * Y coordinate of touch.
  18888. */
  18889. y: number;
  18890. /**
  18891. * Id of touch. Unique for each finger.
  18892. */
  18893. pointerId: number;
  18894. /**
  18895. * Event type passed from DOM.
  18896. */
  18897. type: any;
  18898. }
  18899. }
  18900. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18901. import { Observable } from "babylonjs/Misc/observable";
  18902. import { Nullable } from "babylonjs/types";
  18903. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18904. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18905. /**
  18906. * Manage the mouse inputs to control the movement of a free camera.
  18907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18908. */
  18909. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18910. /**
  18911. * Define if touch is enabled in the mouse input
  18912. */
  18913. touchEnabled: boolean;
  18914. /**
  18915. * Defines the camera the input is attached to.
  18916. */
  18917. camera: FreeCamera;
  18918. /**
  18919. * Defines the buttons associated with the input to handle camera move.
  18920. */
  18921. buttons: number[];
  18922. /**
  18923. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18924. */
  18925. angularSensibility: number;
  18926. private _pointerInput;
  18927. private _onMouseMove;
  18928. private _observer;
  18929. private previousPosition;
  18930. /**
  18931. * Observable for when a pointer move event occurs containing the move offset
  18932. */
  18933. onPointerMovedObservable: Observable<{
  18934. offsetX: number;
  18935. offsetY: number;
  18936. }>;
  18937. /**
  18938. * @hidden
  18939. * If the camera should be rotated automatically based on pointer movement
  18940. */
  18941. _allowCameraRotation: boolean;
  18942. /**
  18943. * Manage the mouse inputs to control the movement of a free camera.
  18944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18945. * @param touchEnabled Defines if touch is enabled or not
  18946. */
  18947. constructor(
  18948. /**
  18949. * Define if touch is enabled in the mouse input
  18950. */
  18951. touchEnabled?: boolean);
  18952. /**
  18953. * Attach the input controls to a specific dom element to get the input from.
  18954. * @param element Defines the element the controls should be listened from
  18955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18956. */
  18957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18958. /**
  18959. * Called on JS contextmenu event.
  18960. * Override this method to provide functionality.
  18961. */
  18962. protected onContextMenu(evt: PointerEvent): void;
  18963. /**
  18964. * Detach the current controls from the specified dom element.
  18965. * @param element Defines the element to stop listening the inputs from
  18966. */
  18967. detachControl(element: Nullable<HTMLElement>): void;
  18968. /**
  18969. * Gets the class name of the current intput.
  18970. * @returns the class name
  18971. */
  18972. getClassName(): string;
  18973. /**
  18974. * Get the friendly name associated with the input class.
  18975. * @returns the input friendly name
  18976. */
  18977. getSimpleName(): string;
  18978. }
  18979. }
  18980. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18981. import { Nullable } from "babylonjs/types";
  18982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18983. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18984. /**
  18985. * Manage the touch inputs to control the movement of a free camera.
  18986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18987. */
  18988. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18989. /**
  18990. * Defines the camera the input is attached to.
  18991. */
  18992. camera: FreeCamera;
  18993. /**
  18994. * Defines the touch sensibility for rotation.
  18995. * The higher the faster.
  18996. */
  18997. touchAngularSensibility: number;
  18998. /**
  18999. * Defines the touch sensibility for move.
  19000. * The higher the faster.
  19001. */
  19002. touchMoveSensibility: number;
  19003. private _offsetX;
  19004. private _offsetY;
  19005. private _pointerPressed;
  19006. private _pointerInput;
  19007. private _observer;
  19008. private _onLostFocus;
  19009. /**
  19010. * Attach the input controls to a specific dom element to get the input from.
  19011. * @param element Defines the element the controls should be listened from
  19012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19013. */
  19014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19015. /**
  19016. * Detach the current controls from the specified dom element.
  19017. * @param element Defines the element to stop listening the inputs from
  19018. */
  19019. detachControl(element: Nullable<HTMLElement>): void;
  19020. /**
  19021. * Update the current camera state depending on the inputs that have been used this frame.
  19022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19023. */
  19024. checkInputs(): void;
  19025. /**
  19026. * Gets the class name of the current intput.
  19027. * @returns the class name
  19028. */
  19029. getClassName(): string;
  19030. /**
  19031. * Get the friendly name associated with the input class.
  19032. * @returns the input friendly name
  19033. */
  19034. getSimpleName(): string;
  19035. }
  19036. }
  19037. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19038. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19039. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19040. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19041. import { Nullable } from "babylonjs/types";
  19042. /**
  19043. * Default Inputs manager for the FreeCamera.
  19044. * It groups all the default supported inputs for ease of use.
  19045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19046. */
  19047. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19048. /**
  19049. * @hidden
  19050. */
  19051. _mouseInput: Nullable<FreeCameraMouseInput>;
  19052. /**
  19053. * Instantiates a new FreeCameraInputsManager.
  19054. * @param camera Defines the camera the inputs belong to
  19055. */
  19056. constructor(camera: FreeCamera);
  19057. /**
  19058. * Add keyboard input support to the input manager.
  19059. * @returns the current input manager
  19060. */
  19061. addKeyboard(): FreeCameraInputsManager;
  19062. /**
  19063. * Add mouse input support to the input manager.
  19064. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19065. * @returns the current input manager
  19066. */
  19067. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19068. /**
  19069. * Removes the mouse input support from the manager
  19070. * @returns the current input manager
  19071. */
  19072. removeMouse(): FreeCameraInputsManager;
  19073. /**
  19074. * Add touch input support to the input manager.
  19075. * @returns the current input manager
  19076. */
  19077. addTouch(): FreeCameraInputsManager;
  19078. /**
  19079. * Remove all attached input methods from a camera
  19080. */
  19081. clear(): void;
  19082. }
  19083. }
  19084. declare module "babylonjs/Cameras/freeCamera" {
  19085. import { Vector3 } from "babylonjs/Maths/math.vector";
  19086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19087. import { Scene } from "babylonjs/scene";
  19088. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19089. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19090. /**
  19091. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19092. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19094. */
  19095. export class FreeCamera extends TargetCamera {
  19096. /**
  19097. * Define the collision ellipsoid of the camera.
  19098. * This is helpful to simulate a camera body like the player body around the camera
  19099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19100. */
  19101. ellipsoid: Vector3;
  19102. /**
  19103. * Define an offset for the position of the ellipsoid around the camera.
  19104. * This can be helpful to determine the center of the body near the gravity center of the body
  19105. * instead of its head.
  19106. */
  19107. ellipsoidOffset: Vector3;
  19108. /**
  19109. * Enable or disable collisions of the camera with the rest of the scene objects.
  19110. */
  19111. checkCollisions: boolean;
  19112. /**
  19113. * Enable or disable gravity on the camera.
  19114. */
  19115. applyGravity: boolean;
  19116. /**
  19117. * Define the input manager associated to the camera.
  19118. */
  19119. inputs: FreeCameraInputsManager;
  19120. /**
  19121. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19122. * Higher values reduce sensitivity.
  19123. */
  19124. get angularSensibility(): number;
  19125. /**
  19126. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19127. * Higher values reduce sensitivity.
  19128. */
  19129. set angularSensibility(value: number);
  19130. /**
  19131. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19132. */
  19133. get keysUp(): number[];
  19134. set keysUp(value: number[]);
  19135. /**
  19136. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19137. */
  19138. get keysUpward(): number[];
  19139. set keysUpward(value: number[]);
  19140. /**
  19141. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19142. */
  19143. get keysDown(): number[];
  19144. set keysDown(value: number[]);
  19145. /**
  19146. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19147. */
  19148. get keysDownward(): number[];
  19149. set keysDownward(value: number[]);
  19150. /**
  19151. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19152. */
  19153. get keysLeft(): number[];
  19154. set keysLeft(value: number[]);
  19155. /**
  19156. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19157. */
  19158. get keysRight(): number[];
  19159. set keysRight(value: number[]);
  19160. /**
  19161. * Event raised when the camera collide with a mesh in the scene.
  19162. */
  19163. onCollide: (collidedMesh: AbstractMesh) => void;
  19164. private _collider;
  19165. private _needMoveForGravity;
  19166. private _oldPosition;
  19167. private _diffPosition;
  19168. private _newPosition;
  19169. /** @hidden */
  19170. _localDirection: Vector3;
  19171. /** @hidden */
  19172. _transformedDirection: Vector3;
  19173. /**
  19174. * Instantiates a Free Camera.
  19175. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19176. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19178. * @param name Define the name of the camera in the scene
  19179. * @param position Define the start position of the camera in the scene
  19180. * @param scene Define the scene the camera belongs to
  19181. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19182. */
  19183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19184. /**
  19185. * Attached controls to the current camera.
  19186. * @param element Defines the element the controls should be listened from
  19187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19188. */
  19189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19190. /**
  19191. * Detach the current controls from the camera.
  19192. * The camera will stop reacting to inputs.
  19193. * @param element Defines the element to stop listening the inputs from
  19194. */
  19195. detachControl(element: HTMLElement): void;
  19196. private _collisionMask;
  19197. /**
  19198. * Define a collision mask to limit the list of object the camera can collide with
  19199. */
  19200. get collisionMask(): number;
  19201. set collisionMask(mask: number);
  19202. /** @hidden */
  19203. _collideWithWorld(displacement: Vector3): void;
  19204. private _onCollisionPositionChange;
  19205. /** @hidden */
  19206. _checkInputs(): void;
  19207. /** @hidden */
  19208. _decideIfNeedsToMove(): boolean;
  19209. /** @hidden */
  19210. _updatePosition(): void;
  19211. /**
  19212. * Destroy the camera and release the current resources hold by it.
  19213. */
  19214. dispose(): void;
  19215. /**
  19216. * Gets the current object class name.
  19217. * @return the class name
  19218. */
  19219. getClassName(): string;
  19220. }
  19221. }
  19222. declare module "babylonjs/Gamepads/gamepad" {
  19223. import { Observable } from "babylonjs/Misc/observable";
  19224. /**
  19225. * Represents a gamepad control stick position
  19226. */
  19227. export class StickValues {
  19228. /**
  19229. * The x component of the control stick
  19230. */
  19231. x: number;
  19232. /**
  19233. * The y component of the control stick
  19234. */
  19235. y: number;
  19236. /**
  19237. * Initializes the gamepad x and y control stick values
  19238. * @param x The x component of the gamepad control stick value
  19239. * @param y The y component of the gamepad control stick value
  19240. */
  19241. constructor(
  19242. /**
  19243. * The x component of the control stick
  19244. */
  19245. x: number,
  19246. /**
  19247. * The y component of the control stick
  19248. */
  19249. y: number);
  19250. }
  19251. /**
  19252. * An interface which manages callbacks for gamepad button changes
  19253. */
  19254. export interface GamepadButtonChanges {
  19255. /**
  19256. * Called when a gamepad has been changed
  19257. */
  19258. changed: boolean;
  19259. /**
  19260. * Called when a gamepad press event has been triggered
  19261. */
  19262. pressChanged: boolean;
  19263. /**
  19264. * Called when a touch event has been triggered
  19265. */
  19266. touchChanged: boolean;
  19267. /**
  19268. * Called when a value has changed
  19269. */
  19270. valueChanged: boolean;
  19271. }
  19272. /**
  19273. * Represents a gamepad
  19274. */
  19275. export class Gamepad {
  19276. /**
  19277. * The id of the gamepad
  19278. */
  19279. id: string;
  19280. /**
  19281. * The index of the gamepad
  19282. */
  19283. index: number;
  19284. /**
  19285. * The browser gamepad
  19286. */
  19287. browserGamepad: any;
  19288. /**
  19289. * Specifies what type of gamepad this represents
  19290. */
  19291. type: number;
  19292. private _leftStick;
  19293. private _rightStick;
  19294. /** @hidden */
  19295. _isConnected: boolean;
  19296. private _leftStickAxisX;
  19297. private _leftStickAxisY;
  19298. private _rightStickAxisX;
  19299. private _rightStickAxisY;
  19300. /**
  19301. * Triggered when the left control stick has been changed
  19302. */
  19303. private _onleftstickchanged;
  19304. /**
  19305. * Triggered when the right control stick has been changed
  19306. */
  19307. private _onrightstickchanged;
  19308. /**
  19309. * Represents a gamepad controller
  19310. */
  19311. static GAMEPAD: number;
  19312. /**
  19313. * Represents a generic controller
  19314. */
  19315. static GENERIC: number;
  19316. /**
  19317. * Represents an XBox controller
  19318. */
  19319. static XBOX: number;
  19320. /**
  19321. * Represents a pose-enabled controller
  19322. */
  19323. static POSE_ENABLED: number;
  19324. /**
  19325. * Represents an Dual Shock controller
  19326. */
  19327. static DUALSHOCK: number;
  19328. /**
  19329. * Specifies whether the left control stick should be Y-inverted
  19330. */
  19331. protected _invertLeftStickY: boolean;
  19332. /**
  19333. * Specifies if the gamepad has been connected
  19334. */
  19335. get isConnected(): boolean;
  19336. /**
  19337. * Initializes the gamepad
  19338. * @param id The id of the gamepad
  19339. * @param index The index of the gamepad
  19340. * @param browserGamepad The browser gamepad
  19341. * @param leftStickX The x component of the left joystick
  19342. * @param leftStickY The y component of the left joystick
  19343. * @param rightStickX The x component of the right joystick
  19344. * @param rightStickY The y component of the right joystick
  19345. */
  19346. constructor(
  19347. /**
  19348. * The id of the gamepad
  19349. */
  19350. id: string,
  19351. /**
  19352. * The index of the gamepad
  19353. */
  19354. index: number,
  19355. /**
  19356. * The browser gamepad
  19357. */
  19358. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19359. /**
  19360. * Callback triggered when the left joystick has changed
  19361. * @param callback
  19362. */
  19363. onleftstickchanged(callback: (values: StickValues) => void): void;
  19364. /**
  19365. * Callback triggered when the right joystick has changed
  19366. * @param callback
  19367. */
  19368. onrightstickchanged(callback: (values: StickValues) => void): void;
  19369. /**
  19370. * Gets the left joystick
  19371. */
  19372. get leftStick(): StickValues;
  19373. /**
  19374. * Sets the left joystick values
  19375. */
  19376. set leftStick(newValues: StickValues);
  19377. /**
  19378. * Gets the right joystick
  19379. */
  19380. get rightStick(): StickValues;
  19381. /**
  19382. * Sets the right joystick value
  19383. */
  19384. set rightStick(newValues: StickValues);
  19385. /**
  19386. * Updates the gamepad joystick positions
  19387. */
  19388. update(): void;
  19389. /**
  19390. * Disposes the gamepad
  19391. */
  19392. dispose(): void;
  19393. }
  19394. /**
  19395. * Represents a generic gamepad
  19396. */
  19397. export class GenericPad extends Gamepad {
  19398. private _buttons;
  19399. private _onbuttondown;
  19400. private _onbuttonup;
  19401. /**
  19402. * Observable triggered when a button has been pressed
  19403. */
  19404. onButtonDownObservable: Observable<number>;
  19405. /**
  19406. * Observable triggered when a button has been released
  19407. */
  19408. onButtonUpObservable: Observable<number>;
  19409. /**
  19410. * Callback triggered when a button has been pressed
  19411. * @param callback Called when a button has been pressed
  19412. */
  19413. onbuttondown(callback: (buttonPressed: number) => void): void;
  19414. /**
  19415. * Callback triggered when a button has been released
  19416. * @param callback Called when a button has been released
  19417. */
  19418. onbuttonup(callback: (buttonReleased: number) => void): void;
  19419. /**
  19420. * Initializes the generic gamepad
  19421. * @param id The id of the generic gamepad
  19422. * @param index The index of the generic gamepad
  19423. * @param browserGamepad The browser gamepad
  19424. */
  19425. constructor(id: string, index: number, browserGamepad: any);
  19426. private _setButtonValue;
  19427. /**
  19428. * Updates the generic gamepad
  19429. */
  19430. update(): void;
  19431. /**
  19432. * Disposes the generic gamepad
  19433. */
  19434. dispose(): void;
  19435. }
  19436. }
  19437. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19438. import { Observable } from "babylonjs/Misc/observable";
  19439. import { Nullable } from "babylonjs/types";
  19440. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19443. import { Ray } from "babylonjs/Culling/ray";
  19444. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19445. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19446. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19447. /**
  19448. * Defines the types of pose enabled controllers that are supported
  19449. */
  19450. export enum PoseEnabledControllerType {
  19451. /**
  19452. * HTC Vive
  19453. */
  19454. VIVE = 0,
  19455. /**
  19456. * Oculus Rift
  19457. */
  19458. OCULUS = 1,
  19459. /**
  19460. * Windows mixed reality
  19461. */
  19462. WINDOWS = 2,
  19463. /**
  19464. * Samsung gear VR
  19465. */
  19466. GEAR_VR = 3,
  19467. /**
  19468. * Google Daydream
  19469. */
  19470. DAYDREAM = 4,
  19471. /**
  19472. * Generic
  19473. */
  19474. GENERIC = 5
  19475. }
  19476. /**
  19477. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19478. */
  19479. export interface MutableGamepadButton {
  19480. /**
  19481. * Value of the button/trigger
  19482. */
  19483. value: number;
  19484. /**
  19485. * If the button/trigger is currently touched
  19486. */
  19487. touched: boolean;
  19488. /**
  19489. * If the button/trigger is currently pressed
  19490. */
  19491. pressed: boolean;
  19492. }
  19493. /**
  19494. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19495. * @hidden
  19496. */
  19497. export interface ExtendedGamepadButton extends GamepadButton {
  19498. /**
  19499. * If the button/trigger is currently pressed
  19500. */
  19501. readonly pressed: boolean;
  19502. /**
  19503. * If the button/trigger is currently touched
  19504. */
  19505. readonly touched: boolean;
  19506. /**
  19507. * Value of the button/trigger
  19508. */
  19509. readonly value: number;
  19510. }
  19511. /** @hidden */
  19512. export interface _GamePadFactory {
  19513. /**
  19514. * Returns whether or not the current gamepad can be created for this type of controller.
  19515. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19516. * @returns true if it can be created, otherwise false
  19517. */
  19518. canCreate(gamepadInfo: any): boolean;
  19519. /**
  19520. * Creates a new instance of the Gamepad.
  19521. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19522. * @returns the new gamepad instance
  19523. */
  19524. create(gamepadInfo: any): Gamepad;
  19525. }
  19526. /**
  19527. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19528. */
  19529. export class PoseEnabledControllerHelper {
  19530. /** @hidden */
  19531. static _ControllerFactories: _GamePadFactory[];
  19532. /** @hidden */
  19533. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19534. /**
  19535. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19536. * @param vrGamepad the gamepad to initialized
  19537. * @returns a vr controller of the type the gamepad identified as
  19538. */
  19539. static InitiateController(vrGamepad: any): Gamepad;
  19540. }
  19541. /**
  19542. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19543. */
  19544. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19545. /**
  19546. * If the controller is used in a webXR session
  19547. */
  19548. isXR: boolean;
  19549. private _deviceRoomPosition;
  19550. private _deviceRoomRotationQuaternion;
  19551. /**
  19552. * The device position in babylon space
  19553. */
  19554. devicePosition: Vector3;
  19555. /**
  19556. * The device rotation in babylon space
  19557. */
  19558. deviceRotationQuaternion: Quaternion;
  19559. /**
  19560. * The scale factor of the device in babylon space
  19561. */
  19562. deviceScaleFactor: number;
  19563. /**
  19564. * (Likely devicePosition should be used instead) The device position in its room space
  19565. */
  19566. position: Vector3;
  19567. /**
  19568. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19569. */
  19570. rotationQuaternion: Quaternion;
  19571. /**
  19572. * The type of controller (Eg. Windows mixed reality)
  19573. */
  19574. controllerType: PoseEnabledControllerType;
  19575. protected _calculatedPosition: Vector3;
  19576. private _calculatedRotation;
  19577. /**
  19578. * The raw pose from the device
  19579. */
  19580. rawPose: DevicePose;
  19581. private _trackPosition;
  19582. private _maxRotationDistFromHeadset;
  19583. private _draggedRoomRotation;
  19584. /**
  19585. * @hidden
  19586. */
  19587. _disableTrackPosition(fixedPosition: Vector3): void;
  19588. /**
  19589. * Internal, the mesh attached to the controller
  19590. * @hidden
  19591. */
  19592. _mesh: Nullable<AbstractMesh>;
  19593. private _poseControlledCamera;
  19594. private _leftHandSystemQuaternion;
  19595. /**
  19596. * Internal, matrix used to convert room space to babylon space
  19597. * @hidden
  19598. */
  19599. _deviceToWorld: Matrix;
  19600. /**
  19601. * Node to be used when casting a ray from the controller
  19602. * @hidden
  19603. */
  19604. _pointingPoseNode: Nullable<TransformNode>;
  19605. /**
  19606. * Name of the child mesh that can be used to cast a ray from the controller
  19607. */
  19608. static readonly POINTING_POSE: string;
  19609. /**
  19610. * Creates a new PoseEnabledController from a gamepad
  19611. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19612. */
  19613. constructor(browserGamepad: any);
  19614. private _workingMatrix;
  19615. /**
  19616. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19617. */
  19618. update(): void;
  19619. /**
  19620. * Updates only the pose device and mesh without doing any button event checking
  19621. */
  19622. protected _updatePoseAndMesh(): void;
  19623. /**
  19624. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19625. * @param poseData raw pose fromthe device
  19626. */
  19627. updateFromDevice(poseData: DevicePose): void;
  19628. /**
  19629. * @hidden
  19630. */
  19631. _meshAttachedObservable: Observable<AbstractMesh>;
  19632. /**
  19633. * Attaches a mesh to the controller
  19634. * @param mesh the mesh to be attached
  19635. */
  19636. attachToMesh(mesh: AbstractMesh): void;
  19637. /**
  19638. * Attaches the controllers mesh to a camera
  19639. * @param camera the camera the mesh should be attached to
  19640. */
  19641. attachToPoseControlledCamera(camera: TargetCamera): void;
  19642. /**
  19643. * Disposes of the controller
  19644. */
  19645. dispose(): void;
  19646. /**
  19647. * The mesh that is attached to the controller
  19648. */
  19649. get mesh(): Nullable<AbstractMesh>;
  19650. /**
  19651. * Gets the ray of the controller in the direction the controller is pointing
  19652. * @param length the length the resulting ray should be
  19653. * @returns a ray in the direction the controller is pointing
  19654. */
  19655. getForwardRay(length?: number): Ray;
  19656. }
  19657. }
  19658. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19659. import { Observable } from "babylonjs/Misc/observable";
  19660. import { Scene } from "babylonjs/scene";
  19661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19662. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19663. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19664. import { Nullable } from "babylonjs/types";
  19665. /**
  19666. * Defines the WebVRController object that represents controllers tracked in 3D space
  19667. */
  19668. export abstract class WebVRController extends PoseEnabledController {
  19669. /**
  19670. * Internal, the default controller model for the controller
  19671. */
  19672. protected _defaultModel: Nullable<AbstractMesh>;
  19673. /**
  19674. * Fired when the trigger state has changed
  19675. */
  19676. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19677. /**
  19678. * Fired when the main button state has changed
  19679. */
  19680. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19681. /**
  19682. * Fired when the secondary button state has changed
  19683. */
  19684. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19685. /**
  19686. * Fired when the pad state has changed
  19687. */
  19688. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19689. /**
  19690. * Fired when controllers stick values have changed
  19691. */
  19692. onPadValuesChangedObservable: Observable<StickValues>;
  19693. /**
  19694. * Array of button availible on the controller
  19695. */
  19696. protected _buttons: Array<MutableGamepadButton>;
  19697. private _onButtonStateChange;
  19698. /**
  19699. * Fired when a controller button's state has changed
  19700. * @param callback the callback containing the button that was modified
  19701. */
  19702. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19703. /**
  19704. * X and Y axis corresponding to the controllers joystick
  19705. */
  19706. pad: StickValues;
  19707. /**
  19708. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19709. */
  19710. hand: string;
  19711. /**
  19712. * The default controller model for the controller
  19713. */
  19714. get defaultModel(): Nullable<AbstractMesh>;
  19715. /**
  19716. * Creates a new WebVRController from a gamepad
  19717. * @param vrGamepad the gamepad that the WebVRController should be created from
  19718. */
  19719. constructor(vrGamepad: any);
  19720. /**
  19721. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19722. */
  19723. update(): void;
  19724. /**
  19725. * Function to be called when a button is modified
  19726. */
  19727. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19728. /**
  19729. * Loads a mesh and attaches it to the controller
  19730. * @param scene the scene the mesh should be added to
  19731. * @param meshLoaded callback for when the mesh has been loaded
  19732. */
  19733. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19734. private _setButtonValue;
  19735. private _changes;
  19736. private _checkChanges;
  19737. /**
  19738. * Disposes of th webVRCOntroller
  19739. */
  19740. dispose(): void;
  19741. }
  19742. }
  19743. declare module "babylonjs/Lights/hemisphericLight" {
  19744. import { Nullable } from "babylonjs/types";
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19747. import { Color3 } from "babylonjs/Maths/math.color";
  19748. import { Effect } from "babylonjs/Materials/effect";
  19749. import { Light } from "babylonjs/Lights/light";
  19750. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19751. /**
  19752. * The HemisphericLight simulates the ambient environment light,
  19753. * so the passed direction is the light reflection direction, not the incoming direction.
  19754. */
  19755. export class HemisphericLight extends Light {
  19756. /**
  19757. * The groundColor is the light in the opposite direction to the one specified during creation.
  19758. * 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.
  19759. */
  19760. groundColor: Color3;
  19761. /**
  19762. * The light reflection direction, not the incoming direction.
  19763. */
  19764. direction: Vector3;
  19765. /**
  19766. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19767. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19768. * The HemisphericLight can't cast shadows.
  19769. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19770. * @param name The friendly name of the light
  19771. * @param direction The direction of the light reflection
  19772. * @param scene The scene the light belongs to
  19773. */
  19774. constructor(name: string, direction: Vector3, scene: Scene);
  19775. protected _buildUniformLayout(): void;
  19776. /**
  19777. * Returns the string "HemisphericLight".
  19778. * @return The class name
  19779. */
  19780. getClassName(): string;
  19781. /**
  19782. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19783. * Returns the updated direction.
  19784. * @param target The target the direction should point to
  19785. * @return The computed direction
  19786. */
  19787. setDirectionToTarget(target: Vector3): Vector3;
  19788. /**
  19789. * Returns the shadow generator associated to the light.
  19790. * @returns Always null for hemispheric lights because it does not support shadows.
  19791. */
  19792. getShadowGenerator(): Nullable<IShadowGenerator>;
  19793. /**
  19794. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19795. * @param effect The effect to update
  19796. * @param lightIndex The index of the light in the effect to update
  19797. * @returns The hemispheric light
  19798. */
  19799. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19800. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19801. /**
  19802. * Computes the world matrix of the node
  19803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19804. * @param useWasUpdatedFlag defines a reserved property
  19805. * @returns the world matrix
  19806. */
  19807. computeWorldMatrix(): Matrix;
  19808. /**
  19809. * Returns the integer 3.
  19810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19811. */
  19812. getTypeID(): number;
  19813. /**
  19814. * Prepares the list of defines specific to the light type.
  19815. * @param defines the list of defines
  19816. * @param lightIndex defines the index of the light for the effect
  19817. */
  19818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19819. }
  19820. }
  19821. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19822. /** @hidden */
  19823. export var vrMultiviewToSingleviewPixelShader: {
  19824. name: string;
  19825. shader: string;
  19826. };
  19827. }
  19828. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19830. import { Scene } from "babylonjs/scene";
  19831. /**
  19832. * Renders to multiple views with a single draw call
  19833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19834. */
  19835. export class MultiviewRenderTarget extends RenderTargetTexture {
  19836. /**
  19837. * Creates a multiview render target
  19838. * @param scene scene used with the render target
  19839. * @param size the size of the render target (used for each view)
  19840. */
  19841. constructor(scene: Scene, size?: number | {
  19842. width: number;
  19843. height: number;
  19844. } | {
  19845. ratio: number;
  19846. });
  19847. /**
  19848. * @hidden
  19849. * @param faceIndex the face index, if its a cube texture
  19850. */
  19851. _bindFrameBuffer(faceIndex?: number): void;
  19852. /**
  19853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19854. * @returns the view count
  19855. */
  19856. getViewCount(): number;
  19857. }
  19858. }
  19859. declare module "babylonjs/Maths/math.frustum" {
  19860. import { Matrix } from "babylonjs/Maths/math.vector";
  19861. import { DeepImmutable } from "babylonjs/types";
  19862. import { Plane } from "babylonjs/Maths/math.plane";
  19863. /**
  19864. * Represents a camera frustum
  19865. */
  19866. export class Frustum {
  19867. /**
  19868. * Gets the planes representing the frustum
  19869. * @param transform matrix to be applied to the returned planes
  19870. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19871. */
  19872. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19873. /**
  19874. * Gets the near frustum plane transformed by the transform matrix
  19875. * @param transform transformation matrix to be applied to the resulting frustum plane
  19876. * @param frustumPlane the resuling frustum plane
  19877. */
  19878. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19879. /**
  19880. * Gets the far frustum plane transformed by the transform matrix
  19881. * @param transform transformation matrix to be applied to the resulting frustum plane
  19882. * @param frustumPlane the resuling frustum plane
  19883. */
  19884. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19885. /**
  19886. * Gets the left frustum plane transformed by the transform matrix
  19887. * @param transform transformation matrix to be applied to the resulting frustum plane
  19888. * @param frustumPlane the resuling frustum plane
  19889. */
  19890. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19891. /**
  19892. * Gets the right frustum plane transformed by the transform matrix
  19893. * @param transform transformation matrix to be applied to the resulting frustum plane
  19894. * @param frustumPlane the resuling frustum plane
  19895. */
  19896. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19897. /**
  19898. * Gets the top frustum plane transformed by the transform matrix
  19899. * @param transform transformation matrix to be applied to the resulting frustum plane
  19900. * @param frustumPlane the resuling frustum plane
  19901. */
  19902. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19903. /**
  19904. * Gets the bottom frustum plane transformed by the transform matrix
  19905. * @param transform transformation matrix to be applied to the resulting frustum plane
  19906. * @param frustumPlane the resuling frustum plane
  19907. */
  19908. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19909. /**
  19910. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19911. * @param transform transformation matrix to be applied to the resulting frustum planes
  19912. * @param frustumPlanes the resuling frustum planes
  19913. */
  19914. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19915. }
  19916. }
  19917. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19918. import { Camera } from "babylonjs/Cameras/camera";
  19919. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19920. import { Nullable } from "babylonjs/types";
  19921. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19922. import { Matrix } from "babylonjs/Maths/math.vector";
  19923. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19924. module "babylonjs/Engines/engine" {
  19925. interface Engine {
  19926. /**
  19927. * Creates a new multiview render target
  19928. * @param width defines the width of the texture
  19929. * @param height defines the height of the texture
  19930. * @returns the created multiview texture
  19931. */
  19932. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19933. /**
  19934. * Binds a multiview framebuffer to be drawn to
  19935. * @param multiviewTexture texture to bind
  19936. */
  19937. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19938. }
  19939. }
  19940. module "babylonjs/Cameras/camera" {
  19941. interface Camera {
  19942. /**
  19943. * @hidden
  19944. * 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)
  19945. */
  19946. _useMultiviewToSingleView: boolean;
  19947. /**
  19948. * @hidden
  19949. * 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)
  19950. */
  19951. _multiviewTexture: Nullable<RenderTargetTexture>;
  19952. /**
  19953. * @hidden
  19954. * ensures the multiview texture of the camera exists and has the specified width/height
  19955. * @param width height to set on the multiview texture
  19956. * @param height width to set on the multiview texture
  19957. */
  19958. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19959. }
  19960. }
  19961. module "babylonjs/scene" {
  19962. interface Scene {
  19963. /** @hidden */
  19964. _transformMatrixR: Matrix;
  19965. /** @hidden */
  19966. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19967. /** @hidden */
  19968. _createMultiviewUbo(): void;
  19969. /** @hidden */
  19970. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19971. /** @hidden */
  19972. _renderMultiviewToSingleView(camera: Camera): void;
  19973. }
  19974. }
  19975. }
  19976. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19977. import { Camera } from "babylonjs/Cameras/camera";
  19978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19979. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19980. import "babylonjs/Engines/Extensions/engine.multiview";
  19981. /**
  19982. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19983. * This will not be used for webXR as it supports displaying texture arrays directly
  19984. */
  19985. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19986. /**
  19987. * Initializes a VRMultiviewToSingleview
  19988. * @param name name of the post process
  19989. * @param camera camera to be applied to
  19990. * @param scaleFactor scaling factor to the size of the output texture
  19991. */
  19992. constructor(name: string, camera: Camera, scaleFactor: number);
  19993. }
  19994. }
  19995. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19996. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19997. import { Nullable } from "babylonjs/types";
  19998. import { Size } from "babylonjs/Maths/math.size";
  19999. import { Observable } from "babylonjs/Misc/observable";
  20000. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20001. /**
  20002. * Interface used to define additional presentation attributes
  20003. */
  20004. export interface IVRPresentationAttributes {
  20005. /**
  20006. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20007. */
  20008. highRefreshRate: boolean;
  20009. /**
  20010. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20011. */
  20012. foveationLevel: number;
  20013. }
  20014. module "babylonjs/Engines/engine" {
  20015. interface Engine {
  20016. /** @hidden */
  20017. _vrDisplay: any;
  20018. /** @hidden */
  20019. _vrSupported: boolean;
  20020. /** @hidden */
  20021. _oldSize: Size;
  20022. /** @hidden */
  20023. _oldHardwareScaleFactor: number;
  20024. /** @hidden */
  20025. _vrExclusivePointerMode: boolean;
  20026. /** @hidden */
  20027. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20028. /** @hidden */
  20029. _onVRDisplayPointerRestricted: () => void;
  20030. /** @hidden */
  20031. _onVRDisplayPointerUnrestricted: () => void;
  20032. /** @hidden */
  20033. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20034. /** @hidden */
  20035. _onVrDisplayDisconnect: Nullable<() => void>;
  20036. /** @hidden */
  20037. _onVrDisplayPresentChange: Nullable<() => void>;
  20038. /**
  20039. * Observable signaled when VR display mode changes
  20040. */
  20041. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20042. /**
  20043. * Observable signaled when VR request present is complete
  20044. */
  20045. onVRRequestPresentComplete: Observable<boolean>;
  20046. /**
  20047. * Observable signaled when VR request present starts
  20048. */
  20049. onVRRequestPresentStart: Observable<Engine>;
  20050. /**
  20051. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20052. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20053. */
  20054. isInVRExclusivePointerMode: boolean;
  20055. /**
  20056. * Gets a boolean indicating if a webVR device was detected
  20057. * @returns true if a webVR device was detected
  20058. */
  20059. isVRDevicePresent(): boolean;
  20060. /**
  20061. * Gets the current webVR device
  20062. * @returns the current webVR device (or null)
  20063. */
  20064. getVRDevice(): any;
  20065. /**
  20066. * Initializes a webVR display and starts listening to display change events
  20067. * The onVRDisplayChangedObservable will be notified upon these changes
  20068. * @returns A promise containing a VRDisplay and if vr is supported
  20069. */
  20070. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20071. /** @hidden */
  20072. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20073. /**
  20074. * Gets or sets the presentation attributes used to configure VR rendering
  20075. */
  20076. vrPresentationAttributes?: IVRPresentationAttributes;
  20077. /**
  20078. * Call this function to switch to webVR mode
  20079. * Will do nothing if webVR is not supported or if there is no webVR device
  20080. * @param options the webvr options provided to the camera. mainly used for multiview
  20081. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20082. */
  20083. enableVR(options: WebVROptions): void;
  20084. /** @hidden */
  20085. _onVRFullScreenTriggered(): void;
  20086. }
  20087. }
  20088. }
  20089. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20090. import { Nullable } from "babylonjs/types";
  20091. import { Observable } from "babylonjs/Misc/observable";
  20092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20093. import { Scene } from "babylonjs/scene";
  20094. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20095. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20096. import { Node } from "babylonjs/node";
  20097. import { Ray } from "babylonjs/Culling/ray";
  20098. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20099. import "babylonjs/Engines/Extensions/engine.webVR";
  20100. /**
  20101. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20102. * IMPORTANT!! The data is right-hand data.
  20103. * @export
  20104. * @interface DevicePose
  20105. */
  20106. export interface DevicePose {
  20107. /**
  20108. * The position of the device, values in array are [x,y,z].
  20109. */
  20110. readonly position: Nullable<Float32Array>;
  20111. /**
  20112. * The linearVelocity of the device, values in array are [x,y,z].
  20113. */
  20114. readonly linearVelocity: Nullable<Float32Array>;
  20115. /**
  20116. * The linearAcceleration of the device, values in array are [x,y,z].
  20117. */
  20118. readonly linearAcceleration: Nullable<Float32Array>;
  20119. /**
  20120. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20121. */
  20122. readonly orientation: Nullable<Float32Array>;
  20123. /**
  20124. * The angularVelocity of the device, values in array are [x,y,z].
  20125. */
  20126. readonly angularVelocity: Nullable<Float32Array>;
  20127. /**
  20128. * The angularAcceleration of the device, values in array are [x,y,z].
  20129. */
  20130. readonly angularAcceleration: Nullable<Float32Array>;
  20131. }
  20132. /**
  20133. * Interface representing a pose controlled object in Babylon.
  20134. * A pose controlled object has both regular pose values as well as pose values
  20135. * from an external device such as a VR head mounted display
  20136. */
  20137. export interface PoseControlled {
  20138. /**
  20139. * The position of the object in babylon space.
  20140. */
  20141. position: Vector3;
  20142. /**
  20143. * The rotation quaternion of the object in babylon space.
  20144. */
  20145. rotationQuaternion: Quaternion;
  20146. /**
  20147. * The position of the device in babylon space.
  20148. */
  20149. devicePosition?: Vector3;
  20150. /**
  20151. * The rotation quaternion of the device in babylon space.
  20152. */
  20153. deviceRotationQuaternion: Quaternion;
  20154. /**
  20155. * The raw pose coming from the device.
  20156. */
  20157. rawPose: Nullable<DevicePose>;
  20158. /**
  20159. * The scale of the device to be used when translating from device space to babylon space.
  20160. */
  20161. deviceScaleFactor: number;
  20162. /**
  20163. * Updates the poseControlled values based on the input device pose.
  20164. * @param poseData the pose data to update the object with
  20165. */
  20166. updateFromDevice(poseData: DevicePose): void;
  20167. }
  20168. /**
  20169. * Set of options to customize the webVRCamera
  20170. */
  20171. export interface WebVROptions {
  20172. /**
  20173. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20174. */
  20175. trackPosition?: boolean;
  20176. /**
  20177. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20178. */
  20179. positionScale?: number;
  20180. /**
  20181. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20182. */
  20183. displayName?: string;
  20184. /**
  20185. * Should the native controller meshes be initialized. (default: true)
  20186. */
  20187. controllerMeshes?: boolean;
  20188. /**
  20189. * Creating a default HemiLight only on controllers. (default: true)
  20190. */
  20191. defaultLightingOnControllers?: boolean;
  20192. /**
  20193. * If you don't want to use the default VR button of the helper. (default: false)
  20194. */
  20195. useCustomVRButton?: boolean;
  20196. /**
  20197. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20198. */
  20199. customVRButton?: HTMLButtonElement;
  20200. /**
  20201. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20202. */
  20203. rayLength?: number;
  20204. /**
  20205. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20206. */
  20207. defaultHeight?: number;
  20208. /**
  20209. * If multiview should be used if availible (default: false)
  20210. */
  20211. useMultiview?: boolean;
  20212. }
  20213. /**
  20214. * This represents a WebVR camera.
  20215. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20216. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20217. */
  20218. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20219. private webVROptions;
  20220. /**
  20221. * @hidden
  20222. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20223. */
  20224. _vrDevice: any;
  20225. /**
  20226. * The rawPose of the vrDevice.
  20227. */
  20228. rawPose: Nullable<DevicePose>;
  20229. private _onVREnabled;
  20230. private _specsVersion;
  20231. private _attached;
  20232. private _frameData;
  20233. protected _descendants: Array<Node>;
  20234. private _deviceRoomPosition;
  20235. /** @hidden */
  20236. _deviceRoomRotationQuaternion: Quaternion;
  20237. private _standingMatrix;
  20238. /**
  20239. * Represents device position in babylon space.
  20240. */
  20241. devicePosition: Vector3;
  20242. /**
  20243. * Represents device rotation in babylon space.
  20244. */
  20245. deviceRotationQuaternion: Quaternion;
  20246. /**
  20247. * The scale of the device to be used when translating from device space to babylon space.
  20248. */
  20249. deviceScaleFactor: number;
  20250. private _deviceToWorld;
  20251. private _worldToDevice;
  20252. /**
  20253. * References to the webVR controllers for the vrDevice.
  20254. */
  20255. controllers: Array<WebVRController>;
  20256. /**
  20257. * Emits an event when a controller is attached.
  20258. */
  20259. onControllersAttachedObservable: Observable<WebVRController[]>;
  20260. /**
  20261. * Emits an event when a controller's mesh has been loaded;
  20262. */
  20263. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20264. /**
  20265. * Emits an event when the HMD's pose has been updated.
  20266. */
  20267. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20268. private _poseSet;
  20269. /**
  20270. * If the rig cameras be used as parent instead of this camera.
  20271. */
  20272. rigParenting: boolean;
  20273. private _lightOnControllers;
  20274. private _defaultHeight?;
  20275. /**
  20276. * Instantiates a WebVRFreeCamera.
  20277. * @param name The name of the WebVRFreeCamera
  20278. * @param position The starting anchor position for the camera
  20279. * @param scene The scene the camera belongs to
  20280. * @param webVROptions a set of customizable options for the webVRCamera
  20281. */
  20282. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20283. /**
  20284. * Gets the device distance from the ground in meters.
  20285. * @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.
  20286. */
  20287. deviceDistanceToRoomGround(): number;
  20288. /**
  20289. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20290. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20291. */
  20292. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20293. /**
  20294. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20295. * @returns A promise with a boolean set to if the standing matrix is supported.
  20296. */
  20297. useStandingMatrixAsync(): Promise<boolean>;
  20298. /**
  20299. * Disposes the camera
  20300. */
  20301. dispose(): void;
  20302. /**
  20303. * Gets a vrController by name.
  20304. * @param name The name of the controller to retreive
  20305. * @returns the controller matching the name specified or null if not found
  20306. */
  20307. getControllerByName(name: string): Nullable<WebVRController>;
  20308. private _leftController;
  20309. /**
  20310. * The controller corresponding to the users left hand.
  20311. */
  20312. get leftController(): Nullable<WebVRController>;
  20313. private _rightController;
  20314. /**
  20315. * The controller corresponding to the users right hand.
  20316. */
  20317. get rightController(): Nullable<WebVRController>;
  20318. /**
  20319. * Casts a ray forward from the vrCamera's gaze.
  20320. * @param length Length of the ray (default: 100)
  20321. * @returns the ray corresponding to the gaze
  20322. */
  20323. getForwardRay(length?: number): Ray;
  20324. /**
  20325. * @hidden
  20326. * Updates the camera based on device's frame data
  20327. */
  20328. _checkInputs(): void;
  20329. /**
  20330. * Updates the poseControlled values based on the input device pose.
  20331. * @param poseData Pose coming from the device
  20332. */
  20333. updateFromDevice(poseData: DevicePose): void;
  20334. private _htmlElementAttached;
  20335. private _detachIfAttached;
  20336. /**
  20337. * WebVR's attach control will start broadcasting frames to the device.
  20338. * Note that in certain browsers (chrome for example) this function must be called
  20339. * within a user-interaction callback. Example:
  20340. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20341. *
  20342. * @param element html element to attach the vrDevice to
  20343. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20344. */
  20345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20346. /**
  20347. * Detaches the camera from the html element and disables VR
  20348. *
  20349. * @param element html element to detach from
  20350. */
  20351. detachControl(element: HTMLElement): void;
  20352. /**
  20353. * @returns the name of this class
  20354. */
  20355. getClassName(): string;
  20356. /**
  20357. * Calls resetPose on the vrDisplay
  20358. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20359. */
  20360. resetToCurrentRotation(): void;
  20361. /**
  20362. * @hidden
  20363. * Updates the rig cameras (left and right eye)
  20364. */
  20365. _updateRigCameras(): void;
  20366. private _workingVector;
  20367. private _oneVector;
  20368. private _workingMatrix;
  20369. private updateCacheCalled;
  20370. private _correctPositionIfNotTrackPosition;
  20371. /**
  20372. * @hidden
  20373. * Updates the cached values of the camera
  20374. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20375. */
  20376. _updateCache(ignoreParentClass?: boolean): void;
  20377. /**
  20378. * @hidden
  20379. * Get current device position in babylon world
  20380. */
  20381. _computeDevicePosition(): void;
  20382. /**
  20383. * Updates the current device position and rotation in the babylon world
  20384. */
  20385. update(): void;
  20386. /**
  20387. * @hidden
  20388. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20389. * @returns an identity matrix
  20390. */
  20391. _getViewMatrix(): Matrix;
  20392. private _tmpMatrix;
  20393. /**
  20394. * This function is called by the two RIG cameras.
  20395. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20396. * @hidden
  20397. */
  20398. _getWebVRViewMatrix(): Matrix;
  20399. /** @hidden */
  20400. _getWebVRProjectionMatrix(): Matrix;
  20401. private _onGamepadConnectedObserver;
  20402. private _onGamepadDisconnectedObserver;
  20403. private _updateCacheWhenTrackingDisabledObserver;
  20404. /**
  20405. * Initializes the controllers and their meshes
  20406. */
  20407. initControllers(): void;
  20408. }
  20409. }
  20410. declare module "babylonjs/PostProcesses/postProcess" {
  20411. import { Nullable } from "babylonjs/types";
  20412. import { SmartArray } from "babylonjs/Misc/smartArray";
  20413. import { Observable } from "babylonjs/Misc/observable";
  20414. import { Vector2 } from "babylonjs/Maths/math.vector";
  20415. import { Camera } from "babylonjs/Cameras/camera";
  20416. import { Effect } from "babylonjs/Materials/effect";
  20417. import "babylonjs/Shaders/postprocess.vertex";
  20418. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20419. import { Engine } from "babylonjs/Engines/engine";
  20420. import { Color4 } from "babylonjs/Maths/math.color";
  20421. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20423. /**
  20424. * Size options for a post process
  20425. */
  20426. export type PostProcessOptions = {
  20427. width: number;
  20428. height: number;
  20429. };
  20430. /**
  20431. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20432. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20433. */
  20434. export class PostProcess {
  20435. /** Name of the PostProcess. */
  20436. name: string;
  20437. /**
  20438. * Gets or sets the unique id of the post process
  20439. */
  20440. uniqueId: number;
  20441. /**
  20442. * Width of the texture to apply the post process on
  20443. */
  20444. width: number;
  20445. /**
  20446. * Height of the texture to apply the post process on
  20447. */
  20448. height: number;
  20449. /**
  20450. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20451. * @hidden
  20452. */
  20453. _outputTexture: Nullable<InternalTexture>;
  20454. /**
  20455. * Sampling mode used by the shader
  20456. * See https://doc.babylonjs.com/classes/3.1/texture
  20457. */
  20458. renderTargetSamplingMode: number;
  20459. /**
  20460. * Clear color to use when screen clearing
  20461. */
  20462. clearColor: Color4;
  20463. /**
  20464. * If the buffer needs to be cleared before applying the post process. (default: true)
  20465. * Should be set to false if shader will overwrite all previous pixels.
  20466. */
  20467. autoClear: boolean;
  20468. /**
  20469. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20470. */
  20471. alphaMode: number;
  20472. /**
  20473. * Sets the setAlphaBlendConstants of the babylon engine
  20474. */
  20475. alphaConstants: Color4;
  20476. /**
  20477. * Animations to be used for the post processing
  20478. */
  20479. animations: import("babylonjs/Animations/animation").Animation[];
  20480. /**
  20481. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20482. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20483. */
  20484. enablePixelPerfectMode: boolean;
  20485. /**
  20486. * Force the postprocess to be applied without taking in account viewport
  20487. */
  20488. forceFullscreenViewport: boolean;
  20489. /**
  20490. * List of inspectable custom properties (used by the Inspector)
  20491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20492. */
  20493. inspectableCustomProperties: IInspectable[];
  20494. /**
  20495. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20496. *
  20497. * | Value | Type | Description |
  20498. * | ----- | ----------------------------------- | ----------- |
  20499. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20500. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20501. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20502. *
  20503. */
  20504. scaleMode: number;
  20505. /**
  20506. * Force textures to be a power of two (default: false)
  20507. */
  20508. alwaysForcePOT: boolean;
  20509. private _samples;
  20510. /**
  20511. * Number of sample textures (default: 1)
  20512. */
  20513. get samples(): number;
  20514. set samples(n: number);
  20515. /**
  20516. * Modify the scale of the post process to be the same as the viewport (default: false)
  20517. */
  20518. adaptScaleToCurrentViewport: boolean;
  20519. private _camera;
  20520. private _scene;
  20521. private _engine;
  20522. private _options;
  20523. private _reusable;
  20524. private _textureType;
  20525. private _textureFormat;
  20526. /**
  20527. * Smart array of input and output textures for the post process.
  20528. * @hidden
  20529. */
  20530. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20531. /**
  20532. * The index in _textures that corresponds to the output texture.
  20533. * @hidden
  20534. */
  20535. _currentRenderTextureInd: number;
  20536. private _effect;
  20537. private _samplers;
  20538. private _fragmentUrl;
  20539. private _vertexUrl;
  20540. private _parameters;
  20541. private _scaleRatio;
  20542. protected _indexParameters: any;
  20543. private _shareOutputWithPostProcess;
  20544. private _texelSize;
  20545. private _forcedOutputTexture;
  20546. /**
  20547. * Returns the fragment url or shader name used in the post process.
  20548. * @returns the fragment url or name in the shader store.
  20549. */
  20550. getEffectName(): string;
  20551. /**
  20552. * An event triggered when the postprocess is activated.
  20553. */
  20554. onActivateObservable: Observable<Camera>;
  20555. private _onActivateObserver;
  20556. /**
  20557. * A function that is added to the onActivateObservable
  20558. */
  20559. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20560. /**
  20561. * An event triggered when the postprocess changes its size.
  20562. */
  20563. onSizeChangedObservable: Observable<PostProcess>;
  20564. private _onSizeChangedObserver;
  20565. /**
  20566. * A function that is added to the onSizeChangedObservable
  20567. */
  20568. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20569. /**
  20570. * An event triggered when the postprocess applies its effect.
  20571. */
  20572. onApplyObservable: Observable<Effect>;
  20573. private _onApplyObserver;
  20574. /**
  20575. * A function that is added to the onApplyObservable
  20576. */
  20577. set onApply(callback: (effect: Effect) => void);
  20578. /**
  20579. * An event triggered before rendering the postprocess
  20580. */
  20581. onBeforeRenderObservable: Observable<Effect>;
  20582. private _onBeforeRenderObserver;
  20583. /**
  20584. * A function that is added to the onBeforeRenderObservable
  20585. */
  20586. set onBeforeRender(callback: (effect: Effect) => void);
  20587. /**
  20588. * An event triggered after rendering the postprocess
  20589. */
  20590. onAfterRenderObservable: Observable<Effect>;
  20591. private _onAfterRenderObserver;
  20592. /**
  20593. * A function that is added to the onAfterRenderObservable
  20594. */
  20595. set onAfterRender(callback: (efect: Effect) => void);
  20596. /**
  20597. * 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
  20598. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20599. */
  20600. get inputTexture(): InternalTexture;
  20601. set inputTexture(value: InternalTexture);
  20602. /**
  20603. * Gets the camera which post process is applied to.
  20604. * @returns The camera the post process is applied to.
  20605. */
  20606. getCamera(): Camera;
  20607. /**
  20608. * Gets the texel size of the postprocess.
  20609. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20610. */
  20611. get texelSize(): Vector2;
  20612. /**
  20613. * Creates a new instance PostProcess
  20614. * @param name The name of the PostProcess.
  20615. * @param fragmentUrl The url of the fragment shader to be used.
  20616. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20617. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20618. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20619. * @param camera The camera to apply the render pass to.
  20620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20621. * @param engine The engine which the post process will be applied. (default: current engine)
  20622. * @param reusable If the post process can be reused on the same frame. (default: false)
  20623. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20624. * @param textureType Type of textures used when performing the post process. (default: 0)
  20625. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20626. * @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
  20627. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20628. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20629. */
  20630. constructor(
  20631. /** Name of the PostProcess. */
  20632. 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);
  20633. /**
  20634. * Gets a string idenfifying the name of the class
  20635. * @returns "PostProcess" string
  20636. */
  20637. getClassName(): string;
  20638. /**
  20639. * Gets the engine which this post process belongs to.
  20640. * @returns The engine the post process was enabled with.
  20641. */
  20642. getEngine(): Engine;
  20643. /**
  20644. * The effect that is created when initializing the post process.
  20645. * @returns The created effect corresponding the the postprocess.
  20646. */
  20647. getEffect(): Effect;
  20648. /**
  20649. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20650. * @param postProcess The post process to share the output with.
  20651. * @returns This post process.
  20652. */
  20653. shareOutputWith(postProcess: PostProcess): PostProcess;
  20654. /**
  20655. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20656. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20657. */
  20658. useOwnOutput(): void;
  20659. /**
  20660. * Updates the effect with the current post process compile time values and recompiles the shader.
  20661. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20662. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20663. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20664. * @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
  20665. * @param onCompiled Called when the shader has been compiled.
  20666. * @param onError Called if there is an error when compiling a shader.
  20667. */
  20668. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20669. /**
  20670. * The post process is reusable if it can be used multiple times within one frame.
  20671. * @returns If the post process is reusable
  20672. */
  20673. isReusable(): boolean;
  20674. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20675. markTextureDirty(): void;
  20676. /**
  20677. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20678. * 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.
  20679. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20680. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20681. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20682. * @returns The target texture that was bound to be written to.
  20683. */
  20684. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20685. /**
  20686. * If the post process is supported.
  20687. */
  20688. get isSupported(): boolean;
  20689. /**
  20690. * The aspect ratio of the output texture.
  20691. */
  20692. get aspectRatio(): number;
  20693. /**
  20694. * Get a value indicating if the post-process is ready to be used
  20695. * @returns true if the post-process is ready (shader is compiled)
  20696. */
  20697. isReady(): boolean;
  20698. /**
  20699. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20700. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20701. */
  20702. apply(): Nullable<Effect>;
  20703. private _disposeTextures;
  20704. /**
  20705. * Disposes the post process.
  20706. * @param camera The camera to dispose the post process on.
  20707. */
  20708. dispose(camera?: Camera): void;
  20709. }
  20710. }
  20711. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20712. /** @hidden */
  20713. export var kernelBlurVaryingDeclaration: {
  20714. name: string;
  20715. shader: string;
  20716. };
  20717. }
  20718. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20719. /** @hidden */
  20720. export var kernelBlurFragment: {
  20721. name: string;
  20722. shader: string;
  20723. };
  20724. }
  20725. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20726. /** @hidden */
  20727. export var kernelBlurFragment2: {
  20728. name: string;
  20729. shader: string;
  20730. };
  20731. }
  20732. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20733. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20734. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20735. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20736. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20737. /** @hidden */
  20738. export var kernelBlurPixelShader: {
  20739. name: string;
  20740. shader: string;
  20741. };
  20742. }
  20743. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20744. /** @hidden */
  20745. export var kernelBlurVertex: {
  20746. name: string;
  20747. shader: string;
  20748. };
  20749. }
  20750. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20751. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20752. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20753. /** @hidden */
  20754. export var kernelBlurVertexShader: {
  20755. name: string;
  20756. shader: string;
  20757. };
  20758. }
  20759. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20760. import { Vector2 } from "babylonjs/Maths/math.vector";
  20761. import { Nullable } from "babylonjs/types";
  20762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20763. import { Camera } from "babylonjs/Cameras/camera";
  20764. import { Effect } from "babylonjs/Materials/effect";
  20765. import { Engine } from "babylonjs/Engines/engine";
  20766. import "babylonjs/Shaders/kernelBlur.fragment";
  20767. import "babylonjs/Shaders/kernelBlur.vertex";
  20768. /**
  20769. * The Blur Post Process which blurs an image based on a kernel and direction.
  20770. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20771. */
  20772. export class BlurPostProcess extends PostProcess {
  20773. /** The direction in which to blur the image. */
  20774. direction: Vector2;
  20775. private blockCompilation;
  20776. protected _kernel: number;
  20777. protected _idealKernel: number;
  20778. protected _packedFloat: boolean;
  20779. private _staticDefines;
  20780. /**
  20781. * Sets the length in pixels of the blur sample region
  20782. */
  20783. set kernel(v: number);
  20784. /**
  20785. * Gets the length in pixels of the blur sample region
  20786. */
  20787. get kernel(): number;
  20788. /**
  20789. * Sets wether or not the blur needs to unpack/repack floats
  20790. */
  20791. set packedFloat(v: boolean);
  20792. /**
  20793. * Gets wether or not the blur is unpacking/repacking floats
  20794. */
  20795. get packedFloat(): boolean;
  20796. /**
  20797. * Creates a new instance BlurPostProcess
  20798. * @param name The name of the effect.
  20799. * @param direction The direction in which to blur the image.
  20800. * @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.
  20801. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20802. * @param camera The camera to apply the render pass to.
  20803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20804. * @param engine The engine which the post process will be applied. (default: current engine)
  20805. * @param reusable If the post process can be reused on the same frame. (default: false)
  20806. * @param textureType Type of textures used when performing the post process. (default: 0)
  20807. * @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)
  20808. */
  20809. constructor(name: string,
  20810. /** The direction in which to blur the image. */
  20811. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20812. /**
  20813. * Updates the effect with the current post process compile time values and recompiles the shader.
  20814. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20815. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20816. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20817. * @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
  20818. * @param onCompiled Called when the shader has been compiled.
  20819. * @param onError Called if there is an error when compiling a shader.
  20820. */
  20821. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20822. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20823. /**
  20824. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20825. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20826. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20827. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20828. * The gaps between physical kernels are compensated for in the weighting of the samples
  20829. * @param idealKernel Ideal blur kernel.
  20830. * @return Nearest best kernel.
  20831. */
  20832. protected _nearestBestKernel(idealKernel: number): number;
  20833. /**
  20834. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20835. * @param x The point on the Gaussian distribution to sample.
  20836. * @return the value of the Gaussian function at x.
  20837. */
  20838. protected _gaussianWeight(x: number): number;
  20839. /**
  20840. * Generates a string that can be used as a floating point number in GLSL.
  20841. * @param x Value to print.
  20842. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20843. * @return GLSL float string.
  20844. */
  20845. protected _glslFloat(x: number, decimalFigures?: number): string;
  20846. }
  20847. }
  20848. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20849. import { Scene } from "babylonjs/scene";
  20850. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20851. import { Plane } from "babylonjs/Maths/math.plane";
  20852. /**
  20853. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20854. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20855. * You can then easily use it as a reflectionTexture on a flat surface.
  20856. * In case the surface is not a plane, please consider relying on reflection probes.
  20857. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20858. */
  20859. export class MirrorTexture extends RenderTargetTexture {
  20860. private scene;
  20861. /**
  20862. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20863. * 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.
  20864. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20865. */
  20866. mirrorPlane: Plane;
  20867. /**
  20868. * Define the blur ratio used to blur the reflection if needed.
  20869. */
  20870. set blurRatio(value: number);
  20871. get blurRatio(): number;
  20872. /**
  20873. * Define the adaptive blur kernel used to blur the reflection if needed.
  20874. * This will autocompute the closest best match for the `blurKernel`
  20875. */
  20876. set adaptiveBlurKernel(value: number);
  20877. /**
  20878. * Define the blur kernel used to blur the reflection if needed.
  20879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20880. */
  20881. set blurKernel(value: number);
  20882. /**
  20883. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20885. */
  20886. set blurKernelX(value: number);
  20887. get blurKernelX(): number;
  20888. /**
  20889. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20890. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20891. */
  20892. set blurKernelY(value: number);
  20893. get blurKernelY(): number;
  20894. private _autoComputeBlurKernel;
  20895. protected _onRatioRescale(): void;
  20896. private _updateGammaSpace;
  20897. private _imageProcessingConfigChangeObserver;
  20898. private _transformMatrix;
  20899. private _mirrorMatrix;
  20900. private _savedViewMatrix;
  20901. private _blurX;
  20902. private _blurY;
  20903. private _adaptiveBlurKernel;
  20904. private _blurKernelX;
  20905. private _blurKernelY;
  20906. private _blurRatio;
  20907. /**
  20908. * Instantiates a Mirror Texture.
  20909. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20910. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20911. * You can then easily use it as a reflectionTexture on a flat surface.
  20912. * In case the surface is not a plane, please consider relying on reflection probes.
  20913. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20914. * @param name
  20915. * @param size
  20916. * @param scene
  20917. * @param generateMipMaps
  20918. * @param type
  20919. * @param samplingMode
  20920. * @param generateDepthBuffer
  20921. */
  20922. constructor(name: string, size: number | {
  20923. width: number;
  20924. height: number;
  20925. } | {
  20926. ratio: number;
  20927. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20928. private _preparePostProcesses;
  20929. /**
  20930. * Clone the mirror texture.
  20931. * @returns the cloned texture
  20932. */
  20933. clone(): MirrorTexture;
  20934. /**
  20935. * Serialize the texture to a JSON representation you could use in Parse later on
  20936. * @returns the serialized JSON representation
  20937. */
  20938. serialize(): any;
  20939. /**
  20940. * Dispose the texture and release its associated resources.
  20941. */
  20942. dispose(): void;
  20943. }
  20944. }
  20945. declare module "babylonjs/Materials/Textures/texture" {
  20946. import { Observable } from "babylonjs/Misc/observable";
  20947. import { Nullable } from "babylonjs/types";
  20948. import { Matrix } from "babylonjs/Maths/math.vector";
  20949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20950. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20951. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20952. import { Scene } from "babylonjs/scene";
  20953. /**
  20954. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20955. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20956. */
  20957. export class Texture extends BaseTexture {
  20958. /**
  20959. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20960. */
  20961. static SerializeBuffers: boolean;
  20962. /** @hidden */
  20963. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20964. /** @hidden */
  20965. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20966. /** @hidden */
  20967. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20968. /** nearest is mag = nearest and min = nearest and mip = linear */
  20969. static readonly NEAREST_SAMPLINGMODE: number;
  20970. /** nearest is mag = nearest and min = nearest and mip = linear */
  20971. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20972. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20973. static readonly BILINEAR_SAMPLINGMODE: number;
  20974. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20975. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20976. /** Trilinear is mag = linear and min = linear and mip = linear */
  20977. static readonly TRILINEAR_SAMPLINGMODE: number;
  20978. /** Trilinear is mag = linear and min = linear and mip = linear */
  20979. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20980. /** mag = nearest and min = nearest and mip = nearest */
  20981. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20982. /** mag = nearest and min = linear and mip = nearest */
  20983. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20984. /** mag = nearest and min = linear and mip = linear */
  20985. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20986. /** mag = nearest and min = linear and mip = none */
  20987. static readonly NEAREST_LINEAR: number;
  20988. /** mag = nearest and min = nearest and mip = none */
  20989. static readonly NEAREST_NEAREST: number;
  20990. /** mag = linear and min = nearest and mip = nearest */
  20991. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20992. /** mag = linear and min = nearest and mip = linear */
  20993. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20994. /** mag = linear and min = linear and mip = none */
  20995. static readonly LINEAR_LINEAR: number;
  20996. /** mag = linear and min = nearest and mip = none */
  20997. static readonly LINEAR_NEAREST: number;
  20998. /** Explicit coordinates mode */
  20999. static readonly EXPLICIT_MODE: number;
  21000. /** Spherical coordinates mode */
  21001. static readonly SPHERICAL_MODE: number;
  21002. /** Planar coordinates mode */
  21003. static readonly PLANAR_MODE: number;
  21004. /** Cubic coordinates mode */
  21005. static readonly CUBIC_MODE: number;
  21006. /** Projection coordinates mode */
  21007. static readonly PROJECTION_MODE: number;
  21008. /** Inverse Cubic coordinates mode */
  21009. static readonly SKYBOX_MODE: number;
  21010. /** Inverse Cubic coordinates mode */
  21011. static readonly INVCUBIC_MODE: number;
  21012. /** Equirectangular coordinates mode */
  21013. static readonly EQUIRECTANGULAR_MODE: number;
  21014. /** Equirectangular Fixed coordinates mode */
  21015. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21016. /** Equirectangular Fixed Mirrored coordinates mode */
  21017. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21018. /** Texture is not repeating outside of 0..1 UVs */
  21019. static readonly CLAMP_ADDRESSMODE: number;
  21020. /** Texture is repeating outside of 0..1 UVs */
  21021. static readonly WRAP_ADDRESSMODE: number;
  21022. /** Texture is repeating and mirrored */
  21023. static readonly MIRROR_ADDRESSMODE: number;
  21024. /**
  21025. * 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
  21026. */
  21027. static UseSerializedUrlIfAny: boolean;
  21028. /**
  21029. * Define the url of the texture.
  21030. */
  21031. url: Nullable<string>;
  21032. /**
  21033. * Define an offset on the texture to offset the u coordinates of the UVs
  21034. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21035. */
  21036. uOffset: number;
  21037. /**
  21038. * Define an offset on the texture to offset the v coordinates of the UVs
  21039. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21040. */
  21041. vOffset: number;
  21042. /**
  21043. * Define an offset on the texture to scale the u coordinates of the UVs
  21044. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21045. */
  21046. uScale: number;
  21047. /**
  21048. * Define an offset on the texture to scale the v coordinates of the UVs
  21049. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21050. */
  21051. vScale: number;
  21052. /**
  21053. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21054. * @see http://doc.babylonjs.com/how_to/more_materials
  21055. */
  21056. uAng: number;
  21057. /**
  21058. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21059. * @see http://doc.babylonjs.com/how_to/more_materials
  21060. */
  21061. vAng: number;
  21062. /**
  21063. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21064. * @see http://doc.babylonjs.com/how_to/more_materials
  21065. */
  21066. wAng: number;
  21067. /**
  21068. * Defines the center of rotation (U)
  21069. */
  21070. uRotationCenter: number;
  21071. /**
  21072. * Defines the center of rotation (V)
  21073. */
  21074. vRotationCenter: number;
  21075. /**
  21076. * Defines the center of rotation (W)
  21077. */
  21078. wRotationCenter: number;
  21079. /**
  21080. * Are mip maps generated for this texture or not.
  21081. */
  21082. get noMipmap(): boolean;
  21083. /**
  21084. * List of inspectable custom properties (used by the Inspector)
  21085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21086. */
  21087. inspectableCustomProperties: Nullable<IInspectable[]>;
  21088. private _noMipmap;
  21089. /** @hidden */
  21090. _invertY: boolean;
  21091. private _rowGenerationMatrix;
  21092. private _cachedTextureMatrix;
  21093. private _projectionModeMatrix;
  21094. private _t0;
  21095. private _t1;
  21096. private _t2;
  21097. private _cachedUOffset;
  21098. private _cachedVOffset;
  21099. private _cachedUScale;
  21100. private _cachedVScale;
  21101. private _cachedUAng;
  21102. private _cachedVAng;
  21103. private _cachedWAng;
  21104. private _cachedProjectionMatrixId;
  21105. private _cachedCoordinatesMode;
  21106. /** @hidden */
  21107. protected _initialSamplingMode: number;
  21108. /** @hidden */
  21109. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21110. private _deleteBuffer;
  21111. protected _format: Nullable<number>;
  21112. private _delayedOnLoad;
  21113. private _delayedOnError;
  21114. private _mimeType?;
  21115. /**
  21116. * Observable triggered once the texture has been loaded.
  21117. */
  21118. onLoadObservable: Observable<Texture>;
  21119. protected _isBlocking: boolean;
  21120. /**
  21121. * Is the texture preventing material to render while loading.
  21122. * If false, a default texture will be used instead of the loading one during the preparation step.
  21123. */
  21124. set isBlocking(value: boolean);
  21125. get isBlocking(): boolean;
  21126. /**
  21127. * Get the current sampling mode associated with the texture.
  21128. */
  21129. get samplingMode(): number;
  21130. /**
  21131. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21132. */
  21133. get invertY(): boolean;
  21134. /**
  21135. * Instantiates a new texture.
  21136. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21137. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21138. * @param url defines the url of the picture to load as a texture
  21139. * @param scene defines the scene or engine the texture will belong to
  21140. * @param noMipmap defines if the texture will require mip maps or not
  21141. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21142. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21143. * @param onLoad defines a callback triggered when the texture has been loaded
  21144. * @param onError defines a callback triggered when an error occurred during the loading session
  21145. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21146. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21147. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21148. * @param mimeType defines an optional mime type information
  21149. */
  21150. 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);
  21151. /**
  21152. * Update the url (and optional buffer) of this texture if url was null during construction.
  21153. * @param url the url of the texture
  21154. * @param buffer the buffer of the texture (defaults to null)
  21155. * @param onLoad callback called when the texture is loaded (defaults to null)
  21156. */
  21157. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21158. /**
  21159. * Finish the loading sequence of a texture flagged as delayed load.
  21160. * @hidden
  21161. */
  21162. delayLoad(): void;
  21163. private _prepareRowForTextureGeneration;
  21164. /**
  21165. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21166. * @returns the transform matrix of the texture.
  21167. */
  21168. getTextureMatrix(uBase?: number): Matrix;
  21169. /**
  21170. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21171. * @returns The reflection texture transform
  21172. */
  21173. getReflectionTextureMatrix(): Matrix;
  21174. /**
  21175. * Clones the texture.
  21176. * @returns the cloned texture
  21177. */
  21178. clone(): Texture;
  21179. /**
  21180. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21181. * @returns The JSON representation of the texture
  21182. */
  21183. serialize(): any;
  21184. /**
  21185. * Get the current class name of the texture useful for serialization or dynamic coding.
  21186. * @returns "Texture"
  21187. */
  21188. getClassName(): string;
  21189. /**
  21190. * Dispose the texture and release its associated resources.
  21191. */
  21192. dispose(): void;
  21193. /**
  21194. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21195. * @param parsedTexture Define the JSON representation of the texture
  21196. * @param scene Define the scene the parsed texture should be instantiated in
  21197. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21198. * @returns The parsed texture if successful
  21199. */
  21200. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21201. /**
  21202. * Creates a texture from its base 64 representation.
  21203. * @param data Define the base64 payload without the data: prefix
  21204. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21205. * @param scene Define the scene the texture should belong to
  21206. * @param noMipmap Forces the texture to not create mip map information if true
  21207. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21208. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21209. * @param onLoad define a callback triggered when the texture has been loaded
  21210. * @param onError define a callback triggered when an error occurred during the loading session
  21211. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21212. * @returns the created texture
  21213. */
  21214. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21215. /**
  21216. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21217. * @param data Define the base64 payload without the data: prefix
  21218. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21219. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21220. * @param scene Define the scene the texture should belong to
  21221. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21222. * @param noMipmap Forces the texture to not create mip map information if true
  21223. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21224. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21225. * @param onLoad define a callback triggered when the texture has been loaded
  21226. * @param onError define a callback triggered when an error occurred during the loading session
  21227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21228. * @returns the created texture
  21229. */
  21230. 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;
  21231. }
  21232. }
  21233. declare module "babylonjs/PostProcesses/postProcessManager" {
  21234. import { Nullable } from "babylonjs/types";
  21235. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21236. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21237. import { Scene } from "babylonjs/scene";
  21238. /**
  21239. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21240. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21241. */
  21242. export class PostProcessManager {
  21243. private _scene;
  21244. private _indexBuffer;
  21245. private _vertexBuffers;
  21246. /**
  21247. * Creates a new instance PostProcess
  21248. * @param scene The scene that the post process is associated with.
  21249. */
  21250. constructor(scene: Scene);
  21251. private _prepareBuffers;
  21252. private _buildIndexBuffer;
  21253. /**
  21254. * Rebuilds the vertex buffers of the manager.
  21255. * @hidden
  21256. */
  21257. _rebuild(): void;
  21258. /**
  21259. * Prepares a frame to be run through a post process.
  21260. * @param sourceTexture The input texture to the post procesess. (default: null)
  21261. * @param postProcesses An array of post processes to be run. (default: null)
  21262. * @returns True if the post processes were able to be run.
  21263. * @hidden
  21264. */
  21265. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21266. /**
  21267. * Manually render a set of post processes to a texture.
  21268. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21269. * @param postProcesses An array of post processes to be run.
  21270. * @param targetTexture The target texture to render to.
  21271. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21272. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21273. * @param lodLevel defines which lod of the texture to render to
  21274. */
  21275. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21276. /**
  21277. * Finalize the result of the output of the postprocesses.
  21278. * @param doNotPresent If true the result will not be displayed to the screen.
  21279. * @param targetTexture The target texture to render to.
  21280. * @param faceIndex The index of the face to bind the target texture to.
  21281. * @param postProcesses The array of post processes to render.
  21282. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21283. * @hidden
  21284. */
  21285. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21286. /**
  21287. * Disposes of the post process manager.
  21288. */
  21289. dispose(): void;
  21290. }
  21291. }
  21292. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21293. import { Observable } from "babylonjs/Misc/observable";
  21294. import { SmartArray } from "babylonjs/Misc/smartArray";
  21295. import { Nullable, Immutable } from "babylonjs/types";
  21296. import { Camera } from "babylonjs/Cameras/camera";
  21297. import { Scene } from "babylonjs/scene";
  21298. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21299. import { Color4 } from "babylonjs/Maths/math.color";
  21300. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21304. import { Texture } from "babylonjs/Materials/Textures/texture";
  21305. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21306. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21307. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21308. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21309. import { Engine } from "babylonjs/Engines/engine";
  21310. /**
  21311. * This Helps creating a texture that will be created from a camera in your scene.
  21312. * It is basically a dynamic texture that could be used to create special effects for instance.
  21313. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21314. */
  21315. export class RenderTargetTexture extends Texture {
  21316. isCube: boolean;
  21317. /**
  21318. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21319. */
  21320. static readonly REFRESHRATE_RENDER_ONCE: number;
  21321. /**
  21322. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21323. */
  21324. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21325. /**
  21326. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21327. * the central point of your effect and can save a lot of performances.
  21328. */
  21329. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21330. /**
  21331. * Use this predicate to dynamically define the list of mesh you want to render.
  21332. * If set, the renderList property will be overwritten.
  21333. */
  21334. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21335. private _renderList;
  21336. /**
  21337. * Use this list to define the list of mesh you want to render.
  21338. */
  21339. get renderList(): Nullable<Array<AbstractMesh>>;
  21340. set renderList(value: Nullable<Array<AbstractMesh>>);
  21341. /**
  21342. * Use this function to overload the renderList array at rendering time.
  21343. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21344. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21345. * the cube (if the RTT is a cube, else layerOrFace=0).
  21346. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21347. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21348. * hold dummy elements!
  21349. */
  21350. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21351. private _hookArray;
  21352. /**
  21353. * Define if particles should be rendered in your texture.
  21354. */
  21355. renderParticles: boolean;
  21356. /**
  21357. * Define if sprites should be rendered in your texture.
  21358. */
  21359. renderSprites: boolean;
  21360. /**
  21361. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21362. */
  21363. coordinatesMode: number;
  21364. /**
  21365. * Define the camera used to render the texture.
  21366. */
  21367. activeCamera: Nullable<Camera>;
  21368. /**
  21369. * Override the mesh isReady function with your own one.
  21370. */
  21371. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21372. /**
  21373. * Override the render function of the texture with your own one.
  21374. */
  21375. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21376. /**
  21377. * Define if camera post processes should be use while rendering the texture.
  21378. */
  21379. useCameraPostProcesses: boolean;
  21380. /**
  21381. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21382. */
  21383. ignoreCameraViewport: boolean;
  21384. private _postProcessManager;
  21385. private _postProcesses;
  21386. private _resizeObserver;
  21387. /**
  21388. * An event triggered when the texture is unbind.
  21389. */
  21390. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21391. /**
  21392. * An event triggered when the texture is unbind.
  21393. */
  21394. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21395. private _onAfterUnbindObserver;
  21396. /**
  21397. * Set a after unbind callback in the texture.
  21398. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21399. */
  21400. set onAfterUnbind(callback: () => void);
  21401. /**
  21402. * An event triggered before rendering the texture
  21403. */
  21404. onBeforeRenderObservable: Observable<number>;
  21405. private _onBeforeRenderObserver;
  21406. /**
  21407. * Set a before render callback in the texture.
  21408. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21409. */
  21410. set onBeforeRender(callback: (faceIndex: number) => void);
  21411. /**
  21412. * An event triggered after rendering the texture
  21413. */
  21414. onAfterRenderObservable: Observable<number>;
  21415. private _onAfterRenderObserver;
  21416. /**
  21417. * Set a after render callback in the texture.
  21418. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21419. */
  21420. set onAfterRender(callback: (faceIndex: number) => void);
  21421. /**
  21422. * An event triggered after the texture clear
  21423. */
  21424. onClearObservable: Observable<Engine>;
  21425. private _onClearObserver;
  21426. /**
  21427. * Set a clear callback in the texture.
  21428. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21429. */
  21430. set onClear(callback: (Engine: Engine) => void);
  21431. /**
  21432. * An event triggered when the texture is resized.
  21433. */
  21434. onResizeObservable: Observable<RenderTargetTexture>;
  21435. /**
  21436. * Define the clear color of the Render Target if it should be different from the scene.
  21437. */
  21438. clearColor: Color4;
  21439. protected _size: number | {
  21440. width: number;
  21441. height: number;
  21442. layers?: number;
  21443. };
  21444. protected _initialSizeParameter: number | {
  21445. width: number;
  21446. height: number;
  21447. } | {
  21448. ratio: number;
  21449. };
  21450. protected _sizeRatio: Nullable<number>;
  21451. /** @hidden */
  21452. _generateMipMaps: boolean;
  21453. protected _renderingManager: RenderingManager;
  21454. /** @hidden */
  21455. _waitingRenderList: string[];
  21456. protected _doNotChangeAspectRatio: boolean;
  21457. protected _currentRefreshId: number;
  21458. protected _refreshRate: number;
  21459. protected _textureMatrix: Matrix;
  21460. protected _samples: number;
  21461. protected _renderTargetOptions: RenderTargetCreationOptions;
  21462. /**
  21463. * Gets render target creation options that were used.
  21464. */
  21465. get renderTargetOptions(): RenderTargetCreationOptions;
  21466. protected _engine: Engine;
  21467. protected _onRatioRescale(): void;
  21468. /**
  21469. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21470. * It must define where the camera used to render the texture is set
  21471. */
  21472. boundingBoxPosition: Vector3;
  21473. private _boundingBoxSize;
  21474. /**
  21475. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21476. * When defined, the cubemap will switch to local mode
  21477. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21478. * @example https://www.babylonjs-playground.com/#RNASML
  21479. */
  21480. set boundingBoxSize(value: Vector3);
  21481. get boundingBoxSize(): Vector3;
  21482. /**
  21483. * In case the RTT has been created with a depth texture, get the associated
  21484. * depth texture.
  21485. * Otherwise, return null.
  21486. */
  21487. get depthStencilTexture(): Nullable<InternalTexture>;
  21488. /**
  21489. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21490. * or used a shadow, depth texture...
  21491. * @param name The friendly name of the texture
  21492. * @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)
  21493. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21494. * @param generateMipMaps True if mip maps need to be generated after render.
  21495. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21496. * @param type The type of the buffer in the RTT (int, half float, float...)
  21497. * @param isCube True if a cube texture needs to be created
  21498. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21499. * @param generateDepthBuffer True to generate a depth buffer
  21500. * @param generateStencilBuffer True to generate a stencil buffer
  21501. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21502. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21504. */
  21505. constructor(name: string, size: number | {
  21506. width: number;
  21507. height: number;
  21508. layers?: number;
  21509. } | {
  21510. ratio: number;
  21511. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21512. /**
  21513. * Creates a depth stencil texture.
  21514. * This is only available in WebGL 2 or with the depth texture extension available.
  21515. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21516. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21517. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21518. */
  21519. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21520. private _processSizeParameter;
  21521. /**
  21522. * Define the number of samples to use in case of MSAA.
  21523. * It defaults to one meaning no MSAA has been enabled.
  21524. */
  21525. get samples(): number;
  21526. set samples(value: number);
  21527. /**
  21528. * Resets the refresh counter of the texture and start bak from scratch.
  21529. * Could be useful to regenerate the texture if it is setup to render only once.
  21530. */
  21531. resetRefreshCounter(): void;
  21532. /**
  21533. * Define the refresh rate of the texture or the rendering frequency.
  21534. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21535. */
  21536. get refreshRate(): number;
  21537. set refreshRate(value: number);
  21538. /**
  21539. * Adds a post process to the render target rendering passes.
  21540. * @param postProcess define the post process to add
  21541. */
  21542. addPostProcess(postProcess: PostProcess): void;
  21543. /**
  21544. * Clear all the post processes attached to the render target
  21545. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21546. */
  21547. clearPostProcesses(dispose?: boolean): void;
  21548. /**
  21549. * Remove one of the post process from the list of attached post processes to the texture
  21550. * @param postProcess define the post process to remove from the list
  21551. */
  21552. removePostProcess(postProcess: PostProcess): void;
  21553. /** @hidden */
  21554. _shouldRender(): boolean;
  21555. /**
  21556. * Gets the actual render size of the texture.
  21557. * @returns the width of the render size
  21558. */
  21559. getRenderSize(): number;
  21560. /**
  21561. * Gets the actual render width of the texture.
  21562. * @returns the width of the render size
  21563. */
  21564. getRenderWidth(): number;
  21565. /**
  21566. * Gets the actual render height of the texture.
  21567. * @returns the height of the render size
  21568. */
  21569. getRenderHeight(): number;
  21570. /**
  21571. * Gets the actual number of layers of the texture.
  21572. * @returns the number of layers
  21573. */
  21574. getRenderLayers(): number;
  21575. /**
  21576. * Get if the texture can be rescaled or not.
  21577. */
  21578. get canRescale(): boolean;
  21579. /**
  21580. * Resize the texture using a ratio.
  21581. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21582. */
  21583. scale(ratio: number): void;
  21584. /**
  21585. * Get the texture reflection matrix used to rotate/transform the reflection.
  21586. * @returns the reflection matrix
  21587. */
  21588. getReflectionTextureMatrix(): Matrix;
  21589. /**
  21590. * Resize the texture to a new desired size.
  21591. * Be carrefull as it will recreate all the data in the new texture.
  21592. * @param size Define the new size. It can be:
  21593. * - a number for squared texture,
  21594. * - an object containing { width: number, height: number }
  21595. * - or an object containing a ratio { ratio: number }
  21596. */
  21597. resize(size: number | {
  21598. width: number;
  21599. height: number;
  21600. } | {
  21601. ratio: number;
  21602. }): void;
  21603. private _defaultRenderListPrepared;
  21604. /**
  21605. * Renders all the objects from the render list into the texture.
  21606. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21607. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21608. */
  21609. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21610. private _bestReflectionRenderTargetDimension;
  21611. private _prepareRenderingManager;
  21612. /**
  21613. * @hidden
  21614. * @param faceIndex face index to bind to if this is a cubetexture
  21615. * @param layer defines the index of the texture to bind in the array
  21616. */
  21617. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21618. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21619. private renderToTarget;
  21620. /**
  21621. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21622. * This allowed control for front to back rendering or reversly depending of the special needs.
  21623. *
  21624. * @param renderingGroupId The rendering group id corresponding to its index
  21625. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21626. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21627. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21628. */
  21629. 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;
  21630. /**
  21631. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21632. *
  21633. * @param renderingGroupId The rendering group id corresponding to its index
  21634. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21635. */
  21636. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21637. /**
  21638. * Clones the texture.
  21639. * @returns the cloned texture
  21640. */
  21641. clone(): RenderTargetTexture;
  21642. /**
  21643. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21644. * @returns The JSON representation of the texture
  21645. */
  21646. serialize(): any;
  21647. /**
  21648. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21649. */
  21650. disposeFramebufferObjects(): void;
  21651. /**
  21652. * Dispose the texture and release its associated resources.
  21653. */
  21654. dispose(): void;
  21655. /** @hidden */
  21656. _rebuild(): void;
  21657. /**
  21658. * Clear the info related to rendering groups preventing retention point in material dispose.
  21659. */
  21660. freeRenderingGroups(): void;
  21661. /**
  21662. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21663. * @returns the view count
  21664. */
  21665. getViewCount(): number;
  21666. }
  21667. }
  21668. declare module "babylonjs/Misc/guid" {
  21669. /**
  21670. * Class used to manipulate GUIDs
  21671. */
  21672. export class GUID {
  21673. /**
  21674. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21675. * Be aware Math.random() could cause collisions, but:
  21676. * "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"
  21677. * @returns a pseudo random id
  21678. */
  21679. static RandomId(): string;
  21680. }
  21681. }
  21682. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21683. import { Nullable } from "babylonjs/types";
  21684. import { Scene } from "babylonjs/scene";
  21685. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21686. import { Material } from "babylonjs/Materials/material";
  21687. import { Effect } from "babylonjs/Materials/effect";
  21688. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21689. /**
  21690. * Options to be used when creating a shadow depth material
  21691. */
  21692. export interface IIOptionShadowDepthMaterial {
  21693. /** Variables in the vertex shader code that need to have their names remapped.
  21694. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21695. * "var_name" should be either: worldPos or vNormalW
  21696. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21697. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21698. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21699. */
  21700. remappedVariables?: string[];
  21701. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21702. standalone?: boolean;
  21703. }
  21704. /**
  21705. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21706. */
  21707. export class ShadowDepthWrapper {
  21708. private _scene;
  21709. private _options?;
  21710. private _baseMaterial;
  21711. private _onEffectCreatedObserver;
  21712. private _subMeshToEffect;
  21713. private _subMeshToDepthEffect;
  21714. private _meshes;
  21715. /** @hidden */
  21716. _matriceNames: any;
  21717. /** Gets the standalone status of the wrapper */
  21718. get standalone(): boolean;
  21719. /** Gets the base material the wrapper is built upon */
  21720. get baseMaterial(): Material;
  21721. /**
  21722. * Instantiate a new shadow depth wrapper.
  21723. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21724. * generate the shadow depth map. For more information, please refer to the documentation:
  21725. * https://doc.babylonjs.com/babylon101/shadows
  21726. * @param baseMaterial Material to wrap
  21727. * @param scene Define the scene the material belongs to
  21728. * @param options Options used to create the wrapper
  21729. */
  21730. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21731. /**
  21732. * Gets the effect to use to generate the depth map
  21733. * @param subMesh subMesh to get the effect for
  21734. * @param shadowGenerator shadow generator to get the effect for
  21735. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21736. */
  21737. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21738. /**
  21739. * Specifies that the submesh is ready to be used for depth rendering
  21740. * @param subMesh submesh to check
  21741. * @param defines the list of defines to take into account when checking the effect
  21742. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21743. * @param useInstances specifies that instances should be used
  21744. * @returns a boolean indicating that the submesh is ready or not
  21745. */
  21746. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21747. /**
  21748. * Disposes the resources
  21749. */
  21750. dispose(): void;
  21751. private _makeEffect;
  21752. }
  21753. }
  21754. declare module "babylonjs/Materials/material" {
  21755. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21756. import { SmartArray } from "babylonjs/Misc/smartArray";
  21757. import { Observable } from "babylonjs/Misc/observable";
  21758. import { Nullable } from "babylonjs/types";
  21759. import { Scene } from "babylonjs/scene";
  21760. import { Matrix } from "babylonjs/Maths/math.vector";
  21761. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21763. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21764. import { Effect } from "babylonjs/Materials/effect";
  21765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21766. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21767. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21768. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21769. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21770. import { Mesh } from "babylonjs/Meshes/mesh";
  21771. import { Animation } from "babylonjs/Animations/animation";
  21772. /**
  21773. * Options for compiling materials.
  21774. */
  21775. export interface IMaterialCompilationOptions {
  21776. /**
  21777. * Defines whether clip planes are enabled.
  21778. */
  21779. clipPlane: boolean;
  21780. /**
  21781. * Defines whether instances are enabled.
  21782. */
  21783. useInstances: boolean;
  21784. }
  21785. /**
  21786. * Base class for the main features of a material in Babylon.js
  21787. */
  21788. export class Material implements IAnimatable {
  21789. /**
  21790. * Returns the triangle fill mode
  21791. */
  21792. static readonly TriangleFillMode: number;
  21793. /**
  21794. * Returns the wireframe mode
  21795. */
  21796. static readonly WireFrameFillMode: number;
  21797. /**
  21798. * Returns the point fill mode
  21799. */
  21800. static readonly PointFillMode: number;
  21801. /**
  21802. * Returns the point list draw mode
  21803. */
  21804. static readonly PointListDrawMode: number;
  21805. /**
  21806. * Returns the line list draw mode
  21807. */
  21808. static readonly LineListDrawMode: number;
  21809. /**
  21810. * Returns the line loop draw mode
  21811. */
  21812. static readonly LineLoopDrawMode: number;
  21813. /**
  21814. * Returns the line strip draw mode
  21815. */
  21816. static readonly LineStripDrawMode: number;
  21817. /**
  21818. * Returns the triangle strip draw mode
  21819. */
  21820. static readonly TriangleStripDrawMode: number;
  21821. /**
  21822. * Returns the triangle fan draw mode
  21823. */
  21824. static readonly TriangleFanDrawMode: number;
  21825. /**
  21826. * Stores the clock-wise side orientation
  21827. */
  21828. static readonly ClockWiseSideOrientation: number;
  21829. /**
  21830. * Stores the counter clock-wise side orientation
  21831. */
  21832. static readonly CounterClockWiseSideOrientation: number;
  21833. /**
  21834. * The dirty texture flag value
  21835. */
  21836. static readonly TextureDirtyFlag: number;
  21837. /**
  21838. * The dirty light flag value
  21839. */
  21840. static readonly LightDirtyFlag: number;
  21841. /**
  21842. * The dirty fresnel flag value
  21843. */
  21844. static readonly FresnelDirtyFlag: number;
  21845. /**
  21846. * The dirty attribute flag value
  21847. */
  21848. static readonly AttributesDirtyFlag: number;
  21849. /**
  21850. * The dirty misc flag value
  21851. */
  21852. static readonly MiscDirtyFlag: number;
  21853. /**
  21854. * The all dirty flag value
  21855. */
  21856. static readonly AllDirtyFlag: number;
  21857. /**
  21858. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21859. */
  21860. static readonly MATERIAL_OPAQUE: number;
  21861. /**
  21862. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21863. */
  21864. static readonly MATERIAL_ALPHATEST: number;
  21865. /**
  21866. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21867. */
  21868. static readonly MATERIAL_ALPHABLEND: number;
  21869. /**
  21870. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21871. * They are also discarded below the alpha cutoff threshold to improve performances.
  21872. */
  21873. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21874. /**
  21875. * Custom callback helping to override the default shader used in the material.
  21876. */
  21877. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21878. /**
  21879. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21880. */
  21881. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21882. /**
  21883. * The ID of the material
  21884. */
  21885. id: string;
  21886. /**
  21887. * Gets or sets the unique id of the material
  21888. */
  21889. uniqueId: number;
  21890. /**
  21891. * The name of the material
  21892. */
  21893. name: string;
  21894. /**
  21895. * Gets or sets user defined metadata
  21896. */
  21897. metadata: any;
  21898. /**
  21899. * For internal use only. Please do not use.
  21900. */
  21901. reservedDataStore: any;
  21902. /**
  21903. * Specifies if the ready state should be checked on each call
  21904. */
  21905. checkReadyOnEveryCall: boolean;
  21906. /**
  21907. * Specifies if the ready state should be checked once
  21908. */
  21909. checkReadyOnlyOnce: boolean;
  21910. /**
  21911. * The state of the material
  21912. */
  21913. state: string;
  21914. /**
  21915. * The alpha value of the material
  21916. */
  21917. protected _alpha: number;
  21918. /**
  21919. * List of inspectable custom properties (used by the Inspector)
  21920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21921. */
  21922. inspectableCustomProperties: IInspectable[];
  21923. /**
  21924. * Sets the alpha value of the material
  21925. */
  21926. set alpha(value: number);
  21927. /**
  21928. * Gets the alpha value of the material
  21929. */
  21930. get alpha(): number;
  21931. /**
  21932. * Specifies if back face culling is enabled
  21933. */
  21934. protected _backFaceCulling: boolean;
  21935. /**
  21936. * Sets the back-face culling state
  21937. */
  21938. set backFaceCulling(value: boolean);
  21939. /**
  21940. * Gets the back-face culling state
  21941. */
  21942. get backFaceCulling(): boolean;
  21943. /**
  21944. * Stores the value for side orientation
  21945. */
  21946. sideOrientation: number;
  21947. /**
  21948. * Callback triggered when the material is compiled
  21949. */
  21950. onCompiled: Nullable<(effect: Effect) => void>;
  21951. /**
  21952. * Callback triggered when an error occurs
  21953. */
  21954. onError: Nullable<(effect: Effect, errors: string) => void>;
  21955. /**
  21956. * Callback triggered to get the render target textures
  21957. */
  21958. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21959. /**
  21960. * Gets a boolean indicating that current material needs to register RTT
  21961. */
  21962. get hasRenderTargetTextures(): boolean;
  21963. /**
  21964. * Specifies if the material should be serialized
  21965. */
  21966. doNotSerialize: boolean;
  21967. /**
  21968. * @hidden
  21969. */
  21970. _storeEffectOnSubMeshes: boolean;
  21971. /**
  21972. * Stores the animations for the material
  21973. */
  21974. animations: Nullable<Array<Animation>>;
  21975. /**
  21976. * An event triggered when the material is disposed
  21977. */
  21978. onDisposeObservable: Observable<Material>;
  21979. /**
  21980. * An observer which watches for dispose events
  21981. */
  21982. private _onDisposeObserver;
  21983. private _onUnBindObservable;
  21984. /**
  21985. * Called during a dispose event
  21986. */
  21987. set onDispose(callback: () => void);
  21988. private _onBindObservable;
  21989. /**
  21990. * An event triggered when the material is bound
  21991. */
  21992. get onBindObservable(): Observable<AbstractMesh>;
  21993. /**
  21994. * An observer which watches for bind events
  21995. */
  21996. private _onBindObserver;
  21997. /**
  21998. * Called during a bind event
  21999. */
  22000. set onBind(callback: (Mesh: AbstractMesh) => void);
  22001. /**
  22002. * An event triggered when the material is unbound
  22003. */
  22004. get onUnBindObservable(): Observable<Material>;
  22005. protected _onEffectCreatedObservable: Nullable<Observable<{
  22006. effect: Effect;
  22007. subMesh: Nullable<SubMesh>;
  22008. }>>;
  22009. /**
  22010. * An event triggered when the effect is (re)created
  22011. */
  22012. get onEffectCreatedObservable(): Observable<{
  22013. effect: Effect;
  22014. subMesh: Nullable<SubMesh>;
  22015. }>;
  22016. /**
  22017. * Stores the value of the alpha mode
  22018. */
  22019. private _alphaMode;
  22020. /**
  22021. * Sets the value of the alpha mode.
  22022. *
  22023. * | Value | Type | Description |
  22024. * | --- | --- | --- |
  22025. * | 0 | ALPHA_DISABLE | |
  22026. * | 1 | ALPHA_ADD | |
  22027. * | 2 | ALPHA_COMBINE | |
  22028. * | 3 | ALPHA_SUBTRACT | |
  22029. * | 4 | ALPHA_MULTIPLY | |
  22030. * | 5 | ALPHA_MAXIMIZED | |
  22031. * | 6 | ALPHA_ONEONE | |
  22032. * | 7 | ALPHA_PREMULTIPLIED | |
  22033. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22034. * | 9 | ALPHA_INTERPOLATE | |
  22035. * | 10 | ALPHA_SCREENMODE | |
  22036. *
  22037. */
  22038. set alphaMode(value: number);
  22039. /**
  22040. * Gets the value of the alpha mode
  22041. */
  22042. get alphaMode(): number;
  22043. /**
  22044. * Stores the state of the need depth pre-pass value
  22045. */
  22046. private _needDepthPrePass;
  22047. /**
  22048. * Sets the need depth pre-pass value
  22049. */
  22050. set needDepthPrePass(value: boolean);
  22051. /**
  22052. * Gets the depth pre-pass value
  22053. */
  22054. get needDepthPrePass(): boolean;
  22055. /**
  22056. * Specifies if depth writing should be disabled
  22057. */
  22058. disableDepthWrite: boolean;
  22059. /**
  22060. * Specifies if color writing should be disabled
  22061. */
  22062. disableColorWrite: boolean;
  22063. /**
  22064. * Specifies if depth writing should be forced
  22065. */
  22066. forceDepthWrite: boolean;
  22067. /**
  22068. * Specifies the depth function that should be used. 0 means the default engine function
  22069. */
  22070. depthFunction: number;
  22071. /**
  22072. * Specifies if there should be a separate pass for culling
  22073. */
  22074. separateCullingPass: boolean;
  22075. /**
  22076. * Stores the state specifing if fog should be enabled
  22077. */
  22078. private _fogEnabled;
  22079. /**
  22080. * Sets the state for enabling fog
  22081. */
  22082. set fogEnabled(value: boolean);
  22083. /**
  22084. * Gets the value of the fog enabled state
  22085. */
  22086. get fogEnabled(): boolean;
  22087. /**
  22088. * Stores the size of points
  22089. */
  22090. pointSize: number;
  22091. /**
  22092. * Stores the z offset value
  22093. */
  22094. zOffset: number;
  22095. get wireframe(): boolean;
  22096. /**
  22097. * Sets the state of wireframe mode
  22098. */
  22099. set wireframe(value: boolean);
  22100. /**
  22101. * Gets the value specifying if point clouds are enabled
  22102. */
  22103. get pointsCloud(): boolean;
  22104. /**
  22105. * Sets the state of point cloud mode
  22106. */
  22107. set pointsCloud(value: boolean);
  22108. /**
  22109. * Gets the material fill mode
  22110. */
  22111. get fillMode(): number;
  22112. /**
  22113. * Sets the material fill mode
  22114. */
  22115. set fillMode(value: number);
  22116. /**
  22117. * @hidden
  22118. * Stores the effects for the material
  22119. */
  22120. _effect: Nullable<Effect>;
  22121. /**
  22122. * Specifies if uniform buffers should be used
  22123. */
  22124. private _useUBO;
  22125. /**
  22126. * Stores a reference to the scene
  22127. */
  22128. private _scene;
  22129. /**
  22130. * Stores the fill mode state
  22131. */
  22132. private _fillMode;
  22133. /**
  22134. * Specifies if the depth write state should be cached
  22135. */
  22136. private _cachedDepthWriteState;
  22137. /**
  22138. * Specifies if the color write state should be cached
  22139. */
  22140. private _cachedColorWriteState;
  22141. /**
  22142. * Specifies if the depth function state should be cached
  22143. */
  22144. private _cachedDepthFunctionState;
  22145. /**
  22146. * Stores the uniform buffer
  22147. */
  22148. protected _uniformBuffer: UniformBuffer;
  22149. /** @hidden */
  22150. _indexInSceneMaterialArray: number;
  22151. /** @hidden */
  22152. meshMap: Nullable<{
  22153. [id: string]: AbstractMesh | undefined;
  22154. }>;
  22155. /**
  22156. * Creates a material instance
  22157. * @param name defines the name of the material
  22158. * @param scene defines the scene to reference
  22159. * @param doNotAdd specifies if the material should be added to the scene
  22160. */
  22161. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22162. /**
  22163. * Returns a string representation of the current material
  22164. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22165. * @returns a string with material information
  22166. */
  22167. toString(fullDetails?: boolean): string;
  22168. /**
  22169. * Gets the class name of the material
  22170. * @returns a string with the class name of the material
  22171. */
  22172. getClassName(): string;
  22173. /**
  22174. * Specifies if updates for the material been locked
  22175. */
  22176. get isFrozen(): boolean;
  22177. /**
  22178. * Locks updates for the material
  22179. */
  22180. freeze(): void;
  22181. /**
  22182. * Unlocks updates for the material
  22183. */
  22184. unfreeze(): void;
  22185. /**
  22186. * Specifies if the material is ready to be used
  22187. * @param mesh defines the mesh to check
  22188. * @param useInstances specifies if instances should be used
  22189. * @returns a boolean indicating if the material is ready to be used
  22190. */
  22191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22192. /**
  22193. * Specifies that the submesh is ready to be used
  22194. * @param mesh defines the mesh to check
  22195. * @param subMesh defines which submesh to check
  22196. * @param useInstances specifies that instances should be used
  22197. * @returns a boolean indicating that the submesh is ready or not
  22198. */
  22199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22200. /**
  22201. * Returns the material effect
  22202. * @returns the effect associated with the material
  22203. */
  22204. getEffect(): Nullable<Effect>;
  22205. /**
  22206. * Returns the current scene
  22207. * @returns a Scene
  22208. */
  22209. getScene(): Scene;
  22210. /**
  22211. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22212. */
  22213. protected _forceAlphaTest: boolean;
  22214. /**
  22215. * The transparency mode of the material.
  22216. */
  22217. protected _transparencyMode: Nullable<number>;
  22218. /**
  22219. * Gets the current transparency mode.
  22220. */
  22221. get transparencyMode(): Nullable<number>;
  22222. /**
  22223. * Sets the transparency mode of the material.
  22224. *
  22225. * | Value | Type | Description |
  22226. * | ----- | ----------------------------------- | ----------- |
  22227. * | 0 | OPAQUE | |
  22228. * | 1 | ALPHATEST | |
  22229. * | 2 | ALPHABLEND | |
  22230. * | 3 | ALPHATESTANDBLEND | |
  22231. *
  22232. */
  22233. set transparencyMode(value: Nullable<number>);
  22234. /**
  22235. * Returns true if alpha blending should be disabled.
  22236. */
  22237. protected get _disableAlphaBlending(): boolean;
  22238. /**
  22239. * Specifies whether or not this material should be rendered in alpha blend mode.
  22240. * @returns a boolean specifying if alpha blending is needed
  22241. */
  22242. needAlphaBlending(): boolean;
  22243. /**
  22244. * Specifies if the mesh will require alpha blending
  22245. * @param mesh defines the mesh to check
  22246. * @returns a boolean specifying if alpha blending is needed for the mesh
  22247. */
  22248. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22249. /**
  22250. * Specifies whether or not this material should be rendered in alpha test mode.
  22251. * @returns a boolean specifying if an alpha test is needed.
  22252. */
  22253. needAlphaTesting(): boolean;
  22254. /**
  22255. * Specifies if material alpha testing should be turned on for the mesh
  22256. * @param mesh defines the mesh to check
  22257. */
  22258. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22259. /**
  22260. * Gets the texture used for the alpha test
  22261. * @returns the texture to use for alpha testing
  22262. */
  22263. getAlphaTestTexture(): Nullable<BaseTexture>;
  22264. /**
  22265. * Marks the material to indicate that it needs to be re-calculated
  22266. */
  22267. markDirty(): void;
  22268. /** @hidden */
  22269. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22270. /**
  22271. * Binds the material to the mesh
  22272. * @param world defines the world transformation matrix
  22273. * @param mesh defines the mesh to bind the material to
  22274. */
  22275. bind(world: Matrix, mesh?: Mesh): void;
  22276. /**
  22277. * Binds the submesh to the material
  22278. * @param world defines the world transformation matrix
  22279. * @param mesh defines the mesh containing the submesh
  22280. * @param subMesh defines the submesh to bind the material to
  22281. */
  22282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22283. /**
  22284. * Binds the world matrix to the material
  22285. * @param world defines the world transformation matrix
  22286. */
  22287. bindOnlyWorldMatrix(world: Matrix): void;
  22288. /**
  22289. * Binds the scene's uniform buffer to the effect.
  22290. * @param effect defines the effect to bind to the scene uniform buffer
  22291. * @param sceneUbo defines the uniform buffer storing scene data
  22292. */
  22293. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22294. /**
  22295. * Binds the view matrix to the effect
  22296. * @param effect defines the effect to bind the view matrix to
  22297. */
  22298. bindView(effect: Effect): void;
  22299. /**
  22300. * Binds the view projection matrix to the effect
  22301. * @param effect defines the effect to bind the view projection matrix to
  22302. */
  22303. bindViewProjection(effect: Effect): void;
  22304. /**
  22305. * Processes to execute after binding the material to a mesh
  22306. * @param mesh defines the rendered mesh
  22307. */
  22308. protected _afterBind(mesh?: Mesh): void;
  22309. /**
  22310. * Unbinds the material from the mesh
  22311. */
  22312. unbind(): void;
  22313. /**
  22314. * Gets the active textures from the material
  22315. * @returns an array of textures
  22316. */
  22317. getActiveTextures(): BaseTexture[];
  22318. /**
  22319. * Specifies if the material uses a texture
  22320. * @param texture defines the texture to check against the material
  22321. * @returns a boolean specifying if the material uses the texture
  22322. */
  22323. hasTexture(texture: BaseTexture): boolean;
  22324. /**
  22325. * Makes a duplicate of the material, and gives it a new name
  22326. * @param name defines the new name for the duplicated material
  22327. * @returns the cloned material
  22328. */
  22329. clone(name: string): Nullable<Material>;
  22330. /**
  22331. * Gets the meshes bound to the material
  22332. * @returns an array of meshes bound to the material
  22333. */
  22334. getBindedMeshes(): AbstractMesh[];
  22335. /**
  22336. * Force shader compilation
  22337. * @param mesh defines the mesh associated with this material
  22338. * @param onCompiled defines a function to execute once the material is compiled
  22339. * @param options defines the options to configure the compilation
  22340. * @param onError defines a function to execute if the material fails compiling
  22341. */
  22342. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22343. /**
  22344. * Force shader compilation
  22345. * @param mesh defines the mesh that will use this material
  22346. * @param options defines additional options for compiling the shaders
  22347. * @returns a promise that resolves when the compilation completes
  22348. */
  22349. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22350. private static readonly _AllDirtyCallBack;
  22351. private static readonly _ImageProcessingDirtyCallBack;
  22352. private static readonly _TextureDirtyCallBack;
  22353. private static readonly _FresnelDirtyCallBack;
  22354. private static readonly _MiscDirtyCallBack;
  22355. private static readonly _LightsDirtyCallBack;
  22356. private static readonly _AttributeDirtyCallBack;
  22357. private static _FresnelAndMiscDirtyCallBack;
  22358. private static _TextureAndMiscDirtyCallBack;
  22359. private static readonly _DirtyCallbackArray;
  22360. private static readonly _RunDirtyCallBacks;
  22361. /**
  22362. * Marks a define in the material to indicate that it needs to be re-computed
  22363. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22364. */
  22365. markAsDirty(flag: number): void;
  22366. /**
  22367. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22368. * @param func defines a function which checks material defines against the submeshes
  22369. */
  22370. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22371. /**
  22372. * Indicates that we need to re-calculated for all submeshes
  22373. */
  22374. protected _markAllSubMeshesAsAllDirty(): void;
  22375. /**
  22376. * Indicates that image processing needs to be re-calculated for all submeshes
  22377. */
  22378. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22379. /**
  22380. * Indicates that textures need to be re-calculated for all submeshes
  22381. */
  22382. protected _markAllSubMeshesAsTexturesDirty(): void;
  22383. /**
  22384. * Indicates that fresnel needs to be re-calculated for all submeshes
  22385. */
  22386. protected _markAllSubMeshesAsFresnelDirty(): void;
  22387. /**
  22388. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22389. */
  22390. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22391. /**
  22392. * Indicates that lights need to be re-calculated for all submeshes
  22393. */
  22394. protected _markAllSubMeshesAsLightsDirty(): void;
  22395. /**
  22396. * Indicates that attributes need to be re-calculated for all submeshes
  22397. */
  22398. protected _markAllSubMeshesAsAttributesDirty(): void;
  22399. /**
  22400. * Indicates that misc needs to be re-calculated for all submeshes
  22401. */
  22402. protected _markAllSubMeshesAsMiscDirty(): void;
  22403. /**
  22404. * Indicates that textures and misc need to be re-calculated for all submeshes
  22405. */
  22406. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22407. /**
  22408. * Disposes the material
  22409. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22410. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22411. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22412. */
  22413. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22414. /** @hidden */
  22415. private releaseVertexArrayObject;
  22416. /**
  22417. * Serializes this material
  22418. * @returns the serialized material object
  22419. */
  22420. serialize(): any;
  22421. /**
  22422. * Creates a material from parsed material data
  22423. * @param parsedMaterial defines parsed material data
  22424. * @param scene defines the hosting scene
  22425. * @param rootUrl defines the root URL to use to load textures
  22426. * @returns a new material
  22427. */
  22428. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22429. }
  22430. }
  22431. declare module "babylonjs/Materials/multiMaterial" {
  22432. import { Nullable } from "babylonjs/types";
  22433. import { Scene } from "babylonjs/scene";
  22434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22435. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22437. import { Material } from "babylonjs/Materials/material";
  22438. /**
  22439. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22440. * separate meshes. This can be use to improve performances.
  22441. * @see http://doc.babylonjs.com/how_to/multi_materials
  22442. */
  22443. export class MultiMaterial extends Material {
  22444. private _subMaterials;
  22445. /**
  22446. * Gets or Sets the list of Materials used within the multi material.
  22447. * They need to be ordered according to the submeshes order in the associated mesh
  22448. */
  22449. get subMaterials(): Nullable<Material>[];
  22450. set subMaterials(value: Nullable<Material>[]);
  22451. /**
  22452. * Function used to align with Node.getChildren()
  22453. * @returns the list of Materials used within the multi material
  22454. */
  22455. getChildren(): Nullable<Material>[];
  22456. /**
  22457. * Instantiates a new Multi Material
  22458. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22459. * separate meshes. This can be use to improve performances.
  22460. * @see http://doc.babylonjs.com/how_to/multi_materials
  22461. * @param name Define the name in the scene
  22462. * @param scene Define the scene the material belongs to
  22463. */
  22464. constructor(name: string, scene: Scene);
  22465. private _hookArray;
  22466. /**
  22467. * Get one of the submaterial by its index in the submaterials array
  22468. * @param index The index to look the sub material at
  22469. * @returns The Material if the index has been defined
  22470. */
  22471. getSubMaterial(index: number): Nullable<Material>;
  22472. /**
  22473. * Get the list of active textures for the whole sub materials list.
  22474. * @returns All the textures that will be used during the rendering
  22475. */
  22476. getActiveTextures(): BaseTexture[];
  22477. /**
  22478. * Gets the current class name of the material e.g. "MultiMaterial"
  22479. * Mainly use in serialization.
  22480. * @returns the class name
  22481. */
  22482. getClassName(): string;
  22483. /**
  22484. * Checks if the material is ready to render the requested sub mesh
  22485. * @param mesh Define the mesh the submesh belongs to
  22486. * @param subMesh Define the sub mesh to look readyness for
  22487. * @param useInstances Define whether or not the material is used with instances
  22488. * @returns true if ready, otherwise false
  22489. */
  22490. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22491. /**
  22492. * Clones the current material and its related sub materials
  22493. * @param name Define the name of the newly cloned material
  22494. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22495. * @returns the cloned material
  22496. */
  22497. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22498. /**
  22499. * Serializes the materials into a JSON representation.
  22500. * @returns the JSON representation
  22501. */
  22502. serialize(): any;
  22503. /**
  22504. * Dispose the material and release its associated resources
  22505. * @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)
  22506. * @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)
  22507. * @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)
  22508. */
  22509. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22510. /**
  22511. * Creates a MultiMaterial from parsed MultiMaterial data.
  22512. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22513. * @param scene defines the hosting scene
  22514. * @returns a new MultiMaterial
  22515. */
  22516. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22517. }
  22518. }
  22519. declare module "babylonjs/Meshes/subMesh" {
  22520. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22521. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22522. import { Engine } from "babylonjs/Engines/engine";
  22523. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22524. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22525. import { Effect } from "babylonjs/Materials/effect";
  22526. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22527. import { Plane } from "babylonjs/Maths/math.plane";
  22528. import { Collider } from "babylonjs/Collisions/collider";
  22529. import { Material } from "babylonjs/Materials/material";
  22530. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22532. import { Mesh } from "babylonjs/Meshes/mesh";
  22533. import { Ray } from "babylonjs/Culling/ray";
  22534. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22535. /**
  22536. * Base class for submeshes
  22537. */
  22538. export class BaseSubMesh {
  22539. /** @hidden */
  22540. _materialDefines: Nullable<MaterialDefines>;
  22541. /** @hidden */
  22542. _materialEffect: Nullable<Effect>;
  22543. /** @hidden */
  22544. _effectOverride: Nullable<Effect>;
  22545. /**
  22546. * Gets material defines used by the effect associated to the sub mesh
  22547. */
  22548. get materialDefines(): Nullable<MaterialDefines>;
  22549. /**
  22550. * Sets material defines used by the effect associated to the sub mesh
  22551. */
  22552. set materialDefines(defines: Nullable<MaterialDefines>);
  22553. /**
  22554. * Gets associated effect
  22555. */
  22556. get effect(): Nullable<Effect>;
  22557. /**
  22558. * Sets associated effect (effect used to render this submesh)
  22559. * @param effect defines the effect to associate with
  22560. * @param defines defines the set of defines used to compile this effect
  22561. */
  22562. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22563. }
  22564. /**
  22565. * Defines a subdivision inside a mesh
  22566. */
  22567. export class SubMesh extends BaseSubMesh implements ICullable {
  22568. /** the material index to use */
  22569. materialIndex: number;
  22570. /** vertex index start */
  22571. verticesStart: number;
  22572. /** vertices count */
  22573. verticesCount: number;
  22574. /** index start */
  22575. indexStart: number;
  22576. /** indices count */
  22577. indexCount: number;
  22578. /** @hidden */
  22579. _linesIndexCount: number;
  22580. private _mesh;
  22581. private _renderingMesh;
  22582. private _boundingInfo;
  22583. private _linesIndexBuffer;
  22584. /** @hidden */
  22585. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22586. /** @hidden */
  22587. _trianglePlanes: Plane[];
  22588. /** @hidden */
  22589. _lastColliderTransformMatrix: Nullable<Matrix>;
  22590. /** @hidden */
  22591. _renderId: number;
  22592. /** @hidden */
  22593. _alphaIndex: number;
  22594. /** @hidden */
  22595. _distanceToCamera: number;
  22596. /** @hidden */
  22597. _id: number;
  22598. private _currentMaterial;
  22599. /**
  22600. * Add a new submesh to a mesh
  22601. * @param materialIndex defines the material index to use
  22602. * @param verticesStart defines vertex index start
  22603. * @param verticesCount defines vertices count
  22604. * @param indexStart defines index start
  22605. * @param indexCount defines indices count
  22606. * @param mesh defines the parent mesh
  22607. * @param renderingMesh defines an optional rendering mesh
  22608. * @param createBoundingBox defines if bounding box should be created for this submesh
  22609. * @returns the new submesh
  22610. */
  22611. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22612. /**
  22613. * Creates a new submesh
  22614. * @param materialIndex defines the material index to use
  22615. * @param verticesStart defines vertex index start
  22616. * @param verticesCount defines vertices count
  22617. * @param indexStart defines index start
  22618. * @param indexCount defines indices count
  22619. * @param mesh defines the parent mesh
  22620. * @param renderingMesh defines an optional rendering mesh
  22621. * @param createBoundingBox defines if bounding box should be created for this submesh
  22622. */
  22623. constructor(
  22624. /** the material index to use */
  22625. materialIndex: number,
  22626. /** vertex index start */
  22627. verticesStart: number,
  22628. /** vertices count */
  22629. verticesCount: number,
  22630. /** index start */
  22631. indexStart: number,
  22632. /** indices count */
  22633. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22634. /**
  22635. * Returns true if this submesh covers the entire parent mesh
  22636. * @ignorenaming
  22637. */
  22638. get IsGlobal(): boolean;
  22639. /**
  22640. * Returns the submesh BoudingInfo object
  22641. * @returns current bounding info (or mesh's one if the submesh is global)
  22642. */
  22643. getBoundingInfo(): BoundingInfo;
  22644. /**
  22645. * Sets the submesh BoundingInfo
  22646. * @param boundingInfo defines the new bounding info to use
  22647. * @returns the SubMesh
  22648. */
  22649. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22650. /**
  22651. * Returns the mesh of the current submesh
  22652. * @return the parent mesh
  22653. */
  22654. getMesh(): AbstractMesh;
  22655. /**
  22656. * Returns the rendering mesh of the submesh
  22657. * @returns the rendering mesh (could be different from parent mesh)
  22658. */
  22659. getRenderingMesh(): Mesh;
  22660. /**
  22661. * Returns the submesh material
  22662. * @returns null or the current material
  22663. */
  22664. getMaterial(): Nullable<Material>;
  22665. /**
  22666. * Sets a new updated BoundingInfo object to the submesh
  22667. * @param data defines an optional position array to use to determine the bounding info
  22668. * @returns the SubMesh
  22669. */
  22670. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22671. /** @hidden */
  22672. _checkCollision(collider: Collider): boolean;
  22673. /**
  22674. * Updates the submesh BoundingInfo
  22675. * @param world defines the world matrix to use to update the bounding info
  22676. * @returns the submesh
  22677. */
  22678. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22679. /**
  22680. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22681. * @param frustumPlanes defines the frustum planes
  22682. * @returns true if the submesh is intersecting with the frustum
  22683. */
  22684. isInFrustum(frustumPlanes: Plane[]): boolean;
  22685. /**
  22686. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22687. * @param frustumPlanes defines the frustum planes
  22688. * @returns true if the submesh is inside the frustum
  22689. */
  22690. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22691. /**
  22692. * Renders the submesh
  22693. * @param enableAlphaMode defines if alpha needs to be used
  22694. * @returns the submesh
  22695. */
  22696. render(enableAlphaMode: boolean): SubMesh;
  22697. /**
  22698. * @hidden
  22699. */
  22700. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22701. /**
  22702. * Checks if the submesh intersects with a ray
  22703. * @param ray defines the ray to test
  22704. * @returns true is the passed ray intersects the submesh bounding box
  22705. */
  22706. canIntersects(ray: Ray): boolean;
  22707. /**
  22708. * Intersects current submesh with a ray
  22709. * @param ray defines the ray to test
  22710. * @param positions defines mesh's positions array
  22711. * @param indices defines mesh's indices array
  22712. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22713. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22714. * @returns intersection info or null if no intersection
  22715. */
  22716. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22717. /** @hidden */
  22718. private _intersectLines;
  22719. /** @hidden */
  22720. private _intersectUnIndexedLines;
  22721. /** @hidden */
  22722. private _intersectTriangles;
  22723. /** @hidden */
  22724. private _intersectUnIndexedTriangles;
  22725. /** @hidden */
  22726. _rebuild(): void;
  22727. /**
  22728. * Creates a new submesh from the passed mesh
  22729. * @param newMesh defines the new hosting mesh
  22730. * @param newRenderingMesh defines an optional rendering mesh
  22731. * @returns the new submesh
  22732. */
  22733. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22734. /**
  22735. * Release associated resources
  22736. */
  22737. dispose(): void;
  22738. /**
  22739. * Gets the class name
  22740. * @returns the string "SubMesh".
  22741. */
  22742. getClassName(): string;
  22743. /**
  22744. * Creates a new submesh from indices data
  22745. * @param materialIndex the index of the main mesh material
  22746. * @param startIndex the index where to start the copy in the mesh indices array
  22747. * @param indexCount the number of indices to copy then from the startIndex
  22748. * @param mesh the main mesh to create the submesh from
  22749. * @param renderingMesh the optional rendering mesh
  22750. * @returns a new submesh
  22751. */
  22752. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22753. }
  22754. }
  22755. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22756. /**
  22757. * Class used to represent data loading progression
  22758. */
  22759. export class SceneLoaderFlags {
  22760. private static _ForceFullSceneLoadingForIncremental;
  22761. private static _ShowLoadingScreen;
  22762. private static _CleanBoneMatrixWeights;
  22763. private static _loggingLevel;
  22764. /**
  22765. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22766. */
  22767. static get ForceFullSceneLoadingForIncremental(): boolean;
  22768. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22769. /**
  22770. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22771. */
  22772. static get ShowLoadingScreen(): boolean;
  22773. static set ShowLoadingScreen(value: boolean);
  22774. /**
  22775. * Defines the current logging level (while loading the scene)
  22776. * @ignorenaming
  22777. */
  22778. static get loggingLevel(): number;
  22779. static set loggingLevel(value: number);
  22780. /**
  22781. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22782. */
  22783. static get CleanBoneMatrixWeights(): boolean;
  22784. static set CleanBoneMatrixWeights(value: boolean);
  22785. }
  22786. }
  22787. declare module "babylonjs/Meshes/geometry" {
  22788. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22789. import { Scene } from "babylonjs/scene";
  22790. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22791. import { Engine } from "babylonjs/Engines/engine";
  22792. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22793. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22794. import { Effect } from "babylonjs/Materials/effect";
  22795. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22796. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22797. import { Mesh } from "babylonjs/Meshes/mesh";
  22798. /**
  22799. * Class used to store geometry data (vertex buffers + index buffer)
  22800. */
  22801. export class Geometry implements IGetSetVerticesData {
  22802. /**
  22803. * Gets or sets the ID of the geometry
  22804. */
  22805. id: string;
  22806. /**
  22807. * Gets or sets the unique ID of the geometry
  22808. */
  22809. uniqueId: number;
  22810. /**
  22811. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22812. */
  22813. delayLoadState: number;
  22814. /**
  22815. * Gets the file containing the data to load when running in delay load state
  22816. */
  22817. delayLoadingFile: Nullable<string>;
  22818. /**
  22819. * Callback called when the geometry is updated
  22820. */
  22821. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22822. private _scene;
  22823. private _engine;
  22824. private _meshes;
  22825. private _totalVertices;
  22826. /** @hidden */
  22827. _indices: IndicesArray;
  22828. /** @hidden */
  22829. _vertexBuffers: {
  22830. [key: string]: VertexBuffer;
  22831. };
  22832. private _isDisposed;
  22833. private _extend;
  22834. private _boundingBias;
  22835. /** @hidden */
  22836. _delayInfo: Array<string>;
  22837. private _indexBuffer;
  22838. private _indexBufferIsUpdatable;
  22839. /** @hidden */
  22840. _boundingInfo: Nullable<BoundingInfo>;
  22841. /** @hidden */
  22842. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22843. /** @hidden */
  22844. _softwareSkinningFrameId: number;
  22845. private _vertexArrayObjects;
  22846. private _updatable;
  22847. /** @hidden */
  22848. _positions: Nullable<Vector3[]>;
  22849. /**
  22850. * 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
  22851. */
  22852. get boundingBias(): Vector2;
  22853. /**
  22854. * 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
  22855. */
  22856. set boundingBias(value: Vector2);
  22857. /**
  22858. * Static function used to attach a new empty geometry to a mesh
  22859. * @param mesh defines the mesh to attach the geometry to
  22860. * @returns the new Geometry
  22861. */
  22862. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22863. /** Get the list of meshes using this geometry */
  22864. get meshes(): Mesh[];
  22865. /**
  22866. * Creates a new geometry
  22867. * @param id defines the unique ID
  22868. * @param scene defines the hosting scene
  22869. * @param vertexData defines the VertexData used to get geometry data
  22870. * @param updatable defines if geometry must be updatable (false by default)
  22871. * @param mesh defines the mesh that will be associated with the geometry
  22872. */
  22873. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22874. /**
  22875. * Gets the current extend of the geometry
  22876. */
  22877. get extend(): {
  22878. minimum: Vector3;
  22879. maximum: Vector3;
  22880. };
  22881. /**
  22882. * Gets the hosting scene
  22883. * @returns the hosting Scene
  22884. */
  22885. getScene(): Scene;
  22886. /**
  22887. * Gets the hosting engine
  22888. * @returns the hosting Engine
  22889. */
  22890. getEngine(): Engine;
  22891. /**
  22892. * Defines if the geometry is ready to use
  22893. * @returns true if the geometry is ready to be used
  22894. */
  22895. isReady(): boolean;
  22896. /**
  22897. * Gets a value indicating that the geometry should not be serialized
  22898. */
  22899. get doNotSerialize(): boolean;
  22900. /** @hidden */
  22901. _rebuild(): void;
  22902. /**
  22903. * Affects all geometry data in one call
  22904. * @param vertexData defines the geometry data
  22905. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22906. */
  22907. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22908. /**
  22909. * Set specific vertex data
  22910. * @param kind defines the data kind (Position, normal, etc...)
  22911. * @param data defines the vertex data to use
  22912. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22913. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22914. */
  22915. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22916. /**
  22917. * Removes a specific vertex data
  22918. * @param kind defines the data kind (Position, normal, etc...)
  22919. */
  22920. removeVerticesData(kind: string): void;
  22921. /**
  22922. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22923. * @param buffer defines the vertex buffer to use
  22924. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22925. */
  22926. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22927. /**
  22928. * Update a specific vertex buffer
  22929. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22930. * It will do nothing if the buffer is not updatable
  22931. * @param kind defines the data kind (Position, normal, etc...)
  22932. * @param data defines the data to use
  22933. * @param offset defines the offset in the target buffer where to store the data
  22934. * @param useBytes set to true if the offset is in bytes
  22935. */
  22936. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22937. /**
  22938. * Update a specific vertex buffer
  22939. * This function will create a new buffer if the current one is not updatable
  22940. * @param kind defines the data kind (Position, normal, etc...)
  22941. * @param data defines the data to use
  22942. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22943. */
  22944. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22945. private _updateBoundingInfo;
  22946. /** @hidden */
  22947. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22948. /**
  22949. * Gets total number of vertices
  22950. * @returns the total number of vertices
  22951. */
  22952. getTotalVertices(): number;
  22953. /**
  22954. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22955. * @param kind defines the data kind (Position, normal, etc...)
  22956. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22957. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22958. * @returns a float array containing vertex data
  22959. */
  22960. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22961. /**
  22962. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22963. * @param kind defines the data kind (Position, normal, etc...)
  22964. * @returns true if the vertex buffer with the specified kind is updatable
  22965. */
  22966. isVertexBufferUpdatable(kind: string): boolean;
  22967. /**
  22968. * Gets a specific vertex buffer
  22969. * @param kind defines the data kind (Position, normal, etc...)
  22970. * @returns a VertexBuffer
  22971. */
  22972. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22973. /**
  22974. * Returns all vertex buffers
  22975. * @return an object holding all vertex buffers indexed by kind
  22976. */
  22977. getVertexBuffers(): Nullable<{
  22978. [key: string]: VertexBuffer;
  22979. }>;
  22980. /**
  22981. * Gets a boolean indicating if specific vertex buffer is present
  22982. * @param kind defines the data kind (Position, normal, etc...)
  22983. * @returns true if data is present
  22984. */
  22985. isVerticesDataPresent(kind: string): boolean;
  22986. /**
  22987. * Gets a list of all attached data kinds (Position, normal, etc...)
  22988. * @returns a list of string containing all kinds
  22989. */
  22990. getVerticesDataKinds(): string[];
  22991. /**
  22992. * Update index buffer
  22993. * @param indices defines the indices to store in the index buffer
  22994. * @param offset defines the offset in the target buffer where to store the data
  22995. * @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)
  22996. */
  22997. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22998. /**
  22999. * Creates a new index buffer
  23000. * @param indices defines the indices to store in the index buffer
  23001. * @param totalVertices defines the total number of vertices (could be null)
  23002. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23003. */
  23004. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23005. /**
  23006. * Return the total number of indices
  23007. * @returns the total number of indices
  23008. */
  23009. getTotalIndices(): number;
  23010. /**
  23011. * Gets the index buffer array
  23012. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23013. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23014. * @returns the index buffer array
  23015. */
  23016. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23017. /**
  23018. * Gets the index buffer
  23019. * @return the index buffer
  23020. */
  23021. getIndexBuffer(): Nullable<DataBuffer>;
  23022. /** @hidden */
  23023. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23024. /**
  23025. * Release the associated resources for a specific mesh
  23026. * @param mesh defines the source mesh
  23027. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23028. */
  23029. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23030. /**
  23031. * Apply current geometry to a given mesh
  23032. * @param mesh defines the mesh to apply geometry to
  23033. */
  23034. applyToMesh(mesh: Mesh): void;
  23035. private _updateExtend;
  23036. private _applyToMesh;
  23037. private notifyUpdate;
  23038. /**
  23039. * Load the geometry if it was flagged as delay loaded
  23040. * @param scene defines the hosting scene
  23041. * @param onLoaded defines a callback called when the geometry is loaded
  23042. */
  23043. load(scene: Scene, onLoaded?: () => void): void;
  23044. private _queueLoad;
  23045. /**
  23046. * Invert the geometry to move from a right handed system to a left handed one.
  23047. */
  23048. toLeftHanded(): void;
  23049. /** @hidden */
  23050. _resetPointsArrayCache(): void;
  23051. /** @hidden */
  23052. _generatePointsArray(): boolean;
  23053. /**
  23054. * Gets a value indicating if the geometry is disposed
  23055. * @returns true if the geometry was disposed
  23056. */
  23057. isDisposed(): boolean;
  23058. private _disposeVertexArrayObjects;
  23059. /**
  23060. * Free all associated resources
  23061. */
  23062. dispose(): void;
  23063. /**
  23064. * Clone the current geometry into a new geometry
  23065. * @param id defines the unique ID of the new geometry
  23066. * @returns a new geometry object
  23067. */
  23068. copy(id: string): Geometry;
  23069. /**
  23070. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23071. * @return a JSON representation of the current geometry data (without the vertices data)
  23072. */
  23073. serialize(): any;
  23074. private toNumberArray;
  23075. /**
  23076. * Serialize all vertices data into a JSON oject
  23077. * @returns a JSON representation of the current geometry data
  23078. */
  23079. serializeVerticeData(): any;
  23080. /**
  23081. * Extracts a clone of a mesh geometry
  23082. * @param mesh defines the source mesh
  23083. * @param id defines the unique ID of the new geometry object
  23084. * @returns the new geometry object
  23085. */
  23086. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23087. /**
  23088. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23089. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23090. * Be aware Math.random() could cause collisions, but:
  23091. * "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"
  23092. * @returns a string containing a new GUID
  23093. */
  23094. static RandomId(): string;
  23095. /** @hidden */
  23096. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23097. private static _CleanMatricesWeights;
  23098. /**
  23099. * Create a new geometry from persisted data (Using .babylon file format)
  23100. * @param parsedVertexData defines the persisted data
  23101. * @param scene defines the hosting scene
  23102. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23103. * @returns the new geometry object
  23104. */
  23105. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23106. }
  23107. }
  23108. declare module "babylonjs/Meshes/mesh.vertexData" {
  23109. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23110. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23111. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23112. import { Geometry } from "babylonjs/Meshes/geometry";
  23113. import { Mesh } from "babylonjs/Meshes/mesh";
  23114. /**
  23115. * Define an interface for all classes that will get and set the data on vertices
  23116. */
  23117. export interface IGetSetVerticesData {
  23118. /**
  23119. * Gets a boolean indicating if specific vertex data is present
  23120. * @param kind defines the vertex data kind to use
  23121. * @returns true is data kind is present
  23122. */
  23123. isVerticesDataPresent(kind: string): boolean;
  23124. /**
  23125. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23126. * @param kind defines the data kind (Position, normal, etc...)
  23127. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23128. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23129. * @returns a float array containing vertex data
  23130. */
  23131. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23132. /**
  23133. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23134. * @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.
  23135. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23136. * @returns the indices array or an empty array if the mesh has no geometry
  23137. */
  23138. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23139. /**
  23140. * Set specific vertex data
  23141. * @param kind defines the data kind (Position, normal, etc...)
  23142. * @param data defines the vertex data to use
  23143. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23144. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23145. */
  23146. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23147. /**
  23148. * Update a specific associated vertex buffer
  23149. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23150. * - VertexBuffer.PositionKind
  23151. * - VertexBuffer.UVKind
  23152. * - VertexBuffer.UV2Kind
  23153. * - VertexBuffer.UV3Kind
  23154. * - VertexBuffer.UV4Kind
  23155. * - VertexBuffer.UV5Kind
  23156. * - VertexBuffer.UV6Kind
  23157. * - VertexBuffer.ColorKind
  23158. * - VertexBuffer.MatricesIndicesKind
  23159. * - VertexBuffer.MatricesIndicesExtraKind
  23160. * - VertexBuffer.MatricesWeightsKind
  23161. * - VertexBuffer.MatricesWeightsExtraKind
  23162. * @param data defines the data source
  23163. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23164. * @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)
  23165. */
  23166. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23167. /**
  23168. * Creates a new index buffer
  23169. * @param indices defines the indices to store in the index buffer
  23170. * @param totalVertices defines the total number of vertices (could be null)
  23171. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23172. */
  23173. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23174. }
  23175. /**
  23176. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23177. */
  23178. export class VertexData {
  23179. /**
  23180. * Mesh side orientation : usually the external or front surface
  23181. */
  23182. static readonly FRONTSIDE: number;
  23183. /**
  23184. * Mesh side orientation : usually the internal or back surface
  23185. */
  23186. static readonly BACKSIDE: number;
  23187. /**
  23188. * Mesh side orientation : both internal and external or front and back surfaces
  23189. */
  23190. static readonly DOUBLESIDE: number;
  23191. /**
  23192. * Mesh side orientation : by default, `FRONTSIDE`
  23193. */
  23194. static readonly DEFAULTSIDE: number;
  23195. /**
  23196. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23197. */
  23198. positions: Nullable<FloatArray>;
  23199. /**
  23200. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23201. */
  23202. normals: Nullable<FloatArray>;
  23203. /**
  23204. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23205. */
  23206. tangents: Nullable<FloatArray>;
  23207. /**
  23208. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23209. */
  23210. uvs: Nullable<FloatArray>;
  23211. /**
  23212. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23213. */
  23214. uvs2: Nullable<FloatArray>;
  23215. /**
  23216. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23217. */
  23218. uvs3: Nullable<FloatArray>;
  23219. /**
  23220. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23221. */
  23222. uvs4: Nullable<FloatArray>;
  23223. /**
  23224. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23225. */
  23226. uvs5: Nullable<FloatArray>;
  23227. /**
  23228. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23229. */
  23230. uvs6: Nullable<FloatArray>;
  23231. /**
  23232. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23233. */
  23234. colors: Nullable<FloatArray>;
  23235. /**
  23236. * 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).
  23237. */
  23238. matricesIndices: Nullable<FloatArray>;
  23239. /**
  23240. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23241. */
  23242. matricesWeights: Nullable<FloatArray>;
  23243. /**
  23244. * An array extending the number of possible indices
  23245. */
  23246. matricesIndicesExtra: Nullable<FloatArray>;
  23247. /**
  23248. * An array extending the number of possible weights when the number of indices is extended
  23249. */
  23250. matricesWeightsExtra: Nullable<FloatArray>;
  23251. /**
  23252. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23253. */
  23254. indices: Nullable<IndicesArray>;
  23255. /**
  23256. * Uses the passed data array to set the set the values for the specified kind of data
  23257. * @param data a linear array of floating numbers
  23258. * @param kind the type of data that is being set, eg positions, colors etc
  23259. */
  23260. set(data: FloatArray, kind: string): void;
  23261. /**
  23262. * Associates the vertexData to the passed Mesh.
  23263. * Sets it as updatable or not (default `false`)
  23264. * @param mesh the mesh the vertexData is applied to
  23265. * @param updatable when used and having the value true allows new data to update the vertexData
  23266. * @returns the VertexData
  23267. */
  23268. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23269. /**
  23270. * Associates the vertexData to the passed Geometry.
  23271. * Sets it as updatable or not (default `false`)
  23272. * @param geometry the geometry the vertexData is applied to
  23273. * @param updatable when used and having the value true allows new data to update the vertexData
  23274. * @returns VertexData
  23275. */
  23276. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23277. /**
  23278. * Updates the associated mesh
  23279. * @param mesh the mesh to be updated
  23280. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23281. * @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
  23282. * @returns VertexData
  23283. */
  23284. updateMesh(mesh: Mesh): VertexData;
  23285. /**
  23286. * Updates the associated geometry
  23287. * @param geometry the geometry to be updated
  23288. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23289. * @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
  23290. * @returns VertexData.
  23291. */
  23292. updateGeometry(geometry: Geometry): VertexData;
  23293. private _applyTo;
  23294. private _update;
  23295. /**
  23296. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23297. * @param matrix the transforming matrix
  23298. * @returns the VertexData
  23299. */
  23300. transform(matrix: Matrix): VertexData;
  23301. /**
  23302. * Merges the passed VertexData into the current one
  23303. * @param other the VertexData to be merged into the current one
  23304. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23305. * @returns the modified VertexData
  23306. */
  23307. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23308. private _mergeElement;
  23309. private _validate;
  23310. /**
  23311. * Serializes the VertexData
  23312. * @returns a serialized object
  23313. */
  23314. serialize(): any;
  23315. /**
  23316. * Extracts the vertexData from a mesh
  23317. * @param mesh the mesh from which to extract the VertexData
  23318. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23319. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23320. * @returns the object VertexData associated to the passed mesh
  23321. */
  23322. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23323. /**
  23324. * Extracts the vertexData from the geometry
  23325. * @param geometry the geometry from which to extract the VertexData
  23326. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23327. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23328. * @returns the object VertexData associated to the passed mesh
  23329. */
  23330. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23331. private static _ExtractFrom;
  23332. /**
  23333. * Creates the VertexData for a Ribbon
  23334. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23335. * * pathArray array of paths, each of which an array of successive Vector3
  23336. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23337. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23338. * * 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
  23339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23340. * * 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)
  23341. * * 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)
  23342. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23343. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23344. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23345. * @returns the VertexData of the ribbon
  23346. */
  23347. static CreateRibbon(options: {
  23348. pathArray: Vector3[][];
  23349. closeArray?: boolean;
  23350. closePath?: boolean;
  23351. offset?: number;
  23352. sideOrientation?: number;
  23353. frontUVs?: Vector4;
  23354. backUVs?: Vector4;
  23355. invertUV?: boolean;
  23356. uvs?: Vector2[];
  23357. colors?: Color4[];
  23358. }): VertexData;
  23359. /**
  23360. * Creates the VertexData for a box
  23361. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23362. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23363. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23364. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23365. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23366. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23367. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23369. * * 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)
  23370. * * 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)
  23371. * @returns the VertexData of the box
  23372. */
  23373. static CreateBox(options: {
  23374. size?: number;
  23375. width?: number;
  23376. height?: number;
  23377. depth?: number;
  23378. faceUV?: Vector4[];
  23379. faceColors?: Color4[];
  23380. sideOrientation?: number;
  23381. frontUVs?: Vector4;
  23382. backUVs?: Vector4;
  23383. }): VertexData;
  23384. /**
  23385. * Creates the VertexData for a tiled box
  23386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23387. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23388. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23389. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23390. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23391. * @returns the VertexData of the box
  23392. */
  23393. static CreateTiledBox(options: {
  23394. pattern?: number;
  23395. width?: number;
  23396. height?: number;
  23397. depth?: number;
  23398. tileSize?: number;
  23399. tileWidth?: number;
  23400. tileHeight?: number;
  23401. alignHorizontal?: number;
  23402. alignVertical?: number;
  23403. faceUV?: Vector4[];
  23404. faceColors?: Color4[];
  23405. sideOrientation?: number;
  23406. }): VertexData;
  23407. /**
  23408. * Creates the VertexData for a tiled plane
  23409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23410. * * pattern a limited pattern arrangement depending on the number
  23411. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23412. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23413. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23414. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23415. * * 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)
  23416. * * 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)
  23417. * @returns the VertexData of the tiled plane
  23418. */
  23419. static CreateTiledPlane(options: {
  23420. pattern?: number;
  23421. tileSize?: number;
  23422. tileWidth?: number;
  23423. tileHeight?: number;
  23424. size?: number;
  23425. width?: number;
  23426. height?: number;
  23427. alignHorizontal?: number;
  23428. alignVertical?: number;
  23429. sideOrientation?: number;
  23430. frontUVs?: Vector4;
  23431. backUVs?: Vector4;
  23432. }): VertexData;
  23433. /**
  23434. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23435. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23436. * * segments sets the number of horizontal strips optional, default 32
  23437. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23438. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23439. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23440. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23441. * * 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
  23442. * * 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
  23443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23444. * * 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)
  23445. * * 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)
  23446. * @returns the VertexData of the ellipsoid
  23447. */
  23448. static CreateSphere(options: {
  23449. segments?: number;
  23450. diameter?: number;
  23451. diameterX?: number;
  23452. diameterY?: number;
  23453. diameterZ?: number;
  23454. arc?: number;
  23455. slice?: number;
  23456. sideOrientation?: number;
  23457. frontUVs?: Vector4;
  23458. backUVs?: Vector4;
  23459. }): VertexData;
  23460. /**
  23461. * Creates the VertexData for a cylinder, cone or prism
  23462. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23463. * * height sets the height (y direction) of the cylinder, optional, default 2
  23464. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23465. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23466. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23467. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23468. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23469. * * 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
  23470. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23471. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23472. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23473. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23475. * * 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)
  23476. * * 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)
  23477. * @returns the VertexData of the cylinder, cone or prism
  23478. */
  23479. static CreateCylinder(options: {
  23480. height?: number;
  23481. diameterTop?: number;
  23482. diameterBottom?: number;
  23483. diameter?: number;
  23484. tessellation?: number;
  23485. subdivisions?: number;
  23486. arc?: number;
  23487. faceColors?: Color4[];
  23488. faceUV?: Vector4[];
  23489. hasRings?: boolean;
  23490. enclose?: boolean;
  23491. sideOrientation?: number;
  23492. frontUVs?: Vector4;
  23493. backUVs?: Vector4;
  23494. }): VertexData;
  23495. /**
  23496. * Creates the VertexData for a torus
  23497. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23498. * * diameter the diameter of the torus, optional default 1
  23499. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23500. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23502. * * 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)
  23503. * * 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)
  23504. * @returns the VertexData of the torus
  23505. */
  23506. static CreateTorus(options: {
  23507. diameter?: number;
  23508. thickness?: number;
  23509. tessellation?: number;
  23510. sideOrientation?: number;
  23511. frontUVs?: Vector4;
  23512. backUVs?: Vector4;
  23513. }): VertexData;
  23514. /**
  23515. * Creates the VertexData of the LineSystem
  23516. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23517. * - lines an array of lines, each line being an array of successive Vector3
  23518. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23519. * @returns the VertexData of the LineSystem
  23520. */
  23521. static CreateLineSystem(options: {
  23522. lines: Vector3[][];
  23523. colors?: Nullable<Color4[][]>;
  23524. }): VertexData;
  23525. /**
  23526. * Create the VertexData for a DashedLines
  23527. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23528. * - points an array successive Vector3
  23529. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23530. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23531. * - dashNb the intended total number of dashes, optional, default 200
  23532. * @returns the VertexData for the DashedLines
  23533. */
  23534. static CreateDashedLines(options: {
  23535. points: Vector3[];
  23536. dashSize?: number;
  23537. gapSize?: number;
  23538. dashNb?: number;
  23539. }): VertexData;
  23540. /**
  23541. * Creates the VertexData for a Ground
  23542. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23543. * - width the width (x direction) of the ground, optional, default 1
  23544. * - height the height (z direction) of the ground, optional, default 1
  23545. * - subdivisions the number of subdivisions per side, optional, default 1
  23546. * @returns the VertexData of the Ground
  23547. */
  23548. static CreateGround(options: {
  23549. width?: number;
  23550. height?: number;
  23551. subdivisions?: number;
  23552. subdivisionsX?: number;
  23553. subdivisionsY?: number;
  23554. }): VertexData;
  23555. /**
  23556. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23557. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23558. * * xmin the ground minimum X coordinate, optional, default -1
  23559. * * zmin the ground minimum Z coordinate, optional, default -1
  23560. * * xmax the ground maximum X coordinate, optional, default 1
  23561. * * zmax the ground maximum Z coordinate, optional, default 1
  23562. * * 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}
  23563. * * 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}
  23564. * @returns the VertexData of the TiledGround
  23565. */
  23566. static CreateTiledGround(options: {
  23567. xmin: number;
  23568. zmin: number;
  23569. xmax: number;
  23570. zmax: number;
  23571. subdivisions?: {
  23572. w: number;
  23573. h: number;
  23574. };
  23575. precision?: {
  23576. w: number;
  23577. h: number;
  23578. };
  23579. }): VertexData;
  23580. /**
  23581. * Creates the VertexData of the Ground designed from a heightmap
  23582. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23583. * * width the width (x direction) of the ground
  23584. * * height the height (z direction) of the ground
  23585. * * subdivisions the number of subdivisions per side
  23586. * * minHeight the minimum altitude on the ground, optional, default 0
  23587. * * maxHeight the maximum altitude on the ground, optional default 1
  23588. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23589. * * buffer the array holding the image color data
  23590. * * bufferWidth the width of image
  23591. * * bufferHeight the height of image
  23592. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23593. * @returns the VertexData of the Ground designed from a heightmap
  23594. */
  23595. static CreateGroundFromHeightMap(options: {
  23596. width: number;
  23597. height: number;
  23598. subdivisions: number;
  23599. minHeight: number;
  23600. maxHeight: number;
  23601. colorFilter: Color3;
  23602. buffer: Uint8Array;
  23603. bufferWidth: number;
  23604. bufferHeight: number;
  23605. alphaFilter: number;
  23606. }): VertexData;
  23607. /**
  23608. * Creates the VertexData for a Plane
  23609. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23610. * * size sets the width and height of the plane to the value of size, optional default 1
  23611. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23612. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23614. * * 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)
  23615. * * 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)
  23616. * @returns the VertexData of the box
  23617. */
  23618. static CreatePlane(options: {
  23619. size?: number;
  23620. width?: number;
  23621. height?: number;
  23622. sideOrientation?: number;
  23623. frontUVs?: Vector4;
  23624. backUVs?: Vector4;
  23625. }): VertexData;
  23626. /**
  23627. * Creates the VertexData of the Disc or regular Polygon
  23628. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23629. * * radius the radius of the disc, optional default 0.5
  23630. * * tessellation the number of polygon sides, optional, default 64
  23631. * * 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
  23632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23633. * * 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)
  23634. * * 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)
  23635. * @returns the VertexData of the box
  23636. */
  23637. static CreateDisc(options: {
  23638. radius?: number;
  23639. tessellation?: number;
  23640. arc?: number;
  23641. sideOrientation?: number;
  23642. frontUVs?: Vector4;
  23643. backUVs?: Vector4;
  23644. }): VertexData;
  23645. /**
  23646. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23647. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23648. * @param polygon a mesh built from polygonTriangulation.build()
  23649. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23650. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23651. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23652. * @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)
  23653. * @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)
  23654. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23655. * @returns the VertexData of the Polygon
  23656. */
  23657. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23658. /**
  23659. * Creates the VertexData of the IcoSphere
  23660. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23661. * * radius the radius of the IcoSphere, optional default 1
  23662. * * radiusX allows stretching in the x direction, optional, default radius
  23663. * * radiusY allows stretching in the y direction, optional, default radius
  23664. * * radiusZ allows stretching in the z direction, optional, default radius
  23665. * * flat when true creates a flat shaded mesh, optional, default true
  23666. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23667. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23668. * * 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)
  23669. * * 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)
  23670. * @returns the VertexData of the IcoSphere
  23671. */
  23672. static CreateIcoSphere(options: {
  23673. radius?: number;
  23674. radiusX?: number;
  23675. radiusY?: number;
  23676. radiusZ?: number;
  23677. flat?: boolean;
  23678. subdivisions?: number;
  23679. sideOrientation?: number;
  23680. frontUVs?: Vector4;
  23681. backUVs?: Vector4;
  23682. }): VertexData;
  23683. /**
  23684. * Creates the VertexData for a Polyhedron
  23685. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23686. * * type provided types are:
  23687. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23688. * * 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)
  23689. * * size the size of the IcoSphere, optional default 1
  23690. * * sizeX allows stretching in the x direction, optional, default size
  23691. * * sizeY allows stretching in the y direction, optional, default size
  23692. * * sizeZ allows stretching in the z direction, optional, default size
  23693. * * 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
  23694. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23695. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23696. * * flat when true creates a flat shaded mesh, optional, default true
  23697. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23699. * * 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)
  23700. * * 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)
  23701. * @returns the VertexData of the Polyhedron
  23702. */
  23703. static CreatePolyhedron(options: {
  23704. type?: number;
  23705. size?: number;
  23706. sizeX?: number;
  23707. sizeY?: number;
  23708. sizeZ?: number;
  23709. custom?: any;
  23710. faceUV?: Vector4[];
  23711. faceColors?: Color4[];
  23712. flat?: boolean;
  23713. sideOrientation?: number;
  23714. frontUVs?: Vector4;
  23715. backUVs?: Vector4;
  23716. }): VertexData;
  23717. /**
  23718. * Creates the VertexData for a TorusKnot
  23719. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23720. * * radius the radius of the torus knot, optional, default 2
  23721. * * tube the thickness of the tube, optional, default 0.5
  23722. * * radialSegments the number of sides on each tube segments, optional, default 32
  23723. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23724. * * p the number of windings around the z axis, optional, default 2
  23725. * * q the number of windings around the x axis, optional, default 3
  23726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23727. * * 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)
  23728. * * 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)
  23729. * @returns the VertexData of the Torus Knot
  23730. */
  23731. static CreateTorusKnot(options: {
  23732. radius?: number;
  23733. tube?: number;
  23734. radialSegments?: number;
  23735. tubularSegments?: number;
  23736. p?: number;
  23737. q?: number;
  23738. sideOrientation?: number;
  23739. frontUVs?: Vector4;
  23740. backUVs?: Vector4;
  23741. }): VertexData;
  23742. /**
  23743. * Compute normals for given positions and indices
  23744. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23745. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23746. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23747. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23748. * * facetNormals : optional array of facet normals (vector3)
  23749. * * facetPositions : optional array of facet positions (vector3)
  23750. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23751. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23752. * * bInfo : optional bounding info, required for facetPartitioning computation
  23753. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23754. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23755. * * useRightHandedSystem: optional boolean to for right handed system computation
  23756. * * depthSort : optional boolean to enable the facet depth sort computation
  23757. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23758. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23759. */
  23760. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23761. facetNormals?: any;
  23762. facetPositions?: any;
  23763. facetPartitioning?: any;
  23764. ratio?: number;
  23765. bInfo?: any;
  23766. bbSize?: Vector3;
  23767. subDiv?: any;
  23768. useRightHandedSystem?: boolean;
  23769. depthSort?: boolean;
  23770. distanceTo?: Vector3;
  23771. depthSortedFacets?: any;
  23772. }): void;
  23773. /** @hidden */
  23774. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23775. /**
  23776. * Applies VertexData created from the imported parameters to the geometry
  23777. * @param parsedVertexData the parsed data from an imported file
  23778. * @param geometry the geometry to apply the VertexData to
  23779. */
  23780. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23781. }
  23782. }
  23783. declare module "babylonjs/Morph/morphTarget" {
  23784. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23785. import { Observable } from "babylonjs/Misc/observable";
  23786. import { Nullable, FloatArray } from "babylonjs/types";
  23787. import { Scene } from "babylonjs/scene";
  23788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23789. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23790. /**
  23791. * Defines a target to use with MorphTargetManager
  23792. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23793. */
  23794. export class MorphTarget implements IAnimatable {
  23795. /** defines the name of the target */
  23796. name: string;
  23797. /**
  23798. * Gets or sets the list of animations
  23799. */
  23800. animations: import("babylonjs/Animations/animation").Animation[];
  23801. private _scene;
  23802. private _positions;
  23803. private _normals;
  23804. private _tangents;
  23805. private _uvs;
  23806. private _influence;
  23807. private _uniqueId;
  23808. /**
  23809. * Observable raised when the influence changes
  23810. */
  23811. onInfluenceChanged: Observable<boolean>;
  23812. /** @hidden */
  23813. _onDataLayoutChanged: Observable<void>;
  23814. /**
  23815. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23816. */
  23817. get influence(): number;
  23818. set influence(influence: number);
  23819. /**
  23820. * Gets or sets the id of the morph Target
  23821. */
  23822. id: string;
  23823. private _animationPropertiesOverride;
  23824. /**
  23825. * Gets or sets the animation properties override
  23826. */
  23827. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23828. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23829. /**
  23830. * Creates a new MorphTarget
  23831. * @param name defines the name of the target
  23832. * @param influence defines the influence to use
  23833. * @param scene defines the scene the morphtarget belongs to
  23834. */
  23835. constructor(
  23836. /** defines the name of the target */
  23837. name: string, influence?: number, scene?: Nullable<Scene>);
  23838. /**
  23839. * Gets the unique ID of this manager
  23840. */
  23841. get uniqueId(): number;
  23842. /**
  23843. * Gets a boolean defining if the target contains position data
  23844. */
  23845. get hasPositions(): boolean;
  23846. /**
  23847. * Gets a boolean defining if the target contains normal data
  23848. */
  23849. get hasNormals(): boolean;
  23850. /**
  23851. * Gets a boolean defining if the target contains tangent data
  23852. */
  23853. get hasTangents(): boolean;
  23854. /**
  23855. * Gets a boolean defining if the target contains texture coordinates data
  23856. */
  23857. get hasUVs(): boolean;
  23858. /**
  23859. * Affects position data to this target
  23860. * @param data defines the position data to use
  23861. */
  23862. setPositions(data: Nullable<FloatArray>): void;
  23863. /**
  23864. * Gets the position data stored in this target
  23865. * @returns a FloatArray containing the position data (or null if not present)
  23866. */
  23867. getPositions(): Nullable<FloatArray>;
  23868. /**
  23869. * Affects normal data to this target
  23870. * @param data defines the normal data to use
  23871. */
  23872. setNormals(data: Nullable<FloatArray>): void;
  23873. /**
  23874. * Gets the normal data stored in this target
  23875. * @returns a FloatArray containing the normal data (or null if not present)
  23876. */
  23877. getNormals(): Nullable<FloatArray>;
  23878. /**
  23879. * Affects tangent data to this target
  23880. * @param data defines the tangent data to use
  23881. */
  23882. setTangents(data: Nullable<FloatArray>): void;
  23883. /**
  23884. * Gets the tangent data stored in this target
  23885. * @returns a FloatArray containing the tangent data (or null if not present)
  23886. */
  23887. getTangents(): Nullable<FloatArray>;
  23888. /**
  23889. * Affects texture coordinates data to this target
  23890. * @param data defines the texture coordinates data to use
  23891. */
  23892. setUVs(data: Nullable<FloatArray>): void;
  23893. /**
  23894. * Gets the texture coordinates data stored in this target
  23895. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23896. */
  23897. getUVs(): Nullable<FloatArray>;
  23898. /**
  23899. * Clone the current target
  23900. * @returns a new MorphTarget
  23901. */
  23902. clone(): MorphTarget;
  23903. /**
  23904. * Serializes the current target into a Serialization object
  23905. * @returns the serialized object
  23906. */
  23907. serialize(): any;
  23908. /**
  23909. * Returns the string "MorphTarget"
  23910. * @returns "MorphTarget"
  23911. */
  23912. getClassName(): string;
  23913. /**
  23914. * Creates a new target from serialized data
  23915. * @param serializationObject defines the serialized data to use
  23916. * @returns a new MorphTarget
  23917. */
  23918. static Parse(serializationObject: any): MorphTarget;
  23919. /**
  23920. * Creates a MorphTarget from mesh data
  23921. * @param mesh defines the source mesh
  23922. * @param name defines the name to use for the new target
  23923. * @param influence defines the influence to attach to the target
  23924. * @returns a new MorphTarget
  23925. */
  23926. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23927. }
  23928. }
  23929. declare module "babylonjs/Morph/morphTargetManager" {
  23930. import { Nullable } from "babylonjs/types";
  23931. import { Scene } from "babylonjs/scene";
  23932. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23933. /**
  23934. * This class is used to deform meshes using morphing between different targets
  23935. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23936. */
  23937. export class MorphTargetManager {
  23938. private _targets;
  23939. private _targetInfluenceChangedObservers;
  23940. private _targetDataLayoutChangedObservers;
  23941. private _activeTargets;
  23942. private _scene;
  23943. private _influences;
  23944. private _supportsNormals;
  23945. private _supportsTangents;
  23946. private _supportsUVs;
  23947. private _vertexCount;
  23948. private _uniqueId;
  23949. private _tempInfluences;
  23950. /**
  23951. * Gets or sets a boolean indicating if normals must be morphed
  23952. */
  23953. enableNormalMorphing: boolean;
  23954. /**
  23955. * Gets or sets a boolean indicating if tangents must be morphed
  23956. */
  23957. enableTangentMorphing: boolean;
  23958. /**
  23959. * Gets or sets a boolean indicating if UV must be morphed
  23960. */
  23961. enableUVMorphing: boolean;
  23962. /**
  23963. * Creates a new MorphTargetManager
  23964. * @param scene defines the current scene
  23965. */
  23966. constructor(scene?: Nullable<Scene>);
  23967. /**
  23968. * Gets the unique ID of this manager
  23969. */
  23970. get uniqueId(): number;
  23971. /**
  23972. * Gets the number of vertices handled by this manager
  23973. */
  23974. get vertexCount(): number;
  23975. /**
  23976. * Gets a boolean indicating if this manager supports morphing of normals
  23977. */
  23978. get supportsNormals(): boolean;
  23979. /**
  23980. * Gets a boolean indicating if this manager supports morphing of tangents
  23981. */
  23982. get supportsTangents(): boolean;
  23983. /**
  23984. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23985. */
  23986. get supportsUVs(): boolean;
  23987. /**
  23988. * Gets the number of targets stored in this manager
  23989. */
  23990. get numTargets(): number;
  23991. /**
  23992. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23993. */
  23994. get numInfluencers(): number;
  23995. /**
  23996. * Gets the list of influences (one per target)
  23997. */
  23998. get influences(): Float32Array;
  23999. /**
  24000. * Gets the active target at specified index. An active target is a target with an influence > 0
  24001. * @param index defines the index to check
  24002. * @returns the requested target
  24003. */
  24004. getActiveTarget(index: number): MorphTarget;
  24005. /**
  24006. * Gets the target at specified index
  24007. * @param index defines the index to check
  24008. * @returns the requested target
  24009. */
  24010. getTarget(index: number): MorphTarget;
  24011. /**
  24012. * Add a new target to this manager
  24013. * @param target defines the target to add
  24014. */
  24015. addTarget(target: MorphTarget): void;
  24016. /**
  24017. * Removes a target from the manager
  24018. * @param target defines the target to remove
  24019. */
  24020. removeTarget(target: MorphTarget): void;
  24021. /**
  24022. * Clone the current manager
  24023. * @returns a new MorphTargetManager
  24024. */
  24025. clone(): MorphTargetManager;
  24026. /**
  24027. * Serializes the current manager into a Serialization object
  24028. * @returns the serialized object
  24029. */
  24030. serialize(): any;
  24031. private _syncActiveTargets;
  24032. /**
  24033. * Syncrhonize the targets with all the meshes using this morph target manager
  24034. */
  24035. synchronize(): void;
  24036. /**
  24037. * Creates a new MorphTargetManager from serialized data
  24038. * @param serializationObject defines the serialized data
  24039. * @param scene defines the hosting scene
  24040. * @returns the new MorphTargetManager
  24041. */
  24042. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24043. }
  24044. }
  24045. declare module "babylonjs/Meshes/meshLODLevel" {
  24046. import { Mesh } from "babylonjs/Meshes/mesh";
  24047. import { Nullable } from "babylonjs/types";
  24048. /**
  24049. * Class used to represent a specific level of detail of a mesh
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24051. */
  24052. export class MeshLODLevel {
  24053. /** Defines the distance where this level should start being displayed */
  24054. distance: number;
  24055. /** Defines the mesh to use to render this level */
  24056. mesh: Nullable<Mesh>;
  24057. /**
  24058. * Creates a new LOD level
  24059. * @param distance defines the distance where this level should star being displayed
  24060. * @param mesh defines the mesh to use to render this level
  24061. */
  24062. constructor(
  24063. /** Defines the distance where this level should start being displayed */
  24064. distance: number,
  24065. /** Defines the mesh to use to render this level */
  24066. mesh: Nullable<Mesh>);
  24067. }
  24068. }
  24069. declare module "babylonjs/Meshes/groundMesh" {
  24070. import { Scene } from "babylonjs/scene";
  24071. import { Vector3 } from "babylonjs/Maths/math.vector";
  24072. import { Mesh } from "babylonjs/Meshes/mesh";
  24073. /**
  24074. * Mesh representing the gorund
  24075. */
  24076. export class GroundMesh extends Mesh {
  24077. /** If octree should be generated */
  24078. generateOctree: boolean;
  24079. private _heightQuads;
  24080. /** @hidden */
  24081. _subdivisionsX: number;
  24082. /** @hidden */
  24083. _subdivisionsY: number;
  24084. /** @hidden */
  24085. _width: number;
  24086. /** @hidden */
  24087. _height: number;
  24088. /** @hidden */
  24089. _minX: number;
  24090. /** @hidden */
  24091. _maxX: number;
  24092. /** @hidden */
  24093. _minZ: number;
  24094. /** @hidden */
  24095. _maxZ: number;
  24096. constructor(name: string, scene: Scene);
  24097. /**
  24098. * "GroundMesh"
  24099. * @returns "GroundMesh"
  24100. */
  24101. getClassName(): string;
  24102. /**
  24103. * The minimum of x and y subdivisions
  24104. */
  24105. get subdivisions(): number;
  24106. /**
  24107. * X subdivisions
  24108. */
  24109. get subdivisionsX(): number;
  24110. /**
  24111. * Y subdivisions
  24112. */
  24113. get subdivisionsY(): number;
  24114. /**
  24115. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24116. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24117. * @param chunksCount the number of subdivisions for x and y
  24118. * @param octreeBlocksSize (Default: 32)
  24119. */
  24120. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24121. /**
  24122. * Returns a height (y) value in the Worl system :
  24123. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24124. * @param x x coordinate
  24125. * @param z z coordinate
  24126. * @returns the ground y position if (x, z) are outside the ground surface.
  24127. */
  24128. getHeightAtCoordinates(x: number, z: number): number;
  24129. /**
  24130. * Returns a normalized vector (Vector3) orthogonal to the ground
  24131. * at the ground coordinates (x, z) expressed in the World system.
  24132. * @param x x coordinate
  24133. * @param z z coordinate
  24134. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24135. */
  24136. getNormalAtCoordinates(x: number, z: number): Vector3;
  24137. /**
  24138. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24139. * at the ground coordinates (x, z) expressed in the World system.
  24140. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24141. * @param x x coordinate
  24142. * @param z z coordinate
  24143. * @param ref vector to store the result
  24144. * @returns the GroundMesh.
  24145. */
  24146. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24147. /**
  24148. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24149. * if the ground has been updated.
  24150. * This can be used in the render loop.
  24151. * @returns the GroundMesh.
  24152. */
  24153. updateCoordinateHeights(): GroundMesh;
  24154. private _getFacetAt;
  24155. private _initHeightQuads;
  24156. private _computeHeightQuads;
  24157. /**
  24158. * Serializes this ground mesh
  24159. * @param serializationObject object to write serialization to
  24160. */
  24161. serialize(serializationObject: any): void;
  24162. /**
  24163. * Parses a serialized ground mesh
  24164. * @param parsedMesh the serialized mesh
  24165. * @param scene the scene to create the ground mesh in
  24166. * @returns the created ground mesh
  24167. */
  24168. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24169. }
  24170. }
  24171. declare module "babylonjs/Physics/physicsJoint" {
  24172. import { Vector3 } from "babylonjs/Maths/math.vector";
  24173. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24174. /**
  24175. * Interface for Physics-Joint data
  24176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24177. */
  24178. export interface PhysicsJointData {
  24179. /**
  24180. * The main pivot of the joint
  24181. */
  24182. mainPivot?: Vector3;
  24183. /**
  24184. * The connected pivot of the joint
  24185. */
  24186. connectedPivot?: Vector3;
  24187. /**
  24188. * The main axis of the joint
  24189. */
  24190. mainAxis?: Vector3;
  24191. /**
  24192. * The connected axis of the joint
  24193. */
  24194. connectedAxis?: Vector3;
  24195. /**
  24196. * The collision of the joint
  24197. */
  24198. collision?: boolean;
  24199. /**
  24200. * Native Oimo/Cannon/Energy data
  24201. */
  24202. nativeParams?: any;
  24203. }
  24204. /**
  24205. * This is a holder class for the physics joint created by the physics plugin
  24206. * It holds a set of functions to control the underlying joint
  24207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24208. */
  24209. export class PhysicsJoint {
  24210. /**
  24211. * The type of the physics joint
  24212. */
  24213. type: number;
  24214. /**
  24215. * The data for the physics joint
  24216. */
  24217. jointData: PhysicsJointData;
  24218. private _physicsJoint;
  24219. protected _physicsPlugin: IPhysicsEnginePlugin;
  24220. /**
  24221. * Initializes the physics joint
  24222. * @param type The type of the physics joint
  24223. * @param jointData The data for the physics joint
  24224. */
  24225. constructor(
  24226. /**
  24227. * The type of the physics joint
  24228. */
  24229. type: number,
  24230. /**
  24231. * The data for the physics joint
  24232. */
  24233. jointData: PhysicsJointData);
  24234. /**
  24235. * Gets the physics joint
  24236. */
  24237. get physicsJoint(): any;
  24238. /**
  24239. * Sets the physics joint
  24240. */
  24241. set physicsJoint(newJoint: any);
  24242. /**
  24243. * Sets the physics plugin
  24244. */
  24245. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24246. /**
  24247. * Execute a function that is physics-plugin specific.
  24248. * @param {Function} func the function that will be executed.
  24249. * It accepts two parameters: the physics world and the physics joint
  24250. */
  24251. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24252. /**
  24253. * Distance-Joint type
  24254. */
  24255. static DistanceJoint: number;
  24256. /**
  24257. * Hinge-Joint type
  24258. */
  24259. static HingeJoint: number;
  24260. /**
  24261. * Ball-and-Socket joint type
  24262. */
  24263. static BallAndSocketJoint: number;
  24264. /**
  24265. * Wheel-Joint type
  24266. */
  24267. static WheelJoint: number;
  24268. /**
  24269. * Slider-Joint type
  24270. */
  24271. static SliderJoint: number;
  24272. /**
  24273. * Prismatic-Joint type
  24274. */
  24275. static PrismaticJoint: number;
  24276. /**
  24277. * Universal-Joint type
  24278. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24279. */
  24280. static UniversalJoint: number;
  24281. /**
  24282. * Hinge-Joint 2 type
  24283. */
  24284. static Hinge2Joint: number;
  24285. /**
  24286. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24287. */
  24288. static PointToPointJoint: number;
  24289. /**
  24290. * Spring-Joint type
  24291. */
  24292. static SpringJoint: number;
  24293. /**
  24294. * Lock-Joint type
  24295. */
  24296. static LockJoint: number;
  24297. }
  24298. /**
  24299. * A class representing a physics distance joint
  24300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24301. */
  24302. export class DistanceJoint extends PhysicsJoint {
  24303. /**
  24304. *
  24305. * @param jointData The data for the Distance-Joint
  24306. */
  24307. constructor(jointData: DistanceJointData);
  24308. /**
  24309. * Update the predefined distance.
  24310. * @param maxDistance The maximum preferred distance
  24311. * @param minDistance The minimum preferred distance
  24312. */
  24313. updateDistance(maxDistance: number, minDistance?: number): void;
  24314. }
  24315. /**
  24316. * Represents a Motor-Enabled Joint
  24317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24318. */
  24319. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24320. /**
  24321. * Initializes the Motor-Enabled Joint
  24322. * @param type The type of the joint
  24323. * @param jointData The physica joint data for the joint
  24324. */
  24325. constructor(type: number, jointData: PhysicsJointData);
  24326. /**
  24327. * Set the motor values.
  24328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24329. * @param force the force to apply
  24330. * @param maxForce max force for this motor.
  24331. */
  24332. setMotor(force?: number, maxForce?: number): void;
  24333. /**
  24334. * Set the motor's limits.
  24335. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24336. * @param upperLimit The upper limit of the motor
  24337. * @param lowerLimit The lower limit of the motor
  24338. */
  24339. setLimit(upperLimit: number, lowerLimit?: number): void;
  24340. }
  24341. /**
  24342. * This class represents a single physics Hinge-Joint
  24343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24344. */
  24345. export class HingeJoint extends MotorEnabledJoint {
  24346. /**
  24347. * Initializes the Hinge-Joint
  24348. * @param jointData The joint data for the Hinge-Joint
  24349. */
  24350. constructor(jointData: PhysicsJointData);
  24351. /**
  24352. * Set the motor values.
  24353. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24354. * @param {number} force the force to apply
  24355. * @param {number} maxForce max force for this motor.
  24356. */
  24357. setMotor(force?: number, maxForce?: number): void;
  24358. /**
  24359. * Set the motor's limits.
  24360. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24361. * @param upperLimit The upper limit of the motor
  24362. * @param lowerLimit The lower limit of the motor
  24363. */
  24364. setLimit(upperLimit: number, lowerLimit?: number): void;
  24365. }
  24366. /**
  24367. * This class represents a dual hinge physics joint (same as wheel joint)
  24368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24369. */
  24370. export class Hinge2Joint extends MotorEnabledJoint {
  24371. /**
  24372. * Initializes the Hinge2-Joint
  24373. * @param jointData The joint data for the Hinge2-Joint
  24374. */
  24375. constructor(jointData: PhysicsJointData);
  24376. /**
  24377. * Set the motor values.
  24378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24379. * @param {number} targetSpeed the speed the motor is to reach
  24380. * @param {number} maxForce max force for this motor.
  24381. * @param {motorIndex} the motor's index, 0 or 1.
  24382. */
  24383. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24384. /**
  24385. * Set the motor limits.
  24386. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24387. * @param {number} upperLimit the upper limit
  24388. * @param {number} lowerLimit lower limit
  24389. * @param {motorIndex} the motor's index, 0 or 1.
  24390. */
  24391. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24392. }
  24393. /**
  24394. * Interface for a motor enabled joint
  24395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24396. */
  24397. export interface IMotorEnabledJoint {
  24398. /**
  24399. * Physics joint
  24400. */
  24401. physicsJoint: any;
  24402. /**
  24403. * Sets the motor of the motor-enabled joint
  24404. * @param force The force of the motor
  24405. * @param maxForce The maximum force of the motor
  24406. * @param motorIndex The index of the motor
  24407. */
  24408. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24409. /**
  24410. * Sets the limit of the motor
  24411. * @param upperLimit The upper limit of the motor
  24412. * @param lowerLimit The lower limit of the motor
  24413. * @param motorIndex The index of the motor
  24414. */
  24415. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24416. }
  24417. /**
  24418. * Joint data for a Distance-Joint
  24419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24420. */
  24421. export interface DistanceJointData extends PhysicsJointData {
  24422. /**
  24423. * Max distance the 2 joint objects can be apart
  24424. */
  24425. maxDistance: number;
  24426. }
  24427. /**
  24428. * Joint data from a spring joint
  24429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24430. */
  24431. export interface SpringJointData extends PhysicsJointData {
  24432. /**
  24433. * Length of the spring
  24434. */
  24435. length: number;
  24436. /**
  24437. * Stiffness of the spring
  24438. */
  24439. stiffness: number;
  24440. /**
  24441. * Damping of the spring
  24442. */
  24443. damping: number;
  24444. /** this callback will be called when applying the force to the impostors. */
  24445. forceApplicationCallback: () => void;
  24446. }
  24447. }
  24448. declare module "babylonjs/Physics/physicsRaycastResult" {
  24449. import { Vector3 } from "babylonjs/Maths/math.vector";
  24450. /**
  24451. * Holds the data for the raycast result
  24452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24453. */
  24454. export class PhysicsRaycastResult {
  24455. private _hasHit;
  24456. private _hitDistance;
  24457. private _hitNormalWorld;
  24458. private _hitPointWorld;
  24459. private _rayFromWorld;
  24460. private _rayToWorld;
  24461. /**
  24462. * Gets if there was a hit
  24463. */
  24464. get hasHit(): boolean;
  24465. /**
  24466. * Gets the distance from the hit
  24467. */
  24468. get hitDistance(): number;
  24469. /**
  24470. * Gets the hit normal/direction in the world
  24471. */
  24472. get hitNormalWorld(): Vector3;
  24473. /**
  24474. * Gets the hit point in the world
  24475. */
  24476. get hitPointWorld(): Vector3;
  24477. /**
  24478. * Gets the ray "start point" of the ray in the world
  24479. */
  24480. get rayFromWorld(): Vector3;
  24481. /**
  24482. * Gets the ray "end point" of the ray in the world
  24483. */
  24484. get rayToWorld(): Vector3;
  24485. /**
  24486. * Sets the hit data (normal & point in world space)
  24487. * @param hitNormalWorld defines the normal in world space
  24488. * @param hitPointWorld defines the point in world space
  24489. */
  24490. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24491. /**
  24492. * Sets the distance from the start point to the hit point
  24493. * @param distance
  24494. */
  24495. setHitDistance(distance: number): void;
  24496. /**
  24497. * Calculates the distance manually
  24498. */
  24499. calculateHitDistance(): void;
  24500. /**
  24501. * Resets all the values to default
  24502. * @param from The from point on world space
  24503. * @param to The to point on world space
  24504. */
  24505. reset(from?: Vector3, to?: Vector3): void;
  24506. }
  24507. /**
  24508. * Interface for the size containing width and height
  24509. */
  24510. interface IXYZ {
  24511. /**
  24512. * X
  24513. */
  24514. x: number;
  24515. /**
  24516. * Y
  24517. */
  24518. y: number;
  24519. /**
  24520. * Z
  24521. */
  24522. z: number;
  24523. }
  24524. }
  24525. declare module "babylonjs/Physics/IPhysicsEngine" {
  24526. import { Nullable } from "babylonjs/types";
  24527. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24529. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24530. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24531. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24532. /**
  24533. * Interface used to describe a physics joint
  24534. */
  24535. export interface PhysicsImpostorJoint {
  24536. /** Defines the main impostor to which the joint is linked */
  24537. mainImpostor: PhysicsImpostor;
  24538. /** Defines the impostor that is connected to the main impostor using this joint */
  24539. connectedImpostor: PhysicsImpostor;
  24540. /** Defines the joint itself */
  24541. joint: PhysicsJoint;
  24542. }
  24543. /** @hidden */
  24544. export interface IPhysicsEnginePlugin {
  24545. world: any;
  24546. name: string;
  24547. setGravity(gravity: Vector3): void;
  24548. setTimeStep(timeStep: number): void;
  24549. getTimeStep(): number;
  24550. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24551. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24552. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24553. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24554. removePhysicsBody(impostor: PhysicsImpostor): void;
  24555. generateJoint(joint: PhysicsImpostorJoint): void;
  24556. removeJoint(joint: PhysicsImpostorJoint): void;
  24557. isSupported(): boolean;
  24558. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24559. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24560. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24561. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24562. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24563. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24564. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24565. getBodyMass(impostor: PhysicsImpostor): number;
  24566. getBodyFriction(impostor: PhysicsImpostor): number;
  24567. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24568. getBodyRestitution(impostor: PhysicsImpostor): number;
  24569. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24570. getBodyPressure?(impostor: PhysicsImpostor): number;
  24571. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24572. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24573. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24574. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24575. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24576. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24577. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24578. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24579. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24580. sleepBody(impostor: PhysicsImpostor): void;
  24581. wakeUpBody(impostor: PhysicsImpostor): void;
  24582. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24583. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24584. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24585. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24586. getRadius(impostor: PhysicsImpostor): number;
  24587. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24588. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24589. dispose(): void;
  24590. }
  24591. /**
  24592. * Interface used to define a physics engine
  24593. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24594. */
  24595. export interface IPhysicsEngine {
  24596. /**
  24597. * Gets the gravity vector used by the simulation
  24598. */
  24599. gravity: Vector3;
  24600. /**
  24601. * Sets the gravity vector used by the simulation
  24602. * @param gravity defines the gravity vector to use
  24603. */
  24604. setGravity(gravity: Vector3): void;
  24605. /**
  24606. * Set the time step of the physics engine.
  24607. * Default is 1/60.
  24608. * To slow it down, enter 1/600 for example.
  24609. * To speed it up, 1/30
  24610. * @param newTimeStep the new timestep to apply to this world.
  24611. */
  24612. setTimeStep(newTimeStep: number): void;
  24613. /**
  24614. * Get the time step of the physics engine.
  24615. * @returns the current time step
  24616. */
  24617. getTimeStep(): number;
  24618. /**
  24619. * Set the sub time step of the physics engine.
  24620. * Default is 0 meaning there is no sub steps
  24621. * To increase physics resolution precision, set a small value (like 1 ms)
  24622. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24623. */
  24624. setSubTimeStep(subTimeStep: number): void;
  24625. /**
  24626. * Get the sub time step of the physics engine.
  24627. * @returns the current sub time step
  24628. */
  24629. getSubTimeStep(): number;
  24630. /**
  24631. * Release all resources
  24632. */
  24633. dispose(): void;
  24634. /**
  24635. * Gets the name of the current physics plugin
  24636. * @returns the name of the plugin
  24637. */
  24638. getPhysicsPluginName(): string;
  24639. /**
  24640. * Adding a new impostor for the impostor tracking.
  24641. * This will be done by the impostor itself.
  24642. * @param impostor the impostor to add
  24643. */
  24644. addImpostor(impostor: PhysicsImpostor): void;
  24645. /**
  24646. * Remove an impostor from the engine.
  24647. * This impostor and its mesh will not longer be updated by the physics engine.
  24648. * @param impostor the impostor to remove
  24649. */
  24650. removeImpostor(impostor: PhysicsImpostor): void;
  24651. /**
  24652. * Add a joint to the physics engine
  24653. * @param mainImpostor defines the main impostor to which the joint is added.
  24654. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24655. * @param joint defines the joint that will connect both impostors.
  24656. */
  24657. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24658. /**
  24659. * Removes a joint from the simulation
  24660. * @param mainImpostor defines the impostor used with the joint
  24661. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24662. * @param joint defines the joint to remove
  24663. */
  24664. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24665. /**
  24666. * Gets the current plugin used to run the simulation
  24667. * @returns current plugin
  24668. */
  24669. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24670. /**
  24671. * Gets the list of physic impostors
  24672. * @returns an array of PhysicsImpostor
  24673. */
  24674. getImpostors(): Array<PhysicsImpostor>;
  24675. /**
  24676. * Gets the impostor for a physics enabled object
  24677. * @param object defines the object impersonated by the impostor
  24678. * @returns the PhysicsImpostor or null if not found
  24679. */
  24680. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24681. /**
  24682. * Gets the impostor for a physics body object
  24683. * @param body defines physics body used by the impostor
  24684. * @returns the PhysicsImpostor or null if not found
  24685. */
  24686. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24687. /**
  24688. * Does a raycast in the physics world
  24689. * @param from when should the ray start?
  24690. * @param to when should the ray end?
  24691. * @returns PhysicsRaycastResult
  24692. */
  24693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24694. /**
  24695. * Called by the scene. No need to call it.
  24696. * @param delta defines the timespam between frames
  24697. */
  24698. _step(delta: number): void;
  24699. }
  24700. }
  24701. declare module "babylonjs/Physics/physicsImpostor" {
  24702. import { Nullable, IndicesArray } from "babylonjs/types";
  24703. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24704. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24706. import { Scene } from "babylonjs/scene";
  24707. import { Bone } from "babylonjs/Bones/bone";
  24708. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24709. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24710. import { Space } from "babylonjs/Maths/math.axis";
  24711. /**
  24712. * The interface for the physics imposter parameters
  24713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24714. */
  24715. export interface PhysicsImpostorParameters {
  24716. /**
  24717. * The mass of the physics imposter
  24718. */
  24719. mass: number;
  24720. /**
  24721. * The friction of the physics imposter
  24722. */
  24723. friction?: number;
  24724. /**
  24725. * The coefficient of restitution of the physics imposter
  24726. */
  24727. restitution?: number;
  24728. /**
  24729. * The native options of the physics imposter
  24730. */
  24731. nativeOptions?: any;
  24732. /**
  24733. * Specifies if the parent should be ignored
  24734. */
  24735. ignoreParent?: boolean;
  24736. /**
  24737. * Specifies if bi-directional transformations should be disabled
  24738. */
  24739. disableBidirectionalTransformation?: boolean;
  24740. /**
  24741. * The pressure inside the physics imposter, soft object only
  24742. */
  24743. pressure?: number;
  24744. /**
  24745. * The stiffness the physics imposter, soft object only
  24746. */
  24747. stiffness?: number;
  24748. /**
  24749. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24750. */
  24751. velocityIterations?: number;
  24752. /**
  24753. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24754. */
  24755. positionIterations?: number;
  24756. /**
  24757. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24758. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24759. * Add to fix multiple points
  24760. */
  24761. fixedPoints?: number;
  24762. /**
  24763. * The collision margin around a soft object
  24764. */
  24765. margin?: number;
  24766. /**
  24767. * The collision margin around a soft object
  24768. */
  24769. damping?: number;
  24770. /**
  24771. * The path for a rope based on an extrusion
  24772. */
  24773. path?: any;
  24774. /**
  24775. * The shape of an extrusion used for a rope based on an extrusion
  24776. */
  24777. shape?: any;
  24778. }
  24779. /**
  24780. * Interface for a physics-enabled object
  24781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24782. */
  24783. export interface IPhysicsEnabledObject {
  24784. /**
  24785. * The position of the physics-enabled object
  24786. */
  24787. position: Vector3;
  24788. /**
  24789. * The rotation of the physics-enabled object
  24790. */
  24791. rotationQuaternion: Nullable<Quaternion>;
  24792. /**
  24793. * The scale of the physics-enabled object
  24794. */
  24795. scaling: Vector3;
  24796. /**
  24797. * The rotation of the physics-enabled object
  24798. */
  24799. rotation?: Vector3;
  24800. /**
  24801. * The parent of the physics-enabled object
  24802. */
  24803. parent?: any;
  24804. /**
  24805. * The bounding info of the physics-enabled object
  24806. * @returns The bounding info of the physics-enabled object
  24807. */
  24808. getBoundingInfo(): BoundingInfo;
  24809. /**
  24810. * Computes the world matrix
  24811. * @param force Specifies if the world matrix should be computed by force
  24812. * @returns A world matrix
  24813. */
  24814. computeWorldMatrix(force: boolean): Matrix;
  24815. /**
  24816. * Gets the world matrix
  24817. * @returns A world matrix
  24818. */
  24819. getWorldMatrix?(): Matrix;
  24820. /**
  24821. * Gets the child meshes
  24822. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24823. * @returns An array of abstract meshes
  24824. */
  24825. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24826. /**
  24827. * Gets the vertex data
  24828. * @param kind The type of vertex data
  24829. * @returns A nullable array of numbers, or a float32 array
  24830. */
  24831. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24832. /**
  24833. * Gets the indices from the mesh
  24834. * @returns A nullable array of index arrays
  24835. */
  24836. getIndices?(): Nullable<IndicesArray>;
  24837. /**
  24838. * Gets the scene from the mesh
  24839. * @returns the indices array or null
  24840. */
  24841. getScene?(): Scene;
  24842. /**
  24843. * Gets the absolute position from the mesh
  24844. * @returns the absolute position
  24845. */
  24846. getAbsolutePosition(): Vector3;
  24847. /**
  24848. * Gets the absolute pivot point from the mesh
  24849. * @returns the absolute pivot point
  24850. */
  24851. getAbsolutePivotPoint(): Vector3;
  24852. /**
  24853. * Rotates the mesh
  24854. * @param axis The axis of rotation
  24855. * @param amount The amount of rotation
  24856. * @param space The space of the rotation
  24857. * @returns The rotation transform node
  24858. */
  24859. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24860. /**
  24861. * Translates the mesh
  24862. * @param axis The axis of translation
  24863. * @param distance The distance of translation
  24864. * @param space The space of the translation
  24865. * @returns The transform node
  24866. */
  24867. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24868. /**
  24869. * Sets the absolute position of the mesh
  24870. * @param absolutePosition The absolute position of the mesh
  24871. * @returns The transform node
  24872. */
  24873. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24874. /**
  24875. * Gets the class name of the mesh
  24876. * @returns The class name
  24877. */
  24878. getClassName(): string;
  24879. }
  24880. /**
  24881. * Represents a physics imposter
  24882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24883. */
  24884. export class PhysicsImpostor {
  24885. /**
  24886. * The physics-enabled object used as the physics imposter
  24887. */
  24888. object: IPhysicsEnabledObject;
  24889. /**
  24890. * The type of the physics imposter
  24891. */
  24892. type: number;
  24893. private _options;
  24894. private _scene?;
  24895. /**
  24896. * The default object size of the imposter
  24897. */
  24898. static DEFAULT_OBJECT_SIZE: Vector3;
  24899. /**
  24900. * The identity quaternion of the imposter
  24901. */
  24902. static IDENTITY_QUATERNION: Quaternion;
  24903. /** @hidden */
  24904. _pluginData: any;
  24905. private _physicsEngine;
  24906. private _physicsBody;
  24907. private _bodyUpdateRequired;
  24908. private _onBeforePhysicsStepCallbacks;
  24909. private _onAfterPhysicsStepCallbacks;
  24910. /** @hidden */
  24911. _onPhysicsCollideCallbacks: Array<{
  24912. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24913. otherImpostors: Array<PhysicsImpostor>;
  24914. }>;
  24915. private _deltaPosition;
  24916. private _deltaRotation;
  24917. private _deltaRotationConjugated;
  24918. /** @hidden */
  24919. _isFromLine: boolean;
  24920. private _parent;
  24921. private _isDisposed;
  24922. private static _tmpVecs;
  24923. private static _tmpQuat;
  24924. /**
  24925. * Specifies if the physics imposter is disposed
  24926. */
  24927. get isDisposed(): boolean;
  24928. /**
  24929. * Gets the mass of the physics imposter
  24930. */
  24931. get mass(): number;
  24932. set mass(value: number);
  24933. /**
  24934. * Gets the coefficient of friction
  24935. */
  24936. get friction(): number;
  24937. /**
  24938. * Sets the coefficient of friction
  24939. */
  24940. set friction(value: number);
  24941. /**
  24942. * Gets the coefficient of restitution
  24943. */
  24944. get restitution(): number;
  24945. /**
  24946. * Sets the coefficient of restitution
  24947. */
  24948. set restitution(value: number);
  24949. /**
  24950. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24951. */
  24952. get pressure(): number;
  24953. /**
  24954. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24955. */
  24956. set pressure(value: number);
  24957. /**
  24958. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24959. */
  24960. get stiffness(): number;
  24961. /**
  24962. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24963. */
  24964. set stiffness(value: number);
  24965. /**
  24966. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24967. */
  24968. get velocityIterations(): number;
  24969. /**
  24970. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24971. */
  24972. set velocityIterations(value: number);
  24973. /**
  24974. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24975. */
  24976. get positionIterations(): number;
  24977. /**
  24978. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24979. */
  24980. set positionIterations(value: number);
  24981. /**
  24982. * The unique id of the physics imposter
  24983. * set by the physics engine when adding this impostor to the array
  24984. */
  24985. uniqueId: number;
  24986. /**
  24987. * @hidden
  24988. */
  24989. soft: boolean;
  24990. /**
  24991. * @hidden
  24992. */
  24993. segments: number;
  24994. private _joints;
  24995. /**
  24996. * Initializes the physics imposter
  24997. * @param object The physics-enabled object used as the physics imposter
  24998. * @param type The type of the physics imposter
  24999. * @param _options The options for the physics imposter
  25000. * @param _scene The Babylon scene
  25001. */
  25002. constructor(
  25003. /**
  25004. * The physics-enabled object used as the physics imposter
  25005. */
  25006. object: IPhysicsEnabledObject,
  25007. /**
  25008. * The type of the physics imposter
  25009. */
  25010. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25011. /**
  25012. * This function will completly initialize this impostor.
  25013. * It will create a new body - but only if this mesh has no parent.
  25014. * If it has, this impostor will not be used other than to define the impostor
  25015. * of the child mesh.
  25016. * @hidden
  25017. */
  25018. _init(): void;
  25019. private _getPhysicsParent;
  25020. /**
  25021. * Should a new body be generated.
  25022. * @returns boolean specifying if body initialization is required
  25023. */
  25024. isBodyInitRequired(): boolean;
  25025. /**
  25026. * Sets the updated scaling
  25027. * @param updated Specifies if the scaling is updated
  25028. */
  25029. setScalingUpdated(): void;
  25030. /**
  25031. * Force a regeneration of this or the parent's impostor's body.
  25032. * Use under cautious - This will remove all joints already implemented.
  25033. */
  25034. forceUpdate(): void;
  25035. /**
  25036. * Gets the body that holds this impostor. Either its own, or its parent.
  25037. */
  25038. get physicsBody(): any;
  25039. /**
  25040. * Get the parent of the physics imposter
  25041. * @returns Physics imposter or null
  25042. */
  25043. get parent(): Nullable<PhysicsImpostor>;
  25044. /**
  25045. * Sets the parent of the physics imposter
  25046. */
  25047. set parent(value: Nullable<PhysicsImpostor>);
  25048. /**
  25049. * Set the physics body. Used mainly by the physics engine/plugin
  25050. */
  25051. set physicsBody(physicsBody: any);
  25052. /**
  25053. * Resets the update flags
  25054. */
  25055. resetUpdateFlags(): void;
  25056. /**
  25057. * Gets the object extend size
  25058. * @returns the object extend size
  25059. */
  25060. getObjectExtendSize(): Vector3;
  25061. /**
  25062. * Gets the object center
  25063. * @returns The object center
  25064. */
  25065. getObjectCenter(): Vector3;
  25066. /**
  25067. * Get a specific parameter from the options parameters
  25068. * @param paramName The object parameter name
  25069. * @returns The object parameter
  25070. */
  25071. getParam(paramName: string): any;
  25072. /**
  25073. * Sets a specific parameter in the options given to the physics plugin
  25074. * @param paramName The parameter name
  25075. * @param value The value of the parameter
  25076. */
  25077. setParam(paramName: string, value: number): void;
  25078. /**
  25079. * Specifically change the body's mass option. Won't recreate the physics body object
  25080. * @param mass The mass of the physics imposter
  25081. */
  25082. setMass(mass: number): void;
  25083. /**
  25084. * Gets the linear velocity
  25085. * @returns linear velocity or null
  25086. */
  25087. getLinearVelocity(): Nullable<Vector3>;
  25088. /**
  25089. * Sets the linear velocity
  25090. * @param velocity linear velocity or null
  25091. */
  25092. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25093. /**
  25094. * Gets the angular velocity
  25095. * @returns angular velocity or null
  25096. */
  25097. getAngularVelocity(): Nullable<Vector3>;
  25098. /**
  25099. * Sets the angular velocity
  25100. * @param velocity The velocity or null
  25101. */
  25102. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25103. /**
  25104. * Execute a function with the physics plugin native code
  25105. * Provide a function the will have two variables - the world object and the physics body object
  25106. * @param func The function to execute with the physics plugin native code
  25107. */
  25108. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25109. /**
  25110. * Register a function that will be executed before the physics world is stepping forward
  25111. * @param func The function to execute before the physics world is stepped forward
  25112. */
  25113. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25114. /**
  25115. * Unregister a function that will be executed before the physics world is stepping forward
  25116. * @param func The function to execute before the physics world is stepped forward
  25117. */
  25118. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25119. /**
  25120. * Register a function that will be executed after the physics step
  25121. * @param func The function to execute after physics step
  25122. */
  25123. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25124. /**
  25125. * Unregisters a function that will be executed after the physics step
  25126. * @param func The function to execute after physics step
  25127. */
  25128. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25129. /**
  25130. * register a function that will be executed when this impostor collides against a different body
  25131. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25132. * @param func Callback that is executed on collision
  25133. */
  25134. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25135. /**
  25136. * Unregisters the physics imposter on contact
  25137. * @param collideAgainst The physics object to collide against
  25138. * @param func Callback to execute on collision
  25139. */
  25140. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25141. private _tmpQuat;
  25142. private _tmpQuat2;
  25143. /**
  25144. * Get the parent rotation
  25145. * @returns The parent rotation
  25146. */
  25147. getParentsRotation(): Quaternion;
  25148. /**
  25149. * this function is executed by the physics engine.
  25150. */
  25151. beforeStep: () => void;
  25152. /**
  25153. * this function is executed by the physics engine
  25154. */
  25155. afterStep: () => void;
  25156. /**
  25157. * Legacy collision detection event support
  25158. */
  25159. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25160. /**
  25161. * event and body object due to cannon's event-based architecture.
  25162. */
  25163. onCollide: (e: {
  25164. body: any;
  25165. }) => void;
  25166. /**
  25167. * Apply a force
  25168. * @param force The force to apply
  25169. * @param contactPoint The contact point for the force
  25170. * @returns The physics imposter
  25171. */
  25172. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25173. /**
  25174. * Apply an impulse
  25175. * @param force The impulse force
  25176. * @param contactPoint The contact point for the impulse force
  25177. * @returns The physics imposter
  25178. */
  25179. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25180. /**
  25181. * A help function to create a joint
  25182. * @param otherImpostor A physics imposter used to create a joint
  25183. * @param jointType The type of joint
  25184. * @param jointData The data for the joint
  25185. * @returns The physics imposter
  25186. */
  25187. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25188. /**
  25189. * Add a joint to this impostor with a different impostor
  25190. * @param otherImpostor A physics imposter used to add a joint
  25191. * @param joint The joint to add
  25192. * @returns The physics imposter
  25193. */
  25194. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25195. /**
  25196. * Add an anchor to a cloth impostor
  25197. * @param otherImpostor rigid impostor to anchor to
  25198. * @param width ratio across width from 0 to 1
  25199. * @param height ratio up height from 0 to 1
  25200. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25201. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25202. * @returns impostor the soft imposter
  25203. */
  25204. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25205. /**
  25206. * Add a hook to a rope impostor
  25207. * @param otherImpostor rigid impostor to anchor to
  25208. * @param length ratio across rope from 0 to 1
  25209. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25210. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25211. * @returns impostor the rope imposter
  25212. */
  25213. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25214. /**
  25215. * Will keep this body still, in a sleep mode.
  25216. * @returns the physics imposter
  25217. */
  25218. sleep(): PhysicsImpostor;
  25219. /**
  25220. * Wake the body up.
  25221. * @returns The physics imposter
  25222. */
  25223. wakeUp(): PhysicsImpostor;
  25224. /**
  25225. * Clones the physics imposter
  25226. * @param newObject The physics imposter clones to this physics-enabled object
  25227. * @returns A nullable physics imposter
  25228. */
  25229. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25230. /**
  25231. * Disposes the physics imposter
  25232. */
  25233. dispose(): void;
  25234. /**
  25235. * Sets the delta position
  25236. * @param position The delta position amount
  25237. */
  25238. setDeltaPosition(position: Vector3): void;
  25239. /**
  25240. * Sets the delta rotation
  25241. * @param rotation The delta rotation amount
  25242. */
  25243. setDeltaRotation(rotation: Quaternion): void;
  25244. /**
  25245. * Gets the box size of the physics imposter and stores the result in the input parameter
  25246. * @param result Stores the box size
  25247. * @returns The physics imposter
  25248. */
  25249. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25250. /**
  25251. * Gets the radius of the physics imposter
  25252. * @returns Radius of the physics imposter
  25253. */
  25254. getRadius(): number;
  25255. /**
  25256. * Sync a bone with this impostor
  25257. * @param bone The bone to sync to the impostor.
  25258. * @param boneMesh The mesh that the bone is influencing.
  25259. * @param jointPivot The pivot of the joint / bone in local space.
  25260. * @param distToJoint Optional distance from the impostor to the joint.
  25261. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25262. */
  25263. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25264. /**
  25265. * Sync impostor to a bone
  25266. * @param bone The bone that the impostor will be synced to.
  25267. * @param boneMesh The mesh that the bone is influencing.
  25268. * @param jointPivot The pivot of the joint / bone in local space.
  25269. * @param distToJoint Optional distance from the impostor to the joint.
  25270. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25271. * @param boneAxis Optional vector3 axis the bone is aligned with
  25272. */
  25273. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25274. /**
  25275. * No-Imposter type
  25276. */
  25277. static NoImpostor: number;
  25278. /**
  25279. * Sphere-Imposter type
  25280. */
  25281. static SphereImpostor: number;
  25282. /**
  25283. * Box-Imposter type
  25284. */
  25285. static BoxImpostor: number;
  25286. /**
  25287. * Plane-Imposter type
  25288. */
  25289. static PlaneImpostor: number;
  25290. /**
  25291. * Mesh-imposter type
  25292. */
  25293. static MeshImpostor: number;
  25294. /**
  25295. * Capsule-Impostor type (Ammo.js plugin only)
  25296. */
  25297. static CapsuleImpostor: number;
  25298. /**
  25299. * Cylinder-Imposter type
  25300. */
  25301. static CylinderImpostor: number;
  25302. /**
  25303. * Particle-Imposter type
  25304. */
  25305. static ParticleImpostor: number;
  25306. /**
  25307. * Heightmap-Imposter type
  25308. */
  25309. static HeightmapImpostor: number;
  25310. /**
  25311. * ConvexHull-Impostor type (Ammo.js plugin only)
  25312. */
  25313. static ConvexHullImpostor: number;
  25314. /**
  25315. * Custom-Imposter type (Ammo.js plugin only)
  25316. */
  25317. static CustomImpostor: number;
  25318. /**
  25319. * Rope-Imposter type
  25320. */
  25321. static RopeImpostor: number;
  25322. /**
  25323. * Cloth-Imposter type
  25324. */
  25325. static ClothImpostor: number;
  25326. /**
  25327. * Softbody-Imposter type
  25328. */
  25329. static SoftbodyImpostor: number;
  25330. }
  25331. }
  25332. declare module "babylonjs/Meshes/mesh" {
  25333. import { Observable } from "babylonjs/Misc/observable";
  25334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25335. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25336. import { Camera } from "babylonjs/Cameras/camera";
  25337. import { Scene } from "babylonjs/scene";
  25338. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25339. import { Color4 } from "babylonjs/Maths/math.color";
  25340. import { Engine } from "babylonjs/Engines/engine";
  25341. import { Node } from "babylonjs/node";
  25342. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25343. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25344. import { Buffer } from "babylonjs/Meshes/buffer";
  25345. import { Geometry } from "babylonjs/Meshes/geometry";
  25346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25348. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25349. import { Effect } from "babylonjs/Materials/effect";
  25350. import { Material } from "babylonjs/Materials/material";
  25351. import { Skeleton } from "babylonjs/Bones/skeleton";
  25352. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25353. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25354. import { Path3D } from "babylonjs/Maths/math.path";
  25355. import { Plane } from "babylonjs/Maths/math.plane";
  25356. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25357. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25358. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25359. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25360. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25361. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25362. /**
  25363. * @hidden
  25364. **/
  25365. export class _CreationDataStorage {
  25366. closePath?: boolean;
  25367. closeArray?: boolean;
  25368. idx: number[];
  25369. dashSize: number;
  25370. gapSize: number;
  25371. path3D: Path3D;
  25372. pathArray: Vector3[][];
  25373. arc: number;
  25374. radius: number;
  25375. cap: number;
  25376. tessellation: number;
  25377. }
  25378. /**
  25379. * @hidden
  25380. **/
  25381. class _InstanceDataStorage {
  25382. visibleInstances: any;
  25383. batchCache: _InstancesBatch;
  25384. instancesBufferSize: number;
  25385. instancesBuffer: Nullable<Buffer>;
  25386. instancesData: Float32Array;
  25387. overridenInstanceCount: number;
  25388. isFrozen: boolean;
  25389. previousBatch: Nullable<_InstancesBatch>;
  25390. hardwareInstancedRendering: boolean;
  25391. sideOrientation: number;
  25392. manualUpdate: boolean;
  25393. }
  25394. /**
  25395. * @hidden
  25396. **/
  25397. export class _InstancesBatch {
  25398. mustReturn: boolean;
  25399. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25400. renderSelf: boolean[];
  25401. hardwareInstancedRendering: boolean[];
  25402. }
  25403. /**
  25404. * Class used to represent renderable models
  25405. */
  25406. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25407. /**
  25408. * Mesh side orientation : usually the external or front surface
  25409. */
  25410. static readonly FRONTSIDE: number;
  25411. /**
  25412. * Mesh side orientation : usually the internal or back surface
  25413. */
  25414. static readonly BACKSIDE: number;
  25415. /**
  25416. * Mesh side orientation : both internal and external or front and back surfaces
  25417. */
  25418. static readonly DOUBLESIDE: number;
  25419. /**
  25420. * Mesh side orientation : by default, `FRONTSIDE`
  25421. */
  25422. static readonly DEFAULTSIDE: number;
  25423. /**
  25424. * Mesh cap setting : no cap
  25425. */
  25426. static readonly NO_CAP: number;
  25427. /**
  25428. * Mesh cap setting : one cap at the beginning of the mesh
  25429. */
  25430. static readonly CAP_START: number;
  25431. /**
  25432. * Mesh cap setting : one cap at the end of the mesh
  25433. */
  25434. static readonly CAP_END: number;
  25435. /**
  25436. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25437. */
  25438. static readonly CAP_ALL: number;
  25439. /**
  25440. * Mesh pattern setting : no flip or rotate
  25441. */
  25442. static readonly NO_FLIP: number;
  25443. /**
  25444. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25445. */
  25446. static readonly FLIP_TILE: number;
  25447. /**
  25448. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25449. */
  25450. static readonly ROTATE_TILE: number;
  25451. /**
  25452. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25453. */
  25454. static readonly FLIP_ROW: number;
  25455. /**
  25456. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25457. */
  25458. static readonly ROTATE_ROW: number;
  25459. /**
  25460. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25461. */
  25462. static readonly FLIP_N_ROTATE_TILE: number;
  25463. /**
  25464. * Mesh pattern setting : rotate pattern and rotate
  25465. */
  25466. static readonly FLIP_N_ROTATE_ROW: number;
  25467. /**
  25468. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25469. */
  25470. static readonly CENTER: number;
  25471. /**
  25472. * Mesh tile positioning : part tiles on left
  25473. */
  25474. static readonly LEFT: number;
  25475. /**
  25476. * Mesh tile positioning : part tiles on right
  25477. */
  25478. static readonly RIGHT: number;
  25479. /**
  25480. * Mesh tile positioning : part tiles on top
  25481. */
  25482. static readonly TOP: number;
  25483. /**
  25484. * Mesh tile positioning : part tiles on bottom
  25485. */
  25486. static readonly BOTTOM: number;
  25487. /**
  25488. * Gets the default side orientation.
  25489. * @param orientation the orientation to value to attempt to get
  25490. * @returns the default orientation
  25491. * @hidden
  25492. */
  25493. static _GetDefaultSideOrientation(orientation?: number): number;
  25494. private _internalMeshDataInfo;
  25495. /**
  25496. * An event triggered before rendering the mesh
  25497. */
  25498. get onBeforeRenderObservable(): Observable<Mesh>;
  25499. /**
  25500. * An event triggered before binding the mesh
  25501. */
  25502. get onBeforeBindObservable(): Observable<Mesh>;
  25503. /**
  25504. * An event triggered after rendering the mesh
  25505. */
  25506. get onAfterRenderObservable(): Observable<Mesh>;
  25507. /**
  25508. * An event triggered before drawing the mesh
  25509. */
  25510. get onBeforeDrawObservable(): Observable<Mesh>;
  25511. private _onBeforeDrawObserver;
  25512. /**
  25513. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25514. */
  25515. set onBeforeDraw(callback: () => void);
  25516. get hasInstances(): boolean;
  25517. /**
  25518. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25519. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25520. */
  25521. delayLoadState: number;
  25522. /**
  25523. * Gets the list of instances created from this mesh
  25524. * it is not supposed to be modified manually.
  25525. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25526. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25527. */
  25528. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25529. /**
  25530. * Gets the file containing delay loading data for this mesh
  25531. */
  25532. delayLoadingFile: string;
  25533. /** @hidden */
  25534. _binaryInfo: any;
  25535. /**
  25536. * User defined function used to change how LOD level selection is done
  25537. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25538. */
  25539. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25540. /**
  25541. * Gets or sets the morph target manager
  25542. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25543. */
  25544. get morphTargetManager(): Nullable<MorphTargetManager>;
  25545. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25546. /** @hidden */
  25547. _creationDataStorage: Nullable<_CreationDataStorage>;
  25548. /** @hidden */
  25549. _geometry: Nullable<Geometry>;
  25550. /** @hidden */
  25551. _delayInfo: Array<string>;
  25552. /** @hidden */
  25553. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25554. /** @hidden */
  25555. _instanceDataStorage: _InstanceDataStorage;
  25556. private _effectiveMaterial;
  25557. /** @hidden */
  25558. _shouldGenerateFlatShading: boolean;
  25559. /** @hidden */
  25560. _originalBuilderSideOrientation: number;
  25561. /**
  25562. * Use this property to change the original side orientation defined at construction time
  25563. */
  25564. overrideMaterialSideOrientation: Nullable<number>;
  25565. /**
  25566. * Gets the source mesh (the one used to clone this one from)
  25567. */
  25568. get source(): Nullable<Mesh>;
  25569. /**
  25570. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25571. */
  25572. get isUnIndexed(): boolean;
  25573. set isUnIndexed(value: boolean);
  25574. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25575. get worldMatrixInstancedBuffer(): Float32Array;
  25576. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25577. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25578. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25579. /**
  25580. * @constructor
  25581. * @param name The value used by scene.getMeshByName() to do a lookup.
  25582. * @param scene The scene to add this mesh to.
  25583. * @param parent The parent of this mesh, if it has one
  25584. * @param source An optional Mesh from which geometry is shared, cloned.
  25585. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25586. * When false, achieved by calling a clone(), also passing False.
  25587. * This will make creation of children, recursive.
  25588. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25589. */
  25590. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25591. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25592. doNotInstantiate: boolean;
  25593. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25594. /**
  25595. * Gets the class name
  25596. * @returns the string "Mesh".
  25597. */
  25598. getClassName(): string;
  25599. /** @hidden */
  25600. get _isMesh(): boolean;
  25601. /**
  25602. * Returns a description of this mesh
  25603. * @param fullDetails define if full details about this mesh must be used
  25604. * @returns a descriptive string representing this mesh
  25605. */
  25606. toString(fullDetails?: boolean): string;
  25607. /** @hidden */
  25608. _unBindEffect(): void;
  25609. /**
  25610. * Gets a boolean indicating if this mesh has LOD
  25611. */
  25612. get hasLODLevels(): boolean;
  25613. /**
  25614. * Gets the list of MeshLODLevel associated with the current mesh
  25615. * @returns an array of MeshLODLevel
  25616. */
  25617. getLODLevels(): MeshLODLevel[];
  25618. private _sortLODLevels;
  25619. /**
  25620. * Add a mesh as LOD level triggered at the given distance.
  25621. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25622. * @param distance The distance from the center of the object to show this level
  25623. * @param mesh The mesh to be added as LOD level (can be null)
  25624. * @return This mesh (for chaining)
  25625. */
  25626. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25627. /**
  25628. * Returns the LOD level mesh at the passed distance or null if not found.
  25629. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25630. * @param distance The distance from the center of the object to show this level
  25631. * @returns a Mesh or `null`
  25632. */
  25633. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25634. /**
  25635. * Remove a mesh from the LOD array
  25636. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25637. * @param mesh defines the mesh to be removed
  25638. * @return This mesh (for chaining)
  25639. */
  25640. removeLODLevel(mesh: Mesh): Mesh;
  25641. /**
  25642. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25643. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25644. * @param camera defines the camera to use to compute distance
  25645. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25646. * @return This mesh (for chaining)
  25647. */
  25648. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25649. /**
  25650. * Gets the mesh internal Geometry object
  25651. */
  25652. get geometry(): Nullable<Geometry>;
  25653. /**
  25654. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25655. * @returns the total number of vertices
  25656. */
  25657. getTotalVertices(): number;
  25658. /**
  25659. * Returns the content of an associated vertex buffer
  25660. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25661. * - VertexBuffer.PositionKind
  25662. * - VertexBuffer.UVKind
  25663. * - VertexBuffer.UV2Kind
  25664. * - VertexBuffer.UV3Kind
  25665. * - VertexBuffer.UV4Kind
  25666. * - VertexBuffer.UV5Kind
  25667. * - VertexBuffer.UV6Kind
  25668. * - VertexBuffer.ColorKind
  25669. * - VertexBuffer.MatricesIndicesKind
  25670. * - VertexBuffer.MatricesIndicesExtraKind
  25671. * - VertexBuffer.MatricesWeightsKind
  25672. * - VertexBuffer.MatricesWeightsExtraKind
  25673. * @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
  25674. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25675. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25676. */
  25677. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25678. /**
  25679. * Returns the mesh VertexBuffer object from the requested `kind`
  25680. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25681. * - VertexBuffer.PositionKind
  25682. * - VertexBuffer.NormalKind
  25683. * - VertexBuffer.UVKind
  25684. * - VertexBuffer.UV2Kind
  25685. * - VertexBuffer.UV3Kind
  25686. * - VertexBuffer.UV4Kind
  25687. * - VertexBuffer.UV5Kind
  25688. * - VertexBuffer.UV6Kind
  25689. * - VertexBuffer.ColorKind
  25690. * - VertexBuffer.MatricesIndicesKind
  25691. * - VertexBuffer.MatricesIndicesExtraKind
  25692. * - VertexBuffer.MatricesWeightsKind
  25693. * - VertexBuffer.MatricesWeightsExtraKind
  25694. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25695. */
  25696. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25697. /**
  25698. * Tests if a specific vertex buffer is associated with this mesh
  25699. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25700. * - VertexBuffer.PositionKind
  25701. * - VertexBuffer.NormalKind
  25702. * - VertexBuffer.UVKind
  25703. * - VertexBuffer.UV2Kind
  25704. * - VertexBuffer.UV3Kind
  25705. * - VertexBuffer.UV4Kind
  25706. * - VertexBuffer.UV5Kind
  25707. * - VertexBuffer.UV6Kind
  25708. * - VertexBuffer.ColorKind
  25709. * - VertexBuffer.MatricesIndicesKind
  25710. * - VertexBuffer.MatricesIndicesExtraKind
  25711. * - VertexBuffer.MatricesWeightsKind
  25712. * - VertexBuffer.MatricesWeightsExtraKind
  25713. * @returns a boolean
  25714. */
  25715. isVerticesDataPresent(kind: string): boolean;
  25716. /**
  25717. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25718. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25719. * - VertexBuffer.PositionKind
  25720. * - VertexBuffer.UVKind
  25721. * - VertexBuffer.UV2Kind
  25722. * - VertexBuffer.UV3Kind
  25723. * - VertexBuffer.UV4Kind
  25724. * - VertexBuffer.UV5Kind
  25725. * - VertexBuffer.UV6Kind
  25726. * - VertexBuffer.ColorKind
  25727. * - VertexBuffer.MatricesIndicesKind
  25728. * - VertexBuffer.MatricesIndicesExtraKind
  25729. * - VertexBuffer.MatricesWeightsKind
  25730. * - VertexBuffer.MatricesWeightsExtraKind
  25731. * @returns a boolean
  25732. */
  25733. isVertexBufferUpdatable(kind: string): boolean;
  25734. /**
  25735. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25736. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25737. * - VertexBuffer.PositionKind
  25738. * - VertexBuffer.NormalKind
  25739. * - VertexBuffer.UVKind
  25740. * - VertexBuffer.UV2Kind
  25741. * - VertexBuffer.UV3Kind
  25742. * - VertexBuffer.UV4Kind
  25743. * - VertexBuffer.UV5Kind
  25744. * - VertexBuffer.UV6Kind
  25745. * - VertexBuffer.ColorKind
  25746. * - VertexBuffer.MatricesIndicesKind
  25747. * - VertexBuffer.MatricesIndicesExtraKind
  25748. * - VertexBuffer.MatricesWeightsKind
  25749. * - VertexBuffer.MatricesWeightsExtraKind
  25750. * @returns an array of strings
  25751. */
  25752. getVerticesDataKinds(): string[];
  25753. /**
  25754. * Returns a positive integer : the total number of indices in this mesh geometry.
  25755. * @returns the numner of indices or zero if the mesh has no geometry.
  25756. */
  25757. getTotalIndices(): number;
  25758. /**
  25759. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25760. * @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.
  25761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25762. * @returns the indices array or an empty array if the mesh has no geometry
  25763. */
  25764. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25765. get isBlocked(): boolean;
  25766. /**
  25767. * Determine if the current mesh is ready to be rendered
  25768. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25769. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25770. * @returns true if all associated assets are ready (material, textures, shaders)
  25771. */
  25772. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25773. /**
  25774. * 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.
  25775. */
  25776. get areNormalsFrozen(): boolean;
  25777. /**
  25778. * 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.
  25779. * @returns the current mesh
  25780. */
  25781. freezeNormals(): Mesh;
  25782. /**
  25783. * 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
  25784. * @returns the current mesh
  25785. */
  25786. unfreezeNormals(): Mesh;
  25787. /**
  25788. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25789. */
  25790. set overridenInstanceCount(count: number);
  25791. /** @hidden */
  25792. _preActivate(): Mesh;
  25793. /** @hidden */
  25794. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25795. /** @hidden */
  25796. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25797. /**
  25798. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25799. * This means the mesh underlying bounding box and sphere are recomputed.
  25800. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25801. * @returns the current mesh
  25802. */
  25803. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25804. /** @hidden */
  25805. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25806. /**
  25807. * This function will subdivide the mesh into multiple submeshes
  25808. * @param count defines the expected number of submeshes
  25809. */
  25810. subdivide(count: number): void;
  25811. /**
  25812. * Copy a FloatArray into a specific associated vertex buffer
  25813. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25814. * - VertexBuffer.PositionKind
  25815. * - VertexBuffer.UVKind
  25816. * - VertexBuffer.UV2Kind
  25817. * - VertexBuffer.UV3Kind
  25818. * - VertexBuffer.UV4Kind
  25819. * - VertexBuffer.UV5Kind
  25820. * - VertexBuffer.UV6Kind
  25821. * - VertexBuffer.ColorKind
  25822. * - VertexBuffer.MatricesIndicesKind
  25823. * - VertexBuffer.MatricesIndicesExtraKind
  25824. * - VertexBuffer.MatricesWeightsKind
  25825. * - VertexBuffer.MatricesWeightsExtraKind
  25826. * @param data defines the data source
  25827. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25828. * @param stride defines the data stride size (can be null)
  25829. * @returns the current mesh
  25830. */
  25831. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25832. /**
  25833. * Delete a vertex buffer associated with this mesh
  25834. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25835. * - VertexBuffer.PositionKind
  25836. * - VertexBuffer.UVKind
  25837. * - VertexBuffer.UV2Kind
  25838. * - VertexBuffer.UV3Kind
  25839. * - VertexBuffer.UV4Kind
  25840. * - VertexBuffer.UV5Kind
  25841. * - VertexBuffer.UV6Kind
  25842. * - VertexBuffer.ColorKind
  25843. * - VertexBuffer.MatricesIndicesKind
  25844. * - VertexBuffer.MatricesIndicesExtraKind
  25845. * - VertexBuffer.MatricesWeightsKind
  25846. * - VertexBuffer.MatricesWeightsExtraKind
  25847. */
  25848. removeVerticesData(kind: string): void;
  25849. /**
  25850. * Flags an associated vertex buffer as updatable
  25851. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25852. * - VertexBuffer.PositionKind
  25853. * - VertexBuffer.UVKind
  25854. * - VertexBuffer.UV2Kind
  25855. * - VertexBuffer.UV3Kind
  25856. * - VertexBuffer.UV4Kind
  25857. * - VertexBuffer.UV5Kind
  25858. * - VertexBuffer.UV6Kind
  25859. * - VertexBuffer.ColorKind
  25860. * - VertexBuffer.MatricesIndicesKind
  25861. * - VertexBuffer.MatricesIndicesExtraKind
  25862. * - VertexBuffer.MatricesWeightsKind
  25863. * - VertexBuffer.MatricesWeightsExtraKind
  25864. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25865. */
  25866. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25867. /**
  25868. * Sets the mesh global Vertex Buffer
  25869. * @param buffer defines the buffer to use
  25870. * @returns the current mesh
  25871. */
  25872. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25873. /**
  25874. * Update a specific associated vertex buffer
  25875. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25876. * - VertexBuffer.PositionKind
  25877. * - VertexBuffer.UVKind
  25878. * - VertexBuffer.UV2Kind
  25879. * - VertexBuffer.UV3Kind
  25880. * - VertexBuffer.UV4Kind
  25881. * - VertexBuffer.UV5Kind
  25882. * - VertexBuffer.UV6Kind
  25883. * - VertexBuffer.ColorKind
  25884. * - VertexBuffer.MatricesIndicesKind
  25885. * - VertexBuffer.MatricesIndicesExtraKind
  25886. * - VertexBuffer.MatricesWeightsKind
  25887. * - VertexBuffer.MatricesWeightsExtraKind
  25888. * @param data defines the data source
  25889. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25890. * @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)
  25891. * @returns the current mesh
  25892. */
  25893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25894. /**
  25895. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25896. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25897. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25898. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25899. * @returns the current mesh
  25900. */
  25901. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25902. /**
  25903. * Creates a un-shared specific occurence of the geometry for the mesh.
  25904. * @returns the current mesh
  25905. */
  25906. makeGeometryUnique(): Mesh;
  25907. /**
  25908. * Set the index buffer of this mesh
  25909. * @param indices defines the source data
  25910. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25911. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25912. * @returns the current mesh
  25913. */
  25914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25915. /**
  25916. * Update the current index buffer
  25917. * @param indices defines the source data
  25918. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25919. * @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)
  25920. * @returns the current mesh
  25921. */
  25922. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25923. /**
  25924. * Invert the geometry to move from a right handed system to a left handed one.
  25925. * @returns the current mesh
  25926. */
  25927. toLeftHanded(): Mesh;
  25928. /** @hidden */
  25929. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25930. /** @hidden */
  25931. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25932. /**
  25933. * Registers for this mesh a javascript function called just before the rendering process
  25934. * @param func defines the function to call before rendering this mesh
  25935. * @returns the current mesh
  25936. */
  25937. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25938. /**
  25939. * Disposes a previously registered javascript function called before the rendering
  25940. * @param func defines the function to remove
  25941. * @returns the current mesh
  25942. */
  25943. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25944. /**
  25945. * Registers for this mesh a javascript function called just after the rendering is complete
  25946. * @param func defines the function to call after rendering this mesh
  25947. * @returns the current mesh
  25948. */
  25949. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25950. /**
  25951. * Disposes a previously registered javascript function called after the rendering.
  25952. * @param func defines the function to remove
  25953. * @returns the current mesh
  25954. */
  25955. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25956. /** @hidden */
  25957. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25958. /** @hidden */
  25959. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25960. /** @hidden */
  25961. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25962. /** @hidden */
  25963. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25964. /** @hidden */
  25965. _rebuild(): void;
  25966. /** @hidden */
  25967. _freeze(): void;
  25968. /** @hidden */
  25969. _unFreeze(): void;
  25970. /**
  25971. * 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
  25972. * @param subMesh defines the subMesh to render
  25973. * @param enableAlphaMode defines if alpha mode can be changed
  25974. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25975. * @returns the current mesh
  25976. */
  25977. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25978. private _onBeforeDraw;
  25979. /**
  25980. * Renormalize the mesh and patch it up if there are no weights
  25981. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25982. * However in the case of zero weights then we set just a single influence to 1.
  25983. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25984. */
  25985. cleanMatrixWeights(): void;
  25986. private normalizeSkinFourWeights;
  25987. private normalizeSkinWeightsAndExtra;
  25988. /**
  25989. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25990. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25991. * the user know there was an issue with importing the mesh
  25992. * @returns a validation object with skinned, valid and report string
  25993. */
  25994. validateSkinning(): {
  25995. skinned: boolean;
  25996. valid: boolean;
  25997. report: string;
  25998. };
  25999. /** @hidden */
  26000. _checkDelayState(): Mesh;
  26001. private _queueLoad;
  26002. /**
  26003. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26004. * A mesh is in the frustum if its bounding box intersects the frustum
  26005. * @param frustumPlanes defines the frustum to test
  26006. * @returns true if the mesh is in the frustum planes
  26007. */
  26008. isInFrustum(frustumPlanes: Plane[]): boolean;
  26009. /**
  26010. * Sets the mesh material by the material or multiMaterial `id` property
  26011. * @param id is a string identifying the material or the multiMaterial
  26012. * @returns the current mesh
  26013. */
  26014. setMaterialByID(id: string): Mesh;
  26015. /**
  26016. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26017. * @returns an array of IAnimatable
  26018. */
  26019. getAnimatables(): IAnimatable[];
  26020. /**
  26021. * Modifies the mesh geometry according to the passed transformation matrix.
  26022. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26023. * The mesh normals are modified using the same transformation.
  26024. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26025. * @param transform defines the transform matrix to use
  26026. * @see http://doc.babylonjs.com/resources/baking_transformations
  26027. * @returns the current mesh
  26028. */
  26029. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26030. /**
  26031. * Modifies the mesh geometry according to its own current World Matrix.
  26032. * The mesh World Matrix is then reset.
  26033. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26034. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26035. * @see http://doc.babylonjs.com/resources/baking_transformations
  26036. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26037. * @returns the current mesh
  26038. */
  26039. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26040. /** @hidden */
  26041. get _positions(): Nullable<Vector3[]>;
  26042. /** @hidden */
  26043. _resetPointsArrayCache(): Mesh;
  26044. /** @hidden */
  26045. _generatePointsArray(): boolean;
  26046. /**
  26047. * Returns a new Mesh object generated from the current mesh properties.
  26048. * This method must not get confused with createInstance()
  26049. * @param name is a string, the name given to the new mesh
  26050. * @param newParent can be any Node object (default `null`)
  26051. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26052. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26053. * @returns a new mesh
  26054. */
  26055. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26056. /**
  26057. * Releases resources associated with this mesh.
  26058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26060. */
  26061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26062. /** @hidden */
  26063. _disposeInstanceSpecificData(): void;
  26064. /**
  26065. * Modifies the mesh geometry according to a displacement map.
  26066. * 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.
  26067. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26068. * @param url is a string, the URL from the image file is to be downloaded.
  26069. * @param minHeight is the lower limit of the displacement.
  26070. * @param maxHeight is the upper limit of the displacement.
  26071. * @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.
  26072. * @param uvOffset is an optional vector2 used to offset UV.
  26073. * @param uvScale is an optional vector2 used to scale UV.
  26074. * @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.
  26075. * @returns the Mesh.
  26076. */
  26077. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26078. /**
  26079. * Modifies the mesh geometry according to a displacementMap buffer.
  26080. * 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.
  26081. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26082. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26083. * @param heightMapWidth is the width of the buffer image.
  26084. * @param heightMapHeight is the height of the buffer image.
  26085. * @param minHeight is the lower limit of the displacement.
  26086. * @param maxHeight is the upper limit of the displacement.
  26087. * @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.
  26088. * @param uvOffset is an optional vector2 used to offset UV.
  26089. * @param uvScale is an optional vector2 used to scale UV.
  26090. * @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.
  26091. * @returns the Mesh.
  26092. */
  26093. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26094. /**
  26095. * Modify the mesh to get a flat shading rendering.
  26096. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26097. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26098. * @returns current mesh
  26099. */
  26100. convertToFlatShadedMesh(): Mesh;
  26101. /**
  26102. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26103. * In other words, more vertices, no more indices and a single bigger VBO.
  26104. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26105. * @returns current mesh
  26106. */
  26107. convertToUnIndexedMesh(): Mesh;
  26108. /**
  26109. * Inverses facet orientations.
  26110. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26111. * @param flipNormals will also inverts the normals
  26112. * @returns current mesh
  26113. */
  26114. flipFaces(flipNormals?: boolean): Mesh;
  26115. /**
  26116. * Increase the number of facets and hence vertices in a mesh
  26117. * Vertex normals are interpolated from existing vertex normals
  26118. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26119. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26120. */
  26121. increaseVertices(numberPerEdge: number): void;
  26122. /**
  26123. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26124. * This will undo any application of covertToFlatShadedMesh
  26125. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26126. */
  26127. forceSharedVertices(): void;
  26128. /** @hidden */
  26129. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26130. /** @hidden */
  26131. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26132. /**
  26133. * Creates a new InstancedMesh object from the mesh model.
  26134. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26135. * @param name defines the name of the new instance
  26136. * @returns a new InstancedMesh
  26137. */
  26138. createInstance(name: string): InstancedMesh;
  26139. /**
  26140. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26141. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26142. * @returns the current mesh
  26143. */
  26144. synchronizeInstances(): Mesh;
  26145. /**
  26146. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26147. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26148. * This should be used together with the simplification to avoid disappearing triangles.
  26149. * @param successCallback an optional success callback to be called after the optimization finished.
  26150. * @returns the current mesh
  26151. */
  26152. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26153. /**
  26154. * Serialize current mesh
  26155. * @param serializationObject defines the object which will receive the serialization data
  26156. */
  26157. serialize(serializationObject: any): void;
  26158. /** @hidden */
  26159. _syncGeometryWithMorphTargetManager(): void;
  26160. /** @hidden */
  26161. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26162. /**
  26163. * Returns a new Mesh object parsed from the source provided.
  26164. * @param parsedMesh is the source
  26165. * @param scene defines the hosting scene
  26166. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26167. * @returns a new Mesh
  26168. */
  26169. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26170. /**
  26171. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26172. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26173. * @param name defines the name of the mesh to create
  26174. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26175. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26176. * @param closePath creates a seam between the first and the last points of each path of the path array
  26177. * @param offset is taken in account only if the `pathArray` is containing a single path
  26178. * @param scene defines the hosting scene
  26179. * @param updatable defines if the mesh must be flagged as updatable
  26180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26181. * @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)
  26182. * @returns a new Mesh
  26183. */
  26184. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26185. /**
  26186. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26187. * @param name defines the name of the mesh to create
  26188. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26189. * @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
  26190. * @param scene defines the hosting scene
  26191. * @param updatable defines if the mesh must be flagged as updatable
  26192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26193. * @returns a new Mesh
  26194. */
  26195. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26196. /**
  26197. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26198. * @param name defines the name of the mesh to create
  26199. * @param size sets the size (float) of each box side (default 1)
  26200. * @param scene defines the hosting scene
  26201. * @param updatable defines if the mesh must be flagged as updatable
  26202. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26203. * @returns a new Mesh
  26204. */
  26205. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26206. /**
  26207. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26208. * @param name defines the name of the mesh to create
  26209. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26210. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26211. * @param scene defines the hosting scene
  26212. * @param updatable defines if the mesh must be flagged as updatable
  26213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26214. * @returns a new Mesh
  26215. */
  26216. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26217. /**
  26218. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26219. * @param name defines the name of the mesh to create
  26220. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26221. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26222. * @param scene defines the hosting scene
  26223. * @returns a new Mesh
  26224. */
  26225. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26226. /**
  26227. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26228. * @param name defines the name of the mesh to create
  26229. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26230. * @param diameterTop set the top cap diameter (floats, default 1)
  26231. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26232. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26233. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26234. * @param scene defines the hosting scene
  26235. * @param updatable defines if the mesh must be flagged as updatable
  26236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26237. * @returns a new Mesh
  26238. */
  26239. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26240. /**
  26241. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26242. * @param name defines the name of the mesh to create
  26243. * @param diameter sets the diameter size (float) of the torus (default 1)
  26244. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26245. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26246. * @param scene defines the hosting scene
  26247. * @param updatable defines if the mesh must be flagged as updatable
  26248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26249. * @returns a new Mesh
  26250. */
  26251. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26252. /**
  26253. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26254. * @param name defines the name of the mesh to create
  26255. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26256. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26257. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26258. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26259. * @param p the number of windings on X axis (positive integers, default 2)
  26260. * @param q the number of windings on Y axis (positive integers, default 3)
  26261. * @param scene defines the hosting scene
  26262. * @param updatable defines if the mesh must be flagged as updatable
  26263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26264. * @returns a new Mesh
  26265. */
  26266. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26267. /**
  26268. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26269. * @param name defines the name of the mesh to create
  26270. * @param points is an array successive Vector3
  26271. * @param scene defines the hosting scene
  26272. * @param updatable defines if the mesh must be flagged as updatable
  26273. * @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).
  26274. * @returns a new Mesh
  26275. */
  26276. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26277. /**
  26278. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26279. * @param name defines the name of the mesh to create
  26280. * @param points is an array successive Vector3
  26281. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26282. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26283. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26284. * @param scene defines the hosting scene
  26285. * @param updatable defines if the mesh must be flagged as updatable
  26286. * @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)
  26287. * @returns a new Mesh
  26288. */
  26289. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26290. /**
  26291. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26292. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26293. * 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.
  26294. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26295. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26296. * Remember you can only change the shape positions, not their number when updating a polygon.
  26297. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26298. * @param name defines the name of the mesh to create
  26299. * @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
  26300. * @param scene defines the hosting scene
  26301. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26302. * @param updatable defines if the mesh must be flagged as updatable
  26303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26304. * @param earcutInjection can be used to inject your own earcut reference
  26305. * @returns a new Mesh
  26306. */
  26307. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26308. /**
  26309. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26310. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26311. * @param name defines the name of the mesh to create
  26312. * @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
  26313. * @param depth defines the height of extrusion
  26314. * @param scene defines the hosting scene
  26315. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26316. * @param updatable defines if the mesh must be flagged as updatable
  26317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26318. * @param earcutInjection can be used to inject your own earcut reference
  26319. * @returns a new Mesh
  26320. */
  26321. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26322. /**
  26323. * Creates an extruded shape mesh.
  26324. * 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
  26325. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26326. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26327. * @param name defines the name of the mesh to create
  26328. * @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
  26329. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26330. * @param scale is the value to scale the shape
  26331. * @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
  26332. * @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
  26333. * @param scene defines the hosting scene
  26334. * @param updatable defines if the mesh must be flagged as updatable
  26335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26336. * @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)
  26337. * @returns a new Mesh
  26338. */
  26339. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26340. /**
  26341. * Creates an custom extruded shape mesh.
  26342. * The custom extrusion is a parametric shape.
  26343. * It has no predefined shape. Its final shape will depend on the input parameters.
  26344. * Please consider using the same method from the MeshBuilder class instead
  26345. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26346. * @param name defines the name of the mesh to create
  26347. * @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
  26348. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26349. * @param scaleFunction is a custom Javascript function called on each path point
  26350. * @param rotationFunction is a custom Javascript function called on each path point
  26351. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26352. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26353. * @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
  26354. * @param scene defines the hosting scene
  26355. * @param updatable defines if the mesh must be flagged as updatable
  26356. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26357. * @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)
  26358. * @returns a new Mesh
  26359. */
  26360. 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;
  26361. /**
  26362. * Creates lathe mesh.
  26363. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26364. * Please consider using the same method from the MeshBuilder class instead
  26365. * @param name defines the name of the mesh to create
  26366. * @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
  26367. * @param radius is the radius value of the lathe
  26368. * @param tessellation is the side number of the lathe.
  26369. * @param scene defines the hosting scene
  26370. * @param updatable defines if the mesh must be flagged as updatable
  26371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26372. * @returns a new Mesh
  26373. */
  26374. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26375. /**
  26376. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26377. * @param name defines the name of the mesh to create
  26378. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26379. * @param scene defines the hosting scene
  26380. * @param updatable defines if the mesh must be flagged as updatable
  26381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26382. * @returns a new Mesh
  26383. */
  26384. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26385. /**
  26386. * Creates a ground mesh.
  26387. * Please consider using the same method from the MeshBuilder class instead
  26388. * @param name defines the name of the mesh to create
  26389. * @param width set the width of the ground
  26390. * @param height set the height of the ground
  26391. * @param subdivisions sets the number of subdivisions per side
  26392. * @param scene defines the hosting scene
  26393. * @param updatable defines if the mesh must be flagged as updatable
  26394. * @returns a new Mesh
  26395. */
  26396. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26397. /**
  26398. * Creates a tiled ground mesh.
  26399. * Please consider using the same method from the MeshBuilder class instead
  26400. * @param name defines the name of the mesh to create
  26401. * @param xmin set the ground minimum X coordinate
  26402. * @param zmin set the ground minimum Y coordinate
  26403. * @param xmax set the ground maximum X coordinate
  26404. * @param zmax set the ground maximum Z coordinate
  26405. * @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
  26406. * @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
  26407. * @param scene defines the hosting scene
  26408. * @param updatable defines if the mesh must be flagged as updatable
  26409. * @returns a new Mesh
  26410. */
  26411. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26412. w: number;
  26413. h: number;
  26414. }, precision: {
  26415. w: number;
  26416. h: number;
  26417. }, scene: Scene, updatable?: boolean): Mesh;
  26418. /**
  26419. * Creates a ground mesh from a height map.
  26420. * Please consider using the same method from the MeshBuilder class instead
  26421. * @see http://doc.babylonjs.com/babylon101/height_map
  26422. * @param name defines the name of the mesh to create
  26423. * @param url sets the URL of the height map image resource
  26424. * @param width set the ground width size
  26425. * @param height set the ground height size
  26426. * @param subdivisions sets the number of subdivision per side
  26427. * @param minHeight is the minimum altitude on the ground
  26428. * @param maxHeight is the maximum altitude on the ground
  26429. * @param scene defines the hosting scene
  26430. * @param updatable defines if the mesh must be flagged as updatable
  26431. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26432. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26433. * @returns a new Mesh
  26434. */
  26435. 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;
  26436. /**
  26437. * Creates a tube mesh.
  26438. * The tube is a parametric shape.
  26439. * It has no predefined shape. Its final shape will depend on the input parameters.
  26440. * Please consider using the same method from the MeshBuilder class instead
  26441. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26442. * @param name defines the name of the mesh to create
  26443. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26444. * @param radius sets the tube radius size
  26445. * @param tessellation is the number of sides on the tubular surface
  26446. * @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
  26447. * @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
  26448. * @param scene defines the hosting scene
  26449. * @param updatable defines if the mesh must be flagged as updatable
  26450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26451. * @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)
  26452. * @returns a new Mesh
  26453. */
  26454. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26455. (i: number, distance: number): number;
  26456. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26457. /**
  26458. * Creates a polyhedron mesh.
  26459. * Please consider using the same method from the MeshBuilder class instead.
  26460. * * 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
  26461. * * The parameter `size` (positive float, default 1) sets the polygon size
  26462. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26463. * * 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`
  26464. * * 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
  26465. * * 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)`)
  26466. * * 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
  26467. * * 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
  26468. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26469. * * If you create a double-sided mesh, you can choose what parts of 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
  26470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26471. * @param name defines the name of the mesh to create
  26472. * @param options defines the options used to create the mesh
  26473. * @param scene defines the hosting scene
  26474. * @returns a new Mesh
  26475. */
  26476. static CreatePolyhedron(name: string, options: {
  26477. type?: number;
  26478. size?: number;
  26479. sizeX?: number;
  26480. sizeY?: number;
  26481. sizeZ?: number;
  26482. custom?: any;
  26483. faceUV?: Vector4[];
  26484. faceColors?: Color4[];
  26485. updatable?: boolean;
  26486. sideOrientation?: number;
  26487. }, scene: Scene): Mesh;
  26488. /**
  26489. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26490. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26491. * * 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`)
  26492. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26493. * * 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
  26494. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26495. * * If you create a double-sided mesh, you can choose what parts of 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
  26496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26497. * @param name defines the name of the mesh
  26498. * @param options defines the options used to create the mesh
  26499. * @param scene defines the hosting scene
  26500. * @returns a new Mesh
  26501. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26502. */
  26503. static CreateIcoSphere(name: string, options: {
  26504. radius?: number;
  26505. flat?: boolean;
  26506. subdivisions?: number;
  26507. sideOrientation?: number;
  26508. updatable?: boolean;
  26509. }, scene: Scene): Mesh;
  26510. /**
  26511. * Creates a decal mesh.
  26512. * Please consider using the same method from the MeshBuilder class instead.
  26513. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26514. * @param name defines the name of the mesh
  26515. * @param sourceMesh defines the mesh receiving the decal
  26516. * @param position sets the position of the decal in world coordinates
  26517. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26518. * @param size sets the decal scaling
  26519. * @param angle sets the angle to rotate the decal
  26520. * @returns a new Mesh
  26521. */
  26522. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26523. /**
  26524. * Prepare internal position array for software CPU skinning
  26525. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26526. */
  26527. setPositionsForCPUSkinning(): Float32Array;
  26528. /**
  26529. * Prepare internal normal array for software CPU skinning
  26530. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26531. */
  26532. setNormalsForCPUSkinning(): Float32Array;
  26533. /**
  26534. * Updates the vertex buffer by applying transformation from the bones
  26535. * @param skeleton defines the skeleton to apply to current mesh
  26536. * @returns the current mesh
  26537. */
  26538. applySkeleton(skeleton: Skeleton): Mesh;
  26539. /**
  26540. * 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
  26541. * @param meshes defines the list of meshes to scan
  26542. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26543. */
  26544. static MinMax(meshes: AbstractMesh[]): {
  26545. min: Vector3;
  26546. max: Vector3;
  26547. };
  26548. /**
  26549. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26550. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26551. * @returns a vector3
  26552. */
  26553. static Center(meshesOrMinMaxVector: {
  26554. min: Vector3;
  26555. max: Vector3;
  26556. } | AbstractMesh[]): Vector3;
  26557. /**
  26558. * Merge the array of meshes into a single mesh for performance reasons.
  26559. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26560. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26561. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26562. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26563. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26564. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26565. * @returns a new mesh
  26566. */
  26567. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26568. /** @hidden */
  26569. addInstance(instance: InstancedMesh): void;
  26570. /** @hidden */
  26571. removeInstance(instance: InstancedMesh): void;
  26572. }
  26573. }
  26574. declare module "babylonjs/Cameras/camera" {
  26575. import { SmartArray } from "babylonjs/Misc/smartArray";
  26576. import { Observable } from "babylonjs/Misc/observable";
  26577. import { Nullable } from "babylonjs/types";
  26578. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26579. import { Scene } from "babylonjs/scene";
  26580. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26581. import { Node } from "babylonjs/node";
  26582. import { Mesh } from "babylonjs/Meshes/mesh";
  26583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26584. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26585. import { Viewport } from "babylonjs/Maths/math.viewport";
  26586. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26588. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26589. import { Ray } from "babylonjs/Culling/ray";
  26590. /**
  26591. * This is the base class of all the camera used in the application.
  26592. * @see http://doc.babylonjs.com/features/cameras
  26593. */
  26594. export class Camera extends Node {
  26595. /** @hidden */
  26596. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26597. /**
  26598. * This is the default projection mode used by the cameras.
  26599. * It helps recreating a feeling of perspective and better appreciate depth.
  26600. * This is the best way to simulate real life cameras.
  26601. */
  26602. static readonly PERSPECTIVE_CAMERA: number;
  26603. /**
  26604. * This helps creating camera with an orthographic mode.
  26605. * 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.
  26606. */
  26607. static readonly ORTHOGRAPHIC_CAMERA: number;
  26608. /**
  26609. * This is the default FOV mode for perspective cameras.
  26610. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26611. */
  26612. static readonly FOVMODE_VERTICAL_FIXED: number;
  26613. /**
  26614. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26615. */
  26616. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26617. /**
  26618. * This specifies ther is no need for a camera rig.
  26619. * Basically only one eye is rendered corresponding to the camera.
  26620. */
  26621. static readonly RIG_MODE_NONE: number;
  26622. /**
  26623. * Simulates a camera Rig with one blue eye and one red eye.
  26624. * This can be use with 3d blue and red glasses.
  26625. */
  26626. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26627. /**
  26628. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26629. */
  26630. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26631. /**
  26632. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26633. */
  26634. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26635. /**
  26636. * Defines that both eyes of the camera will be rendered over under each other.
  26637. */
  26638. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26639. /**
  26640. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26641. */
  26642. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26643. /**
  26644. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26645. */
  26646. static readonly RIG_MODE_VR: number;
  26647. /**
  26648. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26649. */
  26650. static readonly RIG_MODE_WEBVR: number;
  26651. /**
  26652. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26653. */
  26654. static readonly RIG_MODE_CUSTOM: number;
  26655. /**
  26656. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26657. */
  26658. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26659. /**
  26660. * Define the input manager associated with the camera.
  26661. */
  26662. inputs: CameraInputsManager<Camera>;
  26663. /** @hidden */
  26664. _position: Vector3;
  26665. /**
  26666. * Define the current local position of the camera in the scene
  26667. */
  26668. get position(): Vector3;
  26669. set position(newPosition: Vector3);
  26670. /**
  26671. * The vector the camera should consider as up.
  26672. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26673. */
  26674. upVector: Vector3;
  26675. /**
  26676. * Define the current limit on the left side for an orthographic camera
  26677. * In scene unit
  26678. */
  26679. orthoLeft: Nullable<number>;
  26680. /**
  26681. * Define the current limit on the right side for an orthographic camera
  26682. * In scene unit
  26683. */
  26684. orthoRight: Nullable<number>;
  26685. /**
  26686. * Define the current limit on the bottom side for an orthographic camera
  26687. * In scene unit
  26688. */
  26689. orthoBottom: Nullable<number>;
  26690. /**
  26691. * Define the current limit on the top side for an orthographic camera
  26692. * In scene unit
  26693. */
  26694. orthoTop: Nullable<number>;
  26695. /**
  26696. * Field Of View is set in Radians. (default is 0.8)
  26697. */
  26698. fov: number;
  26699. /**
  26700. * Define the minimum distance the camera can see from.
  26701. * This is important to note that the depth buffer are not infinite and the closer it starts
  26702. * the more your scene might encounter depth fighting issue.
  26703. */
  26704. minZ: number;
  26705. /**
  26706. * Define the maximum distance the camera can see to.
  26707. * This is important to note that the depth buffer are not infinite and the further it end
  26708. * the more your scene might encounter depth fighting issue.
  26709. */
  26710. maxZ: number;
  26711. /**
  26712. * Define the default inertia of the camera.
  26713. * This helps giving a smooth feeling to the camera movement.
  26714. */
  26715. inertia: number;
  26716. /**
  26717. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26718. */
  26719. mode: number;
  26720. /**
  26721. * Define whether the camera is intermediate.
  26722. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26723. */
  26724. isIntermediate: boolean;
  26725. /**
  26726. * Define the viewport of the camera.
  26727. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26728. */
  26729. viewport: Viewport;
  26730. /**
  26731. * Restricts the camera to viewing objects with the same layerMask.
  26732. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26733. */
  26734. layerMask: number;
  26735. /**
  26736. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26737. */
  26738. fovMode: number;
  26739. /**
  26740. * Rig mode of the camera.
  26741. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26742. * This is normally controlled byt the camera themselves as internal use.
  26743. */
  26744. cameraRigMode: number;
  26745. /**
  26746. * Defines the distance between both "eyes" in case of a RIG
  26747. */
  26748. interaxialDistance: number;
  26749. /**
  26750. * Defines if stereoscopic rendering is done side by side or over under.
  26751. */
  26752. isStereoscopicSideBySide: boolean;
  26753. /**
  26754. * 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
  26755. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26756. * else in the scene. (Eg. security camera)
  26757. *
  26758. * 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)
  26759. */
  26760. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26761. /**
  26762. * When set, the camera will render to this render target instead of the default canvas
  26763. *
  26764. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26765. */
  26766. outputRenderTarget: Nullable<RenderTargetTexture>;
  26767. /**
  26768. * Observable triggered when the camera view matrix has changed.
  26769. */
  26770. onViewMatrixChangedObservable: Observable<Camera>;
  26771. /**
  26772. * Observable triggered when the camera Projection matrix has changed.
  26773. */
  26774. onProjectionMatrixChangedObservable: Observable<Camera>;
  26775. /**
  26776. * Observable triggered when the inputs have been processed.
  26777. */
  26778. onAfterCheckInputsObservable: Observable<Camera>;
  26779. /**
  26780. * Observable triggered when reset has been called and applied to the camera.
  26781. */
  26782. onRestoreStateObservable: Observable<Camera>;
  26783. /**
  26784. * Is this camera a part of a rig system?
  26785. */
  26786. isRigCamera: boolean;
  26787. /**
  26788. * If isRigCamera set to true this will be set with the parent camera.
  26789. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26790. */
  26791. rigParent?: Camera;
  26792. /** @hidden */
  26793. _cameraRigParams: any;
  26794. /** @hidden */
  26795. _rigCameras: Camera[];
  26796. /** @hidden */
  26797. _rigPostProcess: Nullable<PostProcess>;
  26798. protected _webvrViewMatrix: Matrix;
  26799. /** @hidden */
  26800. _skipRendering: boolean;
  26801. /** @hidden */
  26802. _projectionMatrix: Matrix;
  26803. /** @hidden */
  26804. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26805. /** @hidden */
  26806. _activeMeshes: SmartArray<AbstractMesh>;
  26807. protected _globalPosition: Vector3;
  26808. /** @hidden */
  26809. _computedViewMatrix: Matrix;
  26810. private _doNotComputeProjectionMatrix;
  26811. private _transformMatrix;
  26812. private _frustumPlanes;
  26813. private _refreshFrustumPlanes;
  26814. private _storedFov;
  26815. private _stateStored;
  26816. /**
  26817. * Instantiates a new camera object.
  26818. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26819. * @see http://doc.babylonjs.com/features/cameras
  26820. * @param name Defines the name of the camera in the scene
  26821. * @param position Defines the position of the camera
  26822. * @param scene Defines the scene the camera belongs too
  26823. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26824. */
  26825. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26826. /**
  26827. * Store current camera state (fov, position, etc..)
  26828. * @returns the camera
  26829. */
  26830. storeState(): Camera;
  26831. /**
  26832. * Restores the camera state values if it has been stored. You must call storeState() first
  26833. */
  26834. protected _restoreStateValues(): boolean;
  26835. /**
  26836. * Restored camera state. You must call storeState() first.
  26837. * @returns true if restored and false otherwise
  26838. */
  26839. restoreState(): boolean;
  26840. /**
  26841. * Gets the class name of the camera.
  26842. * @returns the class name
  26843. */
  26844. getClassName(): string;
  26845. /** @hidden */
  26846. readonly _isCamera: boolean;
  26847. /**
  26848. * Gets a string representation of the camera useful for debug purpose.
  26849. * @param fullDetails Defines that a more verboe level of logging is required
  26850. * @returns the string representation
  26851. */
  26852. toString(fullDetails?: boolean): string;
  26853. /**
  26854. * Gets the current world space position of the camera.
  26855. */
  26856. get globalPosition(): Vector3;
  26857. /**
  26858. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26859. * @returns the active meshe list
  26860. */
  26861. getActiveMeshes(): SmartArray<AbstractMesh>;
  26862. /**
  26863. * Check whether a mesh is part of the current active mesh list of the camera
  26864. * @param mesh Defines the mesh to check
  26865. * @returns true if active, false otherwise
  26866. */
  26867. isActiveMesh(mesh: Mesh): boolean;
  26868. /**
  26869. * Is this camera ready to be used/rendered
  26870. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26871. * @return true if the camera is ready
  26872. */
  26873. isReady(completeCheck?: boolean): boolean;
  26874. /** @hidden */
  26875. _initCache(): void;
  26876. /** @hidden */
  26877. _updateCache(ignoreParentClass?: boolean): void;
  26878. /** @hidden */
  26879. _isSynchronized(): boolean;
  26880. /** @hidden */
  26881. _isSynchronizedViewMatrix(): boolean;
  26882. /** @hidden */
  26883. _isSynchronizedProjectionMatrix(): boolean;
  26884. /**
  26885. * Attach the input controls to a specific dom element to get the input from.
  26886. * @param element Defines the element the controls should be listened from
  26887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26888. */
  26889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26890. /**
  26891. * Detach the current controls from the specified dom element.
  26892. * @param element Defines the element to stop listening the inputs from
  26893. */
  26894. detachControl(element: HTMLElement): void;
  26895. /**
  26896. * Update the camera state according to the different inputs gathered during the frame.
  26897. */
  26898. update(): void;
  26899. /** @hidden */
  26900. _checkInputs(): void;
  26901. /** @hidden */
  26902. get rigCameras(): Camera[];
  26903. /**
  26904. * Gets the post process used by the rig cameras
  26905. */
  26906. get rigPostProcess(): Nullable<PostProcess>;
  26907. /**
  26908. * Internal, gets the first post proces.
  26909. * @returns the first post process to be run on this camera.
  26910. */
  26911. _getFirstPostProcess(): Nullable<PostProcess>;
  26912. private _cascadePostProcessesToRigCams;
  26913. /**
  26914. * Attach a post process to the camera.
  26915. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26916. * @param postProcess The post process to attach to the camera
  26917. * @param insertAt The position of the post process in case several of them are in use in the scene
  26918. * @returns the position the post process has been inserted at
  26919. */
  26920. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26921. /**
  26922. * Detach a post process to the camera.
  26923. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26924. * @param postProcess The post process to detach from the camera
  26925. */
  26926. detachPostProcess(postProcess: PostProcess): void;
  26927. /**
  26928. * Gets the current world matrix of the camera
  26929. */
  26930. getWorldMatrix(): Matrix;
  26931. /** @hidden */
  26932. _getViewMatrix(): Matrix;
  26933. /**
  26934. * Gets the current view matrix of the camera.
  26935. * @param force forces the camera to recompute the matrix without looking at the cached state
  26936. * @returns the view matrix
  26937. */
  26938. getViewMatrix(force?: boolean): Matrix;
  26939. /**
  26940. * Freeze the projection matrix.
  26941. * It will prevent the cache check of the camera projection compute and can speed up perf
  26942. * if no parameter of the camera are meant to change
  26943. * @param projection Defines manually a projection if necessary
  26944. */
  26945. freezeProjectionMatrix(projection?: Matrix): void;
  26946. /**
  26947. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26948. */
  26949. unfreezeProjectionMatrix(): void;
  26950. /**
  26951. * Gets the current projection matrix of the camera.
  26952. * @param force forces the camera to recompute the matrix without looking at the cached state
  26953. * @returns the projection matrix
  26954. */
  26955. getProjectionMatrix(force?: boolean): Matrix;
  26956. /**
  26957. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26958. * @returns a Matrix
  26959. */
  26960. getTransformationMatrix(): Matrix;
  26961. private _updateFrustumPlanes;
  26962. /**
  26963. * Checks if a cullable object (mesh...) is in the camera frustum
  26964. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26965. * @param target The object to check
  26966. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26967. * @returns true if the object is in frustum otherwise false
  26968. */
  26969. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26970. /**
  26971. * Checks if a cullable object (mesh...) is in the camera frustum
  26972. * Unlike isInFrustum this cheks the full bounding box
  26973. * @param target The object to check
  26974. * @returns true if the object is in frustum otherwise false
  26975. */
  26976. isCompletelyInFrustum(target: ICullable): boolean;
  26977. /**
  26978. * Gets a ray in the forward direction from the camera.
  26979. * @param length Defines the length of the ray to create
  26980. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26981. * @param origin Defines the start point of the ray which defaults to the camera position
  26982. * @returns the forward ray
  26983. */
  26984. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26985. /**
  26986. * Releases resources associated with this node.
  26987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26989. */
  26990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26991. /** @hidden */
  26992. _isLeftCamera: boolean;
  26993. /**
  26994. * Gets the left camera of a rig setup in case of Rigged Camera
  26995. */
  26996. get isLeftCamera(): boolean;
  26997. /** @hidden */
  26998. _isRightCamera: boolean;
  26999. /**
  27000. * Gets the right camera of a rig setup in case of Rigged Camera
  27001. */
  27002. get isRightCamera(): boolean;
  27003. /**
  27004. * Gets the left camera of a rig setup in case of Rigged Camera
  27005. */
  27006. get leftCamera(): Nullable<FreeCamera>;
  27007. /**
  27008. * Gets the right camera of a rig setup in case of Rigged Camera
  27009. */
  27010. get rightCamera(): Nullable<FreeCamera>;
  27011. /**
  27012. * Gets the left camera target of a rig setup in case of Rigged Camera
  27013. * @returns the target position
  27014. */
  27015. getLeftTarget(): Nullable<Vector3>;
  27016. /**
  27017. * Gets the right camera target of a rig setup in case of Rigged Camera
  27018. * @returns the target position
  27019. */
  27020. getRightTarget(): Nullable<Vector3>;
  27021. /**
  27022. * @hidden
  27023. */
  27024. setCameraRigMode(mode: number, rigParams: any): void;
  27025. /** @hidden */
  27026. static _setStereoscopicRigMode(camera: Camera): void;
  27027. /** @hidden */
  27028. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27029. /** @hidden */
  27030. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27031. /** @hidden */
  27032. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27033. /** @hidden */
  27034. _getVRProjectionMatrix(): Matrix;
  27035. protected _updateCameraRotationMatrix(): void;
  27036. protected _updateWebVRCameraRotationMatrix(): void;
  27037. /**
  27038. * This function MUST be overwritten by the different WebVR cameras available.
  27039. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27040. * @hidden
  27041. */
  27042. _getWebVRProjectionMatrix(): Matrix;
  27043. /**
  27044. * This function MUST be overwritten by the different WebVR cameras available.
  27045. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27046. * @hidden
  27047. */
  27048. _getWebVRViewMatrix(): Matrix;
  27049. /** @hidden */
  27050. setCameraRigParameter(name: string, value: any): void;
  27051. /**
  27052. * needs to be overridden by children so sub has required properties to be copied
  27053. * @hidden
  27054. */
  27055. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27056. /**
  27057. * May need to be overridden by children
  27058. * @hidden
  27059. */
  27060. _updateRigCameras(): void;
  27061. /** @hidden */
  27062. _setupInputs(): void;
  27063. /**
  27064. * Serialiaze the camera setup to a json represention
  27065. * @returns the JSON representation
  27066. */
  27067. serialize(): any;
  27068. /**
  27069. * Clones the current camera.
  27070. * @param name The cloned camera name
  27071. * @returns the cloned camera
  27072. */
  27073. clone(name: string): Camera;
  27074. /**
  27075. * Gets the direction of the camera relative to a given local axis.
  27076. * @param localAxis Defines the reference axis to provide a relative direction.
  27077. * @return the direction
  27078. */
  27079. getDirection(localAxis: Vector3): Vector3;
  27080. /**
  27081. * Returns the current camera absolute rotation
  27082. */
  27083. get absoluteRotation(): Quaternion;
  27084. /**
  27085. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27086. * @param localAxis Defines the reference axis to provide a relative direction.
  27087. * @param result Defines the vector to store the result in
  27088. */
  27089. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27090. /**
  27091. * Gets a camera constructor for a given camera type
  27092. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27093. * @param name The name of the camera the result will be able to instantiate
  27094. * @param scene The scene the result will construct the camera in
  27095. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27096. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27097. * @returns a factory method to construc the camera
  27098. */
  27099. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27100. /**
  27101. * Compute the world matrix of the camera.
  27102. * @returns the camera world matrix
  27103. */
  27104. computeWorldMatrix(): Matrix;
  27105. /**
  27106. * Parse a JSON and creates the camera from the parsed information
  27107. * @param parsedCamera The JSON to parse
  27108. * @param scene The scene to instantiate the camera in
  27109. * @returns the newly constructed camera
  27110. */
  27111. static Parse(parsedCamera: any, scene: Scene): Camera;
  27112. }
  27113. }
  27114. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27115. import { Nullable } from "babylonjs/types";
  27116. import { Scene } from "babylonjs/scene";
  27117. import { Vector4 } from "babylonjs/Maths/math.vector";
  27118. import { Mesh } from "babylonjs/Meshes/mesh";
  27119. /**
  27120. * Class containing static functions to help procedurally build meshes
  27121. */
  27122. export class DiscBuilder {
  27123. /**
  27124. * Creates a plane polygonal mesh. By default, this is a disc
  27125. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27126. * * 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
  27127. * * 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
  27128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27131. * @param name defines the name of the mesh
  27132. * @param options defines the options used to create the mesh
  27133. * @param scene defines the hosting scene
  27134. * @returns the plane polygonal mesh
  27135. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27136. */
  27137. static CreateDisc(name: string, options: {
  27138. radius?: number;
  27139. tessellation?: number;
  27140. arc?: number;
  27141. updatable?: boolean;
  27142. sideOrientation?: number;
  27143. frontUVs?: Vector4;
  27144. backUVs?: Vector4;
  27145. }, scene?: Nullable<Scene>): Mesh;
  27146. }
  27147. }
  27148. declare module "babylonjs/Materials/fresnelParameters" {
  27149. import { DeepImmutable } from "babylonjs/types";
  27150. import { Color3 } from "babylonjs/Maths/math.color";
  27151. /**
  27152. * Options to be used when creating a FresnelParameters.
  27153. */
  27154. export type IFresnelParametersCreationOptions = {
  27155. /**
  27156. * Define the color used on edges (grazing angle)
  27157. */
  27158. leftColor?: Color3;
  27159. /**
  27160. * Define the color used on center
  27161. */
  27162. rightColor?: Color3;
  27163. /**
  27164. * Define bias applied to computed fresnel term
  27165. */
  27166. bias?: number;
  27167. /**
  27168. * Defined the power exponent applied to fresnel term
  27169. */
  27170. power?: number;
  27171. /**
  27172. * Define if the fresnel effect is enable or not.
  27173. */
  27174. isEnabled?: boolean;
  27175. };
  27176. /**
  27177. * Serialized format for FresnelParameters.
  27178. */
  27179. export type IFresnelParametersSerialized = {
  27180. /**
  27181. * Define the color used on edges (grazing angle) [as an array]
  27182. */
  27183. leftColor: number[];
  27184. /**
  27185. * Define the color used on center [as an array]
  27186. */
  27187. rightColor: number[];
  27188. /**
  27189. * Define bias applied to computed fresnel term
  27190. */
  27191. bias: number;
  27192. /**
  27193. * Defined the power exponent applied to fresnel term
  27194. */
  27195. power?: number;
  27196. /**
  27197. * Define if the fresnel effect is enable or not.
  27198. */
  27199. isEnabled: boolean;
  27200. };
  27201. /**
  27202. * This represents all the required information to add a fresnel effect on a material:
  27203. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27204. */
  27205. export class FresnelParameters {
  27206. private _isEnabled;
  27207. /**
  27208. * Define if the fresnel effect is enable or not.
  27209. */
  27210. get isEnabled(): boolean;
  27211. set isEnabled(value: boolean);
  27212. /**
  27213. * Define the color used on edges (grazing angle)
  27214. */
  27215. leftColor: Color3;
  27216. /**
  27217. * Define the color used on center
  27218. */
  27219. rightColor: Color3;
  27220. /**
  27221. * Define bias applied to computed fresnel term
  27222. */
  27223. bias: number;
  27224. /**
  27225. * Defined the power exponent applied to fresnel term
  27226. */
  27227. power: number;
  27228. /**
  27229. * Creates a new FresnelParameters object.
  27230. *
  27231. * @param options provide your own settings to optionally to override defaults
  27232. */
  27233. constructor(options?: IFresnelParametersCreationOptions);
  27234. /**
  27235. * Clones the current fresnel and its valuues
  27236. * @returns a clone fresnel configuration
  27237. */
  27238. clone(): FresnelParameters;
  27239. /**
  27240. * Determines equality between FresnelParameters objects
  27241. * @param otherFresnelParameters defines the second operand
  27242. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27243. */
  27244. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27245. /**
  27246. * Serializes the current fresnel parameters to a JSON representation.
  27247. * @return the JSON serialization
  27248. */
  27249. serialize(): IFresnelParametersSerialized;
  27250. /**
  27251. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27252. * @param parsedFresnelParameters Define the JSON representation
  27253. * @returns the parsed parameters
  27254. */
  27255. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27256. }
  27257. }
  27258. declare module "babylonjs/Materials/pushMaterial" {
  27259. import { Nullable } from "babylonjs/types";
  27260. import { Scene } from "babylonjs/scene";
  27261. import { Matrix } from "babylonjs/Maths/math.vector";
  27262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27263. import { Mesh } from "babylonjs/Meshes/mesh";
  27264. import { Material } from "babylonjs/Materials/material";
  27265. import { Effect } from "babylonjs/Materials/effect";
  27266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27267. /**
  27268. * Base class of materials working in push mode in babylon JS
  27269. * @hidden
  27270. */
  27271. export class PushMaterial extends Material {
  27272. protected _activeEffect: Effect;
  27273. protected _normalMatrix: Matrix;
  27274. /**
  27275. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27276. * This means that the material can keep using a previous shader while a new one is being compiled.
  27277. * This is mostly used when shader parallel compilation is supported (true by default)
  27278. */
  27279. allowShaderHotSwapping: boolean;
  27280. constructor(name: string, scene: Scene);
  27281. getEffect(): Effect;
  27282. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27283. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27284. /**
  27285. * Binds the given world matrix to the active effect
  27286. *
  27287. * @param world the matrix to bind
  27288. */
  27289. bindOnlyWorldMatrix(world: Matrix): void;
  27290. /**
  27291. * Binds the given normal matrix to the active effect
  27292. *
  27293. * @param normalMatrix the matrix to bind
  27294. */
  27295. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27296. bind(world: Matrix, mesh?: Mesh): void;
  27297. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27298. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27299. }
  27300. }
  27301. declare module "babylonjs/Materials/materialFlags" {
  27302. /**
  27303. * This groups all the flags used to control the materials channel.
  27304. */
  27305. export class MaterialFlags {
  27306. private static _DiffuseTextureEnabled;
  27307. /**
  27308. * Are diffuse textures enabled in the application.
  27309. */
  27310. static get DiffuseTextureEnabled(): boolean;
  27311. static set DiffuseTextureEnabled(value: boolean);
  27312. private static _AmbientTextureEnabled;
  27313. /**
  27314. * Are ambient textures enabled in the application.
  27315. */
  27316. static get AmbientTextureEnabled(): boolean;
  27317. static set AmbientTextureEnabled(value: boolean);
  27318. private static _OpacityTextureEnabled;
  27319. /**
  27320. * Are opacity textures enabled in the application.
  27321. */
  27322. static get OpacityTextureEnabled(): boolean;
  27323. static set OpacityTextureEnabled(value: boolean);
  27324. private static _ReflectionTextureEnabled;
  27325. /**
  27326. * Are reflection textures enabled in the application.
  27327. */
  27328. static get ReflectionTextureEnabled(): boolean;
  27329. static set ReflectionTextureEnabled(value: boolean);
  27330. private static _EmissiveTextureEnabled;
  27331. /**
  27332. * Are emissive textures enabled in the application.
  27333. */
  27334. static get EmissiveTextureEnabled(): boolean;
  27335. static set EmissiveTextureEnabled(value: boolean);
  27336. private static _SpecularTextureEnabled;
  27337. /**
  27338. * Are specular textures enabled in the application.
  27339. */
  27340. static get SpecularTextureEnabled(): boolean;
  27341. static set SpecularTextureEnabled(value: boolean);
  27342. private static _BumpTextureEnabled;
  27343. /**
  27344. * Are bump textures enabled in the application.
  27345. */
  27346. static get BumpTextureEnabled(): boolean;
  27347. static set BumpTextureEnabled(value: boolean);
  27348. private static _LightmapTextureEnabled;
  27349. /**
  27350. * Are lightmap textures enabled in the application.
  27351. */
  27352. static get LightmapTextureEnabled(): boolean;
  27353. static set LightmapTextureEnabled(value: boolean);
  27354. private static _RefractionTextureEnabled;
  27355. /**
  27356. * Are refraction textures enabled in the application.
  27357. */
  27358. static get RefractionTextureEnabled(): boolean;
  27359. static set RefractionTextureEnabled(value: boolean);
  27360. private static _ColorGradingTextureEnabled;
  27361. /**
  27362. * Are color grading textures enabled in the application.
  27363. */
  27364. static get ColorGradingTextureEnabled(): boolean;
  27365. static set ColorGradingTextureEnabled(value: boolean);
  27366. private static _FresnelEnabled;
  27367. /**
  27368. * Are fresnels enabled in the application.
  27369. */
  27370. static get FresnelEnabled(): boolean;
  27371. static set FresnelEnabled(value: boolean);
  27372. private static _ClearCoatTextureEnabled;
  27373. /**
  27374. * Are clear coat textures enabled in the application.
  27375. */
  27376. static get ClearCoatTextureEnabled(): boolean;
  27377. static set ClearCoatTextureEnabled(value: boolean);
  27378. private static _ClearCoatBumpTextureEnabled;
  27379. /**
  27380. * Are clear coat bump textures enabled in the application.
  27381. */
  27382. static get ClearCoatBumpTextureEnabled(): boolean;
  27383. static set ClearCoatBumpTextureEnabled(value: boolean);
  27384. private static _ClearCoatTintTextureEnabled;
  27385. /**
  27386. * Are clear coat tint textures enabled in the application.
  27387. */
  27388. static get ClearCoatTintTextureEnabled(): boolean;
  27389. static set ClearCoatTintTextureEnabled(value: boolean);
  27390. private static _SheenTextureEnabled;
  27391. /**
  27392. * Are sheen textures enabled in the application.
  27393. */
  27394. static get SheenTextureEnabled(): boolean;
  27395. static set SheenTextureEnabled(value: boolean);
  27396. private static _AnisotropicTextureEnabled;
  27397. /**
  27398. * Are anisotropic textures enabled in the application.
  27399. */
  27400. static get AnisotropicTextureEnabled(): boolean;
  27401. static set AnisotropicTextureEnabled(value: boolean);
  27402. private static _ThicknessTextureEnabled;
  27403. /**
  27404. * Are thickness textures enabled in the application.
  27405. */
  27406. static get ThicknessTextureEnabled(): boolean;
  27407. static set ThicknessTextureEnabled(value: boolean);
  27408. }
  27409. }
  27410. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27411. /** @hidden */
  27412. export var defaultFragmentDeclaration: {
  27413. name: string;
  27414. shader: string;
  27415. };
  27416. }
  27417. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27418. /** @hidden */
  27419. export var defaultUboDeclaration: {
  27420. name: string;
  27421. shader: string;
  27422. };
  27423. }
  27424. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27425. /** @hidden */
  27426. export var lightFragmentDeclaration: {
  27427. name: string;
  27428. shader: string;
  27429. };
  27430. }
  27431. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27432. /** @hidden */
  27433. export var lightUboDeclaration: {
  27434. name: string;
  27435. shader: string;
  27436. };
  27437. }
  27438. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27439. /** @hidden */
  27440. export var lightsFragmentFunctions: {
  27441. name: string;
  27442. shader: string;
  27443. };
  27444. }
  27445. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27446. /** @hidden */
  27447. export var shadowsFragmentFunctions: {
  27448. name: string;
  27449. shader: string;
  27450. };
  27451. }
  27452. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27453. /** @hidden */
  27454. export var fresnelFunction: {
  27455. name: string;
  27456. shader: string;
  27457. };
  27458. }
  27459. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27460. /** @hidden */
  27461. export var reflectionFunction: {
  27462. name: string;
  27463. shader: string;
  27464. };
  27465. }
  27466. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27467. /** @hidden */
  27468. export var bumpFragmentMainFunctions: {
  27469. name: string;
  27470. shader: string;
  27471. };
  27472. }
  27473. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27474. /** @hidden */
  27475. export var bumpFragmentFunctions: {
  27476. name: string;
  27477. shader: string;
  27478. };
  27479. }
  27480. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27481. /** @hidden */
  27482. export var logDepthDeclaration: {
  27483. name: string;
  27484. shader: string;
  27485. };
  27486. }
  27487. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27488. /** @hidden */
  27489. export var bumpFragment: {
  27490. name: string;
  27491. shader: string;
  27492. };
  27493. }
  27494. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27495. /** @hidden */
  27496. export var depthPrePass: {
  27497. name: string;
  27498. shader: string;
  27499. };
  27500. }
  27501. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27502. /** @hidden */
  27503. export var lightFragment: {
  27504. name: string;
  27505. shader: string;
  27506. };
  27507. }
  27508. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27509. /** @hidden */
  27510. export var logDepthFragment: {
  27511. name: string;
  27512. shader: string;
  27513. };
  27514. }
  27515. declare module "babylonjs/Shaders/default.fragment" {
  27516. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27517. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27519. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27520. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27521. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27522. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27523. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27524. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27525. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27526. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27527. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27528. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27529. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27530. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27531. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27532. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27533. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27534. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27535. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27536. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27537. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27538. /** @hidden */
  27539. export var defaultPixelShader: {
  27540. name: string;
  27541. shader: string;
  27542. };
  27543. }
  27544. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27545. /** @hidden */
  27546. export var defaultVertexDeclaration: {
  27547. name: string;
  27548. shader: string;
  27549. };
  27550. }
  27551. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27552. /** @hidden */
  27553. export var bumpVertexDeclaration: {
  27554. name: string;
  27555. shader: string;
  27556. };
  27557. }
  27558. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27559. /** @hidden */
  27560. export var bumpVertex: {
  27561. name: string;
  27562. shader: string;
  27563. };
  27564. }
  27565. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27566. /** @hidden */
  27567. export var fogVertex: {
  27568. name: string;
  27569. shader: string;
  27570. };
  27571. }
  27572. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27573. /** @hidden */
  27574. export var shadowsVertex: {
  27575. name: string;
  27576. shader: string;
  27577. };
  27578. }
  27579. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27580. /** @hidden */
  27581. export var pointCloudVertex: {
  27582. name: string;
  27583. shader: string;
  27584. };
  27585. }
  27586. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27587. /** @hidden */
  27588. export var logDepthVertex: {
  27589. name: string;
  27590. shader: string;
  27591. };
  27592. }
  27593. declare module "babylonjs/Shaders/default.vertex" {
  27594. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27595. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27597. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27598. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27599. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27601. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27602. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27603. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27604. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27606. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27608. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27609. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27610. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27611. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27612. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27613. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27614. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27615. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27616. /** @hidden */
  27617. export var defaultVertexShader: {
  27618. name: string;
  27619. shader: string;
  27620. };
  27621. }
  27622. declare module "babylonjs/Materials/standardMaterial" {
  27623. import { SmartArray } from "babylonjs/Misc/smartArray";
  27624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27625. import { Nullable } from "babylonjs/types";
  27626. import { Scene } from "babylonjs/scene";
  27627. import { Matrix } from "babylonjs/Maths/math.vector";
  27628. import { Color3 } from "babylonjs/Maths/math.color";
  27629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27631. import { Mesh } from "babylonjs/Meshes/mesh";
  27632. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27633. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27634. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27635. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27636. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27638. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27639. import "babylonjs/Shaders/default.fragment";
  27640. import "babylonjs/Shaders/default.vertex";
  27641. /** @hidden */
  27642. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27643. MAINUV1: boolean;
  27644. MAINUV2: boolean;
  27645. DIFFUSE: boolean;
  27646. DIFFUSEDIRECTUV: number;
  27647. AMBIENT: boolean;
  27648. AMBIENTDIRECTUV: number;
  27649. OPACITY: boolean;
  27650. OPACITYDIRECTUV: number;
  27651. OPACITYRGB: boolean;
  27652. REFLECTION: boolean;
  27653. EMISSIVE: boolean;
  27654. EMISSIVEDIRECTUV: number;
  27655. SPECULAR: boolean;
  27656. SPECULARDIRECTUV: number;
  27657. BUMP: boolean;
  27658. BUMPDIRECTUV: number;
  27659. PARALLAX: boolean;
  27660. PARALLAXOCCLUSION: boolean;
  27661. SPECULAROVERALPHA: boolean;
  27662. CLIPPLANE: boolean;
  27663. CLIPPLANE2: boolean;
  27664. CLIPPLANE3: boolean;
  27665. CLIPPLANE4: boolean;
  27666. CLIPPLANE5: boolean;
  27667. CLIPPLANE6: boolean;
  27668. ALPHATEST: boolean;
  27669. DEPTHPREPASS: boolean;
  27670. ALPHAFROMDIFFUSE: boolean;
  27671. POINTSIZE: boolean;
  27672. FOG: boolean;
  27673. SPECULARTERM: boolean;
  27674. DIFFUSEFRESNEL: boolean;
  27675. OPACITYFRESNEL: boolean;
  27676. REFLECTIONFRESNEL: boolean;
  27677. REFRACTIONFRESNEL: boolean;
  27678. EMISSIVEFRESNEL: boolean;
  27679. FRESNEL: boolean;
  27680. NORMAL: boolean;
  27681. UV1: boolean;
  27682. UV2: boolean;
  27683. VERTEXCOLOR: boolean;
  27684. VERTEXALPHA: boolean;
  27685. NUM_BONE_INFLUENCERS: number;
  27686. BonesPerMesh: number;
  27687. BONETEXTURE: boolean;
  27688. INSTANCES: boolean;
  27689. GLOSSINESS: boolean;
  27690. ROUGHNESS: boolean;
  27691. EMISSIVEASILLUMINATION: boolean;
  27692. LINKEMISSIVEWITHDIFFUSE: boolean;
  27693. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27694. LIGHTMAP: boolean;
  27695. LIGHTMAPDIRECTUV: number;
  27696. OBJECTSPACE_NORMALMAP: boolean;
  27697. USELIGHTMAPASSHADOWMAP: boolean;
  27698. REFLECTIONMAP_3D: boolean;
  27699. REFLECTIONMAP_SPHERICAL: boolean;
  27700. REFLECTIONMAP_PLANAR: boolean;
  27701. REFLECTIONMAP_CUBIC: boolean;
  27702. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27703. REFLECTIONMAP_PROJECTION: boolean;
  27704. REFLECTIONMAP_SKYBOX: boolean;
  27705. REFLECTIONMAP_EXPLICIT: boolean;
  27706. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27707. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27708. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27709. INVERTCUBICMAP: boolean;
  27710. LOGARITHMICDEPTH: boolean;
  27711. REFRACTION: boolean;
  27712. REFRACTIONMAP_3D: boolean;
  27713. REFLECTIONOVERALPHA: boolean;
  27714. TWOSIDEDLIGHTING: boolean;
  27715. SHADOWFLOAT: boolean;
  27716. MORPHTARGETS: boolean;
  27717. MORPHTARGETS_NORMAL: boolean;
  27718. MORPHTARGETS_TANGENT: boolean;
  27719. MORPHTARGETS_UV: boolean;
  27720. NUM_MORPH_INFLUENCERS: number;
  27721. NONUNIFORMSCALING: boolean;
  27722. PREMULTIPLYALPHA: boolean;
  27723. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27724. ALPHABLEND: boolean;
  27725. IMAGEPROCESSING: boolean;
  27726. VIGNETTE: boolean;
  27727. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27728. VIGNETTEBLENDMODEOPAQUE: boolean;
  27729. TONEMAPPING: boolean;
  27730. TONEMAPPING_ACES: boolean;
  27731. CONTRAST: boolean;
  27732. COLORCURVES: boolean;
  27733. COLORGRADING: boolean;
  27734. COLORGRADING3D: boolean;
  27735. SAMPLER3DGREENDEPTH: boolean;
  27736. SAMPLER3DBGRMAP: boolean;
  27737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27738. MULTIVIEW: boolean;
  27739. /**
  27740. * If the reflection texture on this material is in linear color space
  27741. * @hidden
  27742. */
  27743. IS_REFLECTION_LINEAR: boolean;
  27744. /**
  27745. * If the refraction texture on this material is in linear color space
  27746. * @hidden
  27747. */
  27748. IS_REFRACTION_LINEAR: boolean;
  27749. EXPOSURE: boolean;
  27750. constructor();
  27751. setReflectionMode(modeToEnable: string): void;
  27752. }
  27753. /**
  27754. * This is the default material used in Babylon. It is the best trade off between quality
  27755. * and performances.
  27756. * @see http://doc.babylonjs.com/babylon101/materials
  27757. */
  27758. export class StandardMaterial extends PushMaterial {
  27759. private _diffuseTexture;
  27760. /**
  27761. * The basic texture of the material as viewed under a light.
  27762. */
  27763. diffuseTexture: Nullable<BaseTexture>;
  27764. private _ambientTexture;
  27765. /**
  27766. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27767. */
  27768. ambientTexture: Nullable<BaseTexture>;
  27769. private _opacityTexture;
  27770. /**
  27771. * Define the transparency of the material from a texture.
  27772. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27773. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27774. */
  27775. opacityTexture: Nullable<BaseTexture>;
  27776. private _reflectionTexture;
  27777. /**
  27778. * Define the texture used to display the reflection.
  27779. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27780. */
  27781. reflectionTexture: Nullable<BaseTexture>;
  27782. private _emissiveTexture;
  27783. /**
  27784. * Define texture of the material as if self lit.
  27785. * This will be mixed in the final result even in the absence of light.
  27786. */
  27787. emissiveTexture: Nullable<BaseTexture>;
  27788. private _specularTexture;
  27789. /**
  27790. * Define how the color and intensity of the highlight given by the light in the material.
  27791. */
  27792. specularTexture: Nullable<BaseTexture>;
  27793. private _bumpTexture;
  27794. /**
  27795. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27796. * 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.
  27797. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27798. */
  27799. bumpTexture: Nullable<BaseTexture>;
  27800. private _lightmapTexture;
  27801. /**
  27802. * Complex lighting can be computationally expensive to compute at runtime.
  27803. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27804. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27805. */
  27806. lightmapTexture: Nullable<BaseTexture>;
  27807. private _refractionTexture;
  27808. /**
  27809. * Define the texture used to display the refraction.
  27810. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27811. */
  27812. refractionTexture: Nullable<BaseTexture>;
  27813. /**
  27814. * The color of the material lit by the environmental background lighting.
  27815. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27816. */
  27817. ambientColor: Color3;
  27818. /**
  27819. * The basic color of the material as viewed under a light.
  27820. */
  27821. diffuseColor: Color3;
  27822. /**
  27823. * Define how the color and intensity of the highlight given by the light in the material.
  27824. */
  27825. specularColor: Color3;
  27826. /**
  27827. * Define the color of the material as if self lit.
  27828. * This will be mixed in the final result even in the absence of light.
  27829. */
  27830. emissiveColor: Color3;
  27831. /**
  27832. * Defines how sharp are the highlights in the material.
  27833. * The bigger the value the sharper giving a more glossy feeling to the result.
  27834. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27835. */
  27836. specularPower: number;
  27837. private _useAlphaFromDiffuseTexture;
  27838. /**
  27839. * Does the transparency come from the diffuse texture alpha channel.
  27840. */
  27841. useAlphaFromDiffuseTexture: boolean;
  27842. private _useEmissiveAsIllumination;
  27843. /**
  27844. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27845. */
  27846. useEmissiveAsIllumination: boolean;
  27847. private _linkEmissiveWithDiffuse;
  27848. /**
  27849. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27850. * the emissive level when the final color is close to one.
  27851. */
  27852. linkEmissiveWithDiffuse: boolean;
  27853. private _useSpecularOverAlpha;
  27854. /**
  27855. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27856. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27857. */
  27858. useSpecularOverAlpha: boolean;
  27859. private _useReflectionOverAlpha;
  27860. /**
  27861. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27862. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27863. */
  27864. useReflectionOverAlpha: boolean;
  27865. private _disableLighting;
  27866. /**
  27867. * Does lights from the scene impacts this material.
  27868. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27869. */
  27870. disableLighting: boolean;
  27871. private _useObjectSpaceNormalMap;
  27872. /**
  27873. * Allows using an object space normal map (instead of tangent space).
  27874. */
  27875. useObjectSpaceNormalMap: boolean;
  27876. private _useParallax;
  27877. /**
  27878. * Is parallax enabled or not.
  27879. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27880. */
  27881. useParallax: boolean;
  27882. private _useParallaxOcclusion;
  27883. /**
  27884. * Is parallax occlusion enabled or not.
  27885. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27886. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27887. */
  27888. useParallaxOcclusion: boolean;
  27889. /**
  27890. * 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.
  27891. */
  27892. parallaxScaleBias: number;
  27893. private _roughness;
  27894. /**
  27895. * Helps to define how blurry the reflections should appears in the material.
  27896. */
  27897. roughness: number;
  27898. /**
  27899. * In case of refraction, define the value of the index of refraction.
  27900. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27901. */
  27902. indexOfRefraction: number;
  27903. /**
  27904. * Invert the refraction texture alongside the y axis.
  27905. * It can be useful with procedural textures or probe for instance.
  27906. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27907. */
  27908. invertRefractionY: boolean;
  27909. /**
  27910. * Defines the alpha limits in alpha test mode.
  27911. */
  27912. alphaCutOff: number;
  27913. private _useLightmapAsShadowmap;
  27914. /**
  27915. * In case of light mapping, define whether the map contains light or shadow informations.
  27916. */
  27917. useLightmapAsShadowmap: boolean;
  27918. private _diffuseFresnelParameters;
  27919. /**
  27920. * Define the diffuse fresnel parameters of the material.
  27921. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27922. */
  27923. diffuseFresnelParameters: FresnelParameters;
  27924. private _opacityFresnelParameters;
  27925. /**
  27926. * Define the opacity fresnel parameters of the material.
  27927. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27928. */
  27929. opacityFresnelParameters: FresnelParameters;
  27930. private _reflectionFresnelParameters;
  27931. /**
  27932. * Define the reflection fresnel parameters of the material.
  27933. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27934. */
  27935. reflectionFresnelParameters: FresnelParameters;
  27936. private _refractionFresnelParameters;
  27937. /**
  27938. * Define the refraction fresnel parameters of the material.
  27939. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27940. */
  27941. refractionFresnelParameters: FresnelParameters;
  27942. private _emissiveFresnelParameters;
  27943. /**
  27944. * Define the emissive fresnel parameters of the material.
  27945. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27946. */
  27947. emissiveFresnelParameters: FresnelParameters;
  27948. private _useReflectionFresnelFromSpecular;
  27949. /**
  27950. * If true automatically deducts the fresnels values from the material specularity.
  27951. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27952. */
  27953. useReflectionFresnelFromSpecular: boolean;
  27954. private _useGlossinessFromSpecularMapAlpha;
  27955. /**
  27956. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27957. */
  27958. useGlossinessFromSpecularMapAlpha: boolean;
  27959. private _maxSimultaneousLights;
  27960. /**
  27961. * Defines the maximum number of lights that can be used in the material
  27962. */
  27963. maxSimultaneousLights: number;
  27964. private _invertNormalMapX;
  27965. /**
  27966. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27967. */
  27968. invertNormalMapX: boolean;
  27969. private _invertNormalMapY;
  27970. /**
  27971. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27972. */
  27973. invertNormalMapY: boolean;
  27974. private _twoSidedLighting;
  27975. /**
  27976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27977. */
  27978. twoSidedLighting: boolean;
  27979. /**
  27980. * Default configuration related to image processing available in the standard Material.
  27981. */
  27982. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27983. /**
  27984. * Gets the image processing configuration used either in this material.
  27985. */
  27986. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27987. /**
  27988. * Sets the Default image processing configuration used either in the this material.
  27989. *
  27990. * If sets to null, the scene one is in use.
  27991. */
  27992. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27993. /**
  27994. * Keep track of the image processing observer to allow dispose and replace.
  27995. */
  27996. private _imageProcessingObserver;
  27997. /**
  27998. * Attaches a new image processing configuration to the Standard Material.
  27999. * @param configuration
  28000. */
  28001. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  28002. /**
  28003. * Gets wether the color curves effect is enabled.
  28004. */
  28005. get cameraColorCurvesEnabled(): boolean;
  28006. /**
  28007. * Sets wether the color curves effect is enabled.
  28008. */
  28009. set cameraColorCurvesEnabled(value: boolean);
  28010. /**
  28011. * Gets wether the color grading effect is enabled.
  28012. */
  28013. get cameraColorGradingEnabled(): boolean;
  28014. /**
  28015. * Gets wether the color grading effect is enabled.
  28016. */
  28017. set cameraColorGradingEnabled(value: boolean);
  28018. /**
  28019. * Gets wether tonemapping is enabled or not.
  28020. */
  28021. get cameraToneMappingEnabled(): boolean;
  28022. /**
  28023. * Sets wether tonemapping is enabled or not
  28024. */
  28025. set cameraToneMappingEnabled(value: boolean);
  28026. /**
  28027. * The camera exposure used on this material.
  28028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28029. * This corresponds to a photographic exposure.
  28030. */
  28031. get cameraExposure(): number;
  28032. /**
  28033. * The camera exposure used on this material.
  28034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28035. * This corresponds to a photographic exposure.
  28036. */
  28037. set cameraExposure(value: number);
  28038. /**
  28039. * Gets The camera contrast used on this material.
  28040. */
  28041. get cameraContrast(): number;
  28042. /**
  28043. * Sets The camera contrast used on this material.
  28044. */
  28045. set cameraContrast(value: number);
  28046. /**
  28047. * Gets the Color Grading 2D Lookup Texture.
  28048. */
  28049. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28050. /**
  28051. * Sets the Color Grading 2D Lookup Texture.
  28052. */
  28053. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28054. /**
  28055. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28056. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28057. * 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;
  28058. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28059. */
  28060. get cameraColorCurves(): Nullable<ColorCurves>;
  28061. /**
  28062. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28063. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28064. * 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;
  28065. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28066. */
  28067. set cameraColorCurves(value: Nullable<ColorCurves>);
  28068. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28069. protected _worldViewProjectionMatrix: Matrix;
  28070. protected _globalAmbientColor: Color3;
  28071. protected _useLogarithmicDepth: boolean;
  28072. protected _rebuildInParallel: boolean;
  28073. /**
  28074. * Instantiates a new standard material.
  28075. * This is the default material used in Babylon. It is the best trade off between quality
  28076. * and performances.
  28077. * @see http://doc.babylonjs.com/babylon101/materials
  28078. * @param name Define the name of the material in the scene
  28079. * @param scene Define the scene the material belong to
  28080. */
  28081. constructor(name: string, scene: Scene);
  28082. /**
  28083. * Gets a boolean indicating that current material needs to register RTT
  28084. */
  28085. get hasRenderTargetTextures(): boolean;
  28086. /**
  28087. * Gets the current class name of the material e.g. "StandardMaterial"
  28088. * Mainly use in serialization.
  28089. * @returns the class name
  28090. */
  28091. getClassName(): string;
  28092. /**
  28093. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28094. * You can try switching to logarithmic depth.
  28095. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28096. */
  28097. get useLogarithmicDepth(): boolean;
  28098. set useLogarithmicDepth(value: boolean);
  28099. /**
  28100. * Specifies if the material will require alpha blending
  28101. * @returns a boolean specifying if alpha blending is needed
  28102. */
  28103. needAlphaBlending(): boolean;
  28104. /**
  28105. * Specifies if this material should be rendered in alpha test mode
  28106. * @returns a boolean specifying if an alpha test is needed.
  28107. */
  28108. needAlphaTesting(): boolean;
  28109. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28110. /**
  28111. * Get the texture used for alpha test purpose.
  28112. * @returns the diffuse texture in case of the standard material.
  28113. */
  28114. getAlphaTestTexture(): Nullable<BaseTexture>;
  28115. /**
  28116. * Get if the submesh is ready to be used and all its information available.
  28117. * Child classes can use it to update shaders
  28118. * @param mesh defines the mesh to check
  28119. * @param subMesh defines which submesh to check
  28120. * @param useInstances specifies that instances should be used
  28121. * @returns a boolean indicating that the submesh is ready or not
  28122. */
  28123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28124. /**
  28125. * Builds the material UBO layouts.
  28126. * Used internally during the effect preparation.
  28127. */
  28128. buildUniformLayout(): void;
  28129. /**
  28130. * Unbinds the material from the mesh
  28131. */
  28132. unbind(): void;
  28133. /**
  28134. * Binds the submesh to this material by preparing the effect and shader to draw
  28135. * @param world defines the world transformation matrix
  28136. * @param mesh defines the mesh containing the submesh
  28137. * @param subMesh defines the submesh to bind the material to
  28138. */
  28139. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28140. /**
  28141. * Get the list of animatables in the material.
  28142. * @returns the list of animatables object used in the material
  28143. */
  28144. getAnimatables(): IAnimatable[];
  28145. /**
  28146. * Gets the active textures from the material
  28147. * @returns an array of textures
  28148. */
  28149. getActiveTextures(): BaseTexture[];
  28150. /**
  28151. * Specifies if the material uses a texture
  28152. * @param texture defines the texture to check against the material
  28153. * @returns a boolean specifying if the material uses the texture
  28154. */
  28155. hasTexture(texture: BaseTexture): boolean;
  28156. /**
  28157. * Disposes the material
  28158. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28159. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28160. */
  28161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28162. /**
  28163. * Makes a duplicate of the material, and gives it a new name
  28164. * @param name defines the new name for the duplicated material
  28165. * @returns the cloned material
  28166. */
  28167. clone(name: string): StandardMaterial;
  28168. /**
  28169. * Serializes this material in a JSON representation
  28170. * @returns the serialized material object
  28171. */
  28172. serialize(): any;
  28173. /**
  28174. * Creates a standard material from parsed material data
  28175. * @param source defines the JSON representation of the material
  28176. * @param scene defines the hosting scene
  28177. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28178. * @returns a new standard material
  28179. */
  28180. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28181. /**
  28182. * Are diffuse textures enabled in the application.
  28183. */
  28184. static get DiffuseTextureEnabled(): boolean;
  28185. static set DiffuseTextureEnabled(value: boolean);
  28186. /**
  28187. * Are ambient textures enabled in the application.
  28188. */
  28189. static get AmbientTextureEnabled(): boolean;
  28190. static set AmbientTextureEnabled(value: boolean);
  28191. /**
  28192. * Are opacity textures enabled in the application.
  28193. */
  28194. static get OpacityTextureEnabled(): boolean;
  28195. static set OpacityTextureEnabled(value: boolean);
  28196. /**
  28197. * Are reflection textures enabled in the application.
  28198. */
  28199. static get ReflectionTextureEnabled(): boolean;
  28200. static set ReflectionTextureEnabled(value: boolean);
  28201. /**
  28202. * Are emissive textures enabled in the application.
  28203. */
  28204. static get EmissiveTextureEnabled(): boolean;
  28205. static set EmissiveTextureEnabled(value: boolean);
  28206. /**
  28207. * Are specular textures enabled in the application.
  28208. */
  28209. static get SpecularTextureEnabled(): boolean;
  28210. static set SpecularTextureEnabled(value: boolean);
  28211. /**
  28212. * Are bump textures enabled in the application.
  28213. */
  28214. static get BumpTextureEnabled(): boolean;
  28215. static set BumpTextureEnabled(value: boolean);
  28216. /**
  28217. * Are lightmap textures enabled in the application.
  28218. */
  28219. static get LightmapTextureEnabled(): boolean;
  28220. static set LightmapTextureEnabled(value: boolean);
  28221. /**
  28222. * Are refraction textures enabled in the application.
  28223. */
  28224. static get RefractionTextureEnabled(): boolean;
  28225. static set RefractionTextureEnabled(value: boolean);
  28226. /**
  28227. * Are color grading textures enabled in the application.
  28228. */
  28229. static get ColorGradingTextureEnabled(): boolean;
  28230. static set ColorGradingTextureEnabled(value: boolean);
  28231. /**
  28232. * Are fresnels enabled in the application.
  28233. */
  28234. static get FresnelEnabled(): boolean;
  28235. static set FresnelEnabled(value: boolean);
  28236. }
  28237. }
  28238. declare module "babylonjs/Particles/solidParticleSystem" {
  28239. import { Nullable } from "babylonjs/types";
  28240. import { Mesh } from "babylonjs/Meshes/mesh";
  28241. import { Scene, IDisposable } from "babylonjs/scene";
  28242. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28243. import { Material } from "babylonjs/Materials/material";
  28244. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28245. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28246. /**
  28247. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28248. *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.
  28249. * The SPS is also a particle system. It provides some methods to manage the particles.
  28250. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28251. *
  28252. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28253. */
  28254. export class SolidParticleSystem implements IDisposable {
  28255. /**
  28256. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28257. * Example : var p = SPS.particles[i];
  28258. */
  28259. particles: SolidParticle[];
  28260. /**
  28261. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28262. */
  28263. nbParticles: number;
  28264. /**
  28265. * If the particles must ever face the camera (default false). Useful for planar particles.
  28266. */
  28267. billboard: boolean;
  28268. /**
  28269. * Recompute normals when adding a shape
  28270. */
  28271. recomputeNormals: boolean;
  28272. /**
  28273. * This a counter ofr your own usage. It's not set by any SPS functions.
  28274. */
  28275. counter: number;
  28276. /**
  28277. * The SPS name. This name is also given to the underlying mesh.
  28278. */
  28279. name: string;
  28280. /**
  28281. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28282. */
  28283. mesh: Mesh;
  28284. /**
  28285. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28286. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28287. */
  28288. vars: any;
  28289. /**
  28290. * This array is populated when the SPS is set as 'pickable'.
  28291. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28292. * Each element of this array is an object `{idx: int, faceId: int}`.
  28293. * `idx` is the picked particle index in the `SPS.particles` array
  28294. * `faceId` is the picked face index counted within this particle.
  28295. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28296. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28297. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28298. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28299. */
  28300. pickedParticles: {
  28301. idx: number;
  28302. faceId: number;
  28303. }[];
  28304. /**
  28305. * This array is populated when the SPS is set as 'pickable'
  28306. * Each key of this array is a submesh index.
  28307. * Each element of this array is a second array defined like this :
  28308. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28309. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28310. * `idx` is the picked particle index in the `SPS.particles` array
  28311. * `faceId` is the picked face index counted within this particle.
  28312. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28314. */
  28315. pickedBySubMesh: {
  28316. idx: number;
  28317. faceId: number;
  28318. }[][];
  28319. /**
  28320. * This array is populated when `enableDepthSort` is set to true.
  28321. * Each element of this array is an instance of the class DepthSortedParticle.
  28322. */
  28323. depthSortedParticles: DepthSortedParticle[];
  28324. /**
  28325. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28326. * @hidden
  28327. */
  28328. _bSphereOnly: boolean;
  28329. /**
  28330. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28331. * @hidden
  28332. */
  28333. _bSphereRadiusFactor: number;
  28334. private _scene;
  28335. private _positions;
  28336. private _indices;
  28337. private _normals;
  28338. private _colors;
  28339. private _uvs;
  28340. private _indices32;
  28341. private _positions32;
  28342. private _normals32;
  28343. private _fixedNormal32;
  28344. private _colors32;
  28345. private _uvs32;
  28346. private _index;
  28347. private _updatable;
  28348. private _pickable;
  28349. private _isVisibilityBoxLocked;
  28350. private _alwaysVisible;
  28351. private _depthSort;
  28352. private _expandable;
  28353. private _shapeCounter;
  28354. private _copy;
  28355. private _color;
  28356. private _computeParticleColor;
  28357. private _computeParticleTexture;
  28358. private _computeParticleRotation;
  28359. private _computeParticleVertex;
  28360. private _computeBoundingBox;
  28361. private _depthSortParticles;
  28362. private _camera;
  28363. private _mustUnrotateFixedNormals;
  28364. private _particlesIntersect;
  28365. private _needs32Bits;
  28366. private _isNotBuilt;
  28367. private _lastParticleId;
  28368. private _idxOfId;
  28369. private _multimaterialEnabled;
  28370. private _useModelMaterial;
  28371. private _indicesByMaterial;
  28372. private _materialIndexes;
  28373. private _depthSortFunction;
  28374. private _materialSortFunction;
  28375. private _materials;
  28376. private _multimaterial;
  28377. private _materialIndexesById;
  28378. private _defaultMaterial;
  28379. private _autoUpdateSubMeshes;
  28380. private _tmpVertex;
  28381. /**
  28382. * Creates a SPS (Solid Particle System) object.
  28383. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28384. * @param scene (Scene) is the scene in which the SPS is added.
  28385. * @param options defines the options of the sps e.g.
  28386. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28387. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28388. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28389. * * 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.
  28390. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28391. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28392. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28393. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28394. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28395. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28396. */
  28397. constructor(name: string, scene: Scene, options?: {
  28398. updatable?: boolean;
  28399. isPickable?: boolean;
  28400. enableDepthSort?: boolean;
  28401. particleIntersection?: boolean;
  28402. boundingSphereOnly?: boolean;
  28403. bSphereRadiusFactor?: number;
  28404. expandable?: boolean;
  28405. useModelMaterial?: boolean;
  28406. enableMultiMaterial?: boolean;
  28407. });
  28408. /**
  28409. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28410. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28411. * @returns the created mesh
  28412. */
  28413. buildMesh(): Mesh;
  28414. /**
  28415. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28416. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28417. * Thus the particles generated from `digest()` have their property `position` set yet.
  28418. * @param mesh ( Mesh ) is the mesh to be digested
  28419. * @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
  28420. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28421. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28422. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28423. * @returns the current SPS
  28424. */
  28425. digest(mesh: Mesh, options?: {
  28426. facetNb?: number;
  28427. number?: number;
  28428. delta?: number;
  28429. storage?: [];
  28430. }): SolidParticleSystem;
  28431. /**
  28432. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28433. * @hidden
  28434. */
  28435. private _unrotateFixedNormals;
  28436. /**
  28437. * Resets the temporary working copy particle
  28438. * @hidden
  28439. */
  28440. private _resetCopy;
  28441. /**
  28442. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28443. * @param p the current index in the positions array to be updated
  28444. * @param ind the current index in the indices array
  28445. * @param shape a Vector3 array, the shape geometry
  28446. * @param positions the positions array to be updated
  28447. * @param meshInd the shape indices array
  28448. * @param indices the indices array to be updated
  28449. * @param meshUV the shape uv array
  28450. * @param uvs the uv array to be updated
  28451. * @param meshCol the shape color array
  28452. * @param colors the color array to be updated
  28453. * @param meshNor the shape normals array
  28454. * @param normals the normals array to be updated
  28455. * @param idx the particle index
  28456. * @param idxInShape the particle index in its shape
  28457. * @param options the addShape() method passed options
  28458. * @model the particle model
  28459. * @hidden
  28460. */
  28461. private _meshBuilder;
  28462. /**
  28463. * Returns a shape Vector3 array from positions float array
  28464. * @param positions float array
  28465. * @returns a vector3 array
  28466. * @hidden
  28467. */
  28468. private _posToShape;
  28469. /**
  28470. * Returns a shapeUV array from a float uvs (array deep copy)
  28471. * @param uvs as a float array
  28472. * @returns a shapeUV array
  28473. * @hidden
  28474. */
  28475. private _uvsToShapeUV;
  28476. /**
  28477. * Adds a new particle object in the particles array
  28478. * @param idx particle index in particles array
  28479. * @param id particle id
  28480. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28481. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28482. * @param model particle ModelShape object
  28483. * @param shapeId model shape identifier
  28484. * @param idxInShape index of the particle in the current model
  28485. * @param bInfo model bounding info object
  28486. * @param storage target storage array, if any
  28487. * @hidden
  28488. */
  28489. private _addParticle;
  28490. /**
  28491. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28492. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28493. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28494. * @param nb (positive integer) the number of particles to be created from this model
  28495. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28496. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28497. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28498. * @returns the number of shapes in the system
  28499. */
  28500. addShape(mesh: Mesh, nb: number, options?: {
  28501. positionFunction?: any;
  28502. vertexFunction?: any;
  28503. storage?: [];
  28504. }): number;
  28505. /**
  28506. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28507. * @hidden
  28508. */
  28509. private _rebuildParticle;
  28510. /**
  28511. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28512. * @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.
  28513. * @returns the SPS.
  28514. */
  28515. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28516. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28517. * Returns an array with the removed particles.
  28518. * 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.
  28519. * The SPS can't be empty so at least one particle needs to remain in place.
  28520. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28521. * @param start index of the first particle to remove
  28522. * @param end index of the last particle to remove (included)
  28523. * @returns an array populated with the removed particles
  28524. */
  28525. removeParticles(start: number, end: number): SolidParticle[];
  28526. /**
  28527. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28528. * @param solidParticleArray an array populated with Solid Particles objects
  28529. * @returns the SPS
  28530. */
  28531. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28532. /**
  28533. * Creates a new particle and modifies the SPS mesh geometry :
  28534. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28535. * - calls _addParticle() to populate the particle array
  28536. * factorized code from addShape() and insertParticlesFromArray()
  28537. * @param idx particle index in the particles array
  28538. * @param i particle index in its shape
  28539. * @param modelShape particle ModelShape object
  28540. * @param shape shape vertex array
  28541. * @param meshInd shape indices array
  28542. * @param meshUV shape uv array
  28543. * @param meshCol shape color array
  28544. * @param meshNor shape normals array
  28545. * @param bbInfo shape bounding info
  28546. * @param storage target particle storage
  28547. * @options addShape() passed options
  28548. * @hidden
  28549. */
  28550. private _insertNewParticle;
  28551. /**
  28552. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28553. * This method calls `updateParticle()` for each particle of the SPS.
  28554. * For an animated SPS, it is usually called within the render loop.
  28555. * 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.
  28556. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28557. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28558. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28559. * @returns the SPS.
  28560. */
  28561. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28562. /**
  28563. * Disposes the SPS.
  28564. */
  28565. dispose(): void;
  28566. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28567. * idx is the particle index in the SPS
  28568. * faceId is the picked face index counted within this particle.
  28569. * Returns null if the pickInfo can't identify a picked particle.
  28570. * @param pickingInfo (PickingInfo object)
  28571. * @returns {idx: number, faceId: number} or null
  28572. */
  28573. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28574. idx: number;
  28575. faceId: number;
  28576. }>;
  28577. /**
  28578. * Returns a SolidParticle object from its identifier : particle.id
  28579. * @param id (integer) the particle Id
  28580. * @returns the searched particle or null if not found in the SPS.
  28581. */
  28582. getParticleById(id: number): Nullable<SolidParticle>;
  28583. /**
  28584. * Returns a new array populated with the particles having the passed shapeId.
  28585. * @param shapeId (integer) the shape identifier
  28586. * @returns a new solid particle array
  28587. */
  28588. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28589. /**
  28590. * Populates the passed array "ref" with the particles having the passed shapeId.
  28591. * @param shapeId the shape identifier
  28592. * @returns the SPS
  28593. * @param ref
  28594. */
  28595. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28596. /**
  28597. * Computes the required SubMeshes according the materials assigned to the particles.
  28598. * @returns the solid particle system.
  28599. * Does nothing if called before the SPS mesh is built.
  28600. */
  28601. computeSubMeshes(): SolidParticleSystem;
  28602. /**
  28603. * Sorts the solid particles by material when MultiMaterial is enabled.
  28604. * Updates the indices32 array.
  28605. * Updates the indicesByMaterial array.
  28606. * Updates the mesh indices array.
  28607. * @returns the SPS
  28608. * @hidden
  28609. */
  28610. private _sortParticlesByMaterial;
  28611. /**
  28612. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28613. * @hidden
  28614. */
  28615. private _setMaterialIndexesById;
  28616. /**
  28617. * Returns an array with unique values of Materials from the passed array
  28618. * @param array the material array to be checked and filtered
  28619. * @hidden
  28620. */
  28621. private _filterUniqueMaterialId;
  28622. /**
  28623. * Sets a new Standard Material as _defaultMaterial if not already set.
  28624. * @hidden
  28625. */
  28626. private _setDefaultMaterial;
  28627. /**
  28628. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28629. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28630. * @returns the SPS.
  28631. */
  28632. refreshVisibleSize(): SolidParticleSystem;
  28633. /**
  28634. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28635. * @param size the size (float) of the visibility box
  28636. * note : this doesn't lock the SPS mesh bounding box.
  28637. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28638. */
  28639. setVisibilityBox(size: number): void;
  28640. /**
  28641. * Gets whether the SPS as always visible or not
  28642. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28643. */
  28644. get isAlwaysVisible(): boolean;
  28645. /**
  28646. * Sets the SPS as always visible or not
  28647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28648. */
  28649. set isAlwaysVisible(val: boolean);
  28650. /**
  28651. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28652. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28653. */
  28654. set isVisibilityBoxLocked(val: boolean);
  28655. /**
  28656. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28657. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28658. */
  28659. get isVisibilityBoxLocked(): boolean;
  28660. /**
  28661. * Tells to `setParticles()` to compute the particle rotations or not.
  28662. * Default value : true. The SPS is faster when it's set to false.
  28663. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28664. */
  28665. set computeParticleRotation(val: boolean);
  28666. /**
  28667. * Tells to `setParticles()` to compute the particle colors or not.
  28668. * Default value : true. The SPS is faster when it's set to false.
  28669. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28670. */
  28671. set computeParticleColor(val: boolean);
  28672. set computeParticleTexture(val: boolean);
  28673. /**
  28674. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28675. * Default value : false. The SPS is faster when it's set to false.
  28676. * Note : the particle custom vertex positions aren't stored values.
  28677. */
  28678. set computeParticleVertex(val: boolean);
  28679. /**
  28680. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28681. */
  28682. set computeBoundingBox(val: boolean);
  28683. /**
  28684. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28685. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28686. * Default : `true`
  28687. */
  28688. set depthSortParticles(val: boolean);
  28689. /**
  28690. * Gets if `setParticles()` computes the particle rotations or not.
  28691. * Default value : true. The SPS is faster when it's set to false.
  28692. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28693. */
  28694. get computeParticleRotation(): boolean;
  28695. /**
  28696. * Gets if `setParticles()` computes the particle colors or not.
  28697. * Default value : true. The SPS is faster when it's set to false.
  28698. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28699. */
  28700. get computeParticleColor(): boolean;
  28701. /**
  28702. * Gets if `setParticles()` computes the particle textures or not.
  28703. * Default value : true. The SPS is faster when it's set to false.
  28704. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28705. */
  28706. get computeParticleTexture(): boolean;
  28707. /**
  28708. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28709. * Default value : false. The SPS is faster when it's set to false.
  28710. * Note : the particle custom vertex positions aren't stored values.
  28711. */
  28712. get computeParticleVertex(): boolean;
  28713. /**
  28714. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28715. */
  28716. get computeBoundingBox(): boolean;
  28717. /**
  28718. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28719. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28720. * Default : `true`
  28721. */
  28722. get depthSortParticles(): boolean;
  28723. /**
  28724. * Gets if the SPS is created as expandable at construction time.
  28725. * Default : `false`
  28726. */
  28727. get expandable(): boolean;
  28728. /**
  28729. * Gets if the SPS supports the Multi Materials
  28730. */
  28731. get multimaterialEnabled(): boolean;
  28732. /**
  28733. * Gets if the SPS uses the model materials for its own multimaterial.
  28734. */
  28735. get useModelMaterial(): boolean;
  28736. /**
  28737. * The SPS used material array.
  28738. */
  28739. get materials(): Material[];
  28740. /**
  28741. * Sets the SPS MultiMaterial from the passed materials.
  28742. * Note : the passed array is internally copied and not used then by reference.
  28743. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28744. */
  28745. setMultiMaterial(materials: Material[]): void;
  28746. /**
  28747. * The SPS computed multimaterial object
  28748. */
  28749. get multimaterial(): MultiMaterial;
  28750. set multimaterial(mm: MultiMaterial);
  28751. /**
  28752. * If the subMeshes must be updated on the next call to setParticles()
  28753. */
  28754. get autoUpdateSubMeshes(): boolean;
  28755. set autoUpdateSubMeshes(val: boolean);
  28756. /**
  28757. * This function does nothing. It may be overwritten to set all the particle first values.
  28758. * The SPS doesn't call this function, you may have to call it by your own.
  28759. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28760. */
  28761. initParticles(): void;
  28762. /**
  28763. * This function does nothing. It may be overwritten to recycle a particle.
  28764. * The SPS doesn't call this function, you may have to call it by your own.
  28765. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28766. * @param particle The particle to recycle
  28767. * @returns the recycled particle
  28768. */
  28769. recycleParticle(particle: SolidParticle): SolidParticle;
  28770. /**
  28771. * Updates a particle : this function should be overwritten by the user.
  28772. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28773. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28774. * @example : just set a particle position or velocity and recycle conditions
  28775. * @param particle The particle to update
  28776. * @returns the updated particle
  28777. */
  28778. updateParticle(particle: SolidParticle): SolidParticle;
  28779. /**
  28780. * Updates a vertex of a particle : it can be overwritten by the user.
  28781. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28782. * @param particle the current particle
  28783. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28784. * @param pt the index of the current vertex in the particle shape
  28785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28786. * @example : just set a vertex particle position or color
  28787. * @returns the sps
  28788. */
  28789. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28790. /**
  28791. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28792. * This does nothing and may be overwritten by the user.
  28793. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28794. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28795. * @param update the boolean update value actually passed to setParticles()
  28796. */
  28797. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28798. /**
  28799. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28800. * This will be passed three parameters.
  28801. * This does nothing and may be overwritten by the user.
  28802. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28803. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28804. * @param update the boolean update value actually passed to setParticles()
  28805. */
  28806. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28807. }
  28808. }
  28809. declare module "babylonjs/Particles/solidParticle" {
  28810. import { Nullable } from "babylonjs/types";
  28811. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28812. import { Color4 } from "babylonjs/Maths/math.color";
  28813. import { Mesh } from "babylonjs/Meshes/mesh";
  28814. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28815. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28816. import { Plane } from "babylonjs/Maths/math.plane";
  28817. import { Material } from "babylonjs/Materials/material";
  28818. /**
  28819. * Represents one particle of a solid particle system.
  28820. */
  28821. export class SolidParticle {
  28822. /**
  28823. * particle global index
  28824. */
  28825. idx: number;
  28826. /**
  28827. * particle identifier
  28828. */
  28829. id: number;
  28830. /**
  28831. * The color of the particle
  28832. */
  28833. color: Nullable<Color4>;
  28834. /**
  28835. * The world space position of the particle.
  28836. */
  28837. position: Vector3;
  28838. /**
  28839. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28840. */
  28841. rotation: Vector3;
  28842. /**
  28843. * The world space rotation quaternion of the particle.
  28844. */
  28845. rotationQuaternion: Nullable<Quaternion>;
  28846. /**
  28847. * The scaling of the particle.
  28848. */
  28849. scaling: Vector3;
  28850. /**
  28851. * The uvs of the particle.
  28852. */
  28853. uvs: Vector4;
  28854. /**
  28855. * The current speed of the particle.
  28856. */
  28857. velocity: Vector3;
  28858. /**
  28859. * The pivot point in the particle local space.
  28860. */
  28861. pivot: Vector3;
  28862. /**
  28863. * Must the particle be translated from its pivot point in its local space ?
  28864. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28865. * Default : false
  28866. */
  28867. translateFromPivot: boolean;
  28868. /**
  28869. * Is the particle active or not ?
  28870. */
  28871. alive: boolean;
  28872. /**
  28873. * Is the particle visible or not ?
  28874. */
  28875. isVisible: boolean;
  28876. /**
  28877. * Index of this particle in the global "positions" array (Internal use)
  28878. * @hidden
  28879. */
  28880. _pos: number;
  28881. /**
  28882. * @hidden Index of this particle in the global "indices" array (Internal use)
  28883. */
  28884. _ind: number;
  28885. /**
  28886. * @hidden ModelShape of this particle (Internal use)
  28887. */
  28888. _model: ModelShape;
  28889. /**
  28890. * ModelShape id of this particle
  28891. */
  28892. shapeId: number;
  28893. /**
  28894. * Index of the particle in its shape id
  28895. */
  28896. idxInShape: number;
  28897. /**
  28898. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28899. */
  28900. _modelBoundingInfo: BoundingInfo;
  28901. /**
  28902. * @hidden Particle BoundingInfo object (Internal use)
  28903. */
  28904. _boundingInfo: BoundingInfo;
  28905. /**
  28906. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28907. */
  28908. _sps: SolidParticleSystem;
  28909. /**
  28910. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28911. */
  28912. _stillInvisible: boolean;
  28913. /**
  28914. * @hidden Last computed particle rotation matrix
  28915. */
  28916. _rotationMatrix: number[];
  28917. /**
  28918. * Parent particle Id, if any.
  28919. * Default null.
  28920. */
  28921. parentId: Nullable<number>;
  28922. /**
  28923. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28924. */
  28925. materialIndex: Nullable<number>;
  28926. /**
  28927. * Custom object or properties.
  28928. */
  28929. props: Nullable<any>;
  28930. /**
  28931. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28932. * The possible values are :
  28933. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28934. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28936. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28937. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28938. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28939. * */
  28940. cullingStrategy: number;
  28941. /**
  28942. * @hidden Internal global position in the SPS.
  28943. */
  28944. _globalPosition: Vector3;
  28945. /**
  28946. * Creates a Solid Particle object.
  28947. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28948. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28949. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28950. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28951. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28952. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28953. * @param shapeId (integer) is the model shape identifier in the SPS.
  28954. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28955. * @param sps defines the sps it is associated to
  28956. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28957. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28958. */
  28959. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28960. /**
  28961. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28962. * @param target the particle target
  28963. * @returns the current particle
  28964. */
  28965. copyToRef(target: SolidParticle): SolidParticle;
  28966. /**
  28967. * Legacy support, changed scale to scaling
  28968. */
  28969. get scale(): Vector3;
  28970. /**
  28971. * Legacy support, changed scale to scaling
  28972. */
  28973. set scale(scale: Vector3);
  28974. /**
  28975. * Legacy support, changed quaternion to rotationQuaternion
  28976. */
  28977. get quaternion(): Nullable<Quaternion>;
  28978. /**
  28979. * Legacy support, changed quaternion to rotationQuaternion
  28980. */
  28981. set quaternion(q: Nullable<Quaternion>);
  28982. /**
  28983. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28984. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28985. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28986. * @returns true if it intersects
  28987. */
  28988. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28989. /**
  28990. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28991. * A particle is in the frustum if its bounding box intersects the frustum
  28992. * @param frustumPlanes defines the frustum to test
  28993. * @returns true if the particle is in the frustum planes
  28994. */
  28995. isInFrustum(frustumPlanes: Plane[]): boolean;
  28996. /**
  28997. * get the rotation matrix of the particle
  28998. * @hidden
  28999. */
  29000. getRotationMatrix(m: Matrix): void;
  29001. }
  29002. /**
  29003. * Represents the shape of the model used by one particle of a solid particle system.
  29004. * SPS internal tool, don't use it manually.
  29005. */
  29006. export class ModelShape {
  29007. /**
  29008. * The shape id
  29009. * @hidden
  29010. */
  29011. shapeID: number;
  29012. /**
  29013. * flat array of model positions (internal use)
  29014. * @hidden
  29015. */
  29016. _shape: Vector3[];
  29017. /**
  29018. * flat array of model UVs (internal use)
  29019. * @hidden
  29020. */
  29021. _shapeUV: number[];
  29022. /**
  29023. * color array of the model
  29024. * @hidden
  29025. */
  29026. _shapeColors: number[];
  29027. /**
  29028. * indices array of the model
  29029. * @hidden
  29030. */
  29031. _indices: number[];
  29032. /**
  29033. * normals array of the model
  29034. * @hidden
  29035. */
  29036. _normals: number[];
  29037. /**
  29038. * length of the shape in the model indices array (internal use)
  29039. * @hidden
  29040. */
  29041. _indicesLength: number;
  29042. /**
  29043. * Custom position function (internal use)
  29044. * @hidden
  29045. */
  29046. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29047. /**
  29048. * Custom vertex function (internal use)
  29049. * @hidden
  29050. */
  29051. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29052. /**
  29053. * Model material (internal use)
  29054. * @hidden
  29055. */
  29056. _material: Nullable<Material>;
  29057. /**
  29058. * 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.
  29059. * SPS internal tool, don't use it manually.
  29060. * @hidden
  29061. */
  29062. 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>);
  29063. }
  29064. /**
  29065. * Represents a Depth Sorted Particle in the solid particle system.
  29066. * @hidden
  29067. */
  29068. export class DepthSortedParticle {
  29069. /**
  29070. * Particle index
  29071. */
  29072. idx: number;
  29073. /**
  29074. * Index of the particle in the "indices" array
  29075. */
  29076. ind: number;
  29077. /**
  29078. * Length of the particle shape in the "indices" array
  29079. */
  29080. indicesLength: number;
  29081. /**
  29082. * Squared distance from the particle to the camera
  29083. */
  29084. sqDistance: number;
  29085. /**
  29086. * Material index when used with MultiMaterials
  29087. */
  29088. materialIndex: number;
  29089. /**
  29090. * Creates a new sorted particle
  29091. * @param materialIndex
  29092. */
  29093. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29094. }
  29095. /**
  29096. * Represents a solid particle vertex
  29097. */
  29098. export class SolidParticleVertex {
  29099. /**
  29100. * Vertex position
  29101. */
  29102. position: Vector3;
  29103. /**
  29104. * Vertex color
  29105. */
  29106. color: Color4;
  29107. /**
  29108. * Vertex UV
  29109. */
  29110. uv: Vector2;
  29111. /**
  29112. * Creates a new solid particle vertex
  29113. */
  29114. constructor();
  29115. /** Vertex x coordinate */
  29116. get x(): number;
  29117. set x(val: number);
  29118. /** Vertex y coordinate */
  29119. get y(): number;
  29120. set y(val: number);
  29121. /** Vertex z coordinate */
  29122. get z(): number;
  29123. set z(val: number);
  29124. }
  29125. }
  29126. declare module "babylonjs/Collisions/meshCollisionData" {
  29127. import { Collider } from "babylonjs/Collisions/collider";
  29128. import { Vector3 } from "babylonjs/Maths/math.vector";
  29129. import { Nullable } from "babylonjs/types";
  29130. import { Observer } from "babylonjs/Misc/observable";
  29131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29132. /**
  29133. * @hidden
  29134. */
  29135. export class _MeshCollisionData {
  29136. _checkCollisions: boolean;
  29137. _collisionMask: number;
  29138. _collisionGroup: number;
  29139. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29140. _collider: Nullable<Collider>;
  29141. _oldPositionForCollisions: Vector3;
  29142. _diffPositionForCollisions: Vector3;
  29143. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29144. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29145. }
  29146. }
  29147. declare module "babylonjs/Meshes/abstractMesh" {
  29148. import { Observable } from "babylonjs/Misc/observable";
  29149. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29150. import { Camera } from "babylonjs/Cameras/camera";
  29151. import { Scene, IDisposable } from "babylonjs/scene";
  29152. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29153. import { Node } from "babylonjs/node";
  29154. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29155. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29157. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29158. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29159. import { Material } from "babylonjs/Materials/material";
  29160. import { Light } from "babylonjs/Lights/light";
  29161. import { Skeleton } from "babylonjs/Bones/skeleton";
  29162. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29163. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29164. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29165. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29166. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29167. import { Plane } from "babylonjs/Maths/math.plane";
  29168. import { Ray } from "babylonjs/Culling/ray";
  29169. import { Collider } from "babylonjs/Collisions/collider";
  29170. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29171. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29172. /** @hidden */
  29173. class _FacetDataStorage {
  29174. facetPositions: Vector3[];
  29175. facetNormals: Vector3[];
  29176. facetPartitioning: number[][];
  29177. facetNb: number;
  29178. partitioningSubdivisions: number;
  29179. partitioningBBoxRatio: number;
  29180. facetDataEnabled: boolean;
  29181. facetParameters: any;
  29182. bbSize: Vector3;
  29183. subDiv: {
  29184. max: number;
  29185. X: number;
  29186. Y: number;
  29187. Z: number;
  29188. };
  29189. facetDepthSort: boolean;
  29190. facetDepthSortEnabled: boolean;
  29191. depthSortedIndices: IndicesArray;
  29192. depthSortedFacets: {
  29193. ind: number;
  29194. sqDistance: number;
  29195. }[];
  29196. facetDepthSortFunction: (f1: {
  29197. ind: number;
  29198. sqDistance: number;
  29199. }, f2: {
  29200. ind: number;
  29201. sqDistance: number;
  29202. }) => number;
  29203. facetDepthSortFrom: Vector3;
  29204. facetDepthSortOrigin: Vector3;
  29205. invertedMatrix: Matrix;
  29206. }
  29207. /**
  29208. * @hidden
  29209. **/
  29210. class _InternalAbstractMeshDataInfo {
  29211. _hasVertexAlpha: boolean;
  29212. _useVertexColors: boolean;
  29213. _numBoneInfluencers: number;
  29214. _applyFog: boolean;
  29215. _receiveShadows: boolean;
  29216. _facetData: _FacetDataStorage;
  29217. _visibility: number;
  29218. _skeleton: Nullable<Skeleton>;
  29219. _layerMask: number;
  29220. _computeBonesUsingShaders: boolean;
  29221. _isActive: boolean;
  29222. _onlyForInstances: boolean;
  29223. _isActiveIntermediate: boolean;
  29224. _onlyForInstancesIntermediate: boolean;
  29225. _actAsRegularMesh: boolean;
  29226. }
  29227. /**
  29228. * Class used to store all common mesh properties
  29229. */
  29230. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29231. /** No occlusion */
  29232. static OCCLUSION_TYPE_NONE: number;
  29233. /** Occlusion set to optimisitic */
  29234. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29235. /** Occlusion set to strict */
  29236. static OCCLUSION_TYPE_STRICT: number;
  29237. /** Use an accurante occlusion algorithm */
  29238. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29239. /** Use a conservative occlusion algorithm */
  29240. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29241. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29242. * Test order :
  29243. * Is the bounding sphere outside the frustum ?
  29244. * If not, are the bounding box vertices outside the frustum ?
  29245. * It not, then the cullable object is in the frustum.
  29246. */
  29247. static readonly CULLINGSTRATEGY_STANDARD: number;
  29248. /** Culling strategy : Bounding Sphere Only.
  29249. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29250. * It's also less accurate than the standard because some not visible objects can still be selected.
  29251. * Test : is the bounding sphere outside the frustum ?
  29252. * If not, then the cullable object is in the frustum.
  29253. */
  29254. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29255. /** Culling strategy : Optimistic Inclusion.
  29256. * This in an inclusion test first, then the standard exclusion test.
  29257. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29258. * 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.
  29259. * Anyway, it's as accurate as the standard strategy.
  29260. * Test :
  29261. * Is the cullable object bounding sphere center in the frustum ?
  29262. * If not, apply the default culling strategy.
  29263. */
  29264. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29265. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29266. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29267. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29268. * 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.
  29269. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29270. * Test :
  29271. * Is the cullable object bounding sphere center in the frustum ?
  29272. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29273. */
  29274. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29275. /**
  29276. * No billboard
  29277. */
  29278. static get BILLBOARDMODE_NONE(): number;
  29279. /** Billboard on X axis */
  29280. static get BILLBOARDMODE_X(): number;
  29281. /** Billboard on Y axis */
  29282. static get BILLBOARDMODE_Y(): number;
  29283. /** Billboard on Z axis */
  29284. static get BILLBOARDMODE_Z(): number;
  29285. /** Billboard on all axes */
  29286. static get BILLBOARDMODE_ALL(): number;
  29287. /** Billboard on using position instead of orientation */
  29288. static get BILLBOARDMODE_USE_POSITION(): number;
  29289. /** @hidden */
  29290. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29291. /**
  29292. * The culling strategy to use to check whether the mesh must be rendered or not.
  29293. * This value can be changed at any time and will be used on the next render mesh selection.
  29294. * The possible values are :
  29295. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29296. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29297. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29299. * Please read each static variable documentation to get details about the culling process.
  29300. * */
  29301. cullingStrategy: number;
  29302. /**
  29303. * Gets the number of facets in the mesh
  29304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29305. */
  29306. get facetNb(): number;
  29307. /**
  29308. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29310. */
  29311. get partitioningSubdivisions(): number;
  29312. set partitioningSubdivisions(nb: number);
  29313. /**
  29314. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29315. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29317. */
  29318. get partitioningBBoxRatio(): number;
  29319. set partitioningBBoxRatio(ratio: number);
  29320. /**
  29321. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29322. * Works only for updatable meshes.
  29323. * Doesn't work with multi-materials
  29324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29325. */
  29326. get mustDepthSortFacets(): boolean;
  29327. set mustDepthSortFacets(sort: boolean);
  29328. /**
  29329. * The location (Vector3) where the facet depth sort must be computed from.
  29330. * By default, the active camera position.
  29331. * Used only when facet depth sort is enabled
  29332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29333. */
  29334. get facetDepthSortFrom(): Vector3;
  29335. set facetDepthSortFrom(location: Vector3);
  29336. /**
  29337. * gets a boolean indicating if facetData is enabled
  29338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29339. */
  29340. get isFacetDataEnabled(): boolean;
  29341. /** @hidden */
  29342. _updateNonUniformScalingState(value: boolean): boolean;
  29343. /**
  29344. * An event triggered when this mesh collides with another one
  29345. */
  29346. onCollideObservable: Observable<AbstractMesh>;
  29347. /** Set a function to call when this mesh collides with another one */
  29348. set onCollide(callback: () => void);
  29349. /**
  29350. * An event triggered when the collision's position changes
  29351. */
  29352. onCollisionPositionChangeObservable: Observable<Vector3>;
  29353. /** Set a function to call when the collision's position changes */
  29354. set onCollisionPositionChange(callback: () => void);
  29355. /**
  29356. * An event triggered when material is changed
  29357. */
  29358. onMaterialChangedObservable: Observable<AbstractMesh>;
  29359. /**
  29360. * Gets or sets the orientation for POV movement & rotation
  29361. */
  29362. definedFacingForward: boolean;
  29363. /** @hidden */
  29364. _occlusionQuery: Nullable<WebGLQuery>;
  29365. /** @hidden */
  29366. _renderingGroup: Nullable<RenderingGroup>;
  29367. /**
  29368. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29369. */
  29370. get visibility(): number;
  29371. /**
  29372. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29373. */
  29374. set visibility(value: number);
  29375. /** Gets or sets the alpha index used to sort transparent meshes
  29376. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29377. */
  29378. alphaIndex: number;
  29379. /**
  29380. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29381. */
  29382. isVisible: boolean;
  29383. /**
  29384. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29385. */
  29386. isPickable: boolean;
  29387. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29388. showSubMeshesBoundingBox: boolean;
  29389. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29390. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29391. */
  29392. isBlocker: boolean;
  29393. /**
  29394. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29395. */
  29396. enablePointerMoveEvents: boolean;
  29397. /**
  29398. * Specifies the rendering group id for this mesh (0 by default)
  29399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29400. */
  29401. renderingGroupId: number;
  29402. private _material;
  29403. /** Gets or sets current material */
  29404. get material(): Nullable<Material>;
  29405. set material(value: Nullable<Material>);
  29406. /**
  29407. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29408. * @see http://doc.babylonjs.com/babylon101/shadows
  29409. */
  29410. get receiveShadows(): boolean;
  29411. set receiveShadows(value: boolean);
  29412. /** Defines color to use when rendering outline */
  29413. outlineColor: Color3;
  29414. /** Define width to use when rendering outline */
  29415. outlineWidth: number;
  29416. /** Defines color to use when rendering overlay */
  29417. overlayColor: Color3;
  29418. /** Defines alpha to use when rendering overlay */
  29419. overlayAlpha: number;
  29420. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29421. get hasVertexAlpha(): boolean;
  29422. set hasVertexAlpha(value: boolean);
  29423. /** 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) */
  29424. get useVertexColors(): boolean;
  29425. set useVertexColors(value: boolean);
  29426. /**
  29427. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29428. */
  29429. get computeBonesUsingShaders(): boolean;
  29430. set computeBonesUsingShaders(value: boolean);
  29431. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29432. get numBoneInfluencers(): number;
  29433. set numBoneInfluencers(value: number);
  29434. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29435. get applyFog(): boolean;
  29436. set applyFog(value: boolean);
  29437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29438. useOctreeForRenderingSelection: boolean;
  29439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29440. useOctreeForPicking: boolean;
  29441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29442. useOctreeForCollisions: boolean;
  29443. /**
  29444. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29445. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29446. */
  29447. get layerMask(): number;
  29448. set layerMask(value: number);
  29449. /**
  29450. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29451. */
  29452. alwaysSelectAsActiveMesh: boolean;
  29453. /**
  29454. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29455. */
  29456. doNotSyncBoundingInfo: boolean;
  29457. /**
  29458. * Gets or sets the current action manager
  29459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29460. */
  29461. actionManager: Nullable<AbstractActionManager>;
  29462. private _meshCollisionData;
  29463. /**
  29464. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29466. */
  29467. ellipsoid: Vector3;
  29468. /**
  29469. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29471. */
  29472. ellipsoidOffset: Vector3;
  29473. /**
  29474. * Gets or sets a collision mask used to mask collisions (default is -1).
  29475. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29476. */
  29477. get collisionMask(): number;
  29478. set collisionMask(mask: number);
  29479. /**
  29480. * Gets or sets the current collision group mask (-1 by default).
  29481. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29482. */
  29483. get collisionGroup(): number;
  29484. set collisionGroup(mask: number);
  29485. /**
  29486. * Gets or sets current surrounding meshes (null by default).
  29487. *
  29488. * By default collision detection is tested against every mesh in the scene.
  29489. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29490. * meshes will be tested for the collision.
  29491. *
  29492. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29493. */
  29494. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29495. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29496. /**
  29497. * Defines edge width used when edgesRenderer is enabled
  29498. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29499. */
  29500. edgesWidth: number;
  29501. /**
  29502. * Defines edge color used when edgesRenderer is enabled
  29503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29504. */
  29505. edgesColor: Color4;
  29506. /** @hidden */
  29507. _edgesRenderer: Nullable<IEdgesRenderer>;
  29508. /** @hidden */
  29509. _masterMesh: Nullable<AbstractMesh>;
  29510. /** @hidden */
  29511. _boundingInfo: Nullable<BoundingInfo>;
  29512. /** @hidden */
  29513. _renderId: number;
  29514. /**
  29515. * Gets or sets the list of subMeshes
  29516. * @see http://doc.babylonjs.com/how_to/multi_materials
  29517. */
  29518. subMeshes: SubMesh[];
  29519. /** @hidden */
  29520. _intersectionsInProgress: AbstractMesh[];
  29521. /** @hidden */
  29522. _unIndexed: boolean;
  29523. /** @hidden */
  29524. _lightSources: Light[];
  29525. /** Gets the list of lights affecting that mesh */
  29526. get lightSources(): Light[];
  29527. /** @hidden */
  29528. get _positions(): Nullable<Vector3[]>;
  29529. /** @hidden */
  29530. _waitingData: {
  29531. lods: Nullable<any>;
  29532. actions: Nullable<any>;
  29533. freezeWorldMatrix: Nullable<boolean>;
  29534. };
  29535. /** @hidden */
  29536. _bonesTransformMatrices: Nullable<Float32Array>;
  29537. /** @hidden */
  29538. _transformMatrixTexture: Nullable<RawTexture>;
  29539. /**
  29540. * Gets or sets a skeleton to apply skining transformations
  29541. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29542. */
  29543. set skeleton(value: Nullable<Skeleton>);
  29544. get skeleton(): Nullable<Skeleton>;
  29545. /**
  29546. * An event triggered when the mesh is rebuilt.
  29547. */
  29548. onRebuildObservable: Observable<AbstractMesh>;
  29549. /**
  29550. * Creates a new AbstractMesh
  29551. * @param name defines the name of the mesh
  29552. * @param scene defines the hosting scene
  29553. */
  29554. constructor(name: string, scene?: Nullable<Scene>);
  29555. /**
  29556. * Returns the string "AbstractMesh"
  29557. * @returns "AbstractMesh"
  29558. */
  29559. getClassName(): string;
  29560. /**
  29561. * Gets a string representation of the current mesh
  29562. * @param fullDetails defines a boolean indicating if full details must be included
  29563. * @returns a string representation of the current mesh
  29564. */
  29565. toString(fullDetails?: boolean): string;
  29566. /**
  29567. * @hidden
  29568. */
  29569. protected _getEffectiveParent(): Nullable<Node>;
  29570. /** @hidden */
  29571. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29572. /** @hidden */
  29573. _rebuild(): void;
  29574. /** @hidden */
  29575. _resyncLightSources(): void;
  29576. /** @hidden */
  29577. _resyncLightSource(light: Light): void;
  29578. /** @hidden */
  29579. _unBindEffect(): void;
  29580. /** @hidden */
  29581. _removeLightSource(light: Light, dispose: boolean): void;
  29582. private _markSubMeshesAsDirty;
  29583. /** @hidden */
  29584. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29585. /** @hidden */
  29586. _markSubMeshesAsAttributesDirty(): void;
  29587. /** @hidden */
  29588. _markSubMeshesAsMiscDirty(): void;
  29589. /**
  29590. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29591. */
  29592. get scaling(): Vector3;
  29593. set scaling(newScaling: Vector3);
  29594. /**
  29595. * Returns true if the mesh is blocked. Implemented by child classes
  29596. */
  29597. get isBlocked(): boolean;
  29598. /**
  29599. * Returns the mesh itself by default. Implemented by child classes
  29600. * @param camera defines the camera to use to pick the right LOD level
  29601. * @returns the currentAbstractMesh
  29602. */
  29603. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29604. /**
  29605. * Returns 0 by default. Implemented by child classes
  29606. * @returns an integer
  29607. */
  29608. getTotalVertices(): number;
  29609. /**
  29610. * Returns a positive integer : the total number of indices in this mesh geometry.
  29611. * @returns the numner of indices or zero if the mesh has no geometry.
  29612. */
  29613. getTotalIndices(): number;
  29614. /**
  29615. * Returns null by default. Implemented by child classes
  29616. * @returns null
  29617. */
  29618. getIndices(): Nullable<IndicesArray>;
  29619. /**
  29620. * Returns the array of the requested vertex data kind. Implemented by child classes
  29621. * @param kind defines the vertex data kind to use
  29622. * @returns null
  29623. */
  29624. getVerticesData(kind: string): Nullable<FloatArray>;
  29625. /**
  29626. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29627. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29628. * Note that a new underlying VertexBuffer object is created each call.
  29629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29630. * @param kind defines vertex data kind:
  29631. * * VertexBuffer.PositionKind
  29632. * * VertexBuffer.UVKind
  29633. * * VertexBuffer.UV2Kind
  29634. * * VertexBuffer.UV3Kind
  29635. * * VertexBuffer.UV4Kind
  29636. * * VertexBuffer.UV5Kind
  29637. * * VertexBuffer.UV6Kind
  29638. * * VertexBuffer.ColorKind
  29639. * * VertexBuffer.MatricesIndicesKind
  29640. * * VertexBuffer.MatricesIndicesExtraKind
  29641. * * VertexBuffer.MatricesWeightsKind
  29642. * * VertexBuffer.MatricesWeightsExtraKind
  29643. * @param data defines the data source
  29644. * @param updatable defines if the data must be flagged as updatable (or static)
  29645. * @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
  29646. * @returns the current mesh
  29647. */
  29648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29649. /**
  29650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29651. * If the mesh has no geometry, it is simply returned as it is.
  29652. * @param kind defines vertex data kind:
  29653. * * VertexBuffer.PositionKind
  29654. * * VertexBuffer.UVKind
  29655. * * VertexBuffer.UV2Kind
  29656. * * VertexBuffer.UV3Kind
  29657. * * VertexBuffer.UV4Kind
  29658. * * VertexBuffer.UV5Kind
  29659. * * VertexBuffer.UV6Kind
  29660. * * VertexBuffer.ColorKind
  29661. * * VertexBuffer.MatricesIndicesKind
  29662. * * VertexBuffer.MatricesIndicesExtraKind
  29663. * * VertexBuffer.MatricesWeightsKind
  29664. * * VertexBuffer.MatricesWeightsExtraKind
  29665. * @param data defines the data source
  29666. * @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
  29667. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29668. * @returns the current mesh
  29669. */
  29670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29671. /**
  29672. * Sets the mesh indices,
  29673. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29674. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29675. * @param totalVertices Defines the total number of vertices
  29676. * @returns the current mesh
  29677. */
  29678. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29679. /**
  29680. * Gets a boolean indicating if specific vertex data is present
  29681. * @param kind defines the vertex data kind to use
  29682. * @returns true is data kind is present
  29683. */
  29684. isVerticesDataPresent(kind: string): boolean;
  29685. /**
  29686. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29687. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29688. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29689. * @returns a BoundingInfo
  29690. */
  29691. getBoundingInfo(): BoundingInfo;
  29692. /**
  29693. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29694. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29695. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29696. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29697. * @returns the current mesh
  29698. */
  29699. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29700. /**
  29701. * Overwrite the current bounding info
  29702. * @param boundingInfo defines the new bounding info
  29703. * @returns the current mesh
  29704. */
  29705. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29706. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29707. get useBones(): boolean;
  29708. /** @hidden */
  29709. _preActivate(): void;
  29710. /** @hidden */
  29711. _preActivateForIntermediateRendering(renderId: number): void;
  29712. /** @hidden */
  29713. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29714. /** @hidden */
  29715. _postActivate(): void;
  29716. /** @hidden */
  29717. _freeze(): void;
  29718. /** @hidden */
  29719. _unFreeze(): void;
  29720. /**
  29721. * Gets the current world matrix
  29722. * @returns a Matrix
  29723. */
  29724. getWorldMatrix(): Matrix;
  29725. /** @hidden */
  29726. _getWorldMatrixDeterminant(): number;
  29727. /**
  29728. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29729. */
  29730. get isAnInstance(): boolean;
  29731. /**
  29732. * Gets a boolean indicating if this mesh has instances
  29733. */
  29734. get hasInstances(): boolean;
  29735. /**
  29736. * Perform relative position change from the point of view of behind the front of the mesh.
  29737. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29738. * Supports definition of mesh facing forward or backward
  29739. * @param amountRight defines the distance on the right axis
  29740. * @param amountUp defines the distance on the up axis
  29741. * @param amountForward defines the distance on the forward axis
  29742. * @returns the current mesh
  29743. */
  29744. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29745. /**
  29746. * Calculate relative position change from the point of view of behind the front of the mesh.
  29747. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29748. * Supports definition of mesh facing forward or backward
  29749. * @param amountRight defines the distance on the right axis
  29750. * @param amountUp defines the distance on the up axis
  29751. * @param amountForward defines the distance on the forward axis
  29752. * @returns the new displacement vector
  29753. */
  29754. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29755. /**
  29756. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29757. * Supports definition of mesh facing forward or backward
  29758. * @param flipBack defines the flip
  29759. * @param twirlClockwise defines the twirl
  29760. * @param tiltRight defines the tilt
  29761. * @returns the current mesh
  29762. */
  29763. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29764. /**
  29765. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29766. * Supports definition of mesh facing forward or backward.
  29767. * @param flipBack defines the flip
  29768. * @param twirlClockwise defines the twirl
  29769. * @param tiltRight defines the tilt
  29770. * @returns the new rotation vector
  29771. */
  29772. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29773. /**
  29774. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29775. * This means the mesh underlying bounding box and sphere are recomputed.
  29776. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29777. * @returns the current mesh
  29778. */
  29779. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29780. /** @hidden */
  29781. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29782. /** @hidden */
  29783. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29784. /** @hidden */
  29785. _updateBoundingInfo(): AbstractMesh;
  29786. /** @hidden */
  29787. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29788. /** @hidden */
  29789. protected _afterComputeWorldMatrix(): void;
  29790. /** @hidden */
  29791. get _effectiveMesh(): AbstractMesh;
  29792. /**
  29793. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29794. * A mesh is in the frustum if its bounding box intersects the frustum
  29795. * @param frustumPlanes defines the frustum to test
  29796. * @returns true if the mesh is in the frustum planes
  29797. */
  29798. isInFrustum(frustumPlanes: Plane[]): boolean;
  29799. /**
  29800. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29801. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29802. * @param frustumPlanes defines the frustum to test
  29803. * @returns true if the mesh is completely in the frustum planes
  29804. */
  29805. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29806. /**
  29807. * True if the mesh intersects another mesh or a SolidParticle object
  29808. * @param mesh defines a target mesh or SolidParticle to test
  29809. * @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)
  29810. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29811. * @returns true if there is an intersection
  29812. */
  29813. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29814. /**
  29815. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29816. * @param point defines the point to test
  29817. * @returns true if there is an intersection
  29818. */
  29819. intersectsPoint(point: Vector3): boolean;
  29820. /**
  29821. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29823. */
  29824. get checkCollisions(): boolean;
  29825. set checkCollisions(collisionEnabled: boolean);
  29826. /**
  29827. * Gets Collider object used to compute collisions (not physics)
  29828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29829. */
  29830. get collider(): Nullable<Collider>;
  29831. /**
  29832. * Move the mesh using collision engine
  29833. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29834. * @param displacement defines the requested displacement vector
  29835. * @returns the current mesh
  29836. */
  29837. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29838. private _onCollisionPositionChange;
  29839. /** @hidden */
  29840. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29841. /** @hidden */
  29842. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29843. /** @hidden */
  29844. _checkCollision(collider: Collider): AbstractMesh;
  29845. /** @hidden */
  29846. _generatePointsArray(): boolean;
  29847. /**
  29848. * Checks if the passed Ray intersects with the mesh
  29849. * @param ray defines the ray to use
  29850. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29851. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29852. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29853. * @returns the picking info
  29854. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29855. */
  29856. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29857. /**
  29858. * Clones the current mesh
  29859. * @param name defines the mesh name
  29860. * @param newParent defines the new mesh parent
  29861. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29862. * @returns the new mesh
  29863. */
  29864. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29865. /**
  29866. * Disposes all the submeshes of the current meshnp
  29867. * @returns the current mesh
  29868. */
  29869. releaseSubMeshes(): AbstractMesh;
  29870. /**
  29871. * Releases resources associated with this abstract mesh.
  29872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29874. */
  29875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29876. /**
  29877. * Adds the passed mesh as a child to the current mesh
  29878. * @param mesh defines the child mesh
  29879. * @returns the current mesh
  29880. */
  29881. addChild(mesh: AbstractMesh): AbstractMesh;
  29882. /**
  29883. * Removes the passed mesh from the current mesh children list
  29884. * @param mesh defines the child mesh
  29885. * @returns the current mesh
  29886. */
  29887. removeChild(mesh: AbstractMesh): AbstractMesh;
  29888. /** @hidden */
  29889. private _initFacetData;
  29890. /**
  29891. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29892. * This method can be called within the render loop.
  29893. * 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
  29894. * @returns the current mesh
  29895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29896. */
  29897. updateFacetData(): AbstractMesh;
  29898. /**
  29899. * Returns the facetLocalNormals array.
  29900. * The normals are expressed in the mesh local spac
  29901. * @returns an array of Vector3
  29902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29903. */
  29904. getFacetLocalNormals(): Vector3[];
  29905. /**
  29906. * Returns the facetLocalPositions array.
  29907. * The facet positions are expressed in the mesh local space
  29908. * @returns an array of Vector3
  29909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29910. */
  29911. getFacetLocalPositions(): Vector3[];
  29912. /**
  29913. * Returns the facetLocalPartioning array
  29914. * @returns an array of array of numbers
  29915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29916. */
  29917. getFacetLocalPartitioning(): number[][];
  29918. /**
  29919. * Returns the i-th facet position in the world system.
  29920. * This method allocates a new Vector3 per call
  29921. * @param i defines the facet index
  29922. * @returns a new Vector3
  29923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29924. */
  29925. getFacetPosition(i: number): Vector3;
  29926. /**
  29927. * Sets the reference Vector3 with the i-th facet position in the world system
  29928. * @param i defines the facet index
  29929. * @param ref defines the target vector
  29930. * @returns the current mesh
  29931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29932. */
  29933. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29934. /**
  29935. * Returns the i-th facet normal in the world system.
  29936. * This method allocates a new Vector3 per call
  29937. * @param i defines the facet index
  29938. * @returns a new Vector3
  29939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29940. */
  29941. getFacetNormal(i: number): Vector3;
  29942. /**
  29943. * Sets the reference Vector3 with the i-th facet normal in the world system
  29944. * @param i defines the facet index
  29945. * @param ref defines the target vector
  29946. * @returns the current mesh
  29947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29948. */
  29949. getFacetNormalToRef(i: number, ref: Vector3): this;
  29950. /**
  29951. * 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)
  29952. * @param x defines x coordinate
  29953. * @param y defines y coordinate
  29954. * @param z defines z coordinate
  29955. * @returns the array of facet indexes
  29956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29957. */
  29958. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29959. /**
  29960. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29961. * @param projected sets as the (x,y,z) world projection on the facet
  29962. * @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
  29963. * @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
  29964. * @param x defines x coordinate
  29965. * @param y defines y coordinate
  29966. * @param z defines z coordinate
  29967. * @returns the face index if found (or null instead)
  29968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29969. */
  29970. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29971. /**
  29972. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29973. * @param projected sets as the (x,y,z) local projection on the facet
  29974. * @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
  29975. * @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
  29976. * @param x defines x coordinate
  29977. * @param y defines y coordinate
  29978. * @param z defines z coordinate
  29979. * @returns the face index if found (or null instead)
  29980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29981. */
  29982. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29983. /**
  29984. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29985. * @returns the parameters
  29986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29987. */
  29988. getFacetDataParameters(): any;
  29989. /**
  29990. * Disables the feature FacetData and frees the related memory
  29991. * @returns the current mesh
  29992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29993. */
  29994. disableFacetData(): AbstractMesh;
  29995. /**
  29996. * Updates the AbstractMesh indices array
  29997. * @param indices defines the data source
  29998. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29999. * @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)
  30000. * @returns the current mesh
  30001. */
  30002. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  30003. /**
  30004. * Creates new normals data for the mesh
  30005. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30006. * @returns the current mesh
  30007. */
  30008. createNormals(updatable: boolean): AbstractMesh;
  30009. /**
  30010. * Align the mesh with a normal
  30011. * @param normal defines the normal to use
  30012. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30013. * @returns the current mesh
  30014. */
  30015. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30016. /** @hidden */
  30017. _checkOcclusionQuery(): boolean;
  30018. /**
  30019. * Disables the mesh edge rendering mode
  30020. * @returns the currentAbstractMesh
  30021. */
  30022. disableEdgesRendering(): AbstractMesh;
  30023. /**
  30024. * Enables the edge rendering mode on the mesh.
  30025. * This mode makes the mesh edges visible
  30026. * @param epsilon defines the maximal distance between two angles to detect a face
  30027. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30028. * @returns the currentAbstractMesh
  30029. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30030. */
  30031. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30032. }
  30033. }
  30034. declare module "babylonjs/Actions/actionEvent" {
  30035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30036. import { Nullable } from "babylonjs/types";
  30037. import { Sprite } from "babylonjs/Sprites/sprite";
  30038. import { Scene } from "babylonjs/scene";
  30039. import { Vector2 } from "babylonjs/Maths/math.vector";
  30040. /**
  30041. * Interface used to define ActionEvent
  30042. */
  30043. export interface IActionEvent {
  30044. /** The mesh or sprite that triggered the action */
  30045. source: any;
  30046. /** The X mouse cursor position at the time of the event */
  30047. pointerX: number;
  30048. /** The Y mouse cursor position at the time of the event */
  30049. pointerY: number;
  30050. /** The mesh that is currently pointed at (can be null) */
  30051. meshUnderPointer: Nullable<AbstractMesh>;
  30052. /** the original (browser) event that triggered the ActionEvent */
  30053. sourceEvent?: any;
  30054. /** additional data for the event */
  30055. additionalData?: any;
  30056. }
  30057. /**
  30058. * ActionEvent is the event being sent when an action is triggered.
  30059. */
  30060. export class ActionEvent implements IActionEvent {
  30061. /** The mesh or sprite that triggered the action */
  30062. source: any;
  30063. /** The X mouse cursor position at the time of the event */
  30064. pointerX: number;
  30065. /** The Y mouse cursor position at the time of the event */
  30066. pointerY: number;
  30067. /** The mesh that is currently pointed at (can be null) */
  30068. meshUnderPointer: Nullable<AbstractMesh>;
  30069. /** the original (browser) event that triggered the ActionEvent */
  30070. sourceEvent?: any;
  30071. /** additional data for the event */
  30072. additionalData?: any;
  30073. /**
  30074. * Creates a new ActionEvent
  30075. * @param source The mesh or sprite that triggered the action
  30076. * @param pointerX The X mouse cursor position at the time of the event
  30077. * @param pointerY The Y mouse cursor position at the time of the event
  30078. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30079. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30080. * @param additionalData additional data for the event
  30081. */
  30082. constructor(
  30083. /** The mesh or sprite that triggered the action */
  30084. source: any,
  30085. /** The X mouse cursor position at the time of the event */
  30086. pointerX: number,
  30087. /** The Y mouse cursor position at the time of the event */
  30088. pointerY: number,
  30089. /** The mesh that is currently pointed at (can be null) */
  30090. meshUnderPointer: Nullable<AbstractMesh>,
  30091. /** the original (browser) event that triggered the ActionEvent */
  30092. sourceEvent?: any,
  30093. /** additional data for the event */
  30094. additionalData?: any);
  30095. /**
  30096. * Helper function to auto-create an ActionEvent from a source mesh.
  30097. * @param source The source mesh that triggered the event
  30098. * @param evt The original (browser) event
  30099. * @param additionalData additional data for the event
  30100. * @returns the new ActionEvent
  30101. */
  30102. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30103. /**
  30104. * Helper function to auto-create an ActionEvent from a source sprite
  30105. * @param source The source sprite that triggered the event
  30106. * @param scene Scene associated with the sprite
  30107. * @param evt The original (browser) event
  30108. * @param additionalData additional data for the event
  30109. * @returns the new ActionEvent
  30110. */
  30111. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30112. /**
  30113. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30114. * @param scene the scene where the event occurred
  30115. * @param evt The original (browser) event
  30116. * @returns the new ActionEvent
  30117. */
  30118. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30119. /**
  30120. * Helper function to auto-create an ActionEvent from a primitive
  30121. * @param prim defines the target primitive
  30122. * @param pointerPos defines the pointer position
  30123. * @param evt The original (browser) event
  30124. * @param additionalData additional data for the event
  30125. * @returns the new ActionEvent
  30126. */
  30127. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30128. }
  30129. }
  30130. declare module "babylonjs/Actions/abstractActionManager" {
  30131. import { IDisposable } from "babylonjs/scene";
  30132. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30133. import { IAction } from "babylonjs/Actions/action";
  30134. import { Nullable } from "babylonjs/types";
  30135. /**
  30136. * Abstract class used to decouple action Manager from scene and meshes.
  30137. * Do not instantiate.
  30138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30139. */
  30140. export abstract class AbstractActionManager implements IDisposable {
  30141. /** Gets the list of active triggers */
  30142. static Triggers: {
  30143. [key: string]: number;
  30144. };
  30145. /** Gets the cursor to use when hovering items */
  30146. hoverCursor: string;
  30147. /** Gets the list of actions */
  30148. actions: IAction[];
  30149. /**
  30150. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30151. */
  30152. isRecursive: boolean;
  30153. /**
  30154. * Releases all associated resources
  30155. */
  30156. abstract dispose(): void;
  30157. /**
  30158. * Does this action manager has pointer triggers
  30159. */
  30160. abstract get hasPointerTriggers(): boolean;
  30161. /**
  30162. * Does this action manager has pick triggers
  30163. */
  30164. abstract get hasPickTriggers(): boolean;
  30165. /**
  30166. * Process a specific trigger
  30167. * @param trigger defines the trigger to process
  30168. * @param evt defines the event details to be processed
  30169. */
  30170. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30171. /**
  30172. * Does this action manager handles actions of any of the given triggers
  30173. * @param triggers defines the triggers to be tested
  30174. * @return a boolean indicating whether one (or more) of the triggers is handled
  30175. */
  30176. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30177. /**
  30178. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30179. * speed.
  30180. * @param triggerA defines the trigger to be tested
  30181. * @param triggerB defines the trigger to be tested
  30182. * @return a boolean indicating whether one (or more) of the triggers is handled
  30183. */
  30184. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30185. /**
  30186. * Does this action manager handles actions of a given trigger
  30187. * @param trigger defines the trigger to be tested
  30188. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30189. * @return whether the trigger is handled
  30190. */
  30191. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30192. /**
  30193. * Serialize this manager to a JSON object
  30194. * @param name defines the property name to store this manager
  30195. * @returns a JSON representation of this manager
  30196. */
  30197. abstract serialize(name: string): any;
  30198. /**
  30199. * Registers an action to this action manager
  30200. * @param action defines the action to be registered
  30201. * @return the action amended (prepared) after registration
  30202. */
  30203. abstract registerAction(action: IAction): Nullable<IAction>;
  30204. /**
  30205. * Unregisters an action to this action manager
  30206. * @param action defines the action to be unregistered
  30207. * @return a boolean indicating whether the action has been unregistered
  30208. */
  30209. abstract unregisterAction(action: IAction): Boolean;
  30210. /**
  30211. * Does exist one action manager with at least one trigger
  30212. **/
  30213. static get HasTriggers(): boolean;
  30214. /**
  30215. * Does exist one action manager with at least one pick trigger
  30216. **/
  30217. static get HasPickTriggers(): boolean;
  30218. /**
  30219. * Does exist one action manager that handles actions of a given trigger
  30220. * @param trigger defines the trigger to be tested
  30221. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30222. **/
  30223. static HasSpecificTrigger(trigger: number): boolean;
  30224. }
  30225. }
  30226. declare module "babylonjs/node" {
  30227. import { Scene } from "babylonjs/scene";
  30228. import { Nullable } from "babylonjs/types";
  30229. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30230. import { Engine } from "babylonjs/Engines/engine";
  30231. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30232. import { Observable } from "babylonjs/Misc/observable";
  30233. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30235. import { Animatable } from "babylonjs/Animations/animatable";
  30236. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30237. import { Animation } from "babylonjs/Animations/animation";
  30238. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30240. /**
  30241. * Defines how a node can be built from a string name.
  30242. */
  30243. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30244. /**
  30245. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30246. */
  30247. export class Node implements IBehaviorAware<Node> {
  30248. /** @hidden */
  30249. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30250. private static _NodeConstructors;
  30251. /**
  30252. * Add a new node constructor
  30253. * @param type defines the type name of the node to construct
  30254. * @param constructorFunc defines the constructor function
  30255. */
  30256. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30257. /**
  30258. * Returns a node constructor based on type name
  30259. * @param type defines the type name
  30260. * @param name defines the new node name
  30261. * @param scene defines the hosting scene
  30262. * @param options defines optional options to transmit to constructors
  30263. * @returns the new constructor or null
  30264. */
  30265. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30266. /**
  30267. * Gets or sets the name of the node
  30268. */
  30269. name: string;
  30270. /**
  30271. * Gets or sets the id of the node
  30272. */
  30273. id: string;
  30274. /**
  30275. * Gets or sets the unique id of the node
  30276. */
  30277. uniqueId: number;
  30278. /**
  30279. * Gets or sets a string used to store user defined state for the node
  30280. */
  30281. state: string;
  30282. /**
  30283. * Gets or sets an object used to store user defined information for the node
  30284. */
  30285. metadata: any;
  30286. /**
  30287. * For internal use only. Please do not use.
  30288. */
  30289. reservedDataStore: any;
  30290. /**
  30291. * List of inspectable custom properties (used by the Inspector)
  30292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30293. */
  30294. inspectableCustomProperties: IInspectable[];
  30295. private _doNotSerialize;
  30296. /**
  30297. * Gets or sets a boolean used to define if the node must be serialized
  30298. */
  30299. get doNotSerialize(): boolean;
  30300. set doNotSerialize(value: boolean);
  30301. /** @hidden */
  30302. _isDisposed: boolean;
  30303. /**
  30304. * Gets a list of Animations associated with the node
  30305. */
  30306. animations: import("babylonjs/Animations/animation").Animation[];
  30307. protected _ranges: {
  30308. [name: string]: Nullable<AnimationRange>;
  30309. };
  30310. /**
  30311. * Callback raised when the node is ready to be used
  30312. */
  30313. onReady: Nullable<(node: Node) => void>;
  30314. private _isEnabled;
  30315. private _isParentEnabled;
  30316. private _isReady;
  30317. /** @hidden */
  30318. _currentRenderId: number;
  30319. private _parentUpdateId;
  30320. /** @hidden */
  30321. _childUpdateId: number;
  30322. /** @hidden */
  30323. _waitingParentId: Nullable<string>;
  30324. /** @hidden */
  30325. _scene: Scene;
  30326. /** @hidden */
  30327. _cache: any;
  30328. private _parentNode;
  30329. private _children;
  30330. /** @hidden */
  30331. _worldMatrix: Matrix;
  30332. /** @hidden */
  30333. _worldMatrixDeterminant: number;
  30334. /** @hidden */
  30335. _worldMatrixDeterminantIsDirty: boolean;
  30336. /** @hidden */
  30337. private _sceneRootNodesIndex;
  30338. /**
  30339. * Gets a boolean indicating if the node has been disposed
  30340. * @returns true if the node was disposed
  30341. */
  30342. isDisposed(): boolean;
  30343. /**
  30344. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30345. * @see https://doc.babylonjs.com/how_to/parenting
  30346. */
  30347. set parent(parent: Nullable<Node>);
  30348. get parent(): Nullable<Node>;
  30349. /** @hidden */
  30350. _addToSceneRootNodes(): void;
  30351. /** @hidden */
  30352. _removeFromSceneRootNodes(): void;
  30353. private _animationPropertiesOverride;
  30354. /**
  30355. * Gets or sets the animation properties override
  30356. */
  30357. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30358. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30359. /**
  30360. * Gets a string idenfifying the name of the class
  30361. * @returns "Node" string
  30362. */
  30363. getClassName(): string;
  30364. /** @hidden */
  30365. readonly _isNode: boolean;
  30366. /**
  30367. * An event triggered when the mesh is disposed
  30368. */
  30369. onDisposeObservable: Observable<Node>;
  30370. private _onDisposeObserver;
  30371. /**
  30372. * Sets a callback that will be raised when the node will be disposed
  30373. */
  30374. set onDispose(callback: () => void);
  30375. /**
  30376. * Creates a new Node
  30377. * @param name the name and id to be given to this node
  30378. * @param scene the scene this node will be added to
  30379. */
  30380. constructor(name: string, scene?: Nullable<Scene>);
  30381. /**
  30382. * Gets the scene of the node
  30383. * @returns a scene
  30384. */
  30385. getScene(): Scene;
  30386. /**
  30387. * Gets the engine of the node
  30388. * @returns a Engine
  30389. */
  30390. getEngine(): Engine;
  30391. private _behaviors;
  30392. /**
  30393. * Attach a behavior to the node
  30394. * @see http://doc.babylonjs.com/features/behaviour
  30395. * @param behavior defines the behavior to attach
  30396. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30397. * @returns the current Node
  30398. */
  30399. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30400. /**
  30401. * Remove an attached behavior
  30402. * @see http://doc.babylonjs.com/features/behaviour
  30403. * @param behavior defines the behavior to attach
  30404. * @returns the current Node
  30405. */
  30406. removeBehavior(behavior: Behavior<Node>): Node;
  30407. /**
  30408. * Gets the list of attached behaviors
  30409. * @see http://doc.babylonjs.com/features/behaviour
  30410. */
  30411. get behaviors(): Behavior<Node>[];
  30412. /**
  30413. * Gets an attached behavior by name
  30414. * @param name defines the name of the behavior to look for
  30415. * @see http://doc.babylonjs.com/features/behaviour
  30416. * @returns null if behavior was not found else the requested behavior
  30417. */
  30418. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30419. /**
  30420. * Returns the latest update of the World matrix
  30421. * @returns a Matrix
  30422. */
  30423. getWorldMatrix(): Matrix;
  30424. /** @hidden */
  30425. _getWorldMatrixDeterminant(): number;
  30426. /**
  30427. * Returns directly the latest state of the mesh World matrix.
  30428. * A Matrix is returned.
  30429. */
  30430. get worldMatrixFromCache(): Matrix;
  30431. /** @hidden */
  30432. _initCache(): void;
  30433. /** @hidden */
  30434. updateCache(force?: boolean): void;
  30435. /** @hidden */
  30436. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30437. /** @hidden */
  30438. _updateCache(ignoreParentClass?: boolean): void;
  30439. /** @hidden */
  30440. _isSynchronized(): boolean;
  30441. /** @hidden */
  30442. _markSyncedWithParent(): void;
  30443. /** @hidden */
  30444. isSynchronizedWithParent(): boolean;
  30445. /** @hidden */
  30446. isSynchronized(): boolean;
  30447. /**
  30448. * Is this node ready to be used/rendered
  30449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30450. * @return true if the node is ready
  30451. */
  30452. isReady(completeCheck?: boolean): boolean;
  30453. /**
  30454. * Is this node enabled?
  30455. * 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
  30456. * @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
  30457. * @return whether this node (and its parent) is enabled
  30458. */
  30459. isEnabled(checkAncestors?: boolean): boolean;
  30460. /** @hidden */
  30461. protected _syncParentEnabledState(): void;
  30462. /**
  30463. * Set the enabled state of this node
  30464. * @param value defines the new enabled state
  30465. */
  30466. setEnabled(value: boolean): void;
  30467. /**
  30468. * Is this node a descendant of the given node?
  30469. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30470. * @param ancestor defines the parent node to inspect
  30471. * @returns a boolean indicating if this node is a descendant of the given node
  30472. */
  30473. isDescendantOf(ancestor: Node): boolean;
  30474. /** @hidden */
  30475. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30476. /**
  30477. * Will return all nodes that have this node as ascendant
  30478. * @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
  30479. * @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
  30480. * @return all children nodes of all types
  30481. */
  30482. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30483. /**
  30484. * Get all child-meshes of this node
  30485. * @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)
  30486. * @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
  30487. * @returns an array of AbstractMesh
  30488. */
  30489. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30490. /**
  30491. * Get all direct children of this node
  30492. * @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
  30493. * @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)
  30494. * @returns an array of Node
  30495. */
  30496. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30497. /** @hidden */
  30498. _setReady(state: boolean): void;
  30499. /**
  30500. * Get an animation by name
  30501. * @param name defines the name of the animation to look for
  30502. * @returns null if not found else the requested animation
  30503. */
  30504. getAnimationByName(name: string): Nullable<Animation>;
  30505. /**
  30506. * Creates an animation range for this node
  30507. * @param name defines the name of the range
  30508. * @param from defines the starting key
  30509. * @param to defines the end key
  30510. */
  30511. createAnimationRange(name: string, from: number, to: number): void;
  30512. /**
  30513. * Delete a specific animation range
  30514. * @param name defines the name of the range to delete
  30515. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30516. */
  30517. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30518. /**
  30519. * Get an animation range by name
  30520. * @param name defines the name of the animation range to look for
  30521. * @returns null if not found else the requested animation range
  30522. */
  30523. getAnimationRange(name: string): Nullable<AnimationRange>;
  30524. /**
  30525. * Gets the list of all animation ranges defined on this node
  30526. * @returns an array
  30527. */
  30528. getAnimationRanges(): Nullable<AnimationRange>[];
  30529. /**
  30530. * Will start the animation sequence
  30531. * @param name defines the range frames for animation sequence
  30532. * @param loop defines if the animation should loop (false by default)
  30533. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30534. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30535. * @returns the object created for this animation. If range does not exist, it will return null
  30536. */
  30537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30538. /**
  30539. * Serialize animation ranges into a JSON compatible object
  30540. * @returns serialization object
  30541. */
  30542. serializeAnimationRanges(): any;
  30543. /**
  30544. * Computes the world matrix of the node
  30545. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30546. * @returns the world matrix
  30547. */
  30548. computeWorldMatrix(force?: boolean): Matrix;
  30549. /**
  30550. * Releases resources associated with this node.
  30551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30553. */
  30554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30555. /**
  30556. * Parse animation range data from a serialization object and store them into a given node
  30557. * @param node defines where to store the animation ranges
  30558. * @param parsedNode defines the serialization object to read data from
  30559. * @param scene defines the hosting scene
  30560. */
  30561. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30562. /**
  30563. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30564. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30565. * @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
  30566. * @returns the new bounding vectors
  30567. */
  30568. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30569. min: Vector3;
  30570. max: Vector3;
  30571. };
  30572. }
  30573. }
  30574. declare module "babylonjs/Animations/animation" {
  30575. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30576. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30577. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30578. import { Nullable } from "babylonjs/types";
  30579. import { Scene } from "babylonjs/scene";
  30580. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30581. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30582. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30583. import { Node } from "babylonjs/node";
  30584. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30585. import { Size } from "babylonjs/Maths/math.size";
  30586. import { Animatable } from "babylonjs/Animations/animatable";
  30587. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30588. /**
  30589. * @hidden
  30590. */
  30591. export class _IAnimationState {
  30592. key: number;
  30593. repeatCount: number;
  30594. workValue?: any;
  30595. loopMode?: number;
  30596. offsetValue?: any;
  30597. highLimitValue?: any;
  30598. }
  30599. /**
  30600. * Class used to store any kind of animation
  30601. */
  30602. export class Animation {
  30603. /**Name of the animation */
  30604. name: string;
  30605. /**Property to animate */
  30606. targetProperty: string;
  30607. /**The frames per second of the animation */
  30608. framePerSecond: number;
  30609. /**The data type of the animation */
  30610. dataType: number;
  30611. /**The loop mode of the animation */
  30612. loopMode?: number | undefined;
  30613. /**Specifies if blending should be enabled */
  30614. enableBlending?: boolean | undefined;
  30615. /**
  30616. * Use matrix interpolation instead of using direct key value when animating matrices
  30617. */
  30618. static AllowMatricesInterpolation: boolean;
  30619. /**
  30620. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30621. */
  30622. static AllowMatrixDecomposeForInterpolation: boolean;
  30623. /**
  30624. * Stores the key frames of the animation
  30625. */
  30626. private _keys;
  30627. /**
  30628. * Stores the easing function of the animation
  30629. */
  30630. private _easingFunction;
  30631. /**
  30632. * @hidden Internal use only
  30633. */
  30634. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30635. /**
  30636. * The set of event that will be linked to this animation
  30637. */
  30638. private _events;
  30639. /**
  30640. * Stores an array of target property paths
  30641. */
  30642. targetPropertyPath: string[];
  30643. /**
  30644. * Stores the blending speed of the animation
  30645. */
  30646. blendingSpeed: number;
  30647. /**
  30648. * Stores the animation ranges for the animation
  30649. */
  30650. private _ranges;
  30651. /**
  30652. * @hidden Internal use
  30653. */
  30654. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30655. /**
  30656. * Sets up an animation
  30657. * @param property The property to animate
  30658. * @param animationType The animation type to apply
  30659. * @param framePerSecond The frames per second of the animation
  30660. * @param easingFunction The easing function used in the animation
  30661. * @returns The created animation
  30662. */
  30663. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30664. /**
  30665. * Create and start an animation on a node
  30666. * @param name defines the name of the global animation that will be run on all nodes
  30667. * @param node defines the root node where the animation will take place
  30668. * @param targetProperty defines property to animate
  30669. * @param framePerSecond defines the number of frame per second yo use
  30670. * @param totalFrame defines the number of frames in total
  30671. * @param from defines the initial value
  30672. * @param to defines the final value
  30673. * @param loopMode defines which loop mode you want to use (off by default)
  30674. * @param easingFunction defines the easing function to use (linear by default)
  30675. * @param onAnimationEnd defines the callback to call when animation end
  30676. * @returns the animatable created for this animation
  30677. */
  30678. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30679. /**
  30680. * Create and start an animation on a node and its descendants
  30681. * @param name defines the name of the global animation that will be run on all nodes
  30682. * @param node defines the root node where the animation will take place
  30683. * @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
  30684. * @param targetProperty defines property to animate
  30685. * @param framePerSecond defines the number of frame per second to use
  30686. * @param totalFrame defines the number of frames in total
  30687. * @param from defines the initial value
  30688. * @param to defines the final value
  30689. * @param loopMode defines which loop mode you want to use (off by default)
  30690. * @param easingFunction defines the easing function to use (linear by default)
  30691. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30692. * @returns the list of animatables created for all nodes
  30693. * @example https://www.babylonjs-playground.com/#MH0VLI
  30694. */
  30695. 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[]>;
  30696. /**
  30697. * Creates a new animation, merges it with the existing animations and starts it
  30698. * @param name Name of the animation
  30699. * @param node Node which contains the scene that begins the animations
  30700. * @param targetProperty Specifies which property to animate
  30701. * @param framePerSecond The frames per second of the animation
  30702. * @param totalFrame The total number of frames
  30703. * @param from The frame at the beginning of the animation
  30704. * @param to The frame at the end of the animation
  30705. * @param loopMode Specifies the loop mode of the animation
  30706. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30707. * @param onAnimationEnd Callback to run once the animation is complete
  30708. * @returns Nullable animation
  30709. */
  30710. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30711. /**
  30712. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30713. * @param sourceAnimation defines the Animation containing keyframes to convert
  30714. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30715. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30716. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30717. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30718. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30719. */
  30720. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30721. /**
  30722. * Transition property of an host to the target Value
  30723. * @param property The property to transition
  30724. * @param targetValue The target Value of the property
  30725. * @param host The object where the property to animate belongs
  30726. * @param scene Scene used to run the animation
  30727. * @param frameRate Framerate (in frame/s) to use
  30728. * @param transition The transition type we want to use
  30729. * @param duration The duration of the animation, in milliseconds
  30730. * @param onAnimationEnd Callback trigger at the end of the animation
  30731. * @returns Nullable animation
  30732. */
  30733. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30734. /**
  30735. * Return the array of runtime animations currently using this animation
  30736. */
  30737. get runtimeAnimations(): RuntimeAnimation[];
  30738. /**
  30739. * Specifies if any of the runtime animations are currently running
  30740. */
  30741. get hasRunningRuntimeAnimations(): boolean;
  30742. /**
  30743. * Initializes the animation
  30744. * @param name Name of the animation
  30745. * @param targetProperty Property to animate
  30746. * @param framePerSecond The frames per second of the animation
  30747. * @param dataType The data type of the animation
  30748. * @param loopMode The loop mode of the animation
  30749. * @param enableBlending Specifies if blending should be enabled
  30750. */
  30751. constructor(
  30752. /**Name of the animation */
  30753. name: string,
  30754. /**Property to animate */
  30755. targetProperty: string,
  30756. /**The frames per second of the animation */
  30757. framePerSecond: number,
  30758. /**The data type of the animation */
  30759. dataType: number,
  30760. /**The loop mode of the animation */
  30761. loopMode?: number | undefined,
  30762. /**Specifies if blending should be enabled */
  30763. enableBlending?: boolean | undefined);
  30764. /**
  30765. * Converts the animation to a string
  30766. * @param fullDetails support for multiple levels of logging within scene loading
  30767. * @returns String form of the animation
  30768. */
  30769. toString(fullDetails?: boolean): string;
  30770. /**
  30771. * Add an event to this animation
  30772. * @param event Event to add
  30773. */
  30774. addEvent(event: AnimationEvent): void;
  30775. /**
  30776. * Remove all events found at the given frame
  30777. * @param frame The frame to remove events from
  30778. */
  30779. removeEvents(frame: number): void;
  30780. /**
  30781. * Retrieves all the events from the animation
  30782. * @returns Events from the animation
  30783. */
  30784. getEvents(): AnimationEvent[];
  30785. /**
  30786. * Creates an animation range
  30787. * @param name Name of the animation range
  30788. * @param from Starting frame of the animation range
  30789. * @param to Ending frame of the animation
  30790. */
  30791. createRange(name: string, from: number, to: number): void;
  30792. /**
  30793. * Deletes an animation range by name
  30794. * @param name Name of the animation range to delete
  30795. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30796. */
  30797. deleteRange(name: string, deleteFrames?: boolean): void;
  30798. /**
  30799. * Gets the animation range by name, or null if not defined
  30800. * @param name Name of the animation range
  30801. * @returns Nullable animation range
  30802. */
  30803. getRange(name: string): Nullable<AnimationRange>;
  30804. /**
  30805. * Gets the key frames from the animation
  30806. * @returns The key frames of the animation
  30807. */
  30808. getKeys(): Array<IAnimationKey>;
  30809. /**
  30810. * Gets the highest frame rate of the animation
  30811. * @returns Highest frame rate of the animation
  30812. */
  30813. getHighestFrame(): number;
  30814. /**
  30815. * Gets the easing function of the animation
  30816. * @returns Easing function of the animation
  30817. */
  30818. getEasingFunction(): IEasingFunction;
  30819. /**
  30820. * Sets the easing function of the animation
  30821. * @param easingFunction A custom mathematical formula for animation
  30822. */
  30823. setEasingFunction(easingFunction: EasingFunction): void;
  30824. /**
  30825. * Interpolates a scalar linearly
  30826. * @param startValue Start value of the animation curve
  30827. * @param endValue End value of the animation curve
  30828. * @param gradient Scalar amount to interpolate
  30829. * @returns Interpolated scalar value
  30830. */
  30831. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30832. /**
  30833. * Interpolates a scalar cubically
  30834. * @param startValue Start value of the animation curve
  30835. * @param outTangent End tangent of the animation
  30836. * @param endValue End value of the animation curve
  30837. * @param inTangent Start tangent of the animation curve
  30838. * @param gradient Scalar amount to interpolate
  30839. * @returns Interpolated scalar value
  30840. */
  30841. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30842. /**
  30843. * Interpolates a quaternion using a spherical linear interpolation
  30844. * @param startValue Start value of the animation curve
  30845. * @param endValue End value of the animation curve
  30846. * @param gradient Scalar amount to interpolate
  30847. * @returns Interpolated quaternion value
  30848. */
  30849. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30850. /**
  30851. * Interpolates a quaternion cubically
  30852. * @param startValue Start value of the animation curve
  30853. * @param outTangent End tangent of the animation curve
  30854. * @param endValue End value of the animation curve
  30855. * @param inTangent Start tangent of the animation curve
  30856. * @param gradient Scalar amount to interpolate
  30857. * @returns Interpolated quaternion value
  30858. */
  30859. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30860. /**
  30861. * Interpolates a Vector3 linearl
  30862. * @param startValue Start value of the animation curve
  30863. * @param endValue End value of the animation curve
  30864. * @param gradient Scalar amount to interpolate
  30865. * @returns Interpolated scalar value
  30866. */
  30867. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30868. /**
  30869. * Interpolates a Vector3 cubically
  30870. * @param startValue Start value of the animation curve
  30871. * @param outTangent End tangent of the animation
  30872. * @param endValue End value of the animation curve
  30873. * @param inTangent Start tangent of the animation curve
  30874. * @param gradient Scalar amount to interpolate
  30875. * @returns InterpolatedVector3 value
  30876. */
  30877. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30878. /**
  30879. * Interpolates a Vector2 linearly
  30880. * @param startValue Start value of the animation curve
  30881. * @param endValue End value of the animation curve
  30882. * @param gradient Scalar amount to interpolate
  30883. * @returns Interpolated Vector2 value
  30884. */
  30885. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30886. /**
  30887. * Interpolates a Vector2 cubically
  30888. * @param startValue Start value of the animation curve
  30889. * @param outTangent End tangent of the animation
  30890. * @param endValue End value of the animation curve
  30891. * @param inTangent Start tangent of the animation curve
  30892. * @param gradient Scalar amount to interpolate
  30893. * @returns Interpolated Vector2 value
  30894. */
  30895. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30896. /**
  30897. * Interpolates a size linearly
  30898. * @param startValue Start value of the animation curve
  30899. * @param endValue End value of the animation curve
  30900. * @param gradient Scalar amount to interpolate
  30901. * @returns Interpolated Size value
  30902. */
  30903. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30904. /**
  30905. * Interpolates a Color3 linearly
  30906. * @param startValue Start value of the animation curve
  30907. * @param endValue End value of the animation curve
  30908. * @param gradient Scalar amount to interpolate
  30909. * @returns Interpolated Color3 value
  30910. */
  30911. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30912. /**
  30913. * Interpolates a Color4 linearly
  30914. * @param startValue Start value of the animation curve
  30915. * @param endValue End value of the animation curve
  30916. * @param gradient Scalar amount to interpolate
  30917. * @returns Interpolated Color3 value
  30918. */
  30919. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30920. /**
  30921. * @hidden Internal use only
  30922. */
  30923. _getKeyValue(value: any): any;
  30924. /**
  30925. * @hidden Internal use only
  30926. */
  30927. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30928. /**
  30929. * Defines the function to use to interpolate matrices
  30930. * @param startValue defines the start matrix
  30931. * @param endValue defines the end matrix
  30932. * @param gradient defines the gradient between both matrices
  30933. * @param result defines an optional target matrix where to store the interpolation
  30934. * @returns the interpolated matrix
  30935. */
  30936. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30937. /**
  30938. * Makes a copy of the animation
  30939. * @returns Cloned animation
  30940. */
  30941. clone(): Animation;
  30942. /**
  30943. * Sets the key frames of the animation
  30944. * @param values The animation key frames to set
  30945. */
  30946. setKeys(values: Array<IAnimationKey>): void;
  30947. /**
  30948. * Serializes the animation to an object
  30949. * @returns Serialized object
  30950. */
  30951. serialize(): any;
  30952. /**
  30953. * Float animation type
  30954. */
  30955. static readonly ANIMATIONTYPE_FLOAT: number;
  30956. /**
  30957. * Vector3 animation type
  30958. */
  30959. static readonly ANIMATIONTYPE_VECTOR3: number;
  30960. /**
  30961. * Quaternion animation type
  30962. */
  30963. static readonly ANIMATIONTYPE_QUATERNION: number;
  30964. /**
  30965. * Matrix animation type
  30966. */
  30967. static readonly ANIMATIONTYPE_MATRIX: number;
  30968. /**
  30969. * Color3 animation type
  30970. */
  30971. static readonly ANIMATIONTYPE_COLOR3: number;
  30972. /**
  30973. * Color3 animation type
  30974. */
  30975. static readonly ANIMATIONTYPE_COLOR4: number;
  30976. /**
  30977. * Vector2 animation type
  30978. */
  30979. static readonly ANIMATIONTYPE_VECTOR2: number;
  30980. /**
  30981. * Size animation type
  30982. */
  30983. static readonly ANIMATIONTYPE_SIZE: number;
  30984. /**
  30985. * Relative Loop Mode
  30986. */
  30987. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30988. /**
  30989. * Cycle Loop Mode
  30990. */
  30991. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30992. /**
  30993. * Constant Loop Mode
  30994. */
  30995. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30996. /** @hidden */
  30997. static _UniversalLerp(left: any, right: any, amount: number): any;
  30998. /**
  30999. * Parses an animation object and creates an animation
  31000. * @param parsedAnimation Parsed animation object
  31001. * @returns Animation object
  31002. */
  31003. static Parse(parsedAnimation: any): Animation;
  31004. /**
  31005. * Appends the serialized animations from the source animations
  31006. * @param source Source containing the animations
  31007. * @param destination Target to store the animations
  31008. */
  31009. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31010. }
  31011. }
  31012. declare module "babylonjs/Animations/animatable.interface" {
  31013. import { Nullable } from "babylonjs/types";
  31014. import { Animation } from "babylonjs/Animations/animation";
  31015. /**
  31016. * Interface containing an array of animations
  31017. */
  31018. export interface IAnimatable {
  31019. /**
  31020. * Array of animations
  31021. */
  31022. animations: Nullable<Array<Animation>>;
  31023. }
  31024. }
  31025. declare module "babylonjs/Misc/decorators" {
  31026. import { Nullable } from "babylonjs/types";
  31027. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31028. import { Scene } from "babylonjs/scene";
  31029. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31030. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31031. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31032. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31033. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31034. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31035. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31036. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31037. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31038. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31039. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31040. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31041. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31042. /**
  31043. * Decorator used to define property that can be serialized as reference to a camera
  31044. * @param sourceName defines the name of the property to decorate
  31045. */
  31046. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31047. /**
  31048. * Class used to help serialization objects
  31049. */
  31050. export class SerializationHelper {
  31051. /** @hidden */
  31052. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31053. /** @hidden */
  31054. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31055. /** @hidden */
  31056. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31057. /** @hidden */
  31058. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31059. /**
  31060. * Appends the serialized animations from the source animations
  31061. * @param source Source containing the animations
  31062. * @param destination Target to store the animations
  31063. */
  31064. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31065. /**
  31066. * Static function used to serialized a specific entity
  31067. * @param entity defines the entity to serialize
  31068. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31069. * @returns a JSON compatible object representing the serialization of the entity
  31070. */
  31071. static Serialize<T>(entity: T, serializationObject?: any): any;
  31072. /**
  31073. * Creates a new entity from a serialization data object
  31074. * @param creationFunction defines a function used to instanciated the new entity
  31075. * @param source defines the source serialization data
  31076. * @param scene defines the hosting scene
  31077. * @param rootUrl defines the root url for resources
  31078. * @returns a new entity
  31079. */
  31080. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31081. /**
  31082. * Clones an object
  31083. * @param creationFunction defines the function used to instanciate the new object
  31084. * @param source defines the source object
  31085. * @returns the cloned object
  31086. */
  31087. static Clone<T>(creationFunction: () => T, source: T): T;
  31088. /**
  31089. * Instanciates a new object based on a source one (some data will be shared between both object)
  31090. * @param creationFunction defines the function used to instanciate the new object
  31091. * @param source defines the source object
  31092. * @returns the new object
  31093. */
  31094. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31095. }
  31096. }
  31097. declare module "babylonjs/Materials/Textures/baseTexture" {
  31098. import { Observable } from "babylonjs/Misc/observable";
  31099. import { Nullable } from "babylonjs/types";
  31100. import { Scene } from "babylonjs/scene";
  31101. import { Matrix } from "babylonjs/Maths/math.vector";
  31102. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31103. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31104. import { ISize } from "babylonjs/Maths/math.size";
  31105. import "babylonjs/Misc/fileTools";
  31106. /**
  31107. * Base class of all the textures in babylon.
  31108. * It groups all the common properties the materials, post process, lights... might need
  31109. * in order to make a correct use of the texture.
  31110. */
  31111. export class BaseTexture implements IAnimatable {
  31112. /**
  31113. * Default anisotropic filtering level for the application.
  31114. * It is set to 4 as a good tradeoff between perf and quality.
  31115. */
  31116. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31117. /**
  31118. * Gets or sets the unique id of the texture
  31119. */
  31120. uniqueId: number;
  31121. /**
  31122. * Define the name of the texture.
  31123. */
  31124. name: string;
  31125. /**
  31126. * Gets or sets an object used to store user defined information.
  31127. */
  31128. metadata: any;
  31129. /**
  31130. * For internal use only. Please do not use.
  31131. */
  31132. reservedDataStore: any;
  31133. private _hasAlpha;
  31134. /**
  31135. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31136. */
  31137. set hasAlpha(value: boolean);
  31138. get hasAlpha(): boolean;
  31139. /**
  31140. * Defines if the alpha value should be determined via the rgb values.
  31141. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31142. */
  31143. getAlphaFromRGB: boolean;
  31144. /**
  31145. * Intensity or strength of the texture.
  31146. * It is commonly used by materials to fine tune the intensity of the texture
  31147. */
  31148. level: number;
  31149. /**
  31150. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31151. * This is part of the texture as textures usually maps to one uv set.
  31152. */
  31153. coordinatesIndex: number;
  31154. private _coordinatesMode;
  31155. /**
  31156. * How a texture is mapped.
  31157. *
  31158. * | Value | Type | Description |
  31159. * | ----- | ----------------------------------- | ----------- |
  31160. * | 0 | EXPLICIT_MODE | |
  31161. * | 1 | SPHERICAL_MODE | |
  31162. * | 2 | PLANAR_MODE | |
  31163. * | 3 | CUBIC_MODE | |
  31164. * | 4 | PROJECTION_MODE | |
  31165. * | 5 | SKYBOX_MODE | |
  31166. * | 6 | INVCUBIC_MODE | |
  31167. * | 7 | EQUIRECTANGULAR_MODE | |
  31168. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31169. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31170. */
  31171. set coordinatesMode(value: number);
  31172. get coordinatesMode(): number;
  31173. /**
  31174. * | Value | Type | Description |
  31175. * | ----- | ------------------ | ----------- |
  31176. * | 0 | CLAMP_ADDRESSMODE | |
  31177. * | 1 | WRAP_ADDRESSMODE | |
  31178. * | 2 | MIRROR_ADDRESSMODE | |
  31179. */
  31180. wrapU: number;
  31181. /**
  31182. * | Value | Type | Description |
  31183. * | ----- | ------------------ | ----------- |
  31184. * | 0 | CLAMP_ADDRESSMODE | |
  31185. * | 1 | WRAP_ADDRESSMODE | |
  31186. * | 2 | MIRROR_ADDRESSMODE | |
  31187. */
  31188. wrapV: number;
  31189. /**
  31190. * | Value | Type | Description |
  31191. * | ----- | ------------------ | ----------- |
  31192. * | 0 | CLAMP_ADDRESSMODE | |
  31193. * | 1 | WRAP_ADDRESSMODE | |
  31194. * | 2 | MIRROR_ADDRESSMODE | |
  31195. */
  31196. wrapR: number;
  31197. /**
  31198. * With compliant hardware and browser (supporting anisotropic filtering)
  31199. * this defines the level of anisotropic filtering in the texture.
  31200. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31201. */
  31202. anisotropicFilteringLevel: number;
  31203. /**
  31204. * Define if the texture is a cube texture or if false a 2d texture.
  31205. */
  31206. get isCube(): boolean;
  31207. set isCube(value: boolean);
  31208. /**
  31209. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31210. */
  31211. get is3D(): boolean;
  31212. set is3D(value: boolean);
  31213. /**
  31214. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31215. */
  31216. get is2DArray(): boolean;
  31217. set is2DArray(value: boolean);
  31218. /**
  31219. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31220. * HDR texture are usually stored in linear space.
  31221. * This only impacts the PBR and Background materials
  31222. */
  31223. gammaSpace: boolean;
  31224. /**
  31225. * Gets or sets whether or not the texture contains RGBD data.
  31226. */
  31227. get isRGBD(): boolean;
  31228. set isRGBD(value: boolean);
  31229. /**
  31230. * Is Z inverted in the texture (useful in a cube texture).
  31231. */
  31232. invertZ: boolean;
  31233. /**
  31234. * Are mip maps generated for this texture or not.
  31235. */
  31236. get noMipmap(): boolean;
  31237. /**
  31238. * @hidden
  31239. */
  31240. lodLevelInAlpha: boolean;
  31241. /**
  31242. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31243. */
  31244. get lodGenerationOffset(): number;
  31245. set lodGenerationOffset(value: number);
  31246. /**
  31247. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31248. */
  31249. get lodGenerationScale(): number;
  31250. set lodGenerationScale(value: number);
  31251. /**
  31252. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31253. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31254. * average roughness values.
  31255. */
  31256. get linearSpecularLOD(): boolean;
  31257. set linearSpecularLOD(value: boolean);
  31258. /**
  31259. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31260. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31261. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31262. */
  31263. get irradianceTexture(): Nullable<BaseTexture>;
  31264. set irradianceTexture(value: Nullable<BaseTexture>);
  31265. /**
  31266. * Define if the texture is a render target.
  31267. */
  31268. isRenderTarget: boolean;
  31269. /**
  31270. * Define the unique id of the texture in the scene.
  31271. */
  31272. get uid(): string;
  31273. /**
  31274. * Return a string representation of the texture.
  31275. * @returns the texture as a string
  31276. */
  31277. toString(): string;
  31278. /**
  31279. * Get the class name of the texture.
  31280. * @returns "BaseTexture"
  31281. */
  31282. getClassName(): string;
  31283. /**
  31284. * Define the list of animation attached to the texture.
  31285. */
  31286. animations: import("babylonjs/Animations/animation").Animation[];
  31287. /**
  31288. * An event triggered when the texture is disposed.
  31289. */
  31290. onDisposeObservable: Observable<BaseTexture>;
  31291. private _onDisposeObserver;
  31292. /**
  31293. * Callback triggered when the texture has been disposed.
  31294. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31295. */
  31296. set onDispose(callback: () => void);
  31297. /**
  31298. * Define the current state of the loading sequence when in delayed load mode.
  31299. */
  31300. delayLoadState: number;
  31301. private _scene;
  31302. /** @hidden */
  31303. _texture: Nullable<InternalTexture>;
  31304. private _uid;
  31305. /**
  31306. * Define if the texture is preventinga material to render or not.
  31307. * If not and the texture is not ready, the engine will use a default black texture instead.
  31308. */
  31309. get isBlocking(): boolean;
  31310. /**
  31311. * Instantiates a new BaseTexture.
  31312. * Base class of all the textures in babylon.
  31313. * It groups all the common properties the materials, post process, lights... might need
  31314. * in order to make a correct use of the texture.
  31315. * @param scene Define the scene the texture blongs to
  31316. */
  31317. constructor(scene: Nullable<Scene>);
  31318. /**
  31319. * Get the scene the texture belongs to.
  31320. * @returns the scene or null if undefined
  31321. */
  31322. getScene(): Nullable<Scene>;
  31323. /**
  31324. * Get the texture transform matrix used to offset tile the texture for istance.
  31325. * @returns the transformation matrix
  31326. */
  31327. getTextureMatrix(): Matrix;
  31328. /**
  31329. * Get the texture reflection matrix used to rotate/transform the reflection.
  31330. * @returns the reflection matrix
  31331. */
  31332. getReflectionTextureMatrix(): Matrix;
  31333. /**
  31334. * Get the underlying lower level texture from Babylon.
  31335. * @returns the insternal texture
  31336. */
  31337. getInternalTexture(): Nullable<InternalTexture>;
  31338. /**
  31339. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31340. * @returns true if ready or not blocking
  31341. */
  31342. isReadyOrNotBlocking(): boolean;
  31343. /**
  31344. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31345. * @returns true if fully ready
  31346. */
  31347. isReady(): boolean;
  31348. private _cachedSize;
  31349. /**
  31350. * Get the size of the texture.
  31351. * @returns the texture size.
  31352. */
  31353. getSize(): ISize;
  31354. /**
  31355. * Get the base size of the texture.
  31356. * It can be different from the size if the texture has been resized for POT for instance
  31357. * @returns the base size
  31358. */
  31359. getBaseSize(): ISize;
  31360. /**
  31361. * Update the sampling mode of the texture.
  31362. * Default is Trilinear mode.
  31363. *
  31364. * | Value | Type | Description |
  31365. * | ----- | ------------------ | ----------- |
  31366. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31367. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31368. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31369. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31370. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31371. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31372. * | 7 | NEAREST_LINEAR | |
  31373. * | 8 | NEAREST_NEAREST | |
  31374. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31375. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31376. * | 11 | LINEAR_LINEAR | |
  31377. * | 12 | LINEAR_NEAREST | |
  31378. *
  31379. * > _mag_: magnification filter (close to the viewer)
  31380. * > _min_: minification filter (far from the viewer)
  31381. * > _mip_: filter used between mip map levels
  31382. *@param samplingMode Define the new sampling mode of the texture
  31383. */
  31384. updateSamplingMode(samplingMode: number): void;
  31385. /**
  31386. * Scales the texture if is `canRescale()`
  31387. * @param ratio the resize factor we want to use to rescale
  31388. */
  31389. scale(ratio: number): void;
  31390. /**
  31391. * Get if the texture can rescale.
  31392. */
  31393. get canRescale(): boolean;
  31394. /** @hidden */
  31395. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31396. /** @hidden */
  31397. _rebuild(): void;
  31398. /**
  31399. * Triggers the load sequence in delayed load mode.
  31400. */
  31401. delayLoad(): void;
  31402. /**
  31403. * Clones the texture.
  31404. * @returns the cloned texture
  31405. */
  31406. clone(): Nullable<BaseTexture>;
  31407. /**
  31408. * Get the texture underlying type (INT, FLOAT...)
  31409. */
  31410. get textureType(): number;
  31411. /**
  31412. * Get the texture underlying format (RGB, RGBA...)
  31413. */
  31414. get textureFormat(): number;
  31415. /**
  31416. * Indicates that textures need to be re-calculated for all materials
  31417. */
  31418. protected _markAllSubMeshesAsTexturesDirty(): void;
  31419. /**
  31420. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31421. * This will returns an RGBA array buffer containing either in values (0-255) or
  31422. * float values (0-1) depending of the underlying buffer type.
  31423. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31424. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31425. * @param buffer defines a user defined buffer to fill with data (can be null)
  31426. * @returns The Array buffer containing the pixels data.
  31427. */
  31428. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31429. /**
  31430. * Release and destroy the underlying lower level texture aka internalTexture.
  31431. */
  31432. releaseInternalTexture(): void;
  31433. /** @hidden */
  31434. get _lodTextureHigh(): Nullable<BaseTexture>;
  31435. /** @hidden */
  31436. get _lodTextureMid(): Nullable<BaseTexture>;
  31437. /** @hidden */
  31438. get _lodTextureLow(): Nullable<BaseTexture>;
  31439. /**
  31440. * Dispose the texture and release its associated resources.
  31441. */
  31442. dispose(): void;
  31443. /**
  31444. * Serialize the texture into a JSON representation that can be parsed later on.
  31445. * @returns the JSON representation of the texture
  31446. */
  31447. serialize(): any;
  31448. /**
  31449. * Helper function to be called back once a list of texture contains only ready textures.
  31450. * @param textures Define the list of textures to wait for
  31451. * @param callback Define the callback triggered once the entire list will be ready
  31452. */
  31453. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31454. }
  31455. }
  31456. declare module "babylonjs/Materials/effect" {
  31457. import { Observable } from "babylonjs/Misc/observable";
  31458. import { Nullable } from "babylonjs/types";
  31459. import { IDisposable } from "babylonjs/scene";
  31460. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31461. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31462. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31463. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31464. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31465. import { Engine } from "babylonjs/Engines/engine";
  31466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31468. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31470. /**
  31471. * Options to be used when creating an effect.
  31472. */
  31473. export interface IEffectCreationOptions {
  31474. /**
  31475. * Atrributes that will be used in the shader.
  31476. */
  31477. attributes: string[];
  31478. /**
  31479. * Uniform varible names that will be set in the shader.
  31480. */
  31481. uniformsNames: string[];
  31482. /**
  31483. * Uniform buffer variable names that will be set in the shader.
  31484. */
  31485. uniformBuffersNames: string[];
  31486. /**
  31487. * Sampler texture variable names that will be set in the shader.
  31488. */
  31489. samplers: string[];
  31490. /**
  31491. * Define statements that will be set in the shader.
  31492. */
  31493. defines: any;
  31494. /**
  31495. * Possible fallbacks for this effect to improve performance when needed.
  31496. */
  31497. fallbacks: Nullable<IEffectFallbacks>;
  31498. /**
  31499. * Callback that will be called when the shader is compiled.
  31500. */
  31501. onCompiled: Nullable<(effect: Effect) => void>;
  31502. /**
  31503. * Callback that will be called if an error occurs during shader compilation.
  31504. */
  31505. onError: Nullable<(effect: Effect, errors: string) => void>;
  31506. /**
  31507. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31508. */
  31509. indexParameters?: any;
  31510. /**
  31511. * Max number of lights that can be used in the shader.
  31512. */
  31513. maxSimultaneousLights?: number;
  31514. /**
  31515. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31516. */
  31517. transformFeedbackVaryings?: Nullable<string[]>;
  31518. }
  31519. /**
  31520. * Effect containing vertex and fragment shader that can be executed on an object.
  31521. */
  31522. export class Effect implements IDisposable {
  31523. /**
  31524. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31525. */
  31526. static ShadersRepository: string;
  31527. /**
  31528. * Enable logging of the shader code when a compilation error occurs
  31529. */
  31530. static LogShaderCodeOnCompilationError: boolean;
  31531. /**
  31532. * Name of the effect.
  31533. */
  31534. name: any;
  31535. /**
  31536. * String container all the define statements that should be set on the shader.
  31537. */
  31538. defines: string;
  31539. /**
  31540. * Callback that will be called when the shader is compiled.
  31541. */
  31542. onCompiled: Nullable<(effect: Effect) => void>;
  31543. /**
  31544. * Callback that will be called if an error occurs during shader compilation.
  31545. */
  31546. onError: Nullable<(effect: Effect, errors: string) => void>;
  31547. /**
  31548. * Callback that will be called when effect is bound.
  31549. */
  31550. onBind: Nullable<(effect: Effect) => void>;
  31551. /**
  31552. * Unique ID of the effect.
  31553. */
  31554. uniqueId: number;
  31555. /**
  31556. * Observable that will be called when the shader is compiled.
  31557. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31558. */
  31559. onCompileObservable: Observable<Effect>;
  31560. /**
  31561. * Observable that will be called if an error occurs during shader compilation.
  31562. */
  31563. onErrorObservable: Observable<Effect>;
  31564. /** @hidden */
  31565. _onBindObservable: Nullable<Observable<Effect>>;
  31566. /**
  31567. * @hidden
  31568. * Specifies if the effect was previously ready
  31569. */
  31570. _wasPreviouslyReady: boolean;
  31571. /**
  31572. * Observable that will be called when effect is bound.
  31573. */
  31574. get onBindObservable(): Observable<Effect>;
  31575. /** @hidden */
  31576. _bonesComputationForcedToCPU: boolean;
  31577. private static _uniqueIdSeed;
  31578. private _engine;
  31579. private _uniformBuffersNames;
  31580. private _uniformBuffersNamesList;
  31581. private _uniformsNames;
  31582. private _samplerList;
  31583. private _samplers;
  31584. private _isReady;
  31585. private _compilationError;
  31586. private _allFallbacksProcessed;
  31587. private _attributesNames;
  31588. private _attributes;
  31589. private _attributeLocationByName;
  31590. private _uniforms;
  31591. /**
  31592. * Key for the effect.
  31593. * @hidden
  31594. */
  31595. _key: string;
  31596. private _indexParameters;
  31597. private _fallbacks;
  31598. private _vertexSourceCode;
  31599. private _fragmentSourceCode;
  31600. private _vertexSourceCodeOverride;
  31601. private _fragmentSourceCodeOverride;
  31602. private _transformFeedbackVaryings;
  31603. /**
  31604. * Compiled shader to webGL program.
  31605. * @hidden
  31606. */
  31607. _pipelineContext: Nullable<IPipelineContext>;
  31608. private _valueCache;
  31609. private static _baseCache;
  31610. /**
  31611. * Instantiates an effect.
  31612. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31613. * @param baseName Name of the effect.
  31614. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31615. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31616. * @param samplers List of sampler variables that will be passed to the shader.
  31617. * @param engine Engine to be used to render the effect
  31618. * @param defines Define statements to be added to the shader.
  31619. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31620. * @param onCompiled Callback that will be called when the shader is compiled.
  31621. * @param onError Callback that will be called if an error occurs during shader compilation.
  31622. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31623. */
  31624. 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);
  31625. private _useFinalCode;
  31626. /**
  31627. * Unique key for this effect
  31628. */
  31629. get key(): string;
  31630. /**
  31631. * If the effect has been compiled and prepared.
  31632. * @returns if the effect is compiled and prepared.
  31633. */
  31634. isReady(): boolean;
  31635. private _isReadyInternal;
  31636. /**
  31637. * The engine the effect was initialized with.
  31638. * @returns the engine.
  31639. */
  31640. getEngine(): Engine;
  31641. /**
  31642. * The pipeline context for this effect
  31643. * @returns the associated pipeline context
  31644. */
  31645. getPipelineContext(): Nullable<IPipelineContext>;
  31646. /**
  31647. * The set of names of attribute variables for the shader.
  31648. * @returns An array of attribute names.
  31649. */
  31650. getAttributesNames(): string[];
  31651. /**
  31652. * Returns the attribute at the given index.
  31653. * @param index The index of the attribute.
  31654. * @returns The location of the attribute.
  31655. */
  31656. getAttributeLocation(index: number): number;
  31657. /**
  31658. * Returns the attribute based on the name of the variable.
  31659. * @param name of the attribute to look up.
  31660. * @returns the attribute location.
  31661. */
  31662. getAttributeLocationByName(name: string): number;
  31663. /**
  31664. * The number of attributes.
  31665. * @returns the numnber of attributes.
  31666. */
  31667. getAttributesCount(): number;
  31668. /**
  31669. * Gets the index of a uniform variable.
  31670. * @param uniformName of the uniform to look up.
  31671. * @returns the index.
  31672. */
  31673. getUniformIndex(uniformName: string): number;
  31674. /**
  31675. * Returns the attribute based on the name of the variable.
  31676. * @param uniformName of the uniform to look up.
  31677. * @returns the location of the uniform.
  31678. */
  31679. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31680. /**
  31681. * Returns an array of sampler variable names
  31682. * @returns The array of sampler variable names.
  31683. */
  31684. getSamplers(): string[];
  31685. /**
  31686. * Returns an array of uniform variable names
  31687. * @returns The array of uniform variable names.
  31688. */
  31689. getUniformNames(): string[];
  31690. /**
  31691. * Returns an array of uniform buffer variable names
  31692. * @returns The array of uniform buffer variable names.
  31693. */
  31694. getUniformBuffersNames(): string[];
  31695. /**
  31696. * Returns the index parameters used to create the effect
  31697. * @returns The index parameters object
  31698. */
  31699. getIndexParameters(): any;
  31700. /**
  31701. * The error from the last compilation.
  31702. * @returns the error string.
  31703. */
  31704. getCompilationError(): string;
  31705. /**
  31706. * Gets a boolean indicating that all fallbacks were used during compilation
  31707. * @returns true if all fallbacks were used
  31708. */
  31709. allFallbacksProcessed(): boolean;
  31710. /**
  31711. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31712. * @param func The callback to be used.
  31713. */
  31714. executeWhenCompiled(func: (effect: Effect) => void): void;
  31715. private _checkIsReady;
  31716. private _loadShader;
  31717. /**
  31718. * Gets the vertex shader source code of this effect
  31719. */
  31720. get vertexSourceCode(): string;
  31721. /**
  31722. * Gets the fragment shader source code of this effect
  31723. */
  31724. get fragmentSourceCode(): string;
  31725. /**
  31726. * Recompiles the webGL program
  31727. * @param vertexSourceCode The source code for the vertex shader.
  31728. * @param fragmentSourceCode The source code for the fragment shader.
  31729. * @param onCompiled Callback called when completed.
  31730. * @param onError Callback called on error.
  31731. * @hidden
  31732. */
  31733. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31734. /**
  31735. * Prepares the effect
  31736. * @hidden
  31737. */
  31738. _prepareEffect(): void;
  31739. private _getShaderCodeAndErrorLine;
  31740. private _processCompilationErrors;
  31741. /**
  31742. * Checks if the effect is supported. (Must be called after compilation)
  31743. */
  31744. get isSupported(): boolean;
  31745. /**
  31746. * Binds a texture to the engine to be used as output of the shader.
  31747. * @param channel Name of the output variable.
  31748. * @param texture Texture to bind.
  31749. * @hidden
  31750. */
  31751. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31752. /**
  31753. * Sets a texture on the engine to be used in the shader.
  31754. * @param channel Name of the sampler variable.
  31755. * @param texture Texture to set.
  31756. */
  31757. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31758. /**
  31759. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31760. * @param channel Name of the sampler variable.
  31761. * @param texture Texture to set.
  31762. */
  31763. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31764. /**
  31765. * Sets an array of textures on the engine to be used in the shader.
  31766. * @param channel Name of the variable.
  31767. * @param textures Textures to set.
  31768. */
  31769. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31770. /**
  31771. * 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)
  31772. * @param channel Name of the sampler variable.
  31773. * @param postProcess Post process to get the input texture from.
  31774. */
  31775. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31776. /**
  31777. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31778. * 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)
  31779. * @param channel Name of the sampler variable.
  31780. * @param postProcess Post process to get the output texture from.
  31781. */
  31782. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31783. /** @hidden */
  31784. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31785. /** @hidden */
  31786. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31787. /** @hidden */
  31788. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31789. /** @hidden */
  31790. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31791. /**
  31792. * Binds a buffer to a uniform.
  31793. * @param buffer Buffer to bind.
  31794. * @param name Name of the uniform variable to bind to.
  31795. */
  31796. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31797. /**
  31798. * Binds block to a uniform.
  31799. * @param blockName Name of the block to bind.
  31800. * @param index Index to bind.
  31801. */
  31802. bindUniformBlock(blockName: string, index: number): void;
  31803. /**
  31804. * Sets an interger value on a uniform variable.
  31805. * @param uniformName Name of the variable.
  31806. * @param value Value to be set.
  31807. * @returns this effect.
  31808. */
  31809. setInt(uniformName: string, value: number): Effect;
  31810. /**
  31811. * Sets an int array on a uniform variable.
  31812. * @param uniformName Name of the variable.
  31813. * @param array array to be set.
  31814. * @returns this effect.
  31815. */
  31816. setIntArray(uniformName: string, array: Int32Array): Effect;
  31817. /**
  31818. * 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)
  31819. * @param uniformName Name of the variable.
  31820. * @param array array to be set.
  31821. * @returns this effect.
  31822. */
  31823. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31824. /**
  31825. * 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)
  31826. * @param uniformName Name of the variable.
  31827. * @param array array to be set.
  31828. * @returns this effect.
  31829. */
  31830. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31831. /**
  31832. * 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)
  31833. * @param uniformName Name of the variable.
  31834. * @param array array to be set.
  31835. * @returns this effect.
  31836. */
  31837. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31838. /**
  31839. * Sets an float array on a uniform variable.
  31840. * @param uniformName Name of the variable.
  31841. * @param array array to be set.
  31842. * @returns this effect.
  31843. */
  31844. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31845. /**
  31846. * 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)
  31847. * @param uniformName Name of the variable.
  31848. * @param array array to be set.
  31849. * @returns this effect.
  31850. */
  31851. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31852. /**
  31853. * 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)
  31854. * @param uniformName Name of the variable.
  31855. * @param array array to be set.
  31856. * @returns this effect.
  31857. */
  31858. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31859. /**
  31860. * 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)
  31861. * @param uniformName Name of the variable.
  31862. * @param array array to be set.
  31863. * @returns this effect.
  31864. */
  31865. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31866. /**
  31867. * Sets an array on a uniform variable.
  31868. * @param uniformName Name of the variable.
  31869. * @param array array to be set.
  31870. * @returns this effect.
  31871. */
  31872. setArray(uniformName: string, array: number[]): Effect;
  31873. /**
  31874. * 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)
  31875. * @param uniformName Name of the variable.
  31876. * @param array array to be set.
  31877. * @returns this effect.
  31878. */
  31879. setArray2(uniformName: string, array: number[]): Effect;
  31880. /**
  31881. * 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)
  31882. * @param uniformName Name of the variable.
  31883. * @param array array to be set.
  31884. * @returns this effect.
  31885. */
  31886. setArray3(uniformName: string, array: number[]): Effect;
  31887. /**
  31888. * 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)
  31889. * @param uniformName Name of the variable.
  31890. * @param array array to be set.
  31891. * @returns this effect.
  31892. */
  31893. setArray4(uniformName: string, array: number[]): Effect;
  31894. /**
  31895. * Sets matrices on a uniform variable.
  31896. * @param uniformName Name of the variable.
  31897. * @param matrices matrices to be set.
  31898. * @returns this effect.
  31899. */
  31900. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31901. /**
  31902. * Sets matrix on a uniform variable.
  31903. * @param uniformName Name of the variable.
  31904. * @param matrix matrix to be set.
  31905. * @returns this effect.
  31906. */
  31907. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31908. /**
  31909. * 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)
  31910. * @param uniformName Name of the variable.
  31911. * @param matrix matrix to be set.
  31912. * @returns this effect.
  31913. */
  31914. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31915. /**
  31916. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31917. * @param uniformName Name of the variable.
  31918. * @param matrix matrix to be set.
  31919. * @returns this effect.
  31920. */
  31921. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31922. /**
  31923. * Sets a float on a uniform variable.
  31924. * @param uniformName Name of the variable.
  31925. * @param value value to be set.
  31926. * @returns this effect.
  31927. */
  31928. setFloat(uniformName: string, value: number): Effect;
  31929. /**
  31930. * Sets a boolean on a uniform variable.
  31931. * @param uniformName Name of the variable.
  31932. * @param bool value to be set.
  31933. * @returns this effect.
  31934. */
  31935. setBool(uniformName: string, bool: boolean): Effect;
  31936. /**
  31937. * Sets a Vector2 on a uniform variable.
  31938. * @param uniformName Name of the variable.
  31939. * @param vector2 vector2 to be set.
  31940. * @returns this effect.
  31941. */
  31942. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31943. /**
  31944. * Sets a float2 on a uniform variable.
  31945. * @param uniformName Name of the variable.
  31946. * @param x First float in float2.
  31947. * @param y Second float in float2.
  31948. * @returns this effect.
  31949. */
  31950. setFloat2(uniformName: string, x: number, y: number): Effect;
  31951. /**
  31952. * Sets a Vector3 on a uniform variable.
  31953. * @param uniformName Name of the variable.
  31954. * @param vector3 Value to be set.
  31955. * @returns this effect.
  31956. */
  31957. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31958. /**
  31959. * Sets a float3 on a uniform variable.
  31960. * @param uniformName Name of the variable.
  31961. * @param x First float in float3.
  31962. * @param y Second float in float3.
  31963. * @param z Third float in float3.
  31964. * @returns this effect.
  31965. */
  31966. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31967. /**
  31968. * Sets a Vector4 on a uniform variable.
  31969. * @param uniformName Name of the variable.
  31970. * @param vector4 Value to be set.
  31971. * @returns this effect.
  31972. */
  31973. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31974. /**
  31975. * Sets a float4 on a uniform variable.
  31976. * @param uniformName Name of the variable.
  31977. * @param x First float in float4.
  31978. * @param y Second float in float4.
  31979. * @param z Third float in float4.
  31980. * @param w Fourth float in float4.
  31981. * @returns this effect.
  31982. */
  31983. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31984. /**
  31985. * Sets a Color3 on a uniform variable.
  31986. * @param uniformName Name of the variable.
  31987. * @param color3 Value to be set.
  31988. * @returns this effect.
  31989. */
  31990. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31991. /**
  31992. * Sets a Color4 on a uniform variable.
  31993. * @param uniformName Name of the variable.
  31994. * @param color3 Value to be set.
  31995. * @param alpha Alpha value to be set.
  31996. * @returns this effect.
  31997. */
  31998. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31999. /**
  32000. * Sets a Color4 on a uniform variable
  32001. * @param uniformName defines the name of the variable
  32002. * @param color4 defines the value to be set
  32003. * @returns this effect.
  32004. */
  32005. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32006. /** Release all associated resources */
  32007. dispose(): void;
  32008. /**
  32009. * This function will add a new shader to the shader store
  32010. * @param name the name of the shader
  32011. * @param pixelShader optional pixel shader content
  32012. * @param vertexShader optional vertex shader content
  32013. */
  32014. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32015. /**
  32016. * Store of each shader (The can be looked up using effect.key)
  32017. */
  32018. static ShadersStore: {
  32019. [key: string]: string;
  32020. };
  32021. /**
  32022. * Store of each included file for a shader (The can be looked up using effect.key)
  32023. */
  32024. static IncludesShadersStore: {
  32025. [key: string]: string;
  32026. };
  32027. /**
  32028. * Resets the cache of effects.
  32029. */
  32030. static ResetCache(): void;
  32031. }
  32032. }
  32033. declare module "babylonjs/Engines/engineCapabilities" {
  32034. /**
  32035. * Interface used to describe the capabilities of the engine relatively to the current browser
  32036. */
  32037. export interface EngineCapabilities {
  32038. /** Maximum textures units per fragment shader */
  32039. maxTexturesImageUnits: number;
  32040. /** Maximum texture units per vertex shader */
  32041. maxVertexTextureImageUnits: number;
  32042. /** Maximum textures units in the entire pipeline */
  32043. maxCombinedTexturesImageUnits: number;
  32044. /** Maximum texture size */
  32045. maxTextureSize: number;
  32046. /** Maximum texture samples */
  32047. maxSamples?: number;
  32048. /** Maximum cube texture size */
  32049. maxCubemapTextureSize: number;
  32050. /** Maximum render texture size */
  32051. maxRenderTextureSize: number;
  32052. /** Maximum number of vertex attributes */
  32053. maxVertexAttribs: number;
  32054. /** Maximum number of varyings */
  32055. maxVaryingVectors: number;
  32056. /** Maximum number of uniforms per vertex shader */
  32057. maxVertexUniformVectors: number;
  32058. /** Maximum number of uniforms per fragment shader */
  32059. maxFragmentUniformVectors: number;
  32060. /** Defines if standard derivates (dx/dy) are supported */
  32061. standardDerivatives: boolean;
  32062. /** Defines if s3tc texture compression is supported */
  32063. s3tc?: WEBGL_compressed_texture_s3tc;
  32064. /** Defines if pvrtc texture compression is supported */
  32065. pvrtc: any;
  32066. /** Defines if etc1 texture compression is supported */
  32067. etc1: any;
  32068. /** Defines if etc2 texture compression is supported */
  32069. etc2: any;
  32070. /** Defines if astc texture compression is supported */
  32071. astc: any;
  32072. /** Defines if float textures are supported */
  32073. textureFloat: boolean;
  32074. /** Defines if vertex array objects are supported */
  32075. vertexArrayObject: boolean;
  32076. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32077. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32078. /** Gets the maximum level of anisotropy supported */
  32079. maxAnisotropy: number;
  32080. /** Defines if instancing is supported */
  32081. instancedArrays: boolean;
  32082. /** Defines if 32 bits indices are supported */
  32083. uintIndices: boolean;
  32084. /** Defines if high precision shaders are supported */
  32085. highPrecisionShaderSupported: boolean;
  32086. /** Defines if depth reading in the fragment shader is supported */
  32087. fragmentDepthSupported: boolean;
  32088. /** Defines if float texture linear filtering is supported*/
  32089. textureFloatLinearFiltering: boolean;
  32090. /** Defines if rendering to float textures is supported */
  32091. textureFloatRender: boolean;
  32092. /** Defines if half float textures are supported*/
  32093. textureHalfFloat: boolean;
  32094. /** Defines if half float texture linear filtering is supported*/
  32095. textureHalfFloatLinearFiltering: boolean;
  32096. /** Defines if rendering to half float textures is supported */
  32097. textureHalfFloatRender: boolean;
  32098. /** Defines if textureLOD shader command is supported */
  32099. textureLOD: boolean;
  32100. /** Defines if draw buffers extension is supported */
  32101. drawBuffersExtension: boolean;
  32102. /** Defines if depth textures are supported */
  32103. depthTextureExtension: boolean;
  32104. /** Defines if float color buffer are supported */
  32105. colorBufferFloat: boolean;
  32106. /** Gets disjoint timer query extension (null if not supported) */
  32107. timerQuery?: EXT_disjoint_timer_query;
  32108. /** Defines if timestamp can be used with timer query */
  32109. canUseTimestampForTimerQuery: boolean;
  32110. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32111. multiview?: any;
  32112. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32113. oculusMultiview?: any;
  32114. /** Function used to let the system compiles shaders in background */
  32115. parallelShaderCompile?: {
  32116. COMPLETION_STATUS_KHR: number;
  32117. };
  32118. /** Max number of texture samples for MSAA */
  32119. maxMSAASamples: number;
  32120. /** Defines if the blend min max extension is supported */
  32121. blendMinMax: boolean;
  32122. }
  32123. }
  32124. declare module "babylonjs/States/depthCullingState" {
  32125. import { Nullable } from "babylonjs/types";
  32126. /**
  32127. * @hidden
  32128. **/
  32129. export class DepthCullingState {
  32130. private _isDepthTestDirty;
  32131. private _isDepthMaskDirty;
  32132. private _isDepthFuncDirty;
  32133. private _isCullFaceDirty;
  32134. private _isCullDirty;
  32135. private _isZOffsetDirty;
  32136. private _isFrontFaceDirty;
  32137. private _depthTest;
  32138. private _depthMask;
  32139. private _depthFunc;
  32140. private _cull;
  32141. private _cullFace;
  32142. private _zOffset;
  32143. private _frontFace;
  32144. /**
  32145. * Initializes the state.
  32146. */
  32147. constructor();
  32148. get isDirty(): boolean;
  32149. get zOffset(): number;
  32150. set zOffset(value: number);
  32151. get cullFace(): Nullable<number>;
  32152. set cullFace(value: Nullable<number>);
  32153. get cull(): Nullable<boolean>;
  32154. set cull(value: Nullable<boolean>);
  32155. get depthFunc(): Nullable<number>;
  32156. set depthFunc(value: Nullable<number>);
  32157. get depthMask(): boolean;
  32158. set depthMask(value: boolean);
  32159. get depthTest(): boolean;
  32160. set depthTest(value: boolean);
  32161. get frontFace(): Nullable<number>;
  32162. set frontFace(value: Nullable<number>);
  32163. reset(): void;
  32164. apply(gl: WebGLRenderingContext): void;
  32165. }
  32166. }
  32167. declare module "babylonjs/States/stencilState" {
  32168. /**
  32169. * @hidden
  32170. **/
  32171. export class StencilState {
  32172. /** 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 */
  32173. static readonly ALWAYS: number;
  32174. /** Passed to stencilOperation to specify that stencil value must be kept */
  32175. static readonly KEEP: number;
  32176. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32177. static readonly REPLACE: number;
  32178. private _isStencilTestDirty;
  32179. private _isStencilMaskDirty;
  32180. private _isStencilFuncDirty;
  32181. private _isStencilOpDirty;
  32182. private _stencilTest;
  32183. private _stencilMask;
  32184. private _stencilFunc;
  32185. private _stencilFuncRef;
  32186. private _stencilFuncMask;
  32187. private _stencilOpStencilFail;
  32188. private _stencilOpDepthFail;
  32189. private _stencilOpStencilDepthPass;
  32190. get isDirty(): boolean;
  32191. get stencilFunc(): number;
  32192. set stencilFunc(value: number);
  32193. get stencilFuncRef(): number;
  32194. set stencilFuncRef(value: number);
  32195. get stencilFuncMask(): number;
  32196. set stencilFuncMask(value: number);
  32197. get stencilOpStencilFail(): number;
  32198. set stencilOpStencilFail(value: number);
  32199. get stencilOpDepthFail(): number;
  32200. set stencilOpDepthFail(value: number);
  32201. get stencilOpStencilDepthPass(): number;
  32202. set stencilOpStencilDepthPass(value: number);
  32203. get stencilMask(): number;
  32204. set stencilMask(value: number);
  32205. get stencilTest(): boolean;
  32206. set stencilTest(value: boolean);
  32207. constructor();
  32208. reset(): void;
  32209. apply(gl: WebGLRenderingContext): void;
  32210. }
  32211. }
  32212. declare module "babylonjs/States/alphaCullingState" {
  32213. /**
  32214. * @hidden
  32215. **/
  32216. export class AlphaState {
  32217. private _isAlphaBlendDirty;
  32218. private _isBlendFunctionParametersDirty;
  32219. private _isBlendEquationParametersDirty;
  32220. private _isBlendConstantsDirty;
  32221. private _alphaBlend;
  32222. private _blendFunctionParameters;
  32223. private _blendEquationParameters;
  32224. private _blendConstants;
  32225. /**
  32226. * Initializes the state.
  32227. */
  32228. constructor();
  32229. get isDirty(): boolean;
  32230. get alphaBlend(): boolean;
  32231. set alphaBlend(value: boolean);
  32232. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32233. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32234. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32235. reset(): void;
  32236. apply(gl: WebGLRenderingContext): void;
  32237. }
  32238. }
  32239. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32240. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32241. /** @hidden */
  32242. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32243. attributeProcessor(attribute: string): string;
  32244. varyingProcessor(varying: string, isFragment: boolean): string;
  32245. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32246. }
  32247. }
  32248. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32249. /**
  32250. * Interface for attribute information associated with buffer instanciation
  32251. */
  32252. export interface InstancingAttributeInfo {
  32253. /**
  32254. * Name of the GLSL attribute
  32255. * if attribute index is not specified, this is used to retrieve the index from the effect
  32256. */
  32257. attributeName: string;
  32258. /**
  32259. * Index/offset of the attribute in the vertex shader
  32260. * if not specified, this will be computes from the name.
  32261. */
  32262. index?: number;
  32263. /**
  32264. * size of the attribute, 1, 2, 3 or 4
  32265. */
  32266. attributeSize: number;
  32267. /**
  32268. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32269. */
  32270. offset: number;
  32271. /**
  32272. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32273. * default to 1
  32274. */
  32275. divisor?: number;
  32276. /**
  32277. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32278. * default is FLOAT
  32279. */
  32280. attributeType?: number;
  32281. /**
  32282. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32283. */
  32284. normalized?: boolean;
  32285. }
  32286. }
  32287. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32289. import { Nullable } from "babylonjs/types";
  32290. module "babylonjs/Engines/thinEngine" {
  32291. interface ThinEngine {
  32292. /**
  32293. * Update a video texture
  32294. * @param texture defines the texture to update
  32295. * @param video defines the video element to use
  32296. * @param invertY defines if data must be stored with Y axis inverted
  32297. */
  32298. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32299. }
  32300. }
  32301. }
  32302. declare module "babylonjs/Materials/Textures/videoTexture" {
  32303. import { Observable } from "babylonjs/Misc/observable";
  32304. import { Nullable } from "babylonjs/types";
  32305. import { Scene } from "babylonjs/scene";
  32306. import { Texture } from "babylonjs/Materials/Textures/texture";
  32307. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32308. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32309. /**
  32310. * Settings for finer control over video usage
  32311. */
  32312. export interface VideoTextureSettings {
  32313. /**
  32314. * Applies `autoplay` to video, if specified
  32315. */
  32316. autoPlay?: boolean;
  32317. /**
  32318. * Applies `loop` to video, if specified
  32319. */
  32320. loop?: boolean;
  32321. /**
  32322. * Automatically updates internal texture from video at every frame in the render loop
  32323. */
  32324. autoUpdateTexture: boolean;
  32325. /**
  32326. * Image src displayed during the video loading or until the user interacts with the video.
  32327. */
  32328. poster?: string;
  32329. }
  32330. /**
  32331. * If you want to display a video in your scene, this is the special texture for that.
  32332. * This special texture works similar to other textures, with the exception of a few parameters.
  32333. * @see https://doc.babylonjs.com/how_to/video_texture
  32334. */
  32335. export class VideoTexture extends Texture {
  32336. /**
  32337. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32338. */
  32339. readonly autoUpdateTexture: boolean;
  32340. /**
  32341. * The video instance used by the texture internally
  32342. */
  32343. readonly video: HTMLVideoElement;
  32344. private _onUserActionRequestedObservable;
  32345. /**
  32346. * Event triggerd when a dom action is required by the user to play the video.
  32347. * This happens due to recent changes in browser policies preventing video to auto start.
  32348. */
  32349. get onUserActionRequestedObservable(): Observable<Texture>;
  32350. private _generateMipMaps;
  32351. private _engine;
  32352. private _stillImageCaptured;
  32353. private _displayingPosterTexture;
  32354. private _settings;
  32355. private _createInternalTextureOnEvent;
  32356. private _frameId;
  32357. private _currentSrc;
  32358. /**
  32359. * Creates a video texture.
  32360. * If you want to display a video in your scene, this is the special texture for that.
  32361. * This special texture works similar to other textures, with the exception of a few parameters.
  32362. * @see https://doc.babylonjs.com/how_to/video_texture
  32363. * @param name optional name, will detect from video source, if not defined
  32364. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32365. * @param scene is obviously the current scene.
  32366. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32367. * @param invertY is false by default but can be used to invert video on Y axis
  32368. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32369. * @param settings allows finer control over video usage
  32370. */
  32371. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32372. private _getName;
  32373. private _getVideo;
  32374. private _createInternalTexture;
  32375. private reset;
  32376. /**
  32377. * @hidden Internal method to initiate `update`.
  32378. */
  32379. _rebuild(): void;
  32380. /**
  32381. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32382. */
  32383. update(): void;
  32384. /**
  32385. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32386. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32387. */
  32388. updateTexture(isVisible: boolean): void;
  32389. protected _updateInternalTexture: () => void;
  32390. /**
  32391. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32392. * @param url New url.
  32393. */
  32394. updateURL(url: string): void;
  32395. /**
  32396. * Clones the texture.
  32397. * @returns the cloned texture
  32398. */
  32399. clone(): VideoTexture;
  32400. /**
  32401. * Dispose the texture and release its associated resources.
  32402. */
  32403. dispose(): void;
  32404. /**
  32405. * Creates a video texture straight from a stream.
  32406. * @param scene Define the scene the texture should be created in
  32407. * @param stream Define the stream the texture should be created from
  32408. * @returns The created video texture as a promise
  32409. */
  32410. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32411. /**
  32412. * Creates a video texture straight from your WebCam video feed.
  32413. * @param scene Define the scene the texture should be created in
  32414. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32415. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32416. * @returns The created video texture as a promise
  32417. */
  32418. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32419. minWidth: number;
  32420. maxWidth: number;
  32421. minHeight: number;
  32422. maxHeight: number;
  32423. deviceId: string;
  32424. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32425. /**
  32426. * Creates a video texture straight from your WebCam video feed.
  32427. * @param scene Define the scene the texture should be created in
  32428. * @param onReady Define a callback to triggered once the texture will be ready
  32429. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32430. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32431. */
  32432. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32433. minWidth: number;
  32434. maxWidth: number;
  32435. minHeight: number;
  32436. maxHeight: number;
  32437. deviceId: string;
  32438. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32439. }
  32440. }
  32441. declare module "babylonjs/Engines/thinEngine" {
  32442. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32443. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32444. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32445. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32446. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32447. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32448. import { Observable } from "babylonjs/Misc/observable";
  32449. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32450. import { StencilState } from "babylonjs/States/stencilState";
  32451. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32453. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32454. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32455. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32456. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32457. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32458. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32459. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32461. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32462. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32463. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32464. import { WebRequest } from "babylonjs/Misc/webRequest";
  32465. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32466. /**
  32467. * Defines the interface used by objects working like Scene
  32468. * @hidden
  32469. */
  32470. export interface ISceneLike {
  32471. _addPendingData(data: any): void;
  32472. _removePendingData(data: any): void;
  32473. offlineProvider: IOfflineProvider;
  32474. }
  32475. /** Interface defining initialization parameters for Engine class */
  32476. export interface EngineOptions extends WebGLContextAttributes {
  32477. /**
  32478. * Defines if the engine should no exceed a specified device ratio
  32479. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32480. */
  32481. limitDeviceRatio?: number;
  32482. /**
  32483. * Defines if webvr should be enabled automatically
  32484. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32485. */
  32486. autoEnableWebVR?: boolean;
  32487. /**
  32488. * Defines if webgl2 should be turned off even if supported
  32489. * @see http://doc.babylonjs.com/features/webgl2
  32490. */
  32491. disableWebGL2Support?: boolean;
  32492. /**
  32493. * Defines if webaudio should be initialized as well
  32494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32495. */
  32496. audioEngine?: boolean;
  32497. /**
  32498. * Defines if animations should run using a deterministic lock step
  32499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32500. */
  32501. deterministicLockstep?: boolean;
  32502. /** Defines the maximum steps to use with deterministic lock step mode */
  32503. lockstepMaxSteps?: number;
  32504. /** Defines the seconds between each deterministic lock step */
  32505. timeStep?: number;
  32506. /**
  32507. * Defines that engine should ignore context lost events
  32508. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32509. */
  32510. doNotHandleContextLost?: boolean;
  32511. /**
  32512. * Defines that engine should ignore modifying touch action attribute and style
  32513. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32514. */
  32515. doNotHandleTouchAction?: boolean;
  32516. /**
  32517. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32518. */
  32519. useHighPrecisionFloats?: boolean;
  32520. }
  32521. /**
  32522. * The base engine class (root of all engines)
  32523. */
  32524. export class ThinEngine {
  32525. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32526. static ExceptionList: ({
  32527. key: string;
  32528. capture: string;
  32529. captureConstraint: number;
  32530. targets: string[];
  32531. } | {
  32532. key: string;
  32533. capture: null;
  32534. captureConstraint: null;
  32535. targets: string[];
  32536. })[];
  32537. /** @hidden */
  32538. static _TextureLoaders: IInternalTextureLoader[];
  32539. /**
  32540. * Returns the current npm package of the sdk
  32541. */
  32542. static get NpmPackage(): string;
  32543. /**
  32544. * Returns the current version of the framework
  32545. */
  32546. static get Version(): string;
  32547. /**
  32548. * Returns a string describing the current engine
  32549. */
  32550. get description(): string;
  32551. /**
  32552. * Gets or sets the epsilon value used by collision engine
  32553. */
  32554. static CollisionsEpsilon: number;
  32555. /**
  32556. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32557. */
  32558. static get ShadersRepository(): string;
  32559. static set ShadersRepository(value: string);
  32560. /** @hidden */
  32561. _shaderProcessor: IShaderProcessor;
  32562. /**
  32563. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32564. */
  32565. forcePOTTextures: boolean;
  32566. /**
  32567. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32568. */
  32569. isFullscreen: boolean;
  32570. /**
  32571. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32572. */
  32573. cullBackFaces: boolean;
  32574. /**
  32575. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32576. */
  32577. renderEvenInBackground: boolean;
  32578. /**
  32579. * Gets or sets a boolean indicating that cache can be kept between frames
  32580. */
  32581. preventCacheWipeBetweenFrames: boolean;
  32582. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32583. validateShaderPrograms: boolean;
  32584. /**
  32585. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32586. * This can provide greater z depth for distant objects.
  32587. */
  32588. useReverseDepthBuffer: boolean;
  32589. /**
  32590. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32591. */
  32592. disableUniformBuffers: boolean;
  32593. /** @hidden */
  32594. _uniformBuffers: UniformBuffer[];
  32595. /**
  32596. * Gets a boolean indicating that the engine supports uniform buffers
  32597. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32598. */
  32599. get supportsUniformBuffers(): boolean;
  32600. /** @hidden */
  32601. _gl: WebGLRenderingContext;
  32602. /** @hidden */
  32603. _webGLVersion: number;
  32604. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32605. protected _windowIsBackground: boolean;
  32606. protected _creationOptions: EngineOptions;
  32607. protected _highPrecisionShadersAllowed: boolean;
  32608. /** @hidden */
  32609. get _shouldUseHighPrecisionShader(): boolean;
  32610. /**
  32611. * Gets a boolean indicating that only power of 2 textures are supported
  32612. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32613. */
  32614. get needPOTTextures(): boolean;
  32615. /** @hidden */
  32616. _badOS: boolean;
  32617. /** @hidden */
  32618. _badDesktopOS: boolean;
  32619. private _hardwareScalingLevel;
  32620. /** @hidden */
  32621. _caps: EngineCapabilities;
  32622. private _isStencilEnable;
  32623. private _glVersion;
  32624. private _glRenderer;
  32625. private _glVendor;
  32626. /** @hidden */
  32627. _videoTextureSupported: boolean;
  32628. protected _renderingQueueLaunched: boolean;
  32629. protected _activeRenderLoops: (() => void)[];
  32630. /**
  32631. * Observable signaled when a context lost event is raised
  32632. */
  32633. onContextLostObservable: Observable<ThinEngine>;
  32634. /**
  32635. * Observable signaled when a context restored event is raised
  32636. */
  32637. onContextRestoredObservable: Observable<ThinEngine>;
  32638. private _onContextLost;
  32639. private _onContextRestored;
  32640. protected _contextWasLost: boolean;
  32641. /** @hidden */
  32642. _doNotHandleContextLost: boolean;
  32643. /**
  32644. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32646. */
  32647. get doNotHandleContextLost(): boolean;
  32648. set doNotHandleContextLost(value: boolean);
  32649. /**
  32650. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32651. */
  32652. disableVertexArrayObjects: boolean;
  32653. /** @hidden */
  32654. protected _colorWrite: boolean;
  32655. /** @hidden */
  32656. protected _colorWriteChanged: boolean;
  32657. /** @hidden */
  32658. protected _depthCullingState: DepthCullingState;
  32659. /** @hidden */
  32660. protected _stencilState: StencilState;
  32661. /** @hidden */
  32662. _alphaState: AlphaState;
  32663. /** @hidden */
  32664. _alphaMode: number;
  32665. /** @hidden */
  32666. _alphaEquation: number;
  32667. /** @hidden */
  32668. _internalTexturesCache: InternalTexture[];
  32669. /** @hidden */
  32670. protected _activeChannel: number;
  32671. private _currentTextureChannel;
  32672. /** @hidden */
  32673. protected _boundTexturesCache: {
  32674. [key: string]: Nullable<InternalTexture>;
  32675. };
  32676. /** @hidden */
  32677. protected _currentEffect: Nullable<Effect>;
  32678. /** @hidden */
  32679. protected _currentProgram: Nullable<WebGLProgram>;
  32680. private _compiledEffects;
  32681. private _vertexAttribArraysEnabled;
  32682. /** @hidden */
  32683. protected _cachedViewport: Nullable<IViewportLike>;
  32684. private _cachedVertexArrayObject;
  32685. /** @hidden */
  32686. protected _cachedVertexBuffers: any;
  32687. /** @hidden */
  32688. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32689. /** @hidden */
  32690. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32691. /** @hidden */
  32692. _currentRenderTarget: Nullable<InternalTexture>;
  32693. private _uintIndicesCurrentlySet;
  32694. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32695. /** @hidden */
  32696. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32697. private _currentBufferPointers;
  32698. private _currentInstanceLocations;
  32699. private _currentInstanceBuffers;
  32700. private _textureUnits;
  32701. /** @hidden */
  32702. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32703. /** @hidden */
  32704. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32705. /** @hidden */
  32706. _boundRenderFunction: any;
  32707. private _vaoRecordInProgress;
  32708. private _mustWipeVertexAttributes;
  32709. private _emptyTexture;
  32710. private _emptyCubeTexture;
  32711. private _emptyTexture3D;
  32712. private _emptyTexture2DArray;
  32713. /** @hidden */
  32714. _frameHandler: number;
  32715. private _nextFreeTextureSlots;
  32716. private _maxSimultaneousTextures;
  32717. private _activeRequests;
  32718. /** @hidden */
  32719. _transformTextureUrl: Nullable<(url: string) => string>;
  32720. protected get _supportsHardwareTextureRescaling(): boolean;
  32721. private _framebufferDimensionsObject;
  32722. /**
  32723. * sets the object from which width and height will be taken from when getting render width and height
  32724. * Will fallback to the gl object
  32725. * @param dimensions the framebuffer width and height that will be used.
  32726. */
  32727. set framebufferDimensionsObject(dimensions: Nullable<{
  32728. framebufferWidth: number;
  32729. framebufferHeight: number;
  32730. }>);
  32731. /**
  32732. * Gets the current viewport
  32733. */
  32734. get currentViewport(): Nullable<IViewportLike>;
  32735. /**
  32736. * Gets the default empty texture
  32737. */
  32738. get emptyTexture(): InternalTexture;
  32739. /**
  32740. * Gets the default empty 3D texture
  32741. */
  32742. get emptyTexture3D(): InternalTexture;
  32743. /**
  32744. * Gets the default empty 2D array texture
  32745. */
  32746. get emptyTexture2DArray(): InternalTexture;
  32747. /**
  32748. * Gets the default empty cube texture
  32749. */
  32750. get emptyCubeTexture(): InternalTexture;
  32751. /**
  32752. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32753. */
  32754. readonly premultipliedAlpha: boolean;
  32755. /**
  32756. * Observable event triggered before each texture is initialized
  32757. */
  32758. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32759. /**
  32760. * Creates a new engine
  32761. * @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
  32762. * @param antialias defines enable antialiasing (default: false)
  32763. * @param options defines further options to be sent to the getContext() function
  32764. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32765. */
  32766. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32767. private _rebuildInternalTextures;
  32768. private _rebuildEffects;
  32769. /**
  32770. * Gets a boolean indicating if all created effects are ready
  32771. * @returns true if all effects are ready
  32772. */
  32773. areAllEffectsReady(): boolean;
  32774. protected _rebuildBuffers(): void;
  32775. protected _initGLContext(): void;
  32776. /**
  32777. * Gets version of the current webGL context
  32778. */
  32779. get webGLVersion(): number;
  32780. /**
  32781. * Gets a string idenfifying the name of the class
  32782. * @returns "Engine" string
  32783. */
  32784. getClassName(): string;
  32785. /**
  32786. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32787. */
  32788. get isStencilEnable(): boolean;
  32789. /** @hidden */
  32790. _prepareWorkingCanvas(): void;
  32791. /**
  32792. * Reset the texture cache to empty state
  32793. */
  32794. resetTextureCache(): void;
  32795. /**
  32796. * Gets an object containing information about the current webGL context
  32797. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32798. */
  32799. getGlInfo(): {
  32800. vendor: string;
  32801. renderer: string;
  32802. version: string;
  32803. };
  32804. /**
  32805. * Defines the hardware scaling level.
  32806. * By default the hardware scaling level is computed from the window device ratio.
  32807. * 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.
  32808. * @param level defines the level to use
  32809. */
  32810. setHardwareScalingLevel(level: number): void;
  32811. /**
  32812. * Gets the current hardware scaling level.
  32813. * By default the hardware scaling level is computed from the window device ratio.
  32814. * 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.
  32815. * @returns a number indicating the current hardware scaling level
  32816. */
  32817. getHardwareScalingLevel(): number;
  32818. /**
  32819. * Gets the list of loaded textures
  32820. * @returns an array containing all loaded textures
  32821. */
  32822. getLoadedTexturesCache(): InternalTexture[];
  32823. /**
  32824. * Gets the object containing all engine capabilities
  32825. * @returns the EngineCapabilities object
  32826. */
  32827. getCaps(): EngineCapabilities;
  32828. /**
  32829. * stop executing a render loop function and remove it from the execution array
  32830. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32831. */
  32832. stopRenderLoop(renderFunction?: () => void): void;
  32833. /** @hidden */
  32834. _renderLoop(): void;
  32835. /**
  32836. * Gets the HTML canvas attached with the current webGL context
  32837. * @returns a HTML canvas
  32838. */
  32839. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32840. /**
  32841. * Gets host window
  32842. * @returns the host window object
  32843. */
  32844. getHostWindow(): Nullable<Window>;
  32845. /**
  32846. * Gets the current render width
  32847. * @param useScreen defines if screen size must be used (or the current render target if any)
  32848. * @returns a number defining the current render width
  32849. */
  32850. getRenderWidth(useScreen?: boolean): number;
  32851. /**
  32852. * Gets the current render height
  32853. * @param useScreen defines if screen size must be used (or the current render target if any)
  32854. * @returns a number defining the current render height
  32855. */
  32856. getRenderHeight(useScreen?: boolean): number;
  32857. /**
  32858. * Can be used to override the current requestAnimationFrame requester.
  32859. * @hidden
  32860. */
  32861. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32862. /**
  32863. * Register and execute a render loop. The engine can have more than one render function
  32864. * @param renderFunction defines the function to continuously execute
  32865. */
  32866. runRenderLoop(renderFunction: () => void): void;
  32867. /**
  32868. * Clear the current render buffer or the current render target (if any is set up)
  32869. * @param color defines the color to use
  32870. * @param backBuffer defines if the back buffer must be cleared
  32871. * @param depth defines if the depth buffer must be cleared
  32872. * @param stencil defines if the stencil buffer must be cleared
  32873. */
  32874. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32875. private _viewportCached;
  32876. /** @hidden */
  32877. _viewport(x: number, y: number, width: number, height: number): void;
  32878. /**
  32879. * Set the WebGL's viewport
  32880. * @param viewport defines the viewport element to be used
  32881. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32882. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32883. */
  32884. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32885. /**
  32886. * Begin a new frame
  32887. */
  32888. beginFrame(): void;
  32889. /**
  32890. * Enf the current frame
  32891. */
  32892. endFrame(): void;
  32893. /**
  32894. * Resize the view according to the canvas' size
  32895. */
  32896. resize(): void;
  32897. /**
  32898. * Force a specific size of the canvas
  32899. * @param width defines the new canvas' width
  32900. * @param height defines the new canvas' height
  32901. */
  32902. setSize(width: number, height: number): void;
  32903. /**
  32904. * Binds the frame buffer to the specified texture.
  32905. * @param texture The texture to render to or null for the default canvas
  32906. * @param faceIndex The face of the texture to render to in case of cube texture
  32907. * @param requiredWidth The width of the target to render to
  32908. * @param requiredHeight The height of the target to render to
  32909. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32910. * @param lodLevel defines the lod level to bind to the frame buffer
  32911. * @param layer defines the 2d array index to bind to frame buffer to
  32912. */
  32913. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32914. /** @hidden */
  32915. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32916. /**
  32917. * Unbind the current render target texture from the webGL context
  32918. * @param texture defines the render target texture to unbind
  32919. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32920. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32921. */
  32922. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32923. /**
  32924. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32925. */
  32926. flushFramebuffer(): void;
  32927. /**
  32928. * Unbind the current render target and bind the default framebuffer
  32929. */
  32930. restoreDefaultFramebuffer(): void;
  32931. /** @hidden */
  32932. protected _resetVertexBufferBinding(): void;
  32933. /**
  32934. * Creates a vertex buffer
  32935. * @param data the data for the vertex buffer
  32936. * @returns the new WebGL static buffer
  32937. */
  32938. createVertexBuffer(data: DataArray): DataBuffer;
  32939. private _createVertexBuffer;
  32940. /**
  32941. * Creates a dynamic vertex buffer
  32942. * @param data the data for the dynamic vertex buffer
  32943. * @returns the new WebGL dynamic buffer
  32944. */
  32945. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32946. protected _resetIndexBufferBinding(): void;
  32947. /**
  32948. * Creates a new index buffer
  32949. * @param indices defines the content of the index buffer
  32950. * @param updatable defines if the index buffer must be updatable
  32951. * @returns a new webGL buffer
  32952. */
  32953. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32954. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32955. /**
  32956. * Bind a webGL buffer to the webGL context
  32957. * @param buffer defines the buffer to bind
  32958. */
  32959. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32960. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32961. private bindBuffer;
  32962. /**
  32963. * update the bound buffer with the given data
  32964. * @param data defines the data to update
  32965. */
  32966. updateArrayBuffer(data: Float32Array): void;
  32967. private _vertexAttribPointer;
  32968. /** @hidden */
  32969. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32970. private _bindVertexBuffersAttributes;
  32971. /**
  32972. * Records a vertex array object
  32973. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32974. * @param vertexBuffers defines the list of vertex buffers to store
  32975. * @param indexBuffer defines the index buffer to store
  32976. * @param effect defines the effect to store
  32977. * @returns the new vertex array object
  32978. */
  32979. recordVertexArrayObject(vertexBuffers: {
  32980. [key: string]: VertexBuffer;
  32981. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32982. /**
  32983. * Bind a specific vertex array object
  32984. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32985. * @param vertexArrayObject defines the vertex array object to bind
  32986. * @param indexBuffer defines the index buffer to bind
  32987. */
  32988. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32989. /**
  32990. * Bind webGl buffers directly to the webGL context
  32991. * @param vertexBuffer defines the vertex buffer to bind
  32992. * @param indexBuffer defines the index buffer to bind
  32993. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32994. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32995. * @param effect defines the effect associated with the vertex buffer
  32996. */
  32997. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32998. private _unbindVertexArrayObject;
  32999. /**
  33000. * Bind a list of vertex buffers to the webGL context
  33001. * @param vertexBuffers defines the list of vertex buffers to bind
  33002. * @param indexBuffer defines the index buffer to bind
  33003. * @param effect defines the effect associated with the vertex buffers
  33004. */
  33005. bindBuffers(vertexBuffers: {
  33006. [key: string]: Nullable<VertexBuffer>;
  33007. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33008. /**
  33009. * Unbind all instance attributes
  33010. */
  33011. unbindInstanceAttributes(): void;
  33012. /**
  33013. * Release and free the memory of a vertex array object
  33014. * @param vao defines the vertex array object to delete
  33015. */
  33016. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33017. /** @hidden */
  33018. _releaseBuffer(buffer: DataBuffer): boolean;
  33019. protected _deleteBuffer(buffer: DataBuffer): void;
  33020. /**
  33021. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33022. * @param instancesBuffer defines the webGL buffer to update and bind
  33023. * @param data defines the data to store in the buffer
  33024. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33025. */
  33026. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33027. /**
  33028. * Bind the content of a webGL buffer used with instantiation
  33029. * @param instancesBuffer defines the webGL buffer to bind
  33030. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33031. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33032. */
  33033. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33034. /**
  33035. * Disable the instance attribute corresponding to the name in parameter
  33036. * @param name defines the name of the attribute to disable
  33037. */
  33038. disableInstanceAttributeByName(name: string): void;
  33039. /**
  33040. * Disable the instance attribute corresponding to the location in parameter
  33041. * @param attributeLocation defines the attribute location of the attribute to disable
  33042. */
  33043. disableInstanceAttribute(attributeLocation: number): void;
  33044. /**
  33045. * Disable the attribute corresponding to the location in parameter
  33046. * @param attributeLocation defines the attribute location of the attribute to disable
  33047. */
  33048. disableAttributeByIndex(attributeLocation: number): void;
  33049. /**
  33050. * Send a draw order
  33051. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33052. * @param indexStart defines the starting index
  33053. * @param indexCount defines the number of index to draw
  33054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33055. */
  33056. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33057. /**
  33058. * Draw a list of points
  33059. * @param verticesStart defines the index of first vertex to draw
  33060. * @param verticesCount defines the count of vertices to draw
  33061. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33062. */
  33063. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33064. /**
  33065. * Draw a list of unindexed primitives
  33066. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33067. * @param verticesStart defines the index of first vertex to draw
  33068. * @param verticesCount defines the count of vertices to draw
  33069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33070. */
  33071. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33072. /**
  33073. * Draw a list of indexed primitives
  33074. * @param fillMode defines the primitive to use
  33075. * @param indexStart defines the starting index
  33076. * @param indexCount defines the number of index to draw
  33077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33078. */
  33079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33080. /**
  33081. * Draw a list of unindexed primitives
  33082. * @param fillMode defines the primitive to use
  33083. * @param verticesStart defines the index of first vertex to draw
  33084. * @param verticesCount defines the count of vertices to draw
  33085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33086. */
  33087. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33088. private _drawMode;
  33089. /** @hidden */
  33090. protected _reportDrawCall(): void;
  33091. /** @hidden */
  33092. _releaseEffect(effect: Effect): void;
  33093. /** @hidden */
  33094. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33095. /**
  33096. * Create a new effect (used to store vertex/fragment shaders)
  33097. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33098. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33099. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33100. * @param samplers defines an array of string used to represent textures
  33101. * @param defines defines the string containing the defines to use to compile the shaders
  33102. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33103. * @param onCompiled defines a function to call when the effect creation is successful
  33104. * @param onError defines a function to call when the effect creation has failed
  33105. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33106. * @returns the new Effect
  33107. */
  33108. 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;
  33109. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33110. private _compileShader;
  33111. private _compileRawShader;
  33112. /** @hidden */
  33113. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33114. /**
  33115. * Directly creates a webGL program
  33116. * @param pipelineContext defines the pipeline context to attach to
  33117. * @param vertexCode defines the vertex shader code to use
  33118. * @param fragmentCode defines the fragment shader code to use
  33119. * @param context defines the webGL context to use (if not set, the current one will be used)
  33120. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33121. * @returns the new webGL program
  33122. */
  33123. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33124. /**
  33125. * Creates a webGL program
  33126. * @param pipelineContext defines the pipeline context to attach to
  33127. * @param vertexCode defines the vertex shader code to use
  33128. * @param fragmentCode defines the fragment shader code to use
  33129. * @param defines defines the string containing the defines to use to compile the shaders
  33130. * @param context defines the webGL context to use (if not set, the current one will be used)
  33131. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33132. * @returns the new webGL program
  33133. */
  33134. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33135. /**
  33136. * Creates a new pipeline context
  33137. * @returns the new pipeline
  33138. */
  33139. createPipelineContext(): IPipelineContext;
  33140. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33141. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33142. /** @hidden */
  33143. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33144. /** @hidden */
  33145. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33146. /** @hidden */
  33147. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33148. /**
  33149. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33150. * @param pipelineContext defines the pipeline context to use
  33151. * @param uniformsNames defines the list of uniform names
  33152. * @returns an array of webGL uniform locations
  33153. */
  33154. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33155. /**
  33156. * Gets the lsit of active attributes for a given webGL program
  33157. * @param pipelineContext defines the pipeline context to use
  33158. * @param attributesNames defines the list of attribute names to get
  33159. * @returns an array of indices indicating the offset of each attribute
  33160. */
  33161. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33162. /**
  33163. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33164. * @param effect defines the effect to activate
  33165. */
  33166. enableEffect(effect: Nullable<Effect>): void;
  33167. /**
  33168. * Set the value of an uniform to a number (int)
  33169. * @param uniform defines the webGL uniform location where to store the value
  33170. * @param value defines the int number to store
  33171. */
  33172. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33173. /**
  33174. * Set the value of an uniform to an array of int32
  33175. * @param uniform defines the webGL uniform location where to store the value
  33176. * @param array defines the array of int32 to store
  33177. */
  33178. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33179. /**
  33180. * Set the value of an uniform to an array of int32 (stored as vec2)
  33181. * @param uniform defines the webGL uniform location where to store the value
  33182. * @param array defines the array of int32 to store
  33183. */
  33184. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33185. /**
  33186. * Set the value of an uniform to an array of int32 (stored as vec3)
  33187. * @param uniform defines the webGL uniform location where to store the value
  33188. * @param array defines the array of int32 to store
  33189. */
  33190. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33191. /**
  33192. * Set the value of an uniform to an array of int32 (stored as vec4)
  33193. * @param uniform defines the webGL uniform location where to store the value
  33194. * @param array defines the array of int32 to store
  33195. */
  33196. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33197. /**
  33198. * Set the value of an uniform to an array of number
  33199. * @param uniform defines the webGL uniform location where to store the value
  33200. * @param array defines the array of number to store
  33201. */
  33202. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33203. /**
  33204. * Set the value of an uniform to an array of number (stored as vec2)
  33205. * @param uniform defines the webGL uniform location where to store the value
  33206. * @param array defines the array of number to store
  33207. */
  33208. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33209. /**
  33210. * Set the value of an uniform to an array of number (stored as vec3)
  33211. * @param uniform defines the webGL uniform location where to store the value
  33212. * @param array defines the array of number to store
  33213. */
  33214. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33215. /**
  33216. * Set the value of an uniform to an array of number (stored as vec4)
  33217. * @param uniform defines the webGL uniform location where to store the value
  33218. * @param array defines the array of number to store
  33219. */
  33220. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33221. /**
  33222. * Set the value of an uniform to an array of float32 (stored as matrices)
  33223. * @param uniform defines the webGL uniform location where to store the value
  33224. * @param matrices defines the array of float32 to store
  33225. */
  33226. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33227. /**
  33228. * Set the value of an uniform to a matrix (3x3)
  33229. * @param uniform defines the webGL uniform location where to store the value
  33230. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33231. */
  33232. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33233. /**
  33234. * Set the value of an uniform to a matrix (2x2)
  33235. * @param uniform defines the webGL uniform location where to store the value
  33236. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33237. */
  33238. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33239. /**
  33240. * Set the value of an uniform to a number (float)
  33241. * @param uniform defines the webGL uniform location where to store the value
  33242. * @param value defines the float number to store
  33243. */
  33244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33245. /**
  33246. * Set the value of an uniform to a vec2
  33247. * @param uniform defines the webGL uniform location where to store the value
  33248. * @param x defines the 1st component of the value
  33249. * @param y defines the 2nd component of the value
  33250. */
  33251. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33252. /**
  33253. * Set the value of an uniform to a vec3
  33254. * @param uniform defines the webGL uniform location where to store the value
  33255. * @param x defines the 1st component of the value
  33256. * @param y defines the 2nd component of the value
  33257. * @param z defines the 3rd component of the value
  33258. */
  33259. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33260. /**
  33261. * Set the value of an uniform to a vec4
  33262. * @param uniform defines the webGL uniform location where to store the value
  33263. * @param x defines the 1st component of the value
  33264. * @param y defines the 2nd component of the value
  33265. * @param z defines the 3rd component of the value
  33266. * @param w defines the 4th component of the value
  33267. */
  33268. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33269. /**
  33270. * Apply all cached states (depth, culling, stencil and alpha)
  33271. */
  33272. applyStates(): void;
  33273. /**
  33274. * Enable or disable color writing
  33275. * @param enable defines the state to set
  33276. */
  33277. setColorWrite(enable: boolean): void;
  33278. /**
  33279. * Gets a boolean indicating if color writing is enabled
  33280. * @returns the current color writing state
  33281. */
  33282. getColorWrite(): boolean;
  33283. /**
  33284. * Gets the depth culling state manager
  33285. */
  33286. get depthCullingState(): DepthCullingState;
  33287. /**
  33288. * Gets the alpha state manager
  33289. */
  33290. get alphaState(): AlphaState;
  33291. /**
  33292. * Gets the stencil state manager
  33293. */
  33294. get stencilState(): StencilState;
  33295. /**
  33296. * Clears the list of texture accessible through engine.
  33297. * This can help preventing texture load conflict due to name collision.
  33298. */
  33299. clearInternalTexturesCache(): void;
  33300. /**
  33301. * Force the entire cache to be cleared
  33302. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33303. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33304. */
  33305. wipeCaches(bruteForce?: boolean): void;
  33306. /** @hidden */
  33307. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33308. min: number;
  33309. mag: number;
  33310. };
  33311. /** @hidden */
  33312. _createTexture(): WebGLTexture;
  33313. /**
  33314. * Usually called from Texture.ts.
  33315. * Passed information to create a WebGLTexture
  33316. * @param url defines a value which contains one of the following:
  33317. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33318. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33319. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33320. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33321. * @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)
  33322. * @param scene needed for loading to the correct scene
  33323. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33324. * @param onLoad optional callback to be called upon successful completion
  33325. * @param onError optional callback to be called upon failure
  33326. * @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
  33327. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33328. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33329. * @param forcedExtension defines the extension to use to pick the right loader
  33330. * @param mimeType defines an optional mime type
  33331. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33332. */
  33333. 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;
  33334. /**
  33335. * Loads an image as an HTMLImageElement.
  33336. * @param input url string, ArrayBuffer, or Blob to load
  33337. * @param onLoad callback called when the image successfully loads
  33338. * @param onError callback called when the image fails to load
  33339. * @param offlineProvider offline provider for caching
  33340. * @param mimeType optional mime type
  33341. * @returns the HTMLImageElement of the loaded image
  33342. * @hidden
  33343. */
  33344. 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>;
  33345. /**
  33346. * @hidden
  33347. */
  33348. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33349. private _unpackFlipYCached;
  33350. /**
  33351. * In case you are sharing the context with other applications, it might
  33352. * be interested to not cache the unpack flip y state to ensure a consistent
  33353. * value would be set.
  33354. */
  33355. enableUnpackFlipYCached: boolean;
  33356. /** @hidden */
  33357. _unpackFlipY(value: boolean): void;
  33358. /** @hidden */
  33359. _getUnpackAlignement(): number;
  33360. private _getTextureTarget;
  33361. /**
  33362. * Update the sampling mode of a given texture
  33363. * @param samplingMode defines the required sampling mode
  33364. * @param texture defines the texture to update
  33365. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33366. */
  33367. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33368. /**
  33369. * Update the sampling mode of a given texture
  33370. * @param texture defines the texture to update
  33371. * @param wrapU defines the texture wrap mode of the u coordinates
  33372. * @param wrapV defines the texture wrap mode of the v coordinates
  33373. * @param wrapR defines the texture wrap mode of the r coordinates
  33374. */
  33375. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33376. /** @hidden */
  33377. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33378. width: number;
  33379. height: number;
  33380. layers?: number;
  33381. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33382. /** @hidden */
  33383. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33384. /** @hidden */
  33385. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33386. /**
  33387. * Update a portion of an internal texture
  33388. * @param texture defines the texture to update
  33389. * @param imageData defines the data to store into the texture
  33390. * @param xOffset defines the x coordinates of the update rectangle
  33391. * @param yOffset defines the y coordinates of the update rectangle
  33392. * @param width defines the width of the update rectangle
  33393. * @param height defines the height of the update rectangle
  33394. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33395. * @param lod defines the lod level to update (0 by default)
  33396. */
  33397. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33398. /** @hidden */
  33399. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33400. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33401. private _prepareWebGLTexture;
  33402. /** @hidden */
  33403. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33404. private _getDepthStencilBuffer;
  33405. /** @hidden */
  33406. _releaseFramebufferObjects(texture: InternalTexture): void;
  33407. /** @hidden */
  33408. _releaseTexture(texture: InternalTexture): void;
  33409. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33410. protected _setProgram(program: WebGLProgram): void;
  33411. protected _boundUniforms: {
  33412. [key: number]: WebGLUniformLocation;
  33413. };
  33414. /**
  33415. * Binds an effect to the webGL context
  33416. * @param effect defines the effect to bind
  33417. */
  33418. bindSamplers(effect: Effect): void;
  33419. private _activateCurrentTexture;
  33420. /** @hidden */
  33421. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33422. /** @hidden */
  33423. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33424. /**
  33425. * Unbind all textures from the webGL context
  33426. */
  33427. unbindAllTextures(): void;
  33428. /**
  33429. * Sets a texture to the according uniform.
  33430. * @param channel The texture channel
  33431. * @param uniform The uniform to set
  33432. * @param texture The texture to apply
  33433. */
  33434. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33435. private _bindSamplerUniformToChannel;
  33436. private _getTextureWrapMode;
  33437. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33438. /**
  33439. * Sets an array of texture to the webGL context
  33440. * @param channel defines the channel where the texture array must be set
  33441. * @param uniform defines the associated uniform location
  33442. * @param textures defines the array of textures to bind
  33443. */
  33444. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33445. /** @hidden */
  33446. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33447. private _setTextureParameterFloat;
  33448. private _setTextureParameterInteger;
  33449. /**
  33450. * Unbind all vertex attributes from the webGL context
  33451. */
  33452. unbindAllAttributes(): void;
  33453. /**
  33454. * 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
  33455. */
  33456. releaseEffects(): void;
  33457. /**
  33458. * Dispose and release all associated resources
  33459. */
  33460. dispose(): void;
  33461. /**
  33462. * Attach a new callback raised when context lost event is fired
  33463. * @param callback defines the callback to call
  33464. */
  33465. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33466. /**
  33467. * Attach a new callback raised when context restored event is fired
  33468. * @param callback defines the callback to call
  33469. */
  33470. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33471. /**
  33472. * Get the current error code of the webGL context
  33473. * @returns the error code
  33474. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33475. */
  33476. getError(): number;
  33477. private _canRenderToFloatFramebuffer;
  33478. private _canRenderToHalfFloatFramebuffer;
  33479. private _canRenderToFramebuffer;
  33480. /** @hidden */
  33481. _getWebGLTextureType(type: number): number;
  33482. /** @hidden */
  33483. _getInternalFormat(format: number): number;
  33484. /** @hidden */
  33485. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33486. /** @hidden */
  33487. _getRGBAMultiSampleBufferFormat(type: number): number;
  33488. /** @hidden */
  33489. _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;
  33490. /**
  33491. * Loads a file from a url
  33492. * @param url url to load
  33493. * @param onSuccess callback called when the file successfully loads
  33494. * @param onProgress callback called while file is loading (if the server supports this mode)
  33495. * @param offlineProvider defines the offline provider for caching
  33496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33497. * @param onError callback called when the file fails to load
  33498. * @returns a file request object
  33499. * @hidden
  33500. */
  33501. 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;
  33502. /**
  33503. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33504. * @param x defines the x coordinate of the rectangle where pixels must be read
  33505. * @param y defines the y coordinate of the rectangle where pixels must be read
  33506. * @param width defines the width of the rectangle where pixels must be read
  33507. * @param height defines the height of the rectangle where pixels must be read
  33508. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33509. * @returns a Uint8Array containing RGBA colors
  33510. */
  33511. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33512. private static _isSupported;
  33513. /**
  33514. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33515. * @returns true if the engine can be created
  33516. * @ignorenaming
  33517. */
  33518. static isSupported(): boolean;
  33519. /**
  33520. * Find the next highest power of two.
  33521. * @param x Number to start search from.
  33522. * @return Next highest power of two.
  33523. */
  33524. static CeilingPOT(x: number): number;
  33525. /**
  33526. * Find the next lowest power of two.
  33527. * @param x Number to start search from.
  33528. * @return Next lowest power of two.
  33529. */
  33530. static FloorPOT(x: number): number;
  33531. /**
  33532. * Find the nearest power of two.
  33533. * @param x Number to start search from.
  33534. * @return Next nearest power of two.
  33535. */
  33536. static NearestPOT(x: number): number;
  33537. /**
  33538. * Get the closest exponent of two
  33539. * @param value defines the value to approximate
  33540. * @param max defines the maximum value to return
  33541. * @param mode defines how to define the closest value
  33542. * @returns closest exponent of two of the given value
  33543. */
  33544. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33545. /**
  33546. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33547. * @param func - the function to be called
  33548. * @param requester - the object that will request the next frame. Falls back to window.
  33549. * @returns frame number
  33550. */
  33551. static QueueNewFrame(func: () => void, requester?: any): number;
  33552. /**
  33553. * Gets host document
  33554. * @returns the host document object
  33555. */
  33556. getHostDocument(): Nullable<Document>;
  33557. }
  33558. }
  33559. declare module "babylonjs/Maths/sphericalPolynomial" {
  33560. import { Vector3 } from "babylonjs/Maths/math.vector";
  33561. import { Color3 } from "babylonjs/Maths/math.color";
  33562. /**
  33563. * Class representing spherical harmonics coefficients to the 3rd degree
  33564. */
  33565. export class SphericalHarmonics {
  33566. /**
  33567. * Defines whether or not the harmonics have been prescaled for rendering.
  33568. */
  33569. preScaled: boolean;
  33570. /**
  33571. * The l0,0 coefficients of the spherical harmonics
  33572. */
  33573. l00: Vector3;
  33574. /**
  33575. * The l1,-1 coefficients of the spherical harmonics
  33576. */
  33577. l1_1: Vector3;
  33578. /**
  33579. * The l1,0 coefficients of the spherical harmonics
  33580. */
  33581. l10: Vector3;
  33582. /**
  33583. * The l1,1 coefficients of the spherical harmonics
  33584. */
  33585. l11: Vector3;
  33586. /**
  33587. * The l2,-2 coefficients of the spherical harmonics
  33588. */
  33589. l2_2: Vector3;
  33590. /**
  33591. * The l2,-1 coefficients of the spherical harmonics
  33592. */
  33593. l2_1: Vector3;
  33594. /**
  33595. * The l2,0 coefficients of the spherical harmonics
  33596. */
  33597. l20: Vector3;
  33598. /**
  33599. * The l2,1 coefficients of the spherical harmonics
  33600. */
  33601. l21: Vector3;
  33602. /**
  33603. * The l2,2 coefficients of the spherical harmonics
  33604. */
  33605. l22: Vector3;
  33606. /**
  33607. * Adds a light to the spherical harmonics
  33608. * @param direction the direction of the light
  33609. * @param color the color of the light
  33610. * @param deltaSolidAngle the delta solid angle of the light
  33611. */
  33612. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33613. /**
  33614. * Scales the spherical harmonics by the given amount
  33615. * @param scale the amount to scale
  33616. */
  33617. scaleInPlace(scale: number): void;
  33618. /**
  33619. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33620. *
  33621. * ```
  33622. * E_lm = A_l * L_lm
  33623. * ```
  33624. *
  33625. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33626. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33627. * the scaling factors are given in equation 9.
  33628. */
  33629. convertIncidentRadianceToIrradiance(): void;
  33630. /**
  33631. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33632. *
  33633. * ```
  33634. * L = (1/pi) * E * rho
  33635. * ```
  33636. *
  33637. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33638. */
  33639. convertIrradianceToLambertianRadiance(): void;
  33640. /**
  33641. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33642. * required operations at run time.
  33643. *
  33644. * This is simply done by scaling back the SH with Ylm constants parameter.
  33645. * The trigonometric part being applied by the shader at run time.
  33646. */
  33647. preScaleForRendering(): void;
  33648. /**
  33649. * Constructs a spherical harmonics from an array.
  33650. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33651. * @returns the spherical harmonics
  33652. */
  33653. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33654. /**
  33655. * Gets the spherical harmonics from polynomial
  33656. * @param polynomial the spherical polynomial
  33657. * @returns the spherical harmonics
  33658. */
  33659. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33660. }
  33661. /**
  33662. * Class representing spherical polynomial coefficients to the 3rd degree
  33663. */
  33664. export class SphericalPolynomial {
  33665. private _harmonics;
  33666. /**
  33667. * The spherical harmonics used to create the polynomials.
  33668. */
  33669. get preScaledHarmonics(): SphericalHarmonics;
  33670. /**
  33671. * The x coefficients of the spherical polynomial
  33672. */
  33673. x: Vector3;
  33674. /**
  33675. * The y coefficients of the spherical polynomial
  33676. */
  33677. y: Vector3;
  33678. /**
  33679. * The z coefficients of the spherical polynomial
  33680. */
  33681. z: Vector3;
  33682. /**
  33683. * The xx coefficients of the spherical polynomial
  33684. */
  33685. xx: Vector3;
  33686. /**
  33687. * The yy coefficients of the spherical polynomial
  33688. */
  33689. yy: Vector3;
  33690. /**
  33691. * The zz coefficients of the spherical polynomial
  33692. */
  33693. zz: Vector3;
  33694. /**
  33695. * The xy coefficients of the spherical polynomial
  33696. */
  33697. xy: Vector3;
  33698. /**
  33699. * The yz coefficients of the spherical polynomial
  33700. */
  33701. yz: Vector3;
  33702. /**
  33703. * The zx coefficients of the spherical polynomial
  33704. */
  33705. zx: Vector3;
  33706. /**
  33707. * Adds an ambient color to the spherical polynomial
  33708. * @param color the color to add
  33709. */
  33710. addAmbient(color: Color3): void;
  33711. /**
  33712. * Scales the spherical polynomial by the given amount
  33713. * @param scale the amount to scale
  33714. */
  33715. scaleInPlace(scale: number): void;
  33716. /**
  33717. * Gets the spherical polynomial from harmonics
  33718. * @param harmonics the spherical harmonics
  33719. * @returns the spherical polynomial
  33720. */
  33721. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33722. /**
  33723. * Constructs a spherical polynomial from an array.
  33724. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33725. * @returns the spherical polynomial
  33726. */
  33727. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33728. }
  33729. }
  33730. declare module "babylonjs/Materials/Textures/internalTexture" {
  33731. import { Observable } from "babylonjs/Misc/observable";
  33732. import { Nullable, int } from "babylonjs/types";
  33733. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33734. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33735. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33736. /**
  33737. * Defines the source of the internal texture
  33738. */
  33739. export enum InternalTextureSource {
  33740. /**
  33741. * The source of the texture data is unknown
  33742. */
  33743. Unknown = 0,
  33744. /**
  33745. * Texture data comes from an URL
  33746. */
  33747. Url = 1,
  33748. /**
  33749. * Texture data is only used for temporary storage
  33750. */
  33751. Temp = 2,
  33752. /**
  33753. * Texture data comes from raw data (ArrayBuffer)
  33754. */
  33755. Raw = 3,
  33756. /**
  33757. * Texture content is dynamic (video or dynamic texture)
  33758. */
  33759. Dynamic = 4,
  33760. /**
  33761. * Texture content is generated by rendering to it
  33762. */
  33763. RenderTarget = 5,
  33764. /**
  33765. * Texture content is part of a multi render target process
  33766. */
  33767. MultiRenderTarget = 6,
  33768. /**
  33769. * Texture data comes from a cube data file
  33770. */
  33771. Cube = 7,
  33772. /**
  33773. * Texture data comes from a raw cube data
  33774. */
  33775. CubeRaw = 8,
  33776. /**
  33777. * Texture data come from a prefiltered cube data file
  33778. */
  33779. CubePrefiltered = 9,
  33780. /**
  33781. * Texture content is raw 3D data
  33782. */
  33783. Raw3D = 10,
  33784. /**
  33785. * Texture content is raw 2D array data
  33786. */
  33787. Raw2DArray = 11,
  33788. /**
  33789. * Texture content is a depth texture
  33790. */
  33791. Depth = 12,
  33792. /**
  33793. * Texture data comes from a raw cube data encoded with RGBD
  33794. */
  33795. CubeRawRGBD = 13
  33796. }
  33797. /**
  33798. * Class used to store data associated with WebGL texture data for the engine
  33799. * This class should not be used directly
  33800. */
  33801. export class InternalTexture {
  33802. /** @hidden */
  33803. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33804. /**
  33805. * Defines if the texture is ready
  33806. */
  33807. isReady: boolean;
  33808. /**
  33809. * Defines if the texture is a cube texture
  33810. */
  33811. isCube: boolean;
  33812. /**
  33813. * Defines if the texture contains 3D data
  33814. */
  33815. is3D: boolean;
  33816. /**
  33817. * Defines if the texture contains 2D array data
  33818. */
  33819. is2DArray: boolean;
  33820. /**
  33821. * Defines if the texture contains multiview data
  33822. */
  33823. isMultiview: boolean;
  33824. /**
  33825. * Gets the URL used to load this texture
  33826. */
  33827. url: string;
  33828. /**
  33829. * Gets the sampling mode of the texture
  33830. */
  33831. samplingMode: number;
  33832. /**
  33833. * Gets a boolean indicating if the texture needs mipmaps generation
  33834. */
  33835. generateMipMaps: boolean;
  33836. /**
  33837. * Gets the number of samples used by the texture (WebGL2+ only)
  33838. */
  33839. samples: number;
  33840. /**
  33841. * Gets the type of the texture (int, float...)
  33842. */
  33843. type: number;
  33844. /**
  33845. * Gets the format of the texture (RGB, RGBA...)
  33846. */
  33847. format: number;
  33848. /**
  33849. * Observable called when the texture is loaded
  33850. */
  33851. onLoadedObservable: Observable<InternalTexture>;
  33852. /**
  33853. * Gets the width of the texture
  33854. */
  33855. width: number;
  33856. /**
  33857. * Gets the height of the texture
  33858. */
  33859. height: number;
  33860. /**
  33861. * Gets the depth of the texture
  33862. */
  33863. depth: number;
  33864. /**
  33865. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33866. */
  33867. baseWidth: number;
  33868. /**
  33869. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33870. */
  33871. baseHeight: number;
  33872. /**
  33873. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33874. */
  33875. baseDepth: number;
  33876. /**
  33877. * Gets a boolean indicating if the texture is inverted on Y axis
  33878. */
  33879. invertY: boolean;
  33880. /** @hidden */
  33881. _invertVScale: boolean;
  33882. /** @hidden */
  33883. _associatedChannel: number;
  33884. /** @hidden */
  33885. _source: InternalTextureSource;
  33886. /** @hidden */
  33887. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33888. /** @hidden */
  33889. _bufferView: Nullable<ArrayBufferView>;
  33890. /** @hidden */
  33891. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33892. /** @hidden */
  33893. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33894. /** @hidden */
  33895. _size: number;
  33896. /** @hidden */
  33897. _extension: string;
  33898. /** @hidden */
  33899. _files: Nullable<string[]>;
  33900. /** @hidden */
  33901. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33902. /** @hidden */
  33903. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33904. /** @hidden */
  33905. _framebuffer: Nullable<WebGLFramebuffer>;
  33906. /** @hidden */
  33907. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33908. /** @hidden */
  33909. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33910. /** @hidden */
  33911. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33912. /** @hidden */
  33913. _attachments: Nullable<number[]>;
  33914. /** @hidden */
  33915. _cachedCoordinatesMode: Nullable<number>;
  33916. /** @hidden */
  33917. _cachedWrapU: Nullable<number>;
  33918. /** @hidden */
  33919. _cachedWrapV: Nullable<number>;
  33920. /** @hidden */
  33921. _cachedWrapR: Nullable<number>;
  33922. /** @hidden */
  33923. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33924. /** @hidden */
  33925. _isDisabled: boolean;
  33926. /** @hidden */
  33927. _compression: Nullable<string>;
  33928. /** @hidden */
  33929. _generateStencilBuffer: boolean;
  33930. /** @hidden */
  33931. _generateDepthBuffer: boolean;
  33932. /** @hidden */
  33933. _comparisonFunction: number;
  33934. /** @hidden */
  33935. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33936. /** @hidden */
  33937. _lodGenerationScale: number;
  33938. /** @hidden */
  33939. _lodGenerationOffset: number;
  33940. /** @hidden */
  33941. _depthStencilTexture: Nullable<InternalTexture>;
  33942. /** @hidden */
  33943. _colorTextureArray: Nullable<WebGLTexture>;
  33944. /** @hidden */
  33945. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33946. /** @hidden */
  33947. _lodTextureHigh: Nullable<BaseTexture>;
  33948. /** @hidden */
  33949. _lodTextureMid: Nullable<BaseTexture>;
  33950. /** @hidden */
  33951. _lodTextureLow: Nullable<BaseTexture>;
  33952. /** @hidden */
  33953. _isRGBD: boolean;
  33954. /** @hidden */
  33955. _linearSpecularLOD: boolean;
  33956. /** @hidden */
  33957. _irradianceTexture: Nullable<BaseTexture>;
  33958. /** @hidden */
  33959. _webGLTexture: Nullable<WebGLTexture>;
  33960. /** @hidden */
  33961. _references: number;
  33962. private _engine;
  33963. /**
  33964. * Gets the Engine the texture belongs to.
  33965. * @returns The babylon engine
  33966. */
  33967. getEngine(): ThinEngine;
  33968. /**
  33969. * Gets the data source type of the texture
  33970. */
  33971. get source(): InternalTextureSource;
  33972. /**
  33973. * Creates a new InternalTexture
  33974. * @param engine defines the engine to use
  33975. * @param source defines the type of data that will be used
  33976. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33977. */
  33978. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33979. /**
  33980. * Increments the number of references (ie. the number of Texture that point to it)
  33981. */
  33982. incrementReferences(): void;
  33983. /**
  33984. * Change the size of the texture (not the size of the content)
  33985. * @param width defines the new width
  33986. * @param height defines the new height
  33987. * @param depth defines the new depth (1 by default)
  33988. */
  33989. updateSize(width: int, height: int, depth?: int): void;
  33990. /** @hidden */
  33991. _rebuild(): void;
  33992. /** @hidden */
  33993. _swapAndDie(target: InternalTexture): void;
  33994. /**
  33995. * Dispose the current allocated resources
  33996. */
  33997. dispose(): void;
  33998. }
  33999. }
  34000. declare module "babylonjs/Audio/analyser" {
  34001. import { Scene } from "babylonjs/scene";
  34002. /**
  34003. * Class used to work with sound analyzer using fast fourier transform (FFT)
  34004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34005. */
  34006. export class Analyser {
  34007. /**
  34008. * Gets or sets the smoothing
  34009. * @ignorenaming
  34010. */
  34011. SMOOTHING: number;
  34012. /**
  34013. * Gets or sets the FFT table size
  34014. * @ignorenaming
  34015. */
  34016. FFT_SIZE: number;
  34017. /**
  34018. * Gets or sets the bar graph amplitude
  34019. * @ignorenaming
  34020. */
  34021. BARGRAPHAMPLITUDE: number;
  34022. /**
  34023. * Gets or sets the position of the debug canvas
  34024. * @ignorenaming
  34025. */
  34026. DEBUGCANVASPOS: {
  34027. x: number;
  34028. y: number;
  34029. };
  34030. /**
  34031. * Gets or sets the debug canvas size
  34032. * @ignorenaming
  34033. */
  34034. DEBUGCANVASSIZE: {
  34035. width: number;
  34036. height: number;
  34037. };
  34038. private _byteFreqs;
  34039. private _byteTime;
  34040. private _floatFreqs;
  34041. private _webAudioAnalyser;
  34042. private _debugCanvas;
  34043. private _debugCanvasContext;
  34044. private _scene;
  34045. private _registerFunc;
  34046. private _audioEngine;
  34047. /**
  34048. * Creates a new analyser
  34049. * @param scene defines hosting scene
  34050. */
  34051. constructor(scene: Scene);
  34052. /**
  34053. * Get the number of data values you will have to play with for the visualization
  34054. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34055. * @returns a number
  34056. */
  34057. getFrequencyBinCount(): number;
  34058. /**
  34059. * Gets the current frequency data as a byte array
  34060. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34061. * @returns a Uint8Array
  34062. */
  34063. getByteFrequencyData(): Uint8Array;
  34064. /**
  34065. * Gets the current waveform as a byte array
  34066. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34067. * @returns a Uint8Array
  34068. */
  34069. getByteTimeDomainData(): Uint8Array;
  34070. /**
  34071. * Gets the current frequency data as a float array
  34072. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34073. * @returns a Float32Array
  34074. */
  34075. getFloatFrequencyData(): Float32Array;
  34076. /**
  34077. * Renders the debug canvas
  34078. */
  34079. drawDebugCanvas(): void;
  34080. /**
  34081. * Stops rendering the debug canvas and removes it
  34082. */
  34083. stopDebugCanvas(): void;
  34084. /**
  34085. * Connects two audio nodes
  34086. * @param inputAudioNode defines first node to connect
  34087. * @param outputAudioNode defines second node to connect
  34088. */
  34089. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34090. /**
  34091. * Releases all associated resources
  34092. */
  34093. dispose(): void;
  34094. }
  34095. }
  34096. declare module "babylonjs/Audio/audioEngine" {
  34097. import { IDisposable } from "babylonjs/scene";
  34098. import { Analyser } from "babylonjs/Audio/analyser";
  34099. import { Nullable } from "babylonjs/types";
  34100. import { Observable } from "babylonjs/Misc/observable";
  34101. /**
  34102. * This represents an audio engine and it is responsible
  34103. * to play, synchronize and analyse sounds throughout the application.
  34104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34105. */
  34106. export interface IAudioEngine extends IDisposable {
  34107. /**
  34108. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34109. */
  34110. readonly canUseWebAudio: boolean;
  34111. /**
  34112. * Gets the current AudioContext if available.
  34113. */
  34114. readonly audioContext: Nullable<AudioContext>;
  34115. /**
  34116. * The master gain node defines the global audio volume of your audio engine.
  34117. */
  34118. readonly masterGain: GainNode;
  34119. /**
  34120. * Gets whether or not mp3 are supported by your browser.
  34121. */
  34122. readonly isMP3supported: boolean;
  34123. /**
  34124. * Gets whether or not ogg are supported by your browser.
  34125. */
  34126. readonly isOGGsupported: boolean;
  34127. /**
  34128. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34129. * @ignoreNaming
  34130. */
  34131. WarnedWebAudioUnsupported: boolean;
  34132. /**
  34133. * Defines if the audio engine relies on a custom unlocked button.
  34134. * In this case, the embedded button will not be displayed.
  34135. */
  34136. useCustomUnlockedButton: boolean;
  34137. /**
  34138. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34139. */
  34140. readonly unlocked: boolean;
  34141. /**
  34142. * Event raised when audio has been unlocked on the browser.
  34143. */
  34144. onAudioUnlockedObservable: Observable<AudioEngine>;
  34145. /**
  34146. * Event raised when audio has been locked on the browser.
  34147. */
  34148. onAudioLockedObservable: Observable<AudioEngine>;
  34149. /**
  34150. * Flags the audio engine in Locked state.
  34151. * This happens due to new browser policies preventing audio to autoplay.
  34152. */
  34153. lock(): void;
  34154. /**
  34155. * Unlocks the audio engine once a user action has been done on the dom.
  34156. * This is helpful to resume play once browser policies have been satisfied.
  34157. */
  34158. unlock(): void;
  34159. /**
  34160. * Gets the global volume sets on the master gain.
  34161. * @returns the global volume if set or -1 otherwise
  34162. */
  34163. getGlobalVolume(): number;
  34164. /**
  34165. * Sets the global volume of your experience (sets on the master gain).
  34166. * @param newVolume Defines the new global volume of the application
  34167. */
  34168. setGlobalVolume(newVolume: number): void;
  34169. /**
  34170. * Connect the audio engine to an audio analyser allowing some amazing
  34171. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34173. * @param analyser The analyser to connect to the engine
  34174. */
  34175. connectToAnalyser(analyser: Analyser): void;
  34176. }
  34177. /**
  34178. * This represents the default audio engine used in babylon.
  34179. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34181. */
  34182. export class AudioEngine implements IAudioEngine {
  34183. private _audioContext;
  34184. private _audioContextInitialized;
  34185. private _muteButton;
  34186. private _hostElement;
  34187. /**
  34188. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34189. */
  34190. canUseWebAudio: boolean;
  34191. /**
  34192. * The master gain node defines the global audio volume of your audio engine.
  34193. */
  34194. masterGain: GainNode;
  34195. /**
  34196. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34197. * @ignoreNaming
  34198. */
  34199. WarnedWebAudioUnsupported: boolean;
  34200. /**
  34201. * Gets whether or not mp3 are supported by your browser.
  34202. */
  34203. isMP3supported: boolean;
  34204. /**
  34205. * Gets whether or not ogg are supported by your browser.
  34206. */
  34207. isOGGsupported: boolean;
  34208. /**
  34209. * Gets whether audio has been unlocked on the device.
  34210. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34211. * a user interaction has happened.
  34212. */
  34213. unlocked: boolean;
  34214. /**
  34215. * Defines if the audio engine relies on a custom unlocked button.
  34216. * In this case, the embedded button will not be displayed.
  34217. */
  34218. useCustomUnlockedButton: boolean;
  34219. /**
  34220. * Event raised when audio has been unlocked on the browser.
  34221. */
  34222. onAudioUnlockedObservable: Observable<AudioEngine>;
  34223. /**
  34224. * Event raised when audio has been locked on the browser.
  34225. */
  34226. onAudioLockedObservable: Observable<AudioEngine>;
  34227. /**
  34228. * Gets the current AudioContext if available.
  34229. */
  34230. get audioContext(): Nullable<AudioContext>;
  34231. private _connectedAnalyser;
  34232. /**
  34233. * Instantiates a new audio engine.
  34234. *
  34235. * There should be only one per page as some browsers restrict the number
  34236. * of audio contexts you can create.
  34237. * @param hostElement defines the host element where to display the mute icon if necessary
  34238. */
  34239. constructor(hostElement?: Nullable<HTMLElement>);
  34240. /**
  34241. * Flags the audio engine in Locked state.
  34242. * This happens due to new browser policies preventing audio to autoplay.
  34243. */
  34244. lock(): void;
  34245. /**
  34246. * Unlocks the audio engine once a user action has been done on the dom.
  34247. * This is helpful to resume play once browser policies have been satisfied.
  34248. */
  34249. unlock(): void;
  34250. private _resumeAudioContext;
  34251. private _initializeAudioContext;
  34252. private _tryToRun;
  34253. private _triggerRunningState;
  34254. private _triggerSuspendedState;
  34255. private _displayMuteButton;
  34256. private _moveButtonToTopLeft;
  34257. private _onResize;
  34258. private _hideMuteButton;
  34259. /**
  34260. * Destroy and release the resources associated with the audio ccontext.
  34261. */
  34262. dispose(): void;
  34263. /**
  34264. * Gets the global volume sets on the master gain.
  34265. * @returns the global volume if set or -1 otherwise
  34266. */
  34267. getGlobalVolume(): number;
  34268. /**
  34269. * Sets the global volume of your experience (sets on the master gain).
  34270. * @param newVolume Defines the new global volume of the application
  34271. */
  34272. setGlobalVolume(newVolume: number): void;
  34273. /**
  34274. * Connect the audio engine to an audio analyser allowing some amazing
  34275. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34277. * @param analyser The analyser to connect to the engine
  34278. */
  34279. connectToAnalyser(analyser: Analyser): void;
  34280. }
  34281. }
  34282. declare module "babylonjs/Loading/loadingScreen" {
  34283. /**
  34284. * Interface used to present a loading screen while loading a scene
  34285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34286. */
  34287. export interface ILoadingScreen {
  34288. /**
  34289. * Function called to display the loading screen
  34290. */
  34291. displayLoadingUI: () => void;
  34292. /**
  34293. * Function called to hide the loading screen
  34294. */
  34295. hideLoadingUI: () => void;
  34296. /**
  34297. * Gets or sets the color to use for the background
  34298. */
  34299. loadingUIBackgroundColor: string;
  34300. /**
  34301. * Gets or sets the text to display while loading
  34302. */
  34303. loadingUIText: string;
  34304. }
  34305. /**
  34306. * Class used for the default loading screen
  34307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34308. */
  34309. export class DefaultLoadingScreen implements ILoadingScreen {
  34310. private _renderingCanvas;
  34311. private _loadingText;
  34312. private _loadingDivBackgroundColor;
  34313. private _loadingDiv;
  34314. private _loadingTextDiv;
  34315. /** Gets or sets the logo url to use for the default loading screen */
  34316. static DefaultLogoUrl: string;
  34317. /** Gets or sets the spinner url to use for the default loading screen */
  34318. static DefaultSpinnerUrl: string;
  34319. /**
  34320. * Creates a new default loading screen
  34321. * @param _renderingCanvas defines the canvas used to render the scene
  34322. * @param _loadingText defines the default text to display
  34323. * @param _loadingDivBackgroundColor defines the default background color
  34324. */
  34325. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34326. /**
  34327. * Function called to display the loading screen
  34328. */
  34329. displayLoadingUI(): void;
  34330. /**
  34331. * Function called to hide the loading screen
  34332. */
  34333. hideLoadingUI(): void;
  34334. /**
  34335. * Gets or sets the text to display while loading
  34336. */
  34337. set loadingUIText(text: string);
  34338. get loadingUIText(): string;
  34339. /**
  34340. * Gets or sets the color to use for the background
  34341. */
  34342. get loadingUIBackgroundColor(): string;
  34343. set loadingUIBackgroundColor(color: string);
  34344. private _resizeLoadingUI;
  34345. }
  34346. }
  34347. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34348. /**
  34349. * Interface for any object that can request an animation frame
  34350. */
  34351. export interface ICustomAnimationFrameRequester {
  34352. /**
  34353. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34354. */
  34355. renderFunction?: Function;
  34356. /**
  34357. * Called to request the next frame to render to
  34358. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34359. */
  34360. requestAnimationFrame: Function;
  34361. /**
  34362. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34363. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34364. */
  34365. requestID?: number;
  34366. }
  34367. }
  34368. declare module "babylonjs/Misc/performanceMonitor" {
  34369. /**
  34370. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34371. */
  34372. export class PerformanceMonitor {
  34373. private _enabled;
  34374. private _rollingFrameTime;
  34375. private _lastFrameTimeMs;
  34376. /**
  34377. * constructor
  34378. * @param frameSampleSize The number of samples required to saturate the sliding window
  34379. */
  34380. constructor(frameSampleSize?: number);
  34381. /**
  34382. * Samples current frame
  34383. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34384. */
  34385. sampleFrame(timeMs?: number): void;
  34386. /**
  34387. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34388. */
  34389. get averageFrameTime(): number;
  34390. /**
  34391. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34392. */
  34393. get averageFrameTimeVariance(): number;
  34394. /**
  34395. * Returns the frame time of the most recent frame
  34396. */
  34397. get instantaneousFrameTime(): number;
  34398. /**
  34399. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34400. */
  34401. get averageFPS(): number;
  34402. /**
  34403. * Returns the average framerate in frames per second using the most recent frame time
  34404. */
  34405. get instantaneousFPS(): number;
  34406. /**
  34407. * Returns true if enough samples have been taken to completely fill the sliding window
  34408. */
  34409. get isSaturated(): boolean;
  34410. /**
  34411. * Enables contributions to the sliding window sample set
  34412. */
  34413. enable(): void;
  34414. /**
  34415. * Disables contributions to the sliding window sample set
  34416. * Samples will not be interpolated over the disabled period
  34417. */
  34418. disable(): void;
  34419. /**
  34420. * Returns true if sampling is enabled
  34421. */
  34422. get isEnabled(): boolean;
  34423. /**
  34424. * Resets performance monitor
  34425. */
  34426. reset(): void;
  34427. }
  34428. /**
  34429. * RollingAverage
  34430. *
  34431. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34432. */
  34433. export class RollingAverage {
  34434. /**
  34435. * Current average
  34436. */
  34437. average: number;
  34438. /**
  34439. * Current variance
  34440. */
  34441. variance: number;
  34442. protected _samples: Array<number>;
  34443. protected _sampleCount: number;
  34444. protected _pos: number;
  34445. protected _m2: number;
  34446. /**
  34447. * constructor
  34448. * @param length The number of samples required to saturate the sliding window
  34449. */
  34450. constructor(length: number);
  34451. /**
  34452. * Adds a sample to the sample set
  34453. * @param v The sample value
  34454. */
  34455. add(v: number): void;
  34456. /**
  34457. * Returns previously added values or null if outside of history or outside the sliding window domain
  34458. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34459. * @return Value previously recorded with add() or null if outside of range
  34460. */
  34461. history(i: number): number;
  34462. /**
  34463. * Returns true if enough samples have been taken to completely fill the sliding window
  34464. * @return true if sample-set saturated
  34465. */
  34466. isSaturated(): boolean;
  34467. /**
  34468. * Resets the rolling average (equivalent to 0 samples taken so far)
  34469. */
  34470. reset(): void;
  34471. /**
  34472. * Wraps a value around the sample range boundaries
  34473. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34474. * @return Wrapped position in sample range
  34475. */
  34476. protected _wrapPosition(i: number): number;
  34477. }
  34478. }
  34479. declare module "babylonjs/Misc/perfCounter" {
  34480. /**
  34481. * This class is used to track a performance counter which is number based.
  34482. * The user has access to many properties which give statistics of different nature.
  34483. *
  34484. * The implementer can track two kinds of Performance Counter: time and count.
  34485. * 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.
  34486. * 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.
  34487. */
  34488. export class PerfCounter {
  34489. /**
  34490. * Gets or sets a global boolean to turn on and off all the counters
  34491. */
  34492. static Enabled: boolean;
  34493. /**
  34494. * Returns the smallest value ever
  34495. */
  34496. get min(): number;
  34497. /**
  34498. * Returns the biggest value ever
  34499. */
  34500. get max(): number;
  34501. /**
  34502. * Returns the average value since the performance counter is running
  34503. */
  34504. get average(): number;
  34505. /**
  34506. * Returns the average value of the last second the counter was monitored
  34507. */
  34508. get lastSecAverage(): number;
  34509. /**
  34510. * Returns the current value
  34511. */
  34512. get current(): number;
  34513. /**
  34514. * Gets the accumulated total
  34515. */
  34516. get total(): number;
  34517. /**
  34518. * Gets the total value count
  34519. */
  34520. get count(): number;
  34521. /**
  34522. * Creates a new counter
  34523. */
  34524. constructor();
  34525. /**
  34526. * Call this method to start monitoring a new frame.
  34527. * 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.
  34528. */
  34529. fetchNewFrame(): void;
  34530. /**
  34531. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34532. * @param newCount the count value to add to the monitored count
  34533. * @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.
  34534. */
  34535. addCount(newCount: number, fetchResult: boolean): void;
  34536. /**
  34537. * Start monitoring this performance counter
  34538. */
  34539. beginMonitoring(): void;
  34540. /**
  34541. * Compute the time lapsed since the previous beginMonitoring() call.
  34542. * @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
  34543. */
  34544. endMonitoring(newFrame?: boolean): void;
  34545. private _fetchResult;
  34546. private _startMonitoringTime;
  34547. private _min;
  34548. private _max;
  34549. private _average;
  34550. private _current;
  34551. private _totalValueCount;
  34552. private _totalAccumulated;
  34553. private _lastSecAverage;
  34554. private _lastSecAccumulated;
  34555. private _lastSecTime;
  34556. private _lastSecValueCount;
  34557. }
  34558. }
  34559. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34560. module "babylonjs/Engines/thinEngine" {
  34561. interface ThinEngine {
  34562. /**
  34563. * Sets alpha constants used by some alpha blending modes
  34564. * @param r defines the red component
  34565. * @param g defines the green component
  34566. * @param b defines the blue component
  34567. * @param a defines the alpha component
  34568. */
  34569. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34570. /**
  34571. * Sets the current alpha mode
  34572. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34573. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34575. */
  34576. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34577. /**
  34578. * Gets the current alpha mode
  34579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34580. * @returns the current alpha mode
  34581. */
  34582. getAlphaMode(): number;
  34583. /**
  34584. * Sets the current alpha equation
  34585. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34586. */
  34587. setAlphaEquation(equation: number): void;
  34588. /**
  34589. * Gets the current alpha equation.
  34590. * @returns the current alpha equation
  34591. */
  34592. getAlphaEquation(): number;
  34593. }
  34594. }
  34595. }
  34596. declare module "babylonjs/Engines/engine" {
  34597. import { Observable } from "babylonjs/Misc/observable";
  34598. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34599. import { Scene } from "babylonjs/scene";
  34600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34601. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34602. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34603. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34604. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34605. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34606. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34607. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34608. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34610. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34611. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34612. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34613. import "babylonjs/Engines/Extensions/engine.alpha";
  34614. import { Material } from "babylonjs/Materials/material";
  34615. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34616. /**
  34617. * Defines the interface used by display changed events
  34618. */
  34619. export interface IDisplayChangedEventArgs {
  34620. /** Gets the vrDisplay object (if any) */
  34621. vrDisplay: Nullable<any>;
  34622. /** Gets a boolean indicating if webVR is supported */
  34623. vrSupported: boolean;
  34624. }
  34625. /**
  34626. * Defines the interface used by objects containing a viewport (like a camera)
  34627. */
  34628. interface IViewportOwnerLike {
  34629. /**
  34630. * Gets or sets the viewport
  34631. */
  34632. viewport: IViewportLike;
  34633. }
  34634. /**
  34635. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34636. */
  34637. export class Engine extends ThinEngine {
  34638. /** Defines that alpha blending is disabled */
  34639. static readonly ALPHA_DISABLE: number;
  34640. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34641. static readonly ALPHA_ADD: number;
  34642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34643. static readonly ALPHA_COMBINE: number;
  34644. /** Defines that alpha blending to DEST - SRC * DEST */
  34645. static readonly ALPHA_SUBTRACT: number;
  34646. /** Defines that alpha blending to SRC * DEST */
  34647. static readonly ALPHA_MULTIPLY: number;
  34648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34649. static readonly ALPHA_MAXIMIZED: number;
  34650. /** Defines that alpha blending to SRC + DEST */
  34651. static readonly ALPHA_ONEONE: number;
  34652. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34653. static readonly ALPHA_PREMULTIPLIED: number;
  34654. /**
  34655. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34656. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34657. */
  34658. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34659. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34660. static readonly ALPHA_INTERPOLATE: number;
  34661. /**
  34662. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34663. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34664. */
  34665. static readonly ALPHA_SCREENMODE: number;
  34666. /** Defines that the ressource is not delayed*/
  34667. static readonly DELAYLOADSTATE_NONE: number;
  34668. /** Defines that the ressource was successfully delay loaded */
  34669. static readonly DELAYLOADSTATE_LOADED: number;
  34670. /** Defines that the ressource is currently delay loading */
  34671. static readonly DELAYLOADSTATE_LOADING: number;
  34672. /** Defines that the ressource is delayed and has not started loading */
  34673. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34675. static readonly NEVER: number;
  34676. /** 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 */
  34677. static readonly ALWAYS: number;
  34678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34679. static readonly LESS: number;
  34680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34681. static readonly EQUAL: number;
  34682. /** 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 */
  34683. static readonly LEQUAL: number;
  34684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34685. static readonly GREATER: number;
  34686. /** 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 */
  34687. static readonly GEQUAL: number;
  34688. /** 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 */
  34689. static readonly NOTEQUAL: number;
  34690. /** Passed to stencilOperation to specify that stencil value must be kept */
  34691. static readonly KEEP: number;
  34692. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34693. static readonly REPLACE: number;
  34694. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34695. static readonly INCR: number;
  34696. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34697. static readonly DECR: number;
  34698. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34699. static readonly INVERT: number;
  34700. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34701. static readonly INCR_WRAP: number;
  34702. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34703. static readonly DECR_WRAP: number;
  34704. /** Texture is not repeating outside of 0..1 UVs */
  34705. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34706. /** Texture is repeating outside of 0..1 UVs */
  34707. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34708. /** Texture is repeating and mirrored */
  34709. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34710. /** ALPHA */
  34711. static readonly TEXTUREFORMAT_ALPHA: number;
  34712. /** LUMINANCE */
  34713. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34714. /** LUMINANCE_ALPHA */
  34715. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34716. /** RGB */
  34717. static readonly TEXTUREFORMAT_RGB: number;
  34718. /** RGBA */
  34719. static readonly TEXTUREFORMAT_RGBA: number;
  34720. /** RED */
  34721. static readonly TEXTUREFORMAT_RED: number;
  34722. /** RED (2nd reference) */
  34723. static readonly TEXTUREFORMAT_R: number;
  34724. /** RG */
  34725. static readonly TEXTUREFORMAT_RG: number;
  34726. /** RED_INTEGER */
  34727. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34728. /** RED_INTEGER (2nd reference) */
  34729. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34730. /** RG_INTEGER */
  34731. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34732. /** RGB_INTEGER */
  34733. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34734. /** RGBA_INTEGER */
  34735. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34736. /** UNSIGNED_BYTE */
  34737. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34738. /** UNSIGNED_BYTE (2nd reference) */
  34739. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34740. /** FLOAT */
  34741. static readonly TEXTURETYPE_FLOAT: number;
  34742. /** HALF_FLOAT */
  34743. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34744. /** BYTE */
  34745. static readonly TEXTURETYPE_BYTE: number;
  34746. /** SHORT */
  34747. static readonly TEXTURETYPE_SHORT: number;
  34748. /** UNSIGNED_SHORT */
  34749. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34750. /** INT */
  34751. static readonly TEXTURETYPE_INT: number;
  34752. /** UNSIGNED_INT */
  34753. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34754. /** UNSIGNED_SHORT_4_4_4_4 */
  34755. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34756. /** UNSIGNED_SHORT_5_5_5_1 */
  34757. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34758. /** UNSIGNED_SHORT_5_6_5 */
  34759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34760. /** UNSIGNED_INT_2_10_10_10_REV */
  34761. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34762. /** UNSIGNED_INT_24_8 */
  34763. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34764. /** UNSIGNED_INT_10F_11F_11F_REV */
  34765. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34766. /** UNSIGNED_INT_5_9_9_9_REV */
  34767. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34768. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34769. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34770. /** nearest is mag = nearest and min = nearest and mip = linear */
  34771. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34773. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34774. /** Trilinear is mag = linear and min = linear and mip = linear */
  34775. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34776. /** nearest is mag = nearest and min = nearest and mip = linear */
  34777. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34779. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34780. /** Trilinear is mag = linear and min = linear and mip = linear */
  34781. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34782. /** mag = nearest and min = nearest and mip = nearest */
  34783. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34784. /** mag = nearest and min = linear and mip = nearest */
  34785. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34786. /** mag = nearest and min = linear and mip = linear */
  34787. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34788. /** mag = nearest and min = linear and mip = none */
  34789. static readonly TEXTURE_NEAREST_LINEAR: number;
  34790. /** mag = nearest and min = nearest and mip = none */
  34791. static readonly TEXTURE_NEAREST_NEAREST: number;
  34792. /** mag = linear and min = nearest and mip = nearest */
  34793. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34794. /** mag = linear and min = nearest and mip = linear */
  34795. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34796. /** mag = linear and min = linear and mip = none */
  34797. static readonly TEXTURE_LINEAR_LINEAR: number;
  34798. /** mag = linear and min = nearest and mip = none */
  34799. static readonly TEXTURE_LINEAR_NEAREST: number;
  34800. /** Explicit coordinates mode */
  34801. static readonly TEXTURE_EXPLICIT_MODE: number;
  34802. /** Spherical coordinates mode */
  34803. static readonly TEXTURE_SPHERICAL_MODE: number;
  34804. /** Planar coordinates mode */
  34805. static readonly TEXTURE_PLANAR_MODE: number;
  34806. /** Cubic coordinates mode */
  34807. static readonly TEXTURE_CUBIC_MODE: number;
  34808. /** Projection coordinates mode */
  34809. static readonly TEXTURE_PROJECTION_MODE: number;
  34810. /** Skybox coordinates mode */
  34811. static readonly TEXTURE_SKYBOX_MODE: number;
  34812. /** Inverse Cubic coordinates mode */
  34813. static readonly TEXTURE_INVCUBIC_MODE: number;
  34814. /** Equirectangular coordinates mode */
  34815. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34816. /** Equirectangular Fixed coordinates mode */
  34817. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34818. /** Equirectangular Fixed Mirrored coordinates mode */
  34819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34820. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34821. static readonly SCALEMODE_FLOOR: number;
  34822. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34823. static readonly SCALEMODE_NEAREST: number;
  34824. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34825. static readonly SCALEMODE_CEILING: number;
  34826. /**
  34827. * Returns the current npm package of the sdk
  34828. */
  34829. static get NpmPackage(): string;
  34830. /**
  34831. * Returns the current version of the framework
  34832. */
  34833. static get Version(): string;
  34834. /** Gets the list of created engines */
  34835. static get Instances(): Engine[];
  34836. /**
  34837. * Gets the latest created engine
  34838. */
  34839. static get LastCreatedEngine(): Nullable<Engine>;
  34840. /**
  34841. * Gets the latest created scene
  34842. */
  34843. static get LastCreatedScene(): Nullable<Scene>;
  34844. /**
  34845. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34846. * @param flag defines which part of the materials must be marked as dirty
  34847. * @param predicate defines a predicate used to filter which materials should be affected
  34848. */
  34849. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34850. /**
  34851. * Method called to create the default loading screen.
  34852. * This can be overriden in your own app.
  34853. * @param canvas The rendering canvas element
  34854. * @returns The loading screen
  34855. */
  34856. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34857. /**
  34858. * Method called to create the default rescale post process on each engine.
  34859. */
  34860. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34861. /**
  34862. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34863. **/
  34864. enableOfflineSupport: boolean;
  34865. /**
  34866. * 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)
  34867. **/
  34868. disableManifestCheck: boolean;
  34869. /**
  34870. * Gets the list of created scenes
  34871. */
  34872. scenes: Scene[];
  34873. /**
  34874. * Event raised when a new scene is created
  34875. */
  34876. onNewSceneAddedObservable: Observable<Scene>;
  34877. /**
  34878. * Gets the list of created postprocesses
  34879. */
  34880. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34881. /**
  34882. * Gets a boolean indicating if the pointer is currently locked
  34883. */
  34884. isPointerLock: boolean;
  34885. /**
  34886. * Observable event triggered each time the rendering canvas is resized
  34887. */
  34888. onResizeObservable: Observable<Engine>;
  34889. /**
  34890. * Observable event triggered each time the canvas loses focus
  34891. */
  34892. onCanvasBlurObservable: Observable<Engine>;
  34893. /**
  34894. * Observable event triggered each time the canvas gains focus
  34895. */
  34896. onCanvasFocusObservable: Observable<Engine>;
  34897. /**
  34898. * Observable event triggered each time the canvas receives pointerout event
  34899. */
  34900. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34901. /**
  34902. * Observable raised when the engine begins a new frame
  34903. */
  34904. onBeginFrameObservable: Observable<Engine>;
  34905. /**
  34906. * If set, will be used to request the next animation frame for the render loop
  34907. */
  34908. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34909. /**
  34910. * Observable raised when the engine ends the current frame
  34911. */
  34912. onEndFrameObservable: Observable<Engine>;
  34913. /**
  34914. * Observable raised when the engine is about to compile a shader
  34915. */
  34916. onBeforeShaderCompilationObservable: Observable<Engine>;
  34917. /**
  34918. * Observable raised when the engine has jsut compiled a shader
  34919. */
  34920. onAfterShaderCompilationObservable: Observable<Engine>;
  34921. /**
  34922. * Gets the audio engine
  34923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34924. * @ignorenaming
  34925. */
  34926. static audioEngine: IAudioEngine;
  34927. /**
  34928. * Default AudioEngine factory responsible of creating the Audio Engine.
  34929. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34930. */
  34931. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34932. /**
  34933. * Default offline support factory responsible of creating a tool used to store data locally.
  34934. * By default, this will create a Database object if the workload has been embedded.
  34935. */
  34936. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34937. private _loadingScreen;
  34938. private _pointerLockRequested;
  34939. private _dummyFramebuffer;
  34940. private _rescalePostProcess;
  34941. private _deterministicLockstep;
  34942. private _lockstepMaxSteps;
  34943. private _timeStep;
  34944. protected get _supportsHardwareTextureRescaling(): boolean;
  34945. private _fps;
  34946. private _deltaTime;
  34947. /** @hidden */
  34948. _drawCalls: PerfCounter;
  34949. /** 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 */
  34950. canvasTabIndex: number;
  34951. /**
  34952. * Turn this value on if you want to pause FPS computation when in background
  34953. */
  34954. disablePerformanceMonitorInBackground: boolean;
  34955. private _performanceMonitor;
  34956. /**
  34957. * Gets the performance monitor attached to this engine
  34958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34959. */
  34960. get performanceMonitor(): PerformanceMonitor;
  34961. private _onFocus;
  34962. private _onBlur;
  34963. private _onCanvasPointerOut;
  34964. private _onCanvasBlur;
  34965. private _onCanvasFocus;
  34966. private _onFullscreenChange;
  34967. private _onPointerLockChange;
  34968. /**
  34969. * Gets the HTML element used to attach event listeners
  34970. * @returns a HTML element
  34971. */
  34972. getInputElement(): Nullable<HTMLElement>;
  34973. /**
  34974. * Creates a new engine
  34975. * @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
  34976. * @param antialias defines enable antialiasing (default: false)
  34977. * @param options defines further options to be sent to the getContext() function
  34978. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34979. */
  34980. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34981. /**
  34982. * Gets current aspect ratio
  34983. * @param viewportOwner defines the camera to use to get the aspect ratio
  34984. * @param useScreen defines if screen size must be used (or the current render target if any)
  34985. * @returns a number defining the aspect ratio
  34986. */
  34987. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34988. /**
  34989. * Gets current screen aspect ratio
  34990. * @returns a number defining the aspect ratio
  34991. */
  34992. getScreenAspectRatio(): number;
  34993. /**
  34994. * Gets the client rect of the HTML canvas attached with the current webGL context
  34995. * @returns a client rectanglee
  34996. */
  34997. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34998. /**
  34999. * Gets the client rect of the HTML element used for events
  35000. * @returns a client rectanglee
  35001. */
  35002. getInputElementClientRect(): Nullable<ClientRect>;
  35003. /**
  35004. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35006. * @returns true if engine is in deterministic lock step mode
  35007. */
  35008. isDeterministicLockStep(): boolean;
  35009. /**
  35010. * Gets the max steps when engine is running in deterministic lock step
  35011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35012. * @returns the max steps
  35013. */
  35014. getLockstepMaxSteps(): number;
  35015. /**
  35016. * Returns the time in ms between steps when using deterministic lock step.
  35017. * @returns time step in (ms)
  35018. */
  35019. getTimeStep(): number;
  35020. /**
  35021. * Force the mipmap generation for the given render target texture
  35022. * @param texture defines the render target texture to use
  35023. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35024. */
  35025. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35026. /** States */
  35027. /**
  35028. * Set various states to the webGL context
  35029. * @param culling defines backface culling state
  35030. * @param zOffset defines the value to apply to zOffset (0 by default)
  35031. * @param force defines if states must be applied even if cache is up to date
  35032. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35033. */
  35034. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35035. /**
  35036. * Set the z offset to apply to current rendering
  35037. * @param value defines the offset to apply
  35038. */
  35039. setZOffset(value: number): void;
  35040. /**
  35041. * Gets the current value of the zOffset
  35042. * @returns the current zOffset state
  35043. */
  35044. getZOffset(): number;
  35045. /**
  35046. * Enable or disable depth buffering
  35047. * @param enable defines the state to set
  35048. */
  35049. setDepthBuffer(enable: boolean): void;
  35050. /**
  35051. * Gets a boolean indicating if depth writing is enabled
  35052. * @returns the current depth writing state
  35053. */
  35054. getDepthWrite(): boolean;
  35055. /**
  35056. * Enable or disable depth writing
  35057. * @param enable defines the state to set
  35058. */
  35059. setDepthWrite(enable: boolean): void;
  35060. /**
  35061. * Gets a boolean indicating if stencil buffer is enabled
  35062. * @returns the current stencil buffer state
  35063. */
  35064. getStencilBuffer(): boolean;
  35065. /**
  35066. * Enable or disable the stencil buffer
  35067. * @param enable defines if the stencil buffer must be enabled or disabled
  35068. */
  35069. setStencilBuffer(enable: boolean): void;
  35070. /**
  35071. * Gets the current stencil mask
  35072. * @returns a number defining the new stencil mask to use
  35073. */
  35074. getStencilMask(): number;
  35075. /**
  35076. * Sets the current stencil mask
  35077. * @param mask defines the new stencil mask to use
  35078. */
  35079. setStencilMask(mask: number): void;
  35080. /**
  35081. * Gets the current stencil function
  35082. * @returns a number defining the stencil function to use
  35083. */
  35084. getStencilFunction(): number;
  35085. /**
  35086. * Gets the current stencil reference value
  35087. * @returns a number defining the stencil reference value to use
  35088. */
  35089. getStencilFunctionReference(): number;
  35090. /**
  35091. * Gets the current stencil mask
  35092. * @returns a number defining the stencil mask to use
  35093. */
  35094. getStencilFunctionMask(): number;
  35095. /**
  35096. * Sets the current stencil function
  35097. * @param stencilFunc defines the new stencil function to use
  35098. */
  35099. setStencilFunction(stencilFunc: number): void;
  35100. /**
  35101. * Sets the current stencil reference
  35102. * @param reference defines the new stencil reference to use
  35103. */
  35104. setStencilFunctionReference(reference: number): void;
  35105. /**
  35106. * Sets the current stencil mask
  35107. * @param mask defines the new stencil mask to use
  35108. */
  35109. setStencilFunctionMask(mask: number): void;
  35110. /**
  35111. * Gets the current stencil operation when stencil fails
  35112. * @returns a number defining stencil operation to use when stencil fails
  35113. */
  35114. getStencilOperationFail(): number;
  35115. /**
  35116. * Gets the current stencil operation when depth fails
  35117. * @returns a number defining stencil operation to use when depth fails
  35118. */
  35119. getStencilOperationDepthFail(): number;
  35120. /**
  35121. * Gets the current stencil operation when stencil passes
  35122. * @returns a number defining stencil operation to use when stencil passes
  35123. */
  35124. getStencilOperationPass(): number;
  35125. /**
  35126. * Sets the stencil operation to use when stencil fails
  35127. * @param operation defines the stencil operation to use when stencil fails
  35128. */
  35129. setStencilOperationFail(operation: number): void;
  35130. /**
  35131. * Sets the stencil operation to use when depth fails
  35132. * @param operation defines the stencil operation to use when depth fails
  35133. */
  35134. setStencilOperationDepthFail(operation: number): void;
  35135. /**
  35136. * Sets the stencil operation to use when stencil passes
  35137. * @param operation defines the stencil operation to use when stencil passes
  35138. */
  35139. setStencilOperationPass(operation: number): void;
  35140. /**
  35141. * Sets a boolean indicating if the dithering state is enabled or disabled
  35142. * @param value defines the dithering state
  35143. */
  35144. setDitheringState(value: boolean): void;
  35145. /**
  35146. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35147. * @param value defines the rasterizer state
  35148. */
  35149. setRasterizerState(value: boolean): void;
  35150. /**
  35151. * Gets the current depth function
  35152. * @returns a number defining the depth function
  35153. */
  35154. getDepthFunction(): Nullable<number>;
  35155. /**
  35156. * Sets the current depth function
  35157. * @param depthFunc defines the function to use
  35158. */
  35159. setDepthFunction(depthFunc: number): void;
  35160. /**
  35161. * Sets the current depth function to GREATER
  35162. */
  35163. setDepthFunctionToGreater(): void;
  35164. /**
  35165. * Sets the current depth function to GEQUAL
  35166. */
  35167. setDepthFunctionToGreaterOrEqual(): void;
  35168. /**
  35169. * Sets the current depth function to LESS
  35170. */
  35171. setDepthFunctionToLess(): void;
  35172. /**
  35173. * Sets the current depth function to LEQUAL
  35174. */
  35175. setDepthFunctionToLessOrEqual(): void;
  35176. private _cachedStencilBuffer;
  35177. private _cachedStencilFunction;
  35178. private _cachedStencilMask;
  35179. private _cachedStencilOperationPass;
  35180. private _cachedStencilOperationFail;
  35181. private _cachedStencilOperationDepthFail;
  35182. private _cachedStencilReference;
  35183. /**
  35184. * Caches the the state of the stencil buffer
  35185. */
  35186. cacheStencilState(): void;
  35187. /**
  35188. * Restores the state of the stencil buffer
  35189. */
  35190. restoreStencilState(): void;
  35191. /**
  35192. * Directly set the WebGL Viewport
  35193. * @param x defines the x coordinate of the viewport (in screen space)
  35194. * @param y defines the y coordinate of the viewport (in screen space)
  35195. * @param width defines the width of the viewport (in screen space)
  35196. * @param height defines the height of the viewport (in screen space)
  35197. * @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
  35198. */
  35199. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35200. /**
  35201. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35202. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35203. * @param y defines the y-coordinate of the corner of the clear rectangle
  35204. * @param width defines the width of the clear rectangle
  35205. * @param height defines the height of the clear rectangle
  35206. * @param clearColor defines the clear color
  35207. */
  35208. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35209. /**
  35210. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35211. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35212. * @param y defines the y-coordinate of the corner of the clear rectangle
  35213. * @param width defines the width of the clear rectangle
  35214. * @param height defines the height of the clear rectangle
  35215. */
  35216. enableScissor(x: number, y: number, width: number, height: number): void;
  35217. /**
  35218. * Disable previously set scissor test rectangle
  35219. */
  35220. disableScissor(): void;
  35221. protected _reportDrawCall(): void;
  35222. /**
  35223. * Initializes a webVR display and starts listening to display change events
  35224. * The onVRDisplayChangedObservable will be notified upon these changes
  35225. * @returns The onVRDisplayChangedObservable
  35226. */
  35227. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35228. /** @hidden */
  35229. _prepareVRComponent(): void;
  35230. /** @hidden */
  35231. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35232. /** @hidden */
  35233. _submitVRFrame(): void;
  35234. /**
  35235. * Call this function to leave webVR mode
  35236. * Will do nothing if webVR is not supported or if there is no webVR device
  35237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35238. */
  35239. disableVR(): void;
  35240. /**
  35241. * Gets a boolean indicating that the system is in VR mode and is presenting
  35242. * @returns true if VR mode is engaged
  35243. */
  35244. isVRPresenting(): boolean;
  35245. /** @hidden */
  35246. _requestVRFrame(): void;
  35247. /** @hidden */
  35248. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35249. /**
  35250. * Gets the source code of the vertex shader associated with a specific webGL program
  35251. * @param program defines the program to use
  35252. * @returns a string containing the source code of the vertex shader associated with the program
  35253. */
  35254. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35255. /**
  35256. * Gets the source code of the fragment shader associated with a specific webGL program
  35257. * @param program defines the program to use
  35258. * @returns a string containing the source code of the fragment shader associated with the program
  35259. */
  35260. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35261. /**
  35262. * Sets a depth stencil texture from a render target to the according uniform.
  35263. * @param channel The texture channel
  35264. * @param uniform The uniform to set
  35265. * @param texture The render target texture containing the depth stencil texture to apply
  35266. */
  35267. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35268. /**
  35269. * Sets a texture to the webGL context from a postprocess
  35270. * @param channel defines the channel to use
  35271. * @param postProcess defines the source postprocess
  35272. */
  35273. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35274. /**
  35275. * Binds the output of the passed in post process to the texture channel specified
  35276. * @param channel The channel the texture should be bound to
  35277. * @param postProcess The post process which's output should be bound
  35278. */
  35279. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35280. protected _rebuildBuffers(): void;
  35281. /** @hidden */
  35282. _renderFrame(): void;
  35283. _renderLoop(): void;
  35284. /** @hidden */
  35285. _renderViews(): boolean;
  35286. /**
  35287. * Toggle full screen mode
  35288. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35289. */
  35290. switchFullscreen(requestPointerLock: boolean): void;
  35291. /**
  35292. * Enters full screen mode
  35293. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35294. */
  35295. enterFullscreen(requestPointerLock: boolean): void;
  35296. /**
  35297. * Exits full screen mode
  35298. */
  35299. exitFullscreen(): void;
  35300. /**
  35301. * Enters Pointerlock mode
  35302. */
  35303. enterPointerlock(): void;
  35304. /**
  35305. * Exits Pointerlock mode
  35306. */
  35307. exitPointerlock(): void;
  35308. /**
  35309. * Begin a new frame
  35310. */
  35311. beginFrame(): void;
  35312. /**
  35313. * Enf the current frame
  35314. */
  35315. endFrame(): void;
  35316. resize(): void;
  35317. /**
  35318. * Force a specific size of the canvas
  35319. * @param width defines the new canvas' width
  35320. * @param height defines the new canvas' height
  35321. */
  35322. setSize(width: number, height: number): void;
  35323. /**
  35324. * Updates a dynamic vertex buffer.
  35325. * @param vertexBuffer the vertex buffer to update
  35326. * @param data the data used to update the vertex buffer
  35327. * @param byteOffset the byte offset of the data
  35328. * @param byteLength the byte length of the data
  35329. */
  35330. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35331. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35332. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35333. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35334. _releaseTexture(texture: InternalTexture): void;
  35335. /**
  35336. * @hidden
  35337. * Rescales a texture
  35338. * @param source input texutre
  35339. * @param destination destination texture
  35340. * @param scene scene to use to render the resize
  35341. * @param internalFormat format to use when resizing
  35342. * @param onComplete callback to be called when resize has completed
  35343. */
  35344. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35345. /**
  35346. * Gets the current framerate
  35347. * @returns a number representing the framerate
  35348. */
  35349. getFps(): number;
  35350. /**
  35351. * Gets the time spent between current and previous frame
  35352. * @returns a number representing the delta time in ms
  35353. */
  35354. getDeltaTime(): number;
  35355. private _measureFps;
  35356. /** @hidden */
  35357. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35358. /**
  35359. * Update a dynamic index buffer
  35360. * @param indexBuffer defines the target index buffer
  35361. * @param indices defines the data to update
  35362. * @param offset defines the offset in the target index buffer where update should start
  35363. */
  35364. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35365. /**
  35366. * Updates the sample count of a render target texture
  35367. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35368. * @param texture defines the texture to update
  35369. * @param samples defines the sample count to set
  35370. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35371. */
  35372. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35373. /**
  35374. * Updates a depth texture Comparison Mode and Function.
  35375. * If the comparison Function is equal to 0, the mode will be set to none.
  35376. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35377. * @param texture The texture to set the comparison function for
  35378. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35379. */
  35380. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35381. /**
  35382. * Creates a webGL buffer to use with instanciation
  35383. * @param capacity defines the size of the buffer
  35384. * @returns the webGL buffer
  35385. */
  35386. createInstancesBuffer(capacity: number): DataBuffer;
  35387. /**
  35388. * Delete a webGL buffer used with instanciation
  35389. * @param buffer defines the webGL buffer to delete
  35390. */
  35391. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35392. private _clientWaitAsync;
  35393. /** @hidden */
  35394. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35395. /** @hidden */
  35396. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35397. dispose(): void;
  35398. private _disableTouchAction;
  35399. /**
  35400. * Display the loading screen
  35401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35402. */
  35403. displayLoadingUI(): void;
  35404. /**
  35405. * Hide the loading screen
  35406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35407. */
  35408. hideLoadingUI(): void;
  35409. /**
  35410. * Gets the current loading screen object
  35411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35412. */
  35413. get loadingScreen(): ILoadingScreen;
  35414. /**
  35415. * Sets the current loading screen object
  35416. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35417. */
  35418. set loadingScreen(loadingScreen: ILoadingScreen);
  35419. /**
  35420. * Sets the current loading screen text
  35421. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35422. */
  35423. set loadingUIText(text: string);
  35424. /**
  35425. * Sets the current loading screen background color
  35426. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35427. */
  35428. set loadingUIBackgroundColor(color: string);
  35429. /** Pointerlock and fullscreen */
  35430. /**
  35431. * Ask the browser to promote the current element to pointerlock mode
  35432. * @param element defines the DOM element to promote
  35433. */
  35434. static _RequestPointerlock(element: HTMLElement): void;
  35435. /**
  35436. * Asks the browser to exit pointerlock mode
  35437. */
  35438. static _ExitPointerlock(): void;
  35439. /**
  35440. * Ask the browser to promote the current element to fullscreen rendering mode
  35441. * @param element defines the DOM element to promote
  35442. */
  35443. static _RequestFullscreen(element: HTMLElement): void;
  35444. /**
  35445. * Asks the browser to exit fullscreen mode
  35446. */
  35447. static _ExitFullscreen(): void;
  35448. }
  35449. }
  35450. declare module "babylonjs/Engines/engineStore" {
  35451. import { Nullable } from "babylonjs/types";
  35452. import { Engine } from "babylonjs/Engines/engine";
  35453. import { Scene } from "babylonjs/scene";
  35454. /**
  35455. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35456. * during the life time of the application.
  35457. */
  35458. export class EngineStore {
  35459. /** Gets the list of created engines */
  35460. static Instances: import("babylonjs/Engines/engine").Engine[];
  35461. /** @hidden */
  35462. static _LastCreatedScene: Nullable<Scene>;
  35463. /**
  35464. * Gets the latest created engine
  35465. */
  35466. static get LastCreatedEngine(): Nullable<Engine>;
  35467. /**
  35468. * Gets the latest created scene
  35469. */
  35470. static get LastCreatedScene(): Nullable<Scene>;
  35471. /**
  35472. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35473. * @ignorenaming
  35474. */
  35475. static UseFallbackTexture: boolean;
  35476. /**
  35477. * Texture content used if a texture cannot loaded
  35478. * @ignorenaming
  35479. */
  35480. static FallbackTexture: string;
  35481. }
  35482. }
  35483. declare module "babylonjs/Misc/promise" {
  35484. /**
  35485. * Helper class that provides a small promise polyfill
  35486. */
  35487. export class PromisePolyfill {
  35488. /**
  35489. * Static function used to check if the polyfill is required
  35490. * If this is the case then the function will inject the polyfill to window.Promise
  35491. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35492. */
  35493. static Apply(force?: boolean): void;
  35494. }
  35495. }
  35496. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35497. /**
  35498. * Interface for screenshot methods with describe argument called `size` as object with options
  35499. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35500. */
  35501. export interface IScreenshotSize {
  35502. /**
  35503. * number in pixels for canvas height
  35504. */
  35505. height?: number;
  35506. /**
  35507. * multiplier allowing render at a higher or lower resolution
  35508. * If value is defined then height and width will be ignored and taken from camera
  35509. */
  35510. precision?: number;
  35511. /**
  35512. * number in pixels for canvas width
  35513. */
  35514. width?: number;
  35515. }
  35516. }
  35517. declare module "babylonjs/Misc/tools" {
  35518. import { Nullable, float } from "babylonjs/types";
  35519. import { DomManagement } from "babylonjs/Misc/domManagement";
  35520. import { WebRequest } from "babylonjs/Misc/webRequest";
  35521. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35522. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35523. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35524. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35525. import { Camera } from "babylonjs/Cameras/camera";
  35526. import { Engine } from "babylonjs/Engines/engine";
  35527. interface IColor4Like {
  35528. r: float;
  35529. g: float;
  35530. b: float;
  35531. a: float;
  35532. }
  35533. /**
  35534. * Class containing a set of static utilities functions
  35535. */
  35536. export class Tools {
  35537. /**
  35538. * Gets or sets the base URL to use to load assets
  35539. */
  35540. static get BaseUrl(): string;
  35541. static set BaseUrl(value: string);
  35542. /**
  35543. * Enable/Disable Custom HTTP Request Headers globally.
  35544. * default = false
  35545. * @see CustomRequestHeaders
  35546. */
  35547. static UseCustomRequestHeaders: boolean;
  35548. /**
  35549. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35550. * i.e. when loading files, where the server/service expects an Authorization header
  35551. */
  35552. static CustomRequestHeaders: {
  35553. [key: string]: string;
  35554. };
  35555. /**
  35556. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35557. */
  35558. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35559. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35560. /**
  35561. * Default behaviour for cors in the application.
  35562. * It can be a string if the expected behavior is identical in the entire app.
  35563. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35564. */
  35565. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35566. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35567. /**
  35568. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35569. * @ignorenaming
  35570. */
  35571. static get UseFallbackTexture(): boolean;
  35572. static set UseFallbackTexture(value: boolean);
  35573. /**
  35574. * Use this object to register external classes like custom textures or material
  35575. * to allow the laoders to instantiate them
  35576. */
  35577. static get RegisteredExternalClasses(): {
  35578. [key: string]: Object;
  35579. };
  35580. static set RegisteredExternalClasses(classes: {
  35581. [key: string]: Object;
  35582. });
  35583. /**
  35584. * Texture content used if a texture cannot loaded
  35585. * @ignorenaming
  35586. */
  35587. static get fallbackTexture(): string;
  35588. static set fallbackTexture(value: string);
  35589. /**
  35590. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35591. * @param u defines the coordinate on X axis
  35592. * @param v defines the coordinate on Y axis
  35593. * @param width defines the width of the source data
  35594. * @param height defines the height of the source data
  35595. * @param pixels defines the source byte array
  35596. * @param color defines the output color
  35597. */
  35598. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35599. /**
  35600. * Interpolates between a and b via alpha
  35601. * @param a The lower value (returned when alpha = 0)
  35602. * @param b The upper value (returned when alpha = 1)
  35603. * @param alpha The interpolation-factor
  35604. * @return The mixed value
  35605. */
  35606. static Mix(a: number, b: number, alpha: number): number;
  35607. /**
  35608. * Tries to instantiate a new object from a given class name
  35609. * @param className defines the class name to instantiate
  35610. * @returns the new object or null if the system was not able to do the instantiation
  35611. */
  35612. static Instantiate(className: string): any;
  35613. /**
  35614. * Provides a slice function that will work even on IE
  35615. * @param data defines the array to slice
  35616. * @param start defines the start of the data (optional)
  35617. * @param end defines the end of the data (optional)
  35618. * @returns the new sliced array
  35619. */
  35620. static Slice<T>(data: T, start?: number, end?: number): T;
  35621. /**
  35622. * Polyfill for setImmediate
  35623. * @param action defines the action to execute after the current execution block
  35624. */
  35625. static SetImmediate(action: () => void): void;
  35626. /**
  35627. * Function indicating if a number is an exponent of 2
  35628. * @param value defines the value to test
  35629. * @returns true if the value is an exponent of 2
  35630. */
  35631. static IsExponentOfTwo(value: number): boolean;
  35632. private static _tmpFloatArray;
  35633. /**
  35634. * Returns the nearest 32-bit single precision float representation of a Number
  35635. * @param value A Number. If the parameter is of a different type, it will get converted
  35636. * to a number or to NaN if it cannot be converted
  35637. * @returns number
  35638. */
  35639. static FloatRound(value: number): number;
  35640. /**
  35641. * Extracts the filename from a path
  35642. * @param path defines the path to use
  35643. * @returns the filename
  35644. */
  35645. static GetFilename(path: string): string;
  35646. /**
  35647. * Extracts the "folder" part of a path (everything before the filename).
  35648. * @param uri The URI to extract the info from
  35649. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35650. * @returns The "folder" part of the path
  35651. */
  35652. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35653. /**
  35654. * Extracts text content from a DOM element hierarchy
  35655. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35656. */
  35657. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35658. /**
  35659. * Convert an angle in radians to degrees
  35660. * @param angle defines the angle to convert
  35661. * @returns the angle in degrees
  35662. */
  35663. static ToDegrees(angle: number): number;
  35664. /**
  35665. * Convert an angle in degrees to radians
  35666. * @param angle defines the angle to convert
  35667. * @returns the angle in radians
  35668. */
  35669. static ToRadians(angle: number): number;
  35670. /**
  35671. * Returns an array if obj is not an array
  35672. * @param obj defines the object to evaluate as an array
  35673. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35674. * @returns either obj directly if obj is an array or a new array containing obj
  35675. */
  35676. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35677. /**
  35678. * Gets the pointer prefix to use
  35679. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35680. */
  35681. static GetPointerPrefix(): string;
  35682. /**
  35683. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35684. * @param url define the url we are trying
  35685. * @param element define the dom element where to configure the cors policy
  35686. */
  35687. static SetCorsBehavior(url: string | string[], element: {
  35688. crossOrigin: string | null;
  35689. }): void;
  35690. /**
  35691. * Removes unwanted characters from an url
  35692. * @param url defines the url to clean
  35693. * @returns the cleaned url
  35694. */
  35695. static CleanUrl(url: string): string;
  35696. /**
  35697. * Gets or sets a function used to pre-process url before using them to load assets
  35698. */
  35699. static get PreprocessUrl(): (url: string) => string;
  35700. static set PreprocessUrl(processor: (url: string) => string);
  35701. /**
  35702. * Loads an image as an HTMLImageElement.
  35703. * @param input url string, ArrayBuffer, or Blob to load
  35704. * @param onLoad callback called when the image successfully loads
  35705. * @param onError callback called when the image fails to load
  35706. * @param offlineProvider offline provider for caching
  35707. * @param mimeType optional mime type
  35708. * @returns the HTMLImageElement of the loaded image
  35709. */
  35710. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35711. /**
  35712. * Loads a file from a url
  35713. * @param url url string, ArrayBuffer, or Blob to load
  35714. * @param onSuccess callback called when the file successfully loads
  35715. * @param onProgress callback called while file is loading (if the server supports this mode)
  35716. * @param offlineProvider defines the offline provider for caching
  35717. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35718. * @param onError callback called when the file fails to load
  35719. * @returns a file request object
  35720. */
  35721. 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;
  35722. /**
  35723. * Loads a file from a url
  35724. * @param url the file url to load
  35725. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35726. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35727. */
  35728. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35729. /**
  35730. * Load a script (identified by an url). When the url returns, the
  35731. * content of this file is added into a new script element, attached to the DOM (body element)
  35732. * @param scriptUrl defines the url of the script to laod
  35733. * @param onSuccess defines the callback called when the script is loaded
  35734. * @param onError defines the callback to call if an error occurs
  35735. * @param scriptId defines the id of the script element
  35736. */
  35737. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35738. /**
  35739. * Load an asynchronous script (identified by an url). When the url returns, the
  35740. * content of this file is added into a new script element, attached to the DOM (body element)
  35741. * @param scriptUrl defines the url of the script to laod
  35742. * @param scriptId defines the id of the script element
  35743. * @returns a promise request object
  35744. */
  35745. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35746. /**
  35747. * Loads a file from a blob
  35748. * @param fileToLoad defines the blob to use
  35749. * @param callback defines the callback to call when data is loaded
  35750. * @param progressCallback defines the callback to call during loading process
  35751. * @returns a file request object
  35752. */
  35753. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35754. /**
  35755. * Reads a file from a File object
  35756. * @param file defines the file to load
  35757. * @param onSuccess defines the callback to call when data is loaded
  35758. * @param onProgress defines the callback to call during loading process
  35759. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35760. * @param onError defines the callback to call when an error occurs
  35761. * @returns a file request object
  35762. */
  35763. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35764. /**
  35765. * Creates a data url from a given string content
  35766. * @param content defines the content to convert
  35767. * @returns the new data url link
  35768. */
  35769. static FileAsURL(content: string): string;
  35770. /**
  35771. * Format the given number to a specific decimal format
  35772. * @param value defines the number to format
  35773. * @param decimals defines the number of decimals to use
  35774. * @returns the formatted string
  35775. */
  35776. static Format(value: number, decimals?: number): string;
  35777. /**
  35778. * Tries to copy an object by duplicating every property
  35779. * @param source defines the source object
  35780. * @param destination defines the target object
  35781. * @param doNotCopyList defines a list of properties to avoid
  35782. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35783. */
  35784. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35785. /**
  35786. * Gets a boolean indicating if the given object has no own property
  35787. * @param obj defines the object to test
  35788. * @returns true if object has no own property
  35789. */
  35790. static IsEmpty(obj: any): boolean;
  35791. /**
  35792. * Function used to register events at window level
  35793. * @param windowElement defines the Window object to use
  35794. * @param events defines the events to register
  35795. */
  35796. static RegisterTopRootEvents(windowElement: Window, events: {
  35797. name: string;
  35798. handler: Nullable<(e: FocusEvent) => any>;
  35799. }[]): void;
  35800. /**
  35801. * Function used to unregister events from window level
  35802. * @param windowElement defines the Window object to use
  35803. * @param events defines the events to unregister
  35804. */
  35805. static UnregisterTopRootEvents(windowElement: Window, events: {
  35806. name: string;
  35807. handler: Nullable<(e: FocusEvent) => any>;
  35808. }[]): void;
  35809. /**
  35810. * @ignore
  35811. */
  35812. static _ScreenshotCanvas: HTMLCanvasElement;
  35813. /**
  35814. * Dumps the current bound framebuffer
  35815. * @param width defines the rendering width
  35816. * @param height defines the rendering height
  35817. * @param engine defines the hosting engine
  35818. * @param successCallback defines the callback triggered once the data are available
  35819. * @param mimeType defines the mime type of the result
  35820. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35821. */
  35822. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35823. /**
  35824. * Converts the canvas data to blob.
  35825. * This acts as a polyfill for browsers not supporting the to blob function.
  35826. * @param canvas Defines the canvas to extract the data from
  35827. * @param successCallback Defines the callback triggered once the data are available
  35828. * @param mimeType Defines the mime type of the result
  35829. */
  35830. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35831. /**
  35832. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35833. * @param successCallback defines the callback triggered once the data are available
  35834. * @param mimeType defines the mime type of the result
  35835. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35836. */
  35837. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35838. /**
  35839. * Downloads a blob in the browser
  35840. * @param blob defines the blob to download
  35841. * @param fileName defines the name of the downloaded file
  35842. */
  35843. static Download(blob: Blob, fileName: string): void;
  35844. /**
  35845. * Captures a screenshot of the current rendering
  35846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35847. * @param engine defines the rendering engine
  35848. * @param camera defines the source camera
  35849. * @param size This parameter can be set to a single number or to an object with the
  35850. * following (optional) properties: precision, width, height. If a single number is passed,
  35851. * it will be used for both width and height. If an object is passed, the screenshot size
  35852. * will be derived from the parameters. The precision property is a multiplier allowing
  35853. * rendering at a higher or lower resolution
  35854. * @param successCallback defines the callback receives a single parameter which contains the
  35855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35856. * src parameter of an <img> to display it
  35857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35858. * Check your browser for supported MIME types
  35859. */
  35860. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35861. /**
  35862. * Captures a screenshot of the current rendering
  35863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35864. * @param engine defines the rendering engine
  35865. * @param camera defines the source camera
  35866. * @param size This parameter can be set to a single number or to an object with the
  35867. * following (optional) properties: precision, width, height. If a single number is passed,
  35868. * it will be used for both width and height. If an object is passed, the screenshot size
  35869. * will be derived from the parameters. The precision property is a multiplier allowing
  35870. * rendering at a higher or lower resolution
  35871. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35872. * Check your browser for supported MIME types
  35873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35874. * to the src parameter of an <img> to display it
  35875. */
  35876. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35877. /**
  35878. * Generates an image screenshot from the specified camera.
  35879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35880. * @param engine The engine to use for rendering
  35881. * @param camera The camera to use for rendering
  35882. * @param size This parameter can be set to a single number or to an object with the
  35883. * following (optional) properties: precision, width, height. If a single number is passed,
  35884. * it will be used for both width and height. If an object is passed, the screenshot size
  35885. * will be derived from the parameters. The precision property is a multiplier allowing
  35886. * rendering at a higher or lower resolution
  35887. * @param successCallback The callback receives a single parameter which contains the
  35888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35889. * src parameter of an <img> to display it
  35890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35891. * Check your browser for supported MIME types
  35892. * @param samples Texture samples (default: 1)
  35893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35894. * @param fileName A name for for the downloaded file.
  35895. */
  35896. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35897. /**
  35898. * Generates an image screenshot from the specified camera.
  35899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35900. * @param engine The engine to use for rendering
  35901. * @param camera The camera to use for rendering
  35902. * @param size This parameter can be set to a single number or to an object with the
  35903. * following (optional) properties: precision, width, height. If a single number is passed,
  35904. * it will be used for both width and height. If an object is passed, the screenshot size
  35905. * will be derived from the parameters. The precision property is a multiplier allowing
  35906. * rendering at a higher or lower resolution
  35907. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35908. * Check your browser for supported MIME types
  35909. * @param samples Texture samples (default: 1)
  35910. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35911. * @param fileName A name for for the downloaded file.
  35912. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35913. * to the src parameter of an <img> to display it
  35914. */
  35915. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35916. /**
  35917. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35918. * Be aware Math.random() could cause collisions, but:
  35919. * "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"
  35920. * @returns a pseudo random id
  35921. */
  35922. static RandomId(): string;
  35923. /**
  35924. * Test if the given uri is a base64 string
  35925. * @param uri The uri to test
  35926. * @return True if the uri is a base64 string or false otherwise
  35927. */
  35928. static IsBase64(uri: string): boolean;
  35929. /**
  35930. * Decode the given base64 uri.
  35931. * @param uri The uri to decode
  35932. * @return The decoded base64 data.
  35933. */
  35934. static DecodeBase64(uri: string): ArrayBuffer;
  35935. /**
  35936. * Gets the absolute url.
  35937. * @param url the input url
  35938. * @return the absolute url
  35939. */
  35940. static GetAbsoluteUrl(url: string): string;
  35941. /**
  35942. * No log
  35943. */
  35944. static readonly NoneLogLevel: number;
  35945. /**
  35946. * Only message logs
  35947. */
  35948. static readonly MessageLogLevel: number;
  35949. /**
  35950. * Only warning logs
  35951. */
  35952. static readonly WarningLogLevel: number;
  35953. /**
  35954. * Only error logs
  35955. */
  35956. static readonly ErrorLogLevel: number;
  35957. /**
  35958. * All logs
  35959. */
  35960. static readonly AllLogLevel: number;
  35961. /**
  35962. * Gets a value indicating the number of loading errors
  35963. * @ignorenaming
  35964. */
  35965. static get errorsCount(): number;
  35966. /**
  35967. * Callback called when a new log is added
  35968. */
  35969. static OnNewCacheEntry: (entry: string) => void;
  35970. /**
  35971. * Log a message to the console
  35972. * @param message defines the message to log
  35973. */
  35974. static Log(message: string): void;
  35975. /**
  35976. * Write a warning message to the console
  35977. * @param message defines the message to log
  35978. */
  35979. static Warn(message: string): void;
  35980. /**
  35981. * Write an error message to the console
  35982. * @param message defines the message to log
  35983. */
  35984. static Error(message: string): void;
  35985. /**
  35986. * Gets current log cache (list of logs)
  35987. */
  35988. static get LogCache(): string;
  35989. /**
  35990. * Clears the log cache
  35991. */
  35992. static ClearLogCache(): void;
  35993. /**
  35994. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35995. */
  35996. static set LogLevels(level: number);
  35997. /**
  35998. * Checks if the window object exists
  35999. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  36000. */
  36001. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  36002. /**
  36003. * No performance log
  36004. */
  36005. static readonly PerformanceNoneLogLevel: number;
  36006. /**
  36007. * Use user marks to log performance
  36008. */
  36009. static readonly PerformanceUserMarkLogLevel: number;
  36010. /**
  36011. * Log performance to the console
  36012. */
  36013. static readonly PerformanceConsoleLogLevel: number;
  36014. private static _performance;
  36015. /**
  36016. * Sets the current performance log level
  36017. */
  36018. static set PerformanceLogLevel(level: number);
  36019. private static _StartPerformanceCounterDisabled;
  36020. private static _EndPerformanceCounterDisabled;
  36021. private static _StartUserMark;
  36022. private static _EndUserMark;
  36023. private static _StartPerformanceConsole;
  36024. private static _EndPerformanceConsole;
  36025. /**
  36026. * Starts a performance counter
  36027. */
  36028. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36029. /**
  36030. * Ends a specific performance coutner
  36031. */
  36032. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36033. /**
  36034. * Gets either window.performance.now() if supported or Date.now() else
  36035. */
  36036. static get Now(): number;
  36037. /**
  36038. * This method will return the name of the class used to create the instance of the given object.
  36039. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36040. * @param object the object to get the class name from
  36041. * @param isType defines if the object is actually a type
  36042. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36043. */
  36044. static GetClassName(object: any, isType?: boolean): string;
  36045. /**
  36046. * Gets the first element of an array satisfying a given predicate
  36047. * @param array defines the array to browse
  36048. * @param predicate defines the predicate to use
  36049. * @returns null if not found or the element
  36050. */
  36051. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36052. /**
  36053. * This method will return the name of the full name of the class, including its owning module (if any).
  36054. * 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).
  36055. * @param object the object to get the class name from
  36056. * @param isType defines if the object is actually a type
  36057. * @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.
  36058. * @ignorenaming
  36059. */
  36060. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36061. /**
  36062. * Returns a promise that resolves after the given amount of time.
  36063. * @param delay Number of milliseconds to delay
  36064. * @returns Promise that resolves after the given amount of time
  36065. */
  36066. static DelayAsync(delay: number): Promise<void>;
  36067. /**
  36068. * Utility function to detect if the current user agent is Safari
  36069. * @returns whether or not the current user agent is safari
  36070. */
  36071. static IsSafari(): boolean;
  36072. }
  36073. /**
  36074. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36075. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36076. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36077. * @param name The name of the class, case should be preserved
  36078. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36079. */
  36080. export function className(name: string, module?: string): (target: Object) => void;
  36081. /**
  36082. * An implementation of a loop for asynchronous functions.
  36083. */
  36084. export class AsyncLoop {
  36085. /**
  36086. * Defines the number of iterations for the loop
  36087. */
  36088. iterations: number;
  36089. /**
  36090. * Defines the current index of the loop.
  36091. */
  36092. index: number;
  36093. private _done;
  36094. private _fn;
  36095. private _successCallback;
  36096. /**
  36097. * Constructor.
  36098. * @param iterations the number of iterations.
  36099. * @param func the function to run each iteration
  36100. * @param successCallback the callback that will be called upon succesful execution
  36101. * @param offset starting offset.
  36102. */
  36103. constructor(
  36104. /**
  36105. * Defines the number of iterations for the loop
  36106. */
  36107. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36108. /**
  36109. * Execute the next iteration. Must be called after the last iteration was finished.
  36110. */
  36111. executeNext(): void;
  36112. /**
  36113. * Break the loop and run the success callback.
  36114. */
  36115. breakLoop(): void;
  36116. /**
  36117. * Create and run an async loop.
  36118. * @param iterations the number of iterations.
  36119. * @param fn the function to run each iteration
  36120. * @param successCallback the callback that will be called upon succesful execution
  36121. * @param offset starting offset.
  36122. * @returns the created async loop object
  36123. */
  36124. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36125. /**
  36126. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36127. * @param iterations total number of iterations
  36128. * @param syncedIterations number of synchronous iterations in each async iteration.
  36129. * @param fn the function to call each iteration.
  36130. * @param callback a success call back that will be called when iterating stops.
  36131. * @param breakFunction a break condition (optional)
  36132. * @param timeout timeout settings for the setTimeout function. default - 0.
  36133. * @returns the created async loop object
  36134. */
  36135. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36136. }
  36137. }
  36138. declare module "babylonjs/Misc/stringDictionary" {
  36139. import { Nullable } from "babylonjs/types";
  36140. /**
  36141. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36142. * The underlying implementation relies on an associative array to ensure the best performances.
  36143. * The value can be anything including 'null' but except 'undefined'
  36144. */
  36145. export class StringDictionary<T> {
  36146. /**
  36147. * This will clear this dictionary and copy the content from the 'source' one.
  36148. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36149. * @param source the dictionary to take the content from and copy to this dictionary
  36150. */
  36151. copyFrom(source: StringDictionary<T>): void;
  36152. /**
  36153. * Get a value based from its key
  36154. * @param key the given key to get the matching value from
  36155. * @return the value if found, otherwise undefined is returned
  36156. */
  36157. get(key: string): T | undefined;
  36158. /**
  36159. * Get a value from its key or add it if it doesn't exist.
  36160. * This method will ensure you that a given key/data will be present in the dictionary.
  36161. * @param key the given key to get the matching value from
  36162. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36163. * The factory will only be invoked if there's no data for the given key.
  36164. * @return the value corresponding to the key.
  36165. */
  36166. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36167. /**
  36168. * Get a value from its key if present in the dictionary otherwise add it
  36169. * @param key the key to get the value from
  36170. * @param val if there's no such key/value pair in the dictionary add it with this value
  36171. * @return the value corresponding to the key
  36172. */
  36173. getOrAdd(key: string, val: T): T;
  36174. /**
  36175. * Check if there's a given key in the dictionary
  36176. * @param key the key to check for
  36177. * @return true if the key is present, false otherwise
  36178. */
  36179. contains(key: string): boolean;
  36180. /**
  36181. * Add a new key and its corresponding value
  36182. * @param key the key to add
  36183. * @param value the value corresponding to the key
  36184. * @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
  36185. */
  36186. add(key: string, value: T): boolean;
  36187. /**
  36188. * Update a specific value associated to a key
  36189. * @param key defines the key to use
  36190. * @param value defines the value to store
  36191. * @returns true if the value was updated (or false if the key was not found)
  36192. */
  36193. set(key: string, value: T): boolean;
  36194. /**
  36195. * Get the element of the given key and remove it from the dictionary
  36196. * @param key defines the key to search
  36197. * @returns the value associated with the key or null if not found
  36198. */
  36199. getAndRemove(key: string): Nullable<T>;
  36200. /**
  36201. * Remove a key/value from the dictionary.
  36202. * @param key the key to remove
  36203. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36204. */
  36205. remove(key: string): boolean;
  36206. /**
  36207. * Clear the whole content of the dictionary
  36208. */
  36209. clear(): void;
  36210. /**
  36211. * Gets the current count
  36212. */
  36213. get count(): number;
  36214. /**
  36215. * Execute a callback on each key/val of the dictionary.
  36216. * Note that you can remove any element in this dictionary in the callback implementation
  36217. * @param callback the callback to execute on a given key/value pair
  36218. */
  36219. forEach(callback: (key: string, val: T) => void): void;
  36220. /**
  36221. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36222. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36223. * Note that you can remove any element in this dictionary in the callback implementation
  36224. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36225. * @returns the first item
  36226. */
  36227. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36228. private _count;
  36229. private _data;
  36230. }
  36231. }
  36232. declare module "babylonjs/Collisions/collisionCoordinator" {
  36233. import { Nullable } from "babylonjs/types";
  36234. import { Scene } from "babylonjs/scene";
  36235. import { Vector3 } from "babylonjs/Maths/math.vector";
  36236. import { Collider } from "babylonjs/Collisions/collider";
  36237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36238. /** @hidden */
  36239. export interface ICollisionCoordinator {
  36240. createCollider(): Collider;
  36241. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36242. init(scene: Scene): void;
  36243. }
  36244. /** @hidden */
  36245. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36246. private _scene;
  36247. private _scaledPosition;
  36248. private _scaledVelocity;
  36249. private _finalPosition;
  36250. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36251. createCollider(): Collider;
  36252. init(scene: Scene): void;
  36253. private _collideWithWorld;
  36254. }
  36255. }
  36256. declare module "babylonjs/Inputs/scene.inputManager" {
  36257. import { Nullable } from "babylonjs/types";
  36258. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36259. import { Vector2 } from "babylonjs/Maths/math.vector";
  36260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36261. import { Scene } from "babylonjs/scene";
  36262. /**
  36263. * Class used to manage all inputs for the scene.
  36264. */
  36265. export class InputManager {
  36266. /** The distance in pixel that you have to move to prevent some events */
  36267. static DragMovementThreshold: number;
  36268. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36269. static LongPressDelay: number;
  36270. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36271. static DoubleClickDelay: number;
  36272. /** If you need to check double click without raising a single click at first click, enable this flag */
  36273. static ExclusiveDoubleClickMode: boolean;
  36274. private _wheelEventName;
  36275. private _onPointerMove;
  36276. private _onPointerDown;
  36277. private _onPointerUp;
  36278. private _initClickEvent;
  36279. private _initActionManager;
  36280. private _delayedSimpleClick;
  36281. private _delayedSimpleClickTimeout;
  36282. private _previousDelayedSimpleClickTimeout;
  36283. private _meshPickProceed;
  36284. private _previousButtonPressed;
  36285. private _currentPickResult;
  36286. private _previousPickResult;
  36287. private _totalPointersPressed;
  36288. private _doubleClickOccured;
  36289. private _pointerOverMesh;
  36290. private _pickedDownMesh;
  36291. private _pickedUpMesh;
  36292. private _pointerX;
  36293. private _pointerY;
  36294. private _unTranslatedPointerX;
  36295. private _unTranslatedPointerY;
  36296. private _startingPointerPosition;
  36297. private _previousStartingPointerPosition;
  36298. private _startingPointerTime;
  36299. private _previousStartingPointerTime;
  36300. private _pointerCaptures;
  36301. private _onKeyDown;
  36302. private _onKeyUp;
  36303. private _onCanvasFocusObserver;
  36304. private _onCanvasBlurObserver;
  36305. private _scene;
  36306. /**
  36307. * Creates a new InputManager
  36308. * @param scene defines the hosting scene
  36309. */
  36310. constructor(scene: Scene);
  36311. /**
  36312. * Gets the mesh that is currently under the pointer
  36313. */
  36314. get meshUnderPointer(): Nullable<AbstractMesh>;
  36315. /**
  36316. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36317. */
  36318. get unTranslatedPointer(): Vector2;
  36319. /**
  36320. * Gets or sets the current on-screen X position of the pointer
  36321. */
  36322. get pointerX(): number;
  36323. set pointerX(value: number);
  36324. /**
  36325. * Gets or sets the current on-screen Y position of the pointer
  36326. */
  36327. get pointerY(): number;
  36328. set pointerY(value: number);
  36329. private _updatePointerPosition;
  36330. private _processPointerMove;
  36331. private _setRayOnPointerInfo;
  36332. private _checkPrePointerObservable;
  36333. /**
  36334. * Use this method to simulate a pointer move on a mesh
  36335. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36336. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36337. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36338. */
  36339. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36340. /**
  36341. * Use this method to simulate a pointer down on a mesh
  36342. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36343. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36344. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36345. */
  36346. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36347. private _processPointerDown;
  36348. /** @hidden */
  36349. _isPointerSwiping(): boolean;
  36350. /**
  36351. * Use this method to simulate a pointer up on a mesh
  36352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36356. */
  36357. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36358. private _processPointerUp;
  36359. /**
  36360. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36361. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36362. * @returns true if the pointer was captured
  36363. */
  36364. isPointerCaptured(pointerId?: number): boolean;
  36365. /**
  36366. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36367. * @param attachUp defines if you want to attach events to pointerup
  36368. * @param attachDown defines if you want to attach events to pointerdown
  36369. * @param attachMove defines if you want to attach events to pointermove
  36370. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36371. */
  36372. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36373. /**
  36374. * Detaches all event handlers
  36375. */
  36376. detachControl(): void;
  36377. /**
  36378. * Force the value of meshUnderPointer
  36379. * @param mesh defines the mesh to use
  36380. */
  36381. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36382. /**
  36383. * Gets the mesh under the pointer
  36384. * @returns a Mesh or null if no mesh is under the pointer
  36385. */
  36386. getPointerOverMesh(): Nullable<AbstractMesh>;
  36387. }
  36388. }
  36389. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36390. /**
  36391. * Helper class used to generate session unique ID
  36392. */
  36393. export class UniqueIdGenerator {
  36394. private static _UniqueIdCounter;
  36395. /**
  36396. * Gets an unique (relatively to the current scene) Id
  36397. */
  36398. static get UniqueId(): number;
  36399. }
  36400. }
  36401. declare module "babylonjs/Animations/animationGroup" {
  36402. import { Animatable } from "babylonjs/Animations/animatable";
  36403. import { Animation } from "babylonjs/Animations/animation";
  36404. import { Scene, IDisposable } from "babylonjs/scene";
  36405. import { Observable } from "babylonjs/Misc/observable";
  36406. import { Nullable } from "babylonjs/types";
  36407. import "babylonjs/Animations/animatable";
  36408. /**
  36409. * This class defines the direct association between an animation and a target
  36410. */
  36411. export class TargetedAnimation {
  36412. /**
  36413. * Animation to perform
  36414. */
  36415. animation: Animation;
  36416. /**
  36417. * Target to animate
  36418. */
  36419. target: any;
  36420. /**
  36421. * Serialize the object
  36422. * @returns the JSON object representing the current entity
  36423. */
  36424. serialize(): any;
  36425. }
  36426. /**
  36427. * Use this class to create coordinated animations on multiple targets
  36428. */
  36429. export class AnimationGroup implements IDisposable {
  36430. /** The name of the animation group */
  36431. name: string;
  36432. private _scene;
  36433. private _targetedAnimations;
  36434. private _animatables;
  36435. private _from;
  36436. private _to;
  36437. private _isStarted;
  36438. private _isPaused;
  36439. private _speedRatio;
  36440. private _loopAnimation;
  36441. private _isAdditive;
  36442. /**
  36443. * Gets or sets the unique id of the node
  36444. */
  36445. uniqueId: number;
  36446. /**
  36447. * This observable will notify when one animation have ended
  36448. */
  36449. onAnimationEndObservable: Observable<TargetedAnimation>;
  36450. /**
  36451. * Observer raised when one animation loops
  36452. */
  36453. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36454. /**
  36455. * Observer raised when all animations have looped
  36456. */
  36457. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36458. /**
  36459. * This observable will notify when all animations have ended.
  36460. */
  36461. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36462. /**
  36463. * This observable will notify when all animations have paused.
  36464. */
  36465. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36466. /**
  36467. * This observable will notify when all animations are playing.
  36468. */
  36469. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36470. /**
  36471. * Gets the first frame
  36472. */
  36473. get from(): number;
  36474. /**
  36475. * Gets the last frame
  36476. */
  36477. get to(): number;
  36478. /**
  36479. * Define if the animations are started
  36480. */
  36481. get isStarted(): boolean;
  36482. /**
  36483. * Gets a value indicating that the current group is playing
  36484. */
  36485. get isPlaying(): boolean;
  36486. /**
  36487. * Gets or sets the speed ratio to use for all animations
  36488. */
  36489. get speedRatio(): number;
  36490. /**
  36491. * Gets or sets the speed ratio to use for all animations
  36492. */
  36493. set speedRatio(value: number);
  36494. /**
  36495. * Gets or sets if all animations should loop or not
  36496. */
  36497. get loopAnimation(): boolean;
  36498. set loopAnimation(value: boolean);
  36499. /**
  36500. * Gets or sets if all animations should be evaluated additively
  36501. */
  36502. get isAdditive(): boolean;
  36503. set isAdditive(value: boolean);
  36504. /**
  36505. * Gets the targeted animations for this animation group
  36506. */
  36507. get targetedAnimations(): Array<TargetedAnimation>;
  36508. /**
  36509. * returning the list of animatables controlled by this animation group.
  36510. */
  36511. get animatables(): Array<Animatable>;
  36512. /**
  36513. * Instantiates a new Animation Group.
  36514. * This helps managing several animations at once.
  36515. * @see http://doc.babylonjs.com/how_to/group
  36516. * @param name Defines the name of the group
  36517. * @param scene Defines the scene the group belongs to
  36518. */
  36519. constructor(
  36520. /** The name of the animation group */
  36521. name: string, scene?: Nullable<Scene>);
  36522. /**
  36523. * Add an animation (with its target) in the group
  36524. * @param animation defines the animation we want to add
  36525. * @param target defines the target of the animation
  36526. * @returns the TargetedAnimation object
  36527. */
  36528. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36529. /**
  36530. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36531. * It can add constant keys at begin or end
  36532. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36533. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36534. * @returns the animation group
  36535. */
  36536. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36537. private _animationLoopCount;
  36538. private _animationLoopFlags;
  36539. private _processLoop;
  36540. /**
  36541. * Start all animations on given targets
  36542. * @param loop defines if animations must loop
  36543. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36544. * @param from defines the from key (optional)
  36545. * @param to defines the to key (optional)
  36546. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36547. * @returns the current animation group
  36548. */
  36549. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36550. /**
  36551. * Pause all animations
  36552. * @returns the animation group
  36553. */
  36554. pause(): AnimationGroup;
  36555. /**
  36556. * Play all animations to initial state
  36557. * This function will start() the animations if they were not started or will restart() them if they were paused
  36558. * @param loop defines if animations must loop
  36559. * @returns the animation group
  36560. */
  36561. play(loop?: boolean): AnimationGroup;
  36562. /**
  36563. * Reset all animations to initial state
  36564. * @returns the animation group
  36565. */
  36566. reset(): AnimationGroup;
  36567. /**
  36568. * Restart animations from key 0
  36569. * @returns the animation group
  36570. */
  36571. restart(): AnimationGroup;
  36572. /**
  36573. * Stop all animations
  36574. * @returns the animation group
  36575. */
  36576. stop(): AnimationGroup;
  36577. /**
  36578. * Set animation weight for all animatables
  36579. * @param weight defines the weight to use
  36580. * @return the animationGroup
  36581. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36582. */
  36583. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36584. /**
  36585. * Synchronize and normalize all animatables with a source animatable
  36586. * @param root defines the root animatable to synchronize with
  36587. * @return the animationGroup
  36588. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36589. */
  36590. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36591. /**
  36592. * Goes to a specific frame in this animation group
  36593. * @param frame the frame number to go to
  36594. * @return the animationGroup
  36595. */
  36596. goToFrame(frame: number): AnimationGroup;
  36597. /**
  36598. * Dispose all associated resources
  36599. */
  36600. dispose(): void;
  36601. private _checkAnimationGroupEnded;
  36602. /**
  36603. * Clone the current animation group and returns a copy
  36604. * @param newName defines the name of the new group
  36605. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36606. * @returns the new aniamtion group
  36607. */
  36608. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36609. /**
  36610. * Serializes the animationGroup to an object
  36611. * @returns Serialized object
  36612. */
  36613. serialize(): any;
  36614. /**
  36615. * Returns a new AnimationGroup object parsed from the source provided.
  36616. * @param parsedAnimationGroup defines the source
  36617. * @param scene defines the scene that will receive the animationGroup
  36618. * @returns a new AnimationGroup
  36619. */
  36620. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36621. /**
  36622. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36623. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36624. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36625. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36626. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36627. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36628. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36629. */
  36630. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36631. /**
  36632. * Returns the string "AnimationGroup"
  36633. * @returns "AnimationGroup"
  36634. */
  36635. getClassName(): string;
  36636. /**
  36637. * Creates a detailled string about the object
  36638. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36639. * @returns a string representing the object
  36640. */
  36641. toString(fullDetails?: boolean): string;
  36642. }
  36643. }
  36644. declare module "babylonjs/scene" {
  36645. import { Nullable } from "babylonjs/types";
  36646. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36647. import { Observable } from "babylonjs/Misc/observable";
  36648. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36649. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36650. import { Geometry } from "babylonjs/Meshes/geometry";
  36651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36652. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36654. import { Mesh } from "babylonjs/Meshes/mesh";
  36655. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36656. import { Bone } from "babylonjs/Bones/bone";
  36657. import { Skeleton } from "babylonjs/Bones/skeleton";
  36658. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36659. import { Camera } from "babylonjs/Cameras/camera";
  36660. import { AbstractScene } from "babylonjs/abstractScene";
  36661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36662. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36663. import { Material } from "babylonjs/Materials/material";
  36664. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36665. import { Effect } from "babylonjs/Materials/effect";
  36666. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36667. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36668. import { Light } from "babylonjs/Lights/light";
  36669. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36670. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36671. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36672. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36673. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36674. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36675. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36676. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36677. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36678. import { Engine } from "babylonjs/Engines/engine";
  36679. import { Node } from "babylonjs/node";
  36680. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36681. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36682. import { WebRequest } from "babylonjs/Misc/webRequest";
  36683. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36684. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36685. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36686. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36687. import { Plane } from "babylonjs/Maths/math.plane";
  36688. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36689. import { Ray } from "babylonjs/Culling/ray";
  36690. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36691. import { Animation } from "babylonjs/Animations/animation";
  36692. import { Animatable } from "babylonjs/Animations/animatable";
  36693. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36694. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36695. import { Collider } from "babylonjs/Collisions/collider";
  36696. /**
  36697. * Define an interface for all classes that will hold resources
  36698. */
  36699. export interface IDisposable {
  36700. /**
  36701. * Releases all held resources
  36702. */
  36703. dispose(): void;
  36704. }
  36705. /** Interface defining initialization parameters for Scene class */
  36706. export interface SceneOptions {
  36707. /**
  36708. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36709. * It will improve performance when the number of geometries becomes important.
  36710. */
  36711. useGeometryUniqueIdsMap?: boolean;
  36712. /**
  36713. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36714. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36715. */
  36716. useMaterialMeshMap?: boolean;
  36717. /**
  36718. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36719. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36720. */
  36721. useClonedMeshMap?: boolean;
  36722. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36723. virtual?: boolean;
  36724. }
  36725. /**
  36726. * Represents a scene to be rendered by the engine.
  36727. * @see http://doc.babylonjs.com/features/scene
  36728. */
  36729. export class Scene extends AbstractScene implements IAnimatable {
  36730. /** The fog is deactivated */
  36731. static readonly FOGMODE_NONE: number;
  36732. /** The fog density is following an exponential function */
  36733. static readonly FOGMODE_EXP: number;
  36734. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36735. static readonly FOGMODE_EXP2: number;
  36736. /** The fog density is following a linear function. */
  36737. static readonly FOGMODE_LINEAR: number;
  36738. /**
  36739. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36741. */
  36742. static MinDeltaTime: number;
  36743. /**
  36744. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36746. */
  36747. static MaxDeltaTime: number;
  36748. /**
  36749. * Factory used to create the default material.
  36750. * @param name The name of the material to create
  36751. * @param scene The scene to create the material for
  36752. * @returns The default material
  36753. */
  36754. static DefaultMaterialFactory(scene: Scene): Material;
  36755. /**
  36756. * Factory used to create the a collision coordinator.
  36757. * @returns The collision coordinator
  36758. */
  36759. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36760. /** @hidden */
  36761. _inputManager: InputManager;
  36762. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36763. cameraToUseForPointers: Nullable<Camera>;
  36764. /** @hidden */
  36765. readonly _isScene: boolean;
  36766. /** @hidden */
  36767. _blockEntityCollection: boolean;
  36768. /**
  36769. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36770. */
  36771. autoClear: boolean;
  36772. /**
  36773. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36774. */
  36775. autoClearDepthAndStencil: boolean;
  36776. /**
  36777. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36778. */
  36779. clearColor: Color4;
  36780. /**
  36781. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36782. */
  36783. ambientColor: Color3;
  36784. /**
  36785. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36786. * It should only be one of the following (if not the default embedded one):
  36787. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36788. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36789. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36790. * The material properties need to be setup according to the type of texture in use.
  36791. */
  36792. environmentBRDFTexture: BaseTexture;
  36793. /** @hidden */
  36794. protected _environmentTexture: Nullable<BaseTexture>;
  36795. /**
  36796. * Texture used in all pbr material as the reflection texture.
  36797. * As in the majority of the scene they are the same (exception for multi room and so on),
  36798. * this is easier to reference from here than from all the materials.
  36799. */
  36800. get environmentTexture(): Nullable<BaseTexture>;
  36801. /**
  36802. * Texture used in all pbr material as the reflection texture.
  36803. * As in the majority of the scene they are the same (exception for multi room and so on),
  36804. * this is easier to set here than in all the materials.
  36805. */
  36806. set environmentTexture(value: Nullable<BaseTexture>);
  36807. /** @hidden */
  36808. protected _environmentIntensity: number;
  36809. /**
  36810. * Intensity of the environment in all pbr material.
  36811. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36812. * As in the majority of the scene they are the same (exception for multi room and so on),
  36813. * this is easier to reference from here than from all the materials.
  36814. */
  36815. get environmentIntensity(): number;
  36816. /**
  36817. * Intensity of the environment in all pbr material.
  36818. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36819. * As in the majority of the scene they are the same (exception for multi room and so on),
  36820. * this is easier to set here than in all the materials.
  36821. */
  36822. set environmentIntensity(value: number);
  36823. /** @hidden */
  36824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36825. /**
  36826. * Default image processing configuration used either in the rendering
  36827. * Forward main pass or through the imageProcessingPostProcess if present.
  36828. * As in the majority of the scene they are the same (exception for multi camera),
  36829. * this is easier to reference from here than from all the materials and post process.
  36830. *
  36831. * No setter as we it is a shared configuration, you can set the values instead.
  36832. */
  36833. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36834. private _forceWireframe;
  36835. /**
  36836. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36837. */
  36838. set forceWireframe(value: boolean);
  36839. get forceWireframe(): boolean;
  36840. private _skipFrustumClipping;
  36841. /**
  36842. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36843. */
  36844. set skipFrustumClipping(value: boolean);
  36845. get skipFrustumClipping(): boolean;
  36846. private _forcePointsCloud;
  36847. /**
  36848. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36849. */
  36850. set forcePointsCloud(value: boolean);
  36851. get forcePointsCloud(): boolean;
  36852. /**
  36853. * Gets or sets the active clipplane 1
  36854. */
  36855. clipPlane: Nullable<Plane>;
  36856. /**
  36857. * Gets or sets the active clipplane 2
  36858. */
  36859. clipPlane2: Nullable<Plane>;
  36860. /**
  36861. * Gets or sets the active clipplane 3
  36862. */
  36863. clipPlane3: Nullable<Plane>;
  36864. /**
  36865. * Gets or sets the active clipplane 4
  36866. */
  36867. clipPlane4: Nullable<Plane>;
  36868. /**
  36869. * Gets or sets the active clipplane 5
  36870. */
  36871. clipPlane5: Nullable<Plane>;
  36872. /**
  36873. * Gets or sets the active clipplane 6
  36874. */
  36875. clipPlane6: Nullable<Plane>;
  36876. /**
  36877. * Gets or sets a boolean indicating if animations are enabled
  36878. */
  36879. animationsEnabled: boolean;
  36880. private _animationPropertiesOverride;
  36881. /**
  36882. * Gets or sets the animation properties override
  36883. */
  36884. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36885. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36886. /**
  36887. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36888. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36889. */
  36890. useConstantAnimationDeltaTime: boolean;
  36891. /**
  36892. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36893. * Please note that it requires to run a ray cast through the scene on every frame
  36894. */
  36895. constantlyUpdateMeshUnderPointer: boolean;
  36896. /**
  36897. * Defines the HTML cursor to use when hovering over interactive elements
  36898. */
  36899. hoverCursor: string;
  36900. /**
  36901. * Defines the HTML default cursor to use (empty by default)
  36902. */
  36903. defaultCursor: string;
  36904. /**
  36905. * Defines whether cursors are handled by the scene.
  36906. */
  36907. doNotHandleCursors: boolean;
  36908. /**
  36909. * This is used to call preventDefault() on pointer down
  36910. * in order to block unwanted artifacts like system double clicks
  36911. */
  36912. preventDefaultOnPointerDown: boolean;
  36913. /**
  36914. * This is used to call preventDefault() on pointer up
  36915. * in order to block unwanted artifacts like system double clicks
  36916. */
  36917. preventDefaultOnPointerUp: boolean;
  36918. /**
  36919. * Gets or sets user defined metadata
  36920. */
  36921. metadata: any;
  36922. /**
  36923. * For internal use only. Please do not use.
  36924. */
  36925. reservedDataStore: any;
  36926. /**
  36927. * Gets the name of the plugin used to load this scene (null by default)
  36928. */
  36929. loadingPluginName: string;
  36930. /**
  36931. * Use this array to add regular expressions used to disable offline support for specific urls
  36932. */
  36933. disableOfflineSupportExceptionRules: RegExp[];
  36934. /**
  36935. * An event triggered when the scene is disposed.
  36936. */
  36937. onDisposeObservable: Observable<Scene>;
  36938. private _onDisposeObserver;
  36939. /** Sets a function to be executed when this scene is disposed. */
  36940. set onDispose(callback: () => void);
  36941. /**
  36942. * An event triggered before rendering the scene (right after animations and physics)
  36943. */
  36944. onBeforeRenderObservable: Observable<Scene>;
  36945. private _onBeforeRenderObserver;
  36946. /** Sets a function to be executed before rendering this scene */
  36947. set beforeRender(callback: Nullable<() => void>);
  36948. /**
  36949. * An event triggered after rendering the scene
  36950. */
  36951. onAfterRenderObservable: Observable<Scene>;
  36952. /**
  36953. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36954. */
  36955. onAfterRenderCameraObservable: Observable<Camera>;
  36956. private _onAfterRenderObserver;
  36957. /** Sets a function to be executed after rendering this scene */
  36958. set afterRender(callback: Nullable<() => void>);
  36959. /**
  36960. * An event triggered before animating the scene
  36961. */
  36962. onBeforeAnimationsObservable: Observable<Scene>;
  36963. /**
  36964. * An event triggered after animations processing
  36965. */
  36966. onAfterAnimationsObservable: Observable<Scene>;
  36967. /**
  36968. * An event triggered before draw calls are ready to be sent
  36969. */
  36970. onBeforeDrawPhaseObservable: Observable<Scene>;
  36971. /**
  36972. * An event triggered after draw calls have been sent
  36973. */
  36974. onAfterDrawPhaseObservable: Observable<Scene>;
  36975. /**
  36976. * An event triggered when the scene is ready
  36977. */
  36978. onReadyObservable: Observable<Scene>;
  36979. /**
  36980. * An event triggered before rendering a camera
  36981. */
  36982. onBeforeCameraRenderObservable: Observable<Camera>;
  36983. private _onBeforeCameraRenderObserver;
  36984. /** Sets a function to be executed before rendering a camera*/
  36985. set beforeCameraRender(callback: () => void);
  36986. /**
  36987. * An event triggered after rendering a camera
  36988. */
  36989. onAfterCameraRenderObservable: Observable<Camera>;
  36990. private _onAfterCameraRenderObserver;
  36991. /** Sets a function to be executed after rendering a camera*/
  36992. set afterCameraRender(callback: () => void);
  36993. /**
  36994. * An event triggered when active meshes evaluation is about to start
  36995. */
  36996. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36997. /**
  36998. * An event triggered when active meshes evaluation is done
  36999. */
  37000. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  37001. /**
  37002. * An event triggered when particles rendering is about to start
  37003. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37004. */
  37005. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37006. /**
  37007. * An event triggered when particles rendering is done
  37008. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37009. */
  37010. onAfterParticlesRenderingObservable: Observable<Scene>;
  37011. /**
  37012. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37013. */
  37014. onDataLoadedObservable: Observable<Scene>;
  37015. /**
  37016. * An event triggered when a camera is created
  37017. */
  37018. onNewCameraAddedObservable: Observable<Camera>;
  37019. /**
  37020. * An event triggered when a camera is removed
  37021. */
  37022. onCameraRemovedObservable: Observable<Camera>;
  37023. /**
  37024. * An event triggered when a light is created
  37025. */
  37026. onNewLightAddedObservable: Observable<Light>;
  37027. /**
  37028. * An event triggered when a light is removed
  37029. */
  37030. onLightRemovedObservable: Observable<Light>;
  37031. /**
  37032. * An event triggered when a geometry is created
  37033. */
  37034. onNewGeometryAddedObservable: Observable<Geometry>;
  37035. /**
  37036. * An event triggered when a geometry is removed
  37037. */
  37038. onGeometryRemovedObservable: Observable<Geometry>;
  37039. /**
  37040. * An event triggered when a transform node is created
  37041. */
  37042. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37043. /**
  37044. * An event triggered when a transform node is removed
  37045. */
  37046. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37047. /**
  37048. * An event triggered when a mesh is created
  37049. */
  37050. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37051. /**
  37052. * An event triggered when a mesh is removed
  37053. */
  37054. onMeshRemovedObservable: Observable<AbstractMesh>;
  37055. /**
  37056. * An event triggered when a skeleton is created
  37057. */
  37058. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37059. /**
  37060. * An event triggered when a skeleton is removed
  37061. */
  37062. onSkeletonRemovedObservable: Observable<Skeleton>;
  37063. /**
  37064. * An event triggered when a material is created
  37065. */
  37066. onNewMaterialAddedObservable: Observable<Material>;
  37067. /**
  37068. * An event triggered when a material is removed
  37069. */
  37070. onMaterialRemovedObservable: Observable<Material>;
  37071. /**
  37072. * An event triggered when a texture is created
  37073. */
  37074. onNewTextureAddedObservable: Observable<BaseTexture>;
  37075. /**
  37076. * An event triggered when a texture is removed
  37077. */
  37078. onTextureRemovedObservable: Observable<BaseTexture>;
  37079. /**
  37080. * An event triggered when render targets are about to be rendered
  37081. * Can happen multiple times per frame.
  37082. */
  37083. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37084. /**
  37085. * An event triggered when render targets were rendered.
  37086. * Can happen multiple times per frame.
  37087. */
  37088. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37089. /**
  37090. * An event triggered before calculating deterministic simulation step
  37091. */
  37092. onBeforeStepObservable: Observable<Scene>;
  37093. /**
  37094. * An event triggered after calculating deterministic simulation step
  37095. */
  37096. onAfterStepObservable: Observable<Scene>;
  37097. /**
  37098. * An event triggered when the activeCamera property is updated
  37099. */
  37100. onActiveCameraChanged: Observable<Scene>;
  37101. /**
  37102. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37103. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37104. * 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)
  37105. */
  37106. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37107. /**
  37108. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37109. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37110. * 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)
  37111. */
  37112. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37113. /**
  37114. * This Observable will when a mesh has been imported into the scene.
  37115. */
  37116. onMeshImportedObservable: Observable<AbstractMesh>;
  37117. /**
  37118. * This Observable will when an animation file has been imported into the scene.
  37119. */
  37120. onAnimationFileImportedObservable: Observable<Scene>;
  37121. /**
  37122. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37123. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37124. */
  37125. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37126. /** @hidden */
  37127. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37128. /**
  37129. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37130. */
  37131. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37132. /**
  37133. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37134. */
  37135. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37136. /**
  37137. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37138. */
  37139. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37140. /** Callback called when a pointer move is detected */
  37141. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37142. /** Callback called when a pointer down is detected */
  37143. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37144. /** Callback called when a pointer up is detected */
  37145. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37146. /** Callback called when a pointer pick is detected */
  37147. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37148. /**
  37149. * 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).
  37150. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37151. */
  37152. onPrePointerObservable: Observable<PointerInfoPre>;
  37153. /**
  37154. * Observable event triggered each time an input event is received from the rendering canvas
  37155. */
  37156. onPointerObservable: Observable<PointerInfo>;
  37157. /**
  37158. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37159. */
  37160. get unTranslatedPointer(): Vector2;
  37161. /**
  37162. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37163. */
  37164. static get DragMovementThreshold(): number;
  37165. static set DragMovementThreshold(value: number);
  37166. /**
  37167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37168. */
  37169. static get LongPressDelay(): number;
  37170. static set LongPressDelay(value: number);
  37171. /**
  37172. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37173. */
  37174. static get DoubleClickDelay(): number;
  37175. static set DoubleClickDelay(value: number);
  37176. /** If you need to check double click without raising a single click at first click, enable this flag */
  37177. static get ExclusiveDoubleClickMode(): boolean;
  37178. static set ExclusiveDoubleClickMode(value: boolean);
  37179. /** @hidden */
  37180. _mirroredCameraPosition: Nullable<Vector3>;
  37181. /**
  37182. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37183. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37184. */
  37185. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37186. /**
  37187. * Observable event triggered each time an keyboard event is received from the hosting window
  37188. */
  37189. onKeyboardObservable: Observable<KeyboardInfo>;
  37190. private _useRightHandedSystem;
  37191. /**
  37192. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37193. */
  37194. set useRightHandedSystem(value: boolean);
  37195. get useRightHandedSystem(): boolean;
  37196. private _timeAccumulator;
  37197. private _currentStepId;
  37198. private _currentInternalStep;
  37199. /**
  37200. * Sets the step Id used by deterministic lock step
  37201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37202. * @param newStepId defines the step Id
  37203. */
  37204. setStepId(newStepId: number): void;
  37205. /**
  37206. * Gets the step Id used by deterministic lock step
  37207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37208. * @returns the step Id
  37209. */
  37210. getStepId(): number;
  37211. /**
  37212. * Gets the internal step used by deterministic lock step
  37213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37214. * @returns the internal step
  37215. */
  37216. getInternalStep(): number;
  37217. private _fogEnabled;
  37218. /**
  37219. * Gets or sets a boolean indicating if fog is enabled on this scene
  37220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37221. * (Default is true)
  37222. */
  37223. set fogEnabled(value: boolean);
  37224. get fogEnabled(): boolean;
  37225. private _fogMode;
  37226. /**
  37227. * Gets or sets the fog mode to use
  37228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37229. * | mode | value |
  37230. * | --- | --- |
  37231. * | FOGMODE_NONE | 0 |
  37232. * | FOGMODE_EXP | 1 |
  37233. * | FOGMODE_EXP2 | 2 |
  37234. * | FOGMODE_LINEAR | 3 |
  37235. */
  37236. set fogMode(value: number);
  37237. get fogMode(): number;
  37238. /**
  37239. * Gets or sets the fog color to use
  37240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37241. * (Default is Color3(0.2, 0.2, 0.3))
  37242. */
  37243. fogColor: Color3;
  37244. /**
  37245. * Gets or sets the fog density to use
  37246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37247. * (Default is 0.1)
  37248. */
  37249. fogDensity: number;
  37250. /**
  37251. * Gets or sets the fog start distance to use
  37252. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37253. * (Default is 0)
  37254. */
  37255. fogStart: number;
  37256. /**
  37257. * Gets or sets the fog end distance to use
  37258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37259. * (Default is 1000)
  37260. */
  37261. fogEnd: number;
  37262. private _shadowsEnabled;
  37263. /**
  37264. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37265. */
  37266. set shadowsEnabled(value: boolean);
  37267. get shadowsEnabled(): boolean;
  37268. private _lightsEnabled;
  37269. /**
  37270. * Gets or sets a boolean indicating if lights are enabled on this scene
  37271. */
  37272. set lightsEnabled(value: boolean);
  37273. get lightsEnabled(): boolean;
  37274. /** All of the active cameras added to this scene. */
  37275. activeCameras: Camera[];
  37276. /** @hidden */
  37277. _activeCamera: Nullable<Camera>;
  37278. /** Gets or sets the current active camera */
  37279. get activeCamera(): Nullable<Camera>;
  37280. set activeCamera(value: Nullable<Camera>);
  37281. private _defaultMaterial;
  37282. /** The default material used on meshes when no material is affected */
  37283. get defaultMaterial(): Material;
  37284. /** The default material used on meshes when no material is affected */
  37285. set defaultMaterial(value: Material);
  37286. private _texturesEnabled;
  37287. /**
  37288. * Gets or sets a boolean indicating if textures are enabled on this scene
  37289. */
  37290. set texturesEnabled(value: boolean);
  37291. get texturesEnabled(): boolean;
  37292. /**
  37293. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37294. */
  37295. physicsEnabled: boolean;
  37296. /**
  37297. * Gets or sets a boolean indicating if particles are enabled on this scene
  37298. */
  37299. particlesEnabled: boolean;
  37300. /**
  37301. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37302. */
  37303. spritesEnabled: boolean;
  37304. private _skeletonsEnabled;
  37305. /**
  37306. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37307. */
  37308. set skeletonsEnabled(value: boolean);
  37309. get skeletonsEnabled(): boolean;
  37310. /**
  37311. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37312. */
  37313. lensFlaresEnabled: boolean;
  37314. /**
  37315. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37317. */
  37318. collisionsEnabled: boolean;
  37319. private _collisionCoordinator;
  37320. /** @hidden */
  37321. get collisionCoordinator(): ICollisionCoordinator;
  37322. /**
  37323. * Defines the gravity applied to this scene (used only for collisions)
  37324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37325. */
  37326. gravity: Vector3;
  37327. /**
  37328. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37329. */
  37330. postProcessesEnabled: boolean;
  37331. /**
  37332. * The list of postprocesses added to the scene
  37333. */
  37334. postProcesses: PostProcess[];
  37335. /**
  37336. * Gets the current postprocess manager
  37337. */
  37338. postProcessManager: PostProcessManager;
  37339. /**
  37340. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37341. */
  37342. renderTargetsEnabled: boolean;
  37343. /**
  37344. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37345. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37346. */
  37347. dumpNextRenderTargets: boolean;
  37348. /**
  37349. * The list of user defined render targets added to the scene
  37350. */
  37351. customRenderTargets: RenderTargetTexture[];
  37352. /**
  37353. * Defines if texture loading must be delayed
  37354. * If true, textures will only be loaded when they need to be rendered
  37355. */
  37356. useDelayedTextureLoading: boolean;
  37357. /**
  37358. * Gets the list of meshes imported to the scene through SceneLoader
  37359. */
  37360. importedMeshesFiles: String[];
  37361. /**
  37362. * Gets or sets a boolean indicating if probes are enabled on this scene
  37363. */
  37364. probesEnabled: boolean;
  37365. /**
  37366. * Gets or sets the current offline provider to use to store scene data
  37367. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37368. */
  37369. offlineProvider: IOfflineProvider;
  37370. /**
  37371. * Gets or sets the action manager associated with the scene
  37372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37373. */
  37374. actionManager: AbstractActionManager;
  37375. private _meshesForIntersections;
  37376. /**
  37377. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37378. */
  37379. proceduralTexturesEnabled: boolean;
  37380. private _engine;
  37381. private _totalVertices;
  37382. /** @hidden */
  37383. _activeIndices: PerfCounter;
  37384. /** @hidden */
  37385. _activeParticles: PerfCounter;
  37386. /** @hidden */
  37387. _activeBones: PerfCounter;
  37388. private _animationRatio;
  37389. /** @hidden */
  37390. _animationTimeLast: number;
  37391. /** @hidden */
  37392. _animationTime: number;
  37393. /**
  37394. * Gets or sets a general scale for animation speed
  37395. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37396. */
  37397. animationTimeScale: number;
  37398. /** @hidden */
  37399. _cachedMaterial: Nullable<Material>;
  37400. /** @hidden */
  37401. _cachedEffect: Nullable<Effect>;
  37402. /** @hidden */
  37403. _cachedVisibility: Nullable<number>;
  37404. private _renderId;
  37405. private _frameId;
  37406. private _executeWhenReadyTimeoutId;
  37407. private _intermediateRendering;
  37408. private _viewUpdateFlag;
  37409. private _projectionUpdateFlag;
  37410. /** @hidden */
  37411. _toBeDisposed: Nullable<IDisposable>[];
  37412. private _activeRequests;
  37413. /** @hidden */
  37414. _pendingData: any[];
  37415. private _isDisposed;
  37416. /**
  37417. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37418. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37419. */
  37420. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37421. private _activeMeshes;
  37422. private _processedMaterials;
  37423. private _renderTargets;
  37424. /** @hidden */
  37425. _activeParticleSystems: SmartArray<IParticleSystem>;
  37426. private _activeSkeletons;
  37427. private _softwareSkinnedMeshes;
  37428. private _renderingManager;
  37429. /** @hidden */
  37430. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37431. private _transformMatrix;
  37432. private _sceneUbo;
  37433. /** @hidden */
  37434. _viewMatrix: Matrix;
  37435. private _projectionMatrix;
  37436. /** @hidden */
  37437. _forcedViewPosition: Nullable<Vector3>;
  37438. /** @hidden */
  37439. _frustumPlanes: Plane[];
  37440. /**
  37441. * Gets the list of frustum planes (built from the active camera)
  37442. */
  37443. get frustumPlanes(): Plane[];
  37444. /**
  37445. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37446. * This is useful if there are more lights that the maximum simulteanous authorized
  37447. */
  37448. requireLightSorting: boolean;
  37449. /** @hidden */
  37450. readonly useMaterialMeshMap: boolean;
  37451. /** @hidden */
  37452. readonly useClonedMeshMap: boolean;
  37453. private _externalData;
  37454. private _uid;
  37455. /**
  37456. * @hidden
  37457. * Backing store of defined scene components.
  37458. */
  37459. _components: ISceneComponent[];
  37460. /**
  37461. * @hidden
  37462. * Backing store of defined scene components.
  37463. */
  37464. _serializableComponents: ISceneSerializableComponent[];
  37465. /**
  37466. * List of components to register on the next registration step.
  37467. */
  37468. private _transientComponents;
  37469. /**
  37470. * Registers the transient components if needed.
  37471. */
  37472. private _registerTransientComponents;
  37473. /**
  37474. * @hidden
  37475. * Add a component to the scene.
  37476. * Note that the ccomponent could be registered on th next frame if this is called after
  37477. * the register component stage.
  37478. * @param component Defines the component to add to the scene
  37479. */
  37480. _addComponent(component: ISceneComponent): void;
  37481. /**
  37482. * @hidden
  37483. * Gets a component from the scene.
  37484. * @param name defines the name of the component to retrieve
  37485. * @returns the component or null if not present
  37486. */
  37487. _getComponent(name: string): Nullable<ISceneComponent>;
  37488. /**
  37489. * @hidden
  37490. * Defines the actions happening before camera updates.
  37491. */
  37492. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37493. /**
  37494. * @hidden
  37495. * Defines the actions happening before clear the canvas.
  37496. */
  37497. _beforeClearStage: Stage<SimpleStageAction>;
  37498. /**
  37499. * @hidden
  37500. * Defines the actions when collecting render targets for the frame.
  37501. */
  37502. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37503. /**
  37504. * @hidden
  37505. * Defines the actions happening for one camera in the frame.
  37506. */
  37507. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37508. /**
  37509. * @hidden
  37510. * Defines the actions happening during the per mesh ready checks.
  37511. */
  37512. _isReadyForMeshStage: Stage<MeshStageAction>;
  37513. /**
  37514. * @hidden
  37515. * Defines the actions happening before evaluate active mesh checks.
  37516. */
  37517. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37518. /**
  37519. * @hidden
  37520. * Defines the actions happening during the evaluate sub mesh checks.
  37521. */
  37522. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37523. /**
  37524. * @hidden
  37525. * Defines the actions happening during the active mesh stage.
  37526. */
  37527. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37528. /**
  37529. * @hidden
  37530. * Defines the actions happening during the per camera render target step.
  37531. */
  37532. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37533. /**
  37534. * @hidden
  37535. * Defines the actions happening just before the active camera is drawing.
  37536. */
  37537. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37538. /**
  37539. * @hidden
  37540. * Defines the actions happening just before a render target is drawing.
  37541. */
  37542. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37543. /**
  37544. * @hidden
  37545. * Defines the actions happening just before a rendering group is drawing.
  37546. */
  37547. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37548. /**
  37549. * @hidden
  37550. * Defines the actions happening just before a mesh is drawing.
  37551. */
  37552. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37553. /**
  37554. * @hidden
  37555. * Defines the actions happening just after a mesh has been drawn.
  37556. */
  37557. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37558. /**
  37559. * @hidden
  37560. * Defines the actions happening just after a rendering group has been drawn.
  37561. */
  37562. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37563. /**
  37564. * @hidden
  37565. * Defines the actions happening just after the active camera has been drawn.
  37566. */
  37567. _afterCameraDrawStage: Stage<CameraStageAction>;
  37568. /**
  37569. * @hidden
  37570. * Defines the actions happening just after a render target has been drawn.
  37571. */
  37572. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37573. /**
  37574. * @hidden
  37575. * Defines the actions happening just after rendering all cameras and computing intersections.
  37576. */
  37577. _afterRenderStage: Stage<SimpleStageAction>;
  37578. /**
  37579. * @hidden
  37580. * Defines the actions happening when a pointer move event happens.
  37581. */
  37582. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37583. /**
  37584. * @hidden
  37585. * Defines the actions happening when a pointer down event happens.
  37586. */
  37587. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37588. /**
  37589. * @hidden
  37590. * Defines the actions happening when a pointer up event happens.
  37591. */
  37592. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37593. /**
  37594. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37595. */
  37596. private geometriesByUniqueId;
  37597. /**
  37598. * Creates a new Scene
  37599. * @param engine defines the engine to use to render this scene
  37600. * @param options defines the scene options
  37601. */
  37602. constructor(engine: Engine, options?: SceneOptions);
  37603. /**
  37604. * Gets a string idenfifying the name of the class
  37605. * @returns "Scene" string
  37606. */
  37607. getClassName(): string;
  37608. private _defaultMeshCandidates;
  37609. /**
  37610. * @hidden
  37611. */
  37612. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37613. private _defaultSubMeshCandidates;
  37614. /**
  37615. * @hidden
  37616. */
  37617. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37618. /**
  37619. * Sets the default candidate providers for the scene.
  37620. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37621. * and getCollidingSubMeshCandidates to their default function
  37622. */
  37623. setDefaultCandidateProviders(): void;
  37624. /**
  37625. * Gets the mesh that is currently under the pointer
  37626. */
  37627. get meshUnderPointer(): Nullable<AbstractMesh>;
  37628. /**
  37629. * Gets or sets the current on-screen X position of the pointer
  37630. */
  37631. get pointerX(): number;
  37632. set pointerX(value: number);
  37633. /**
  37634. * Gets or sets the current on-screen Y position of the pointer
  37635. */
  37636. get pointerY(): number;
  37637. set pointerY(value: number);
  37638. /**
  37639. * Gets the cached material (ie. the latest rendered one)
  37640. * @returns the cached material
  37641. */
  37642. getCachedMaterial(): Nullable<Material>;
  37643. /**
  37644. * Gets the cached effect (ie. the latest rendered one)
  37645. * @returns the cached effect
  37646. */
  37647. getCachedEffect(): Nullable<Effect>;
  37648. /**
  37649. * Gets the cached visibility state (ie. the latest rendered one)
  37650. * @returns the cached visibility state
  37651. */
  37652. getCachedVisibility(): Nullable<number>;
  37653. /**
  37654. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37655. * @param material defines the current material
  37656. * @param effect defines the current effect
  37657. * @param visibility defines the current visibility state
  37658. * @returns true if one parameter is not cached
  37659. */
  37660. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37661. /**
  37662. * Gets the engine associated with the scene
  37663. * @returns an Engine
  37664. */
  37665. getEngine(): Engine;
  37666. /**
  37667. * Gets the total number of vertices rendered per frame
  37668. * @returns the total number of vertices rendered per frame
  37669. */
  37670. getTotalVertices(): number;
  37671. /**
  37672. * Gets the performance counter for total vertices
  37673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37674. */
  37675. get totalVerticesPerfCounter(): PerfCounter;
  37676. /**
  37677. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37678. * @returns the total number of active indices rendered per frame
  37679. */
  37680. getActiveIndices(): number;
  37681. /**
  37682. * Gets the performance counter for active indices
  37683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37684. */
  37685. get totalActiveIndicesPerfCounter(): PerfCounter;
  37686. /**
  37687. * Gets the total number of active particles rendered per frame
  37688. * @returns the total number of active particles rendered per frame
  37689. */
  37690. getActiveParticles(): number;
  37691. /**
  37692. * Gets the performance counter for active particles
  37693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37694. */
  37695. get activeParticlesPerfCounter(): PerfCounter;
  37696. /**
  37697. * Gets the total number of active bones rendered per frame
  37698. * @returns the total number of active bones rendered per frame
  37699. */
  37700. getActiveBones(): number;
  37701. /**
  37702. * Gets the performance counter for active bones
  37703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37704. */
  37705. get activeBonesPerfCounter(): PerfCounter;
  37706. /**
  37707. * Gets the array of active meshes
  37708. * @returns an array of AbstractMesh
  37709. */
  37710. getActiveMeshes(): SmartArray<AbstractMesh>;
  37711. /**
  37712. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37713. * @returns a number
  37714. */
  37715. getAnimationRatio(): number;
  37716. /**
  37717. * Gets an unique Id for the current render phase
  37718. * @returns a number
  37719. */
  37720. getRenderId(): number;
  37721. /**
  37722. * Gets an unique Id for the current frame
  37723. * @returns a number
  37724. */
  37725. getFrameId(): number;
  37726. /** Call this function if you want to manually increment the render Id*/
  37727. incrementRenderId(): void;
  37728. private _createUbo;
  37729. /**
  37730. * Use this method to simulate a pointer move on a mesh
  37731. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37732. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37733. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37734. * @returns the current scene
  37735. */
  37736. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37737. /**
  37738. * Use this method to simulate a pointer down on a mesh
  37739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37742. * @returns the current scene
  37743. */
  37744. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37745. /**
  37746. * Use this method to simulate a pointer up on a mesh
  37747. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37748. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37749. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37750. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37751. * @returns the current scene
  37752. */
  37753. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37754. /**
  37755. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37756. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37757. * @returns true if the pointer was captured
  37758. */
  37759. isPointerCaptured(pointerId?: number): boolean;
  37760. /**
  37761. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37762. * @param attachUp defines if you want to attach events to pointerup
  37763. * @param attachDown defines if you want to attach events to pointerdown
  37764. * @param attachMove defines if you want to attach events to pointermove
  37765. */
  37766. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37767. /** Detaches all event handlers*/
  37768. detachControl(): void;
  37769. /**
  37770. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37771. * Delay loaded resources are not taking in account
  37772. * @return true if all required resources are ready
  37773. */
  37774. isReady(): boolean;
  37775. /** Resets all cached information relative to material (including effect and visibility) */
  37776. resetCachedMaterial(): void;
  37777. /**
  37778. * Registers a function to be called before every frame render
  37779. * @param func defines the function to register
  37780. */
  37781. registerBeforeRender(func: () => void): void;
  37782. /**
  37783. * Unregisters a function called before every frame render
  37784. * @param func defines the function to unregister
  37785. */
  37786. unregisterBeforeRender(func: () => void): void;
  37787. /**
  37788. * Registers a function to be called after every frame render
  37789. * @param func defines the function to register
  37790. */
  37791. registerAfterRender(func: () => void): void;
  37792. /**
  37793. * Unregisters a function called after every frame render
  37794. * @param func defines the function to unregister
  37795. */
  37796. unregisterAfterRender(func: () => void): void;
  37797. private _executeOnceBeforeRender;
  37798. /**
  37799. * The provided function will run before render once and will be disposed afterwards.
  37800. * A timeout delay can be provided so that the function will be executed in N ms.
  37801. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37802. * @param func The function to be executed.
  37803. * @param timeout optional delay in ms
  37804. */
  37805. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37806. /** @hidden */
  37807. _addPendingData(data: any): void;
  37808. /** @hidden */
  37809. _removePendingData(data: any): void;
  37810. /**
  37811. * Returns the number of items waiting to be loaded
  37812. * @returns the number of items waiting to be loaded
  37813. */
  37814. getWaitingItemsCount(): number;
  37815. /**
  37816. * Returns a boolean indicating if the scene is still loading data
  37817. */
  37818. get isLoading(): boolean;
  37819. /**
  37820. * Registers a function to be executed when the scene is ready
  37821. * @param {Function} func - the function to be executed
  37822. */
  37823. executeWhenReady(func: () => void): void;
  37824. /**
  37825. * Returns a promise that resolves when the scene is ready
  37826. * @returns A promise that resolves when the scene is ready
  37827. */
  37828. whenReadyAsync(): Promise<void>;
  37829. /** @hidden */
  37830. _checkIsReady(): void;
  37831. /**
  37832. * Gets all animatable attached to the scene
  37833. */
  37834. get animatables(): Animatable[];
  37835. /**
  37836. * Resets the last animation time frame.
  37837. * Useful to override when animations start running when loading a scene for the first time.
  37838. */
  37839. resetLastAnimationTimeFrame(): void;
  37840. /**
  37841. * Gets the current view matrix
  37842. * @returns a Matrix
  37843. */
  37844. getViewMatrix(): Matrix;
  37845. /**
  37846. * Gets the current projection matrix
  37847. * @returns a Matrix
  37848. */
  37849. getProjectionMatrix(): Matrix;
  37850. /**
  37851. * Gets the current transform matrix
  37852. * @returns a Matrix made of View * Projection
  37853. */
  37854. getTransformMatrix(): Matrix;
  37855. /**
  37856. * Sets the current transform matrix
  37857. * @param viewL defines the View matrix to use
  37858. * @param projectionL defines the Projection matrix to use
  37859. * @param viewR defines the right View matrix to use (if provided)
  37860. * @param projectionR defines the right Projection matrix to use (if provided)
  37861. */
  37862. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37863. /**
  37864. * Gets the uniform buffer used to store scene data
  37865. * @returns a UniformBuffer
  37866. */
  37867. getSceneUniformBuffer(): UniformBuffer;
  37868. /**
  37869. * Gets an unique (relatively to the current scene) Id
  37870. * @returns an unique number for the scene
  37871. */
  37872. getUniqueId(): number;
  37873. /**
  37874. * Add a mesh to the list of scene's meshes
  37875. * @param newMesh defines the mesh to add
  37876. * @param recursive if all child meshes should also be added to the scene
  37877. */
  37878. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37879. /**
  37880. * Remove a mesh for the list of scene's meshes
  37881. * @param toRemove defines the mesh to remove
  37882. * @param recursive if all child meshes should also be removed from the scene
  37883. * @returns the index where the mesh was in the mesh list
  37884. */
  37885. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37886. /**
  37887. * Add a transform node to the list of scene's transform nodes
  37888. * @param newTransformNode defines the transform node to add
  37889. */
  37890. addTransformNode(newTransformNode: TransformNode): void;
  37891. /**
  37892. * Remove a transform node for the list of scene's transform nodes
  37893. * @param toRemove defines the transform node to remove
  37894. * @returns the index where the transform node was in the transform node list
  37895. */
  37896. removeTransformNode(toRemove: TransformNode): number;
  37897. /**
  37898. * Remove a skeleton for the list of scene's skeletons
  37899. * @param toRemove defines the skeleton to remove
  37900. * @returns the index where the skeleton was in the skeleton list
  37901. */
  37902. removeSkeleton(toRemove: Skeleton): number;
  37903. /**
  37904. * Remove a morph target for the list of scene's morph targets
  37905. * @param toRemove defines the morph target to remove
  37906. * @returns the index where the morph target was in the morph target list
  37907. */
  37908. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37909. /**
  37910. * Remove a light for the list of scene's lights
  37911. * @param toRemove defines the light to remove
  37912. * @returns the index where the light was in the light list
  37913. */
  37914. removeLight(toRemove: Light): number;
  37915. /**
  37916. * Remove a camera for the list of scene's cameras
  37917. * @param toRemove defines the camera to remove
  37918. * @returns the index where the camera was in the camera list
  37919. */
  37920. removeCamera(toRemove: Camera): number;
  37921. /**
  37922. * Remove a particle system for the list of scene's particle systems
  37923. * @param toRemove defines the particle system to remove
  37924. * @returns the index where the particle system was in the particle system list
  37925. */
  37926. removeParticleSystem(toRemove: IParticleSystem): number;
  37927. /**
  37928. * Remove a animation for the list of scene's animations
  37929. * @param toRemove defines the animation to remove
  37930. * @returns the index where the animation was in the animation list
  37931. */
  37932. removeAnimation(toRemove: Animation): number;
  37933. /**
  37934. * Will stop the animation of the given target
  37935. * @param target - the target
  37936. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37937. * @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)
  37938. */
  37939. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37940. /**
  37941. * Removes the given animation group from this scene.
  37942. * @param toRemove The animation group to remove
  37943. * @returns The index of the removed animation group
  37944. */
  37945. removeAnimationGroup(toRemove: AnimationGroup): number;
  37946. /**
  37947. * Removes the given multi-material from this scene.
  37948. * @param toRemove The multi-material to remove
  37949. * @returns The index of the removed multi-material
  37950. */
  37951. removeMultiMaterial(toRemove: MultiMaterial): number;
  37952. /**
  37953. * Removes the given material from this scene.
  37954. * @param toRemove The material to remove
  37955. * @returns The index of the removed material
  37956. */
  37957. removeMaterial(toRemove: Material): number;
  37958. /**
  37959. * Removes the given action manager from this scene.
  37960. * @param toRemove The action manager to remove
  37961. * @returns The index of the removed action manager
  37962. */
  37963. removeActionManager(toRemove: AbstractActionManager): number;
  37964. /**
  37965. * Removes the given texture from this scene.
  37966. * @param toRemove The texture to remove
  37967. * @returns The index of the removed texture
  37968. */
  37969. removeTexture(toRemove: BaseTexture): number;
  37970. /**
  37971. * Adds the given light to this scene
  37972. * @param newLight The light to add
  37973. */
  37974. addLight(newLight: Light): void;
  37975. /**
  37976. * Sorts the list list based on light priorities
  37977. */
  37978. sortLightsByPriority(): void;
  37979. /**
  37980. * Adds the given camera to this scene
  37981. * @param newCamera The camera to add
  37982. */
  37983. addCamera(newCamera: Camera): void;
  37984. /**
  37985. * Adds the given skeleton to this scene
  37986. * @param newSkeleton The skeleton to add
  37987. */
  37988. addSkeleton(newSkeleton: Skeleton): void;
  37989. /**
  37990. * Adds the given particle system to this scene
  37991. * @param newParticleSystem The particle system to add
  37992. */
  37993. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37994. /**
  37995. * Adds the given animation to this scene
  37996. * @param newAnimation The animation to add
  37997. */
  37998. addAnimation(newAnimation: Animation): void;
  37999. /**
  38000. * Adds the given animation group to this scene.
  38001. * @param newAnimationGroup The animation group to add
  38002. */
  38003. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  38004. /**
  38005. * Adds the given multi-material to this scene
  38006. * @param newMultiMaterial The multi-material to add
  38007. */
  38008. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38009. /**
  38010. * Adds the given material to this scene
  38011. * @param newMaterial The material to add
  38012. */
  38013. addMaterial(newMaterial: Material): void;
  38014. /**
  38015. * Adds the given morph target to this scene
  38016. * @param newMorphTargetManager The morph target to add
  38017. */
  38018. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38019. /**
  38020. * Adds the given geometry to this scene
  38021. * @param newGeometry The geometry to add
  38022. */
  38023. addGeometry(newGeometry: Geometry): void;
  38024. /**
  38025. * Adds the given action manager to this scene
  38026. * @param newActionManager The action manager to add
  38027. */
  38028. addActionManager(newActionManager: AbstractActionManager): void;
  38029. /**
  38030. * Adds the given texture to this scene.
  38031. * @param newTexture The texture to add
  38032. */
  38033. addTexture(newTexture: BaseTexture): void;
  38034. /**
  38035. * Switch active camera
  38036. * @param newCamera defines the new active camera
  38037. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38038. */
  38039. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38040. /**
  38041. * sets the active camera of the scene using its ID
  38042. * @param id defines the camera's ID
  38043. * @return the new active camera or null if none found.
  38044. */
  38045. setActiveCameraByID(id: string): Nullable<Camera>;
  38046. /**
  38047. * sets the active camera of the scene using its name
  38048. * @param name defines the camera's name
  38049. * @returns the new active camera or null if none found.
  38050. */
  38051. setActiveCameraByName(name: string): Nullable<Camera>;
  38052. /**
  38053. * get an animation group using its name
  38054. * @param name defines the material's name
  38055. * @return the animation group or null if none found.
  38056. */
  38057. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38058. /**
  38059. * Get a material using its unique id
  38060. * @param uniqueId defines the material's unique id
  38061. * @return the material or null if none found.
  38062. */
  38063. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38064. /**
  38065. * get a material using its id
  38066. * @param id defines the material's ID
  38067. * @return the material or null if none found.
  38068. */
  38069. getMaterialByID(id: string): Nullable<Material>;
  38070. /**
  38071. * Gets a the last added material using a given id
  38072. * @param id defines the material's ID
  38073. * @return the last material with the given id or null if none found.
  38074. */
  38075. getLastMaterialByID(id: string): Nullable<Material>;
  38076. /**
  38077. * Gets a material using its name
  38078. * @param name defines the material's name
  38079. * @return the material or null if none found.
  38080. */
  38081. getMaterialByName(name: string): Nullable<Material>;
  38082. /**
  38083. * Get a texture using its unique id
  38084. * @param uniqueId defines the texture's unique id
  38085. * @return the texture or null if none found.
  38086. */
  38087. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38088. /**
  38089. * Gets a camera using its id
  38090. * @param id defines the id to look for
  38091. * @returns the camera or null if not found
  38092. */
  38093. getCameraByID(id: string): Nullable<Camera>;
  38094. /**
  38095. * Gets a camera using its unique id
  38096. * @param uniqueId defines the unique id to look for
  38097. * @returns the camera or null if not found
  38098. */
  38099. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38100. /**
  38101. * Gets a camera using its name
  38102. * @param name defines the camera's name
  38103. * @return the camera or null if none found.
  38104. */
  38105. getCameraByName(name: string): Nullable<Camera>;
  38106. /**
  38107. * Gets a bone using its id
  38108. * @param id defines the bone's id
  38109. * @return the bone or null if not found
  38110. */
  38111. getBoneByID(id: string): Nullable<Bone>;
  38112. /**
  38113. * Gets a bone using its id
  38114. * @param name defines the bone's name
  38115. * @return the bone or null if not found
  38116. */
  38117. getBoneByName(name: string): Nullable<Bone>;
  38118. /**
  38119. * Gets a light node using its name
  38120. * @param name defines the the light's name
  38121. * @return the light or null if none found.
  38122. */
  38123. getLightByName(name: string): Nullable<Light>;
  38124. /**
  38125. * Gets a light node using its id
  38126. * @param id defines the light's id
  38127. * @return the light or null if none found.
  38128. */
  38129. getLightByID(id: string): Nullable<Light>;
  38130. /**
  38131. * Gets a light node using its scene-generated unique ID
  38132. * @param uniqueId defines the light's unique id
  38133. * @return the light or null if none found.
  38134. */
  38135. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38136. /**
  38137. * Gets a particle system by id
  38138. * @param id defines the particle system id
  38139. * @return the corresponding system or null if none found
  38140. */
  38141. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38142. /**
  38143. * Gets a geometry using its ID
  38144. * @param id defines the geometry's id
  38145. * @return the geometry or null if none found.
  38146. */
  38147. getGeometryByID(id: string): Nullable<Geometry>;
  38148. private _getGeometryByUniqueID;
  38149. /**
  38150. * Add a new geometry to this scene
  38151. * @param geometry defines the geometry to be added to the scene.
  38152. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38153. * @return a boolean defining if the geometry was added or not
  38154. */
  38155. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38156. /**
  38157. * Removes an existing geometry
  38158. * @param geometry defines the geometry to be removed from the scene
  38159. * @return a boolean defining if the geometry was removed or not
  38160. */
  38161. removeGeometry(geometry: Geometry): boolean;
  38162. /**
  38163. * Gets the list of geometries attached to the scene
  38164. * @returns an array of Geometry
  38165. */
  38166. getGeometries(): Geometry[];
  38167. /**
  38168. * Gets the first added mesh found of a given ID
  38169. * @param id defines the id to search for
  38170. * @return the mesh found or null if not found at all
  38171. */
  38172. getMeshByID(id: string): Nullable<AbstractMesh>;
  38173. /**
  38174. * Gets a list of meshes using their id
  38175. * @param id defines the id to search for
  38176. * @returns a list of meshes
  38177. */
  38178. getMeshesByID(id: string): Array<AbstractMesh>;
  38179. /**
  38180. * Gets the first added transform node found of a given ID
  38181. * @param id defines the id to search for
  38182. * @return the found transform node or null if not found at all.
  38183. */
  38184. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38185. /**
  38186. * Gets a transform node with its auto-generated unique id
  38187. * @param uniqueId efines the unique id to search for
  38188. * @return the found transform node or null if not found at all.
  38189. */
  38190. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38191. /**
  38192. * Gets a list of transform nodes using their id
  38193. * @param id defines the id to search for
  38194. * @returns a list of transform nodes
  38195. */
  38196. getTransformNodesByID(id: string): Array<TransformNode>;
  38197. /**
  38198. * Gets a mesh with its auto-generated unique id
  38199. * @param uniqueId defines the unique id to search for
  38200. * @return the found mesh or null if not found at all.
  38201. */
  38202. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38203. /**
  38204. * Gets a the last added mesh using a given id
  38205. * @param id defines the id to search for
  38206. * @return the found mesh or null if not found at all.
  38207. */
  38208. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38209. /**
  38210. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38211. * @param id defines the id to search for
  38212. * @return the found node or null if not found at all
  38213. */
  38214. getLastEntryByID(id: string): Nullable<Node>;
  38215. /**
  38216. * Gets a node (Mesh, Camera, Light) using a given id
  38217. * @param id defines the id to search for
  38218. * @return the found node or null if not found at all
  38219. */
  38220. getNodeByID(id: string): Nullable<Node>;
  38221. /**
  38222. * Gets a node (Mesh, Camera, Light) using a given name
  38223. * @param name defines the name to search for
  38224. * @return the found node or null if not found at all.
  38225. */
  38226. getNodeByName(name: string): Nullable<Node>;
  38227. /**
  38228. * Gets a mesh using a given name
  38229. * @param name defines the name to search for
  38230. * @return the found mesh or null if not found at all.
  38231. */
  38232. getMeshByName(name: string): Nullable<AbstractMesh>;
  38233. /**
  38234. * Gets a transform node using a given name
  38235. * @param name defines the name to search for
  38236. * @return the found transform node or null if not found at all.
  38237. */
  38238. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38239. /**
  38240. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38241. * @param id defines the id to search for
  38242. * @return the found skeleton or null if not found at all.
  38243. */
  38244. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38245. /**
  38246. * Gets a skeleton using a given auto generated unique id
  38247. * @param uniqueId defines the unique id to search for
  38248. * @return the found skeleton or null if not found at all.
  38249. */
  38250. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38251. /**
  38252. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38253. * @param id defines the id to search for
  38254. * @return the found skeleton or null if not found at all.
  38255. */
  38256. getSkeletonById(id: string): Nullable<Skeleton>;
  38257. /**
  38258. * Gets a skeleton using a given name
  38259. * @param name defines the name to search for
  38260. * @return the found skeleton or null if not found at all.
  38261. */
  38262. getSkeletonByName(name: string): Nullable<Skeleton>;
  38263. /**
  38264. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38265. * @param id defines the id to search for
  38266. * @return the found morph target manager or null if not found at all.
  38267. */
  38268. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38269. /**
  38270. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38271. * @param id defines the id to search for
  38272. * @return the found morph target or null if not found at all.
  38273. */
  38274. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38275. /**
  38276. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38277. * @param name defines the name to search for
  38278. * @return the found morph target or null if not found at all.
  38279. */
  38280. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38281. /**
  38282. * Gets a boolean indicating if the given mesh is active
  38283. * @param mesh defines the mesh to look for
  38284. * @returns true if the mesh is in the active list
  38285. */
  38286. isActiveMesh(mesh: AbstractMesh): boolean;
  38287. /**
  38288. * Return a unique id as a string which can serve as an identifier for the scene
  38289. */
  38290. get uid(): string;
  38291. /**
  38292. * Add an externaly attached data from its key.
  38293. * This method call will fail and return false, if such key already exists.
  38294. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38295. * @param key the unique key that identifies the data
  38296. * @param data the data object to associate to the key for this Engine instance
  38297. * @return true if no such key were already present and the data was added successfully, false otherwise
  38298. */
  38299. addExternalData<T>(key: string, data: T): boolean;
  38300. /**
  38301. * Get an externaly attached data from its key
  38302. * @param key the unique key that identifies the data
  38303. * @return the associated data, if present (can be null), or undefined if not present
  38304. */
  38305. getExternalData<T>(key: string): Nullable<T>;
  38306. /**
  38307. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38308. * @param key the unique key that identifies the data
  38309. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38310. * @return the associated data, can be null if the factory returned null.
  38311. */
  38312. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38313. /**
  38314. * Remove an externaly attached data from the Engine instance
  38315. * @param key the unique key that identifies the data
  38316. * @return true if the data was successfully removed, false if it doesn't exist
  38317. */
  38318. removeExternalData(key: string): boolean;
  38319. private _evaluateSubMesh;
  38320. /**
  38321. * Clear the processed materials smart array preventing retention point in material dispose.
  38322. */
  38323. freeProcessedMaterials(): void;
  38324. private _preventFreeActiveMeshesAndRenderingGroups;
  38325. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38326. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38327. * when disposing several meshes in a row or a hierarchy of meshes.
  38328. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38329. */
  38330. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38331. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38332. /**
  38333. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38334. */
  38335. freeActiveMeshes(): void;
  38336. /**
  38337. * Clear the info related to rendering groups preventing retention points during dispose.
  38338. */
  38339. freeRenderingGroups(): void;
  38340. /** @hidden */
  38341. _isInIntermediateRendering(): boolean;
  38342. /**
  38343. * Lambda returning the list of potentially active meshes.
  38344. */
  38345. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38346. /**
  38347. * Lambda returning the list of potentially active sub meshes.
  38348. */
  38349. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38350. /**
  38351. * Lambda returning the list of potentially intersecting sub meshes.
  38352. */
  38353. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38354. /**
  38355. * Lambda returning the list of potentially colliding sub meshes.
  38356. */
  38357. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38358. private _activeMeshesFrozen;
  38359. private _skipEvaluateActiveMeshesCompletely;
  38360. /**
  38361. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38362. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38363. * @returns the current scene
  38364. */
  38365. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38366. /**
  38367. * Use this function to restart evaluating active meshes on every frame
  38368. * @returns the current scene
  38369. */
  38370. unfreezeActiveMeshes(): Scene;
  38371. private _evaluateActiveMeshes;
  38372. private _activeMesh;
  38373. /**
  38374. * Update the transform matrix to update from the current active camera
  38375. * @param force defines a boolean used to force the update even if cache is up to date
  38376. */
  38377. updateTransformMatrix(force?: boolean): void;
  38378. private _bindFrameBuffer;
  38379. /** @hidden */
  38380. _allowPostProcessClearColor: boolean;
  38381. /** @hidden */
  38382. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38383. private _processSubCameras;
  38384. private _checkIntersections;
  38385. /** @hidden */
  38386. _advancePhysicsEngineStep(step: number): void;
  38387. /**
  38388. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38389. */
  38390. getDeterministicFrameTime: () => number;
  38391. /** @hidden */
  38392. _animate(): void;
  38393. /** Execute all animations (for a frame) */
  38394. animate(): void;
  38395. /**
  38396. * Render the scene
  38397. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38398. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38399. */
  38400. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38401. /**
  38402. * Freeze all materials
  38403. * A frozen material will not be updatable but should be faster to render
  38404. */
  38405. freezeMaterials(): void;
  38406. /**
  38407. * Unfreeze all materials
  38408. * A frozen material will not be updatable but should be faster to render
  38409. */
  38410. unfreezeMaterials(): void;
  38411. /**
  38412. * Releases all held ressources
  38413. */
  38414. dispose(): void;
  38415. /**
  38416. * Gets if the scene is already disposed
  38417. */
  38418. get isDisposed(): boolean;
  38419. /**
  38420. * Call this function to reduce memory footprint of the scene.
  38421. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38422. */
  38423. clearCachedVertexData(): void;
  38424. /**
  38425. * This function will remove the local cached buffer data from texture.
  38426. * It will save memory but will prevent the texture from being rebuilt
  38427. */
  38428. cleanCachedTextureBuffer(): void;
  38429. /**
  38430. * Get the world extend vectors with an optional filter
  38431. *
  38432. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38433. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38434. */
  38435. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38436. min: Vector3;
  38437. max: Vector3;
  38438. };
  38439. /**
  38440. * Creates a ray that can be used to pick in the scene
  38441. * @param x defines the x coordinate of the origin (on-screen)
  38442. * @param y defines the y coordinate of the origin (on-screen)
  38443. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38444. * @param camera defines the camera to use for the picking
  38445. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38446. * @returns a Ray
  38447. */
  38448. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38449. /**
  38450. * Creates a ray that can be used to pick in the scene
  38451. * @param x defines the x coordinate of the origin (on-screen)
  38452. * @param y defines the y coordinate of the origin (on-screen)
  38453. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38454. * @param result defines the ray where to store the picking ray
  38455. * @param camera defines the camera to use for the picking
  38456. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38457. * @returns the current scene
  38458. */
  38459. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38460. /**
  38461. * Creates a ray that can be used to pick in the scene
  38462. * @param x defines the x coordinate of the origin (on-screen)
  38463. * @param y defines the y coordinate of the origin (on-screen)
  38464. * @param camera defines the camera to use for the picking
  38465. * @returns a Ray
  38466. */
  38467. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38468. /**
  38469. * Creates a ray that can be used to pick in the scene
  38470. * @param x defines the x coordinate of the origin (on-screen)
  38471. * @param y defines the y coordinate of the origin (on-screen)
  38472. * @param result defines the ray where to store the picking ray
  38473. * @param camera defines the camera to use for the picking
  38474. * @returns the current scene
  38475. */
  38476. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38477. /** Launch a ray to try to pick a mesh in the scene
  38478. * @param x position on screen
  38479. * @param y position on screen
  38480. * @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
  38481. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38482. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38484. * @returns a PickingInfo
  38485. */
  38486. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38487. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38488. * @param x position on screen
  38489. * @param y position on screen
  38490. * @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
  38491. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38492. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38493. * @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)
  38494. */
  38495. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38496. /** Use the given ray to pick a mesh in the scene
  38497. * @param ray The ray to use to pick meshes
  38498. * @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
  38499. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38501. * @returns a PickingInfo
  38502. */
  38503. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38504. /**
  38505. * Launch a ray to try to pick a mesh in the scene
  38506. * @param x X position on screen
  38507. * @param y Y position on screen
  38508. * @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
  38509. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38511. * @returns an array of PickingInfo
  38512. */
  38513. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38514. /**
  38515. * Launch a ray to try to pick a mesh in the scene
  38516. * @param ray Ray to use
  38517. * @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
  38518. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38519. * @returns an array of PickingInfo
  38520. */
  38521. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38522. /**
  38523. * Force the value of meshUnderPointer
  38524. * @param mesh defines the mesh to use
  38525. */
  38526. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38527. /**
  38528. * Gets the mesh under the pointer
  38529. * @returns a Mesh or null if no mesh is under the pointer
  38530. */
  38531. getPointerOverMesh(): Nullable<AbstractMesh>;
  38532. /** @hidden */
  38533. _rebuildGeometries(): void;
  38534. /** @hidden */
  38535. _rebuildTextures(): void;
  38536. private _getByTags;
  38537. /**
  38538. * Get a list of meshes by tags
  38539. * @param tagsQuery defines the tags query to use
  38540. * @param forEach defines a predicate used to filter results
  38541. * @returns an array of Mesh
  38542. */
  38543. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38544. /**
  38545. * Get a list of cameras by tags
  38546. * @param tagsQuery defines the tags query to use
  38547. * @param forEach defines a predicate used to filter results
  38548. * @returns an array of Camera
  38549. */
  38550. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38551. /**
  38552. * Get a list of lights by tags
  38553. * @param tagsQuery defines the tags query to use
  38554. * @param forEach defines a predicate used to filter results
  38555. * @returns an array of Light
  38556. */
  38557. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38558. /**
  38559. * Get a list of materials by tags
  38560. * @param tagsQuery defines the tags query to use
  38561. * @param forEach defines a predicate used to filter results
  38562. * @returns an array of Material
  38563. */
  38564. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38565. /**
  38566. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38567. * This allowed control for front to back rendering or reversly depending of the special needs.
  38568. *
  38569. * @param renderingGroupId The rendering group id corresponding to its index
  38570. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38571. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38572. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38573. */
  38574. 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;
  38575. /**
  38576. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38577. *
  38578. * @param renderingGroupId The rendering group id corresponding to its index
  38579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38580. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38581. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38582. */
  38583. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38584. /**
  38585. * Gets the current auto clear configuration for one rendering group of the rendering
  38586. * manager.
  38587. * @param index the rendering group index to get the information for
  38588. * @returns The auto clear setup for the requested rendering group
  38589. */
  38590. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38591. private _blockMaterialDirtyMechanism;
  38592. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38593. get blockMaterialDirtyMechanism(): boolean;
  38594. set blockMaterialDirtyMechanism(value: boolean);
  38595. /**
  38596. * Will flag all materials as dirty to trigger new shader compilation
  38597. * @param flag defines the flag used to specify which material part must be marked as dirty
  38598. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38599. */
  38600. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38601. /** @hidden */
  38602. _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;
  38603. /** @hidden */
  38604. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38605. /** @hidden */
  38606. _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;
  38607. /** @hidden */
  38608. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38609. /** @hidden */
  38610. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38611. /** @hidden */
  38612. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38613. }
  38614. }
  38615. declare module "babylonjs/assetContainer" {
  38616. import { AbstractScene } from "babylonjs/abstractScene";
  38617. import { Scene } from "babylonjs/scene";
  38618. import { Mesh } from "babylonjs/Meshes/mesh";
  38619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38620. import { Skeleton } from "babylonjs/Bones/skeleton";
  38621. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38622. import { Animatable } from "babylonjs/Animations/animatable";
  38623. import { Nullable } from "babylonjs/types";
  38624. import { Node } from "babylonjs/node";
  38625. /**
  38626. * Set of assets to keep when moving a scene into an asset container.
  38627. */
  38628. export class KeepAssets extends AbstractScene {
  38629. }
  38630. /**
  38631. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38632. */
  38633. export class InstantiatedEntries {
  38634. /**
  38635. * List of new root nodes (eg. nodes with no parent)
  38636. */
  38637. rootNodes: TransformNode[];
  38638. /**
  38639. * List of new skeletons
  38640. */
  38641. skeletons: Skeleton[];
  38642. /**
  38643. * List of new animation groups
  38644. */
  38645. animationGroups: AnimationGroup[];
  38646. }
  38647. /**
  38648. * Container with a set of assets that can be added or removed from a scene.
  38649. */
  38650. export class AssetContainer extends AbstractScene {
  38651. private _wasAddedToScene;
  38652. /**
  38653. * The scene the AssetContainer belongs to.
  38654. */
  38655. scene: Scene;
  38656. /**
  38657. * Instantiates an AssetContainer.
  38658. * @param scene The scene the AssetContainer belongs to.
  38659. */
  38660. constructor(scene: Scene);
  38661. /**
  38662. * Instantiate or clone all meshes and add the new ones to the scene.
  38663. * Skeletons and animation groups will all be cloned
  38664. * @param nameFunction defines an optional function used to get new names for clones
  38665. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38666. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38667. */
  38668. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38669. /**
  38670. * Adds all the assets from the container to the scene.
  38671. */
  38672. addAllToScene(): void;
  38673. /**
  38674. * Removes all the assets in the container from the scene
  38675. */
  38676. removeAllFromScene(): void;
  38677. /**
  38678. * Disposes all the assets in the container
  38679. */
  38680. dispose(): void;
  38681. private _moveAssets;
  38682. /**
  38683. * Removes all the assets contained in the scene and adds them to the container.
  38684. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38685. */
  38686. moveAllFromScene(keepAssets?: KeepAssets): void;
  38687. /**
  38688. * 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.
  38689. * @returns the root mesh
  38690. */
  38691. createRootMesh(): Mesh;
  38692. /**
  38693. * Merge animations (direct and animation groups) from this asset container into a scene
  38694. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38695. * @param animatables set of animatables to retarget to a node from the scene
  38696. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38697. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38698. */
  38699. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38700. }
  38701. }
  38702. declare module "babylonjs/abstractScene" {
  38703. import { Scene } from "babylonjs/scene";
  38704. import { Nullable } from "babylonjs/types";
  38705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38706. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38707. import { Geometry } from "babylonjs/Meshes/geometry";
  38708. import { Skeleton } from "babylonjs/Bones/skeleton";
  38709. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38710. import { AssetContainer } from "babylonjs/assetContainer";
  38711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38712. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38714. import { Material } from "babylonjs/Materials/material";
  38715. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38716. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38717. import { Camera } from "babylonjs/Cameras/camera";
  38718. import { Light } from "babylonjs/Lights/light";
  38719. import { Node } from "babylonjs/node";
  38720. import { Animation } from "babylonjs/Animations/animation";
  38721. /**
  38722. * Defines how the parser contract is defined.
  38723. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38724. */
  38725. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38726. /**
  38727. * Defines how the individual parser contract is defined.
  38728. * These parser can parse an individual asset
  38729. */
  38730. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38731. /**
  38732. * Base class of the scene acting as a container for the different elements composing a scene.
  38733. * This class is dynamically extended by the different components of the scene increasing
  38734. * flexibility and reducing coupling
  38735. */
  38736. export abstract class AbstractScene {
  38737. /**
  38738. * Stores the list of available parsers in the application.
  38739. */
  38740. private static _BabylonFileParsers;
  38741. /**
  38742. * Stores the list of available individual parsers in the application.
  38743. */
  38744. private static _IndividualBabylonFileParsers;
  38745. /**
  38746. * Adds a parser in the list of available ones
  38747. * @param name Defines the name of the parser
  38748. * @param parser Defines the parser to add
  38749. */
  38750. static AddParser(name: string, parser: BabylonFileParser): void;
  38751. /**
  38752. * Gets a general parser from the list of avaialble ones
  38753. * @param name Defines the name of the parser
  38754. * @returns the requested parser or null
  38755. */
  38756. static GetParser(name: string): Nullable<BabylonFileParser>;
  38757. /**
  38758. * Adds n individual parser in the list of available ones
  38759. * @param name Defines the name of the parser
  38760. * @param parser Defines the parser to add
  38761. */
  38762. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38763. /**
  38764. * Gets an individual parser from the list of avaialble ones
  38765. * @param name Defines the name of the parser
  38766. * @returns the requested parser or null
  38767. */
  38768. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38769. /**
  38770. * Parser json data and populate both a scene and its associated container object
  38771. * @param jsonData Defines the data to parse
  38772. * @param scene Defines the scene to parse the data for
  38773. * @param container Defines the container attached to the parsing sequence
  38774. * @param rootUrl Defines the root url of the data
  38775. */
  38776. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38777. /**
  38778. * Gets the list of root nodes (ie. nodes with no parent)
  38779. */
  38780. rootNodes: Node[];
  38781. /** All of the cameras added to this scene
  38782. * @see http://doc.babylonjs.com/babylon101/cameras
  38783. */
  38784. cameras: Camera[];
  38785. /**
  38786. * All of the lights added to this scene
  38787. * @see http://doc.babylonjs.com/babylon101/lights
  38788. */
  38789. lights: Light[];
  38790. /**
  38791. * All of the (abstract) meshes added to this scene
  38792. */
  38793. meshes: AbstractMesh[];
  38794. /**
  38795. * The list of skeletons added to the scene
  38796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38797. */
  38798. skeletons: Skeleton[];
  38799. /**
  38800. * All of the particle systems added to this scene
  38801. * @see http://doc.babylonjs.com/babylon101/particles
  38802. */
  38803. particleSystems: IParticleSystem[];
  38804. /**
  38805. * Gets a list of Animations associated with the scene
  38806. */
  38807. animations: Animation[];
  38808. /**
  38809. * All of the animation groups added to this scene
  38810. * @see http://doc.babylonjs.com/how_to/group
  38811. */
  38812. animationGroups: AnimationGroup[];
  38813. /**
  38814. * All of the multi-materials added to this scene
  38815. * @see http://doc.babylonjs.com/how_to/multi_materials
  38816. */
  38817. multiMaterials: MultiMaterial[];
  38818. /**
  38819. * All of the materials added to this scene
  38820. * In the context of a Scene, it is not supposed to be modified manually.
  38821. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38822. * Note also that the order of the Material within the array is not significant and might change.
  38823. * @see http://doc.babylonjs.com/babylon101/materials
  38824. */
  38825. materials: Material[];
  38826. /**
  38827. * The list of morph target managers added to the scene
  38828. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38829. */
  38830. morphTargetManagers: MorphTargetManager[];
  38831. /**
  38832. * The list of geometries used in the scene.
  38833. */
  38834. geometries: Geometry[];
  38835. /**
  38836. * All of the tranform nodes added to this scene
  38837. * In the context of a Scene, it is not supposed to be modified manually.
  38838. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38839. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38840. * @see http://doc.babylonjs.com/how_to/transformnode
  38841. */
  38842. transformNodes: TransformNode[];
  38843. /**
  38844. * ActionManagers available on the scene.
  38845. */
  38846. actionManagers: AbstractActionManager[];
  38847. /**
  38848. * Textures to keep.
  38849. */
  38850. textures: BaseTexture[];
  38851. /**
  38852. * Environment texture for the scene
  38853. */
  38854. environmentTexture: Nullable<BaseTexture>;
  38855. /**
  38856. * @returns all meshes, lights, cameras, transformNodes and bones
  38857. */
  38858. getNodes(): Array<Node>;
  38859. }
  38860. }
  38861. declare module "babylonjs/Audio/sound" {
  38862. import { Observable } from "babylonjs/Misc/observable";
  38863. import { Vector3 } from "babylonjs/Maths/math.vector";
  38864. import { Nullable } from "babylonjs/types";
  38865. import { Scene } from "babylonjs/scene";
  38866. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38867. /**
  38868. * Interface used to define options for Sound class
  38869. */
  38870. export interface ISoundOptions {
  38871. /**
  38872. * Does the sound autoplay once loaded.
  38873. */
  38874. autoplay?: boolean;
  38875. /**
  38876. * Does the sound loop after it finishes playing once.
  38877. */
  38878. loop?: boolean;
  38879. /**
  38880. * Sound's volume
  38881. */
  38882. volume?: number;
  38883. /**
  38884. * Is it a spatial sound?
  38885. */
  38886. spatialSound?: boolean;
  38887. /**
  38888. * Maximum distance to hear that sound
  38889. */
  38890. maxDistance?: number;
  38891. /**
  38892. * Uses user defined attenuation function
  38893. */
  38894. useCustomAttenuation?: boolean;
  38895. /**
  38896. * Define the roll off factor of spatial sounds.
  38897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38898. */
  38899. rolloffFactor?: number;
  38900. /**
  38901. * Define the reference distance the sound should be heard perfectly.
  38902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38903. */
  38904. refDistance?: number;
  38905. /**
  38906. * Define the distance attenuation model the sound will follow.
  38907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38908. */
  38909. distanceModel?: string;
  38910. /**
  38911. * Defines the playback speed (1 by default)
  38912. */
  38913. playbackRate?: number;
  38914. /**
  38915. * Defines if the sound is from a streaming source
  38916. */
  38917. streaming?: boolean;
  38918. /**
  38919. * Defines an optional length (in seconds) inside the sound file
  38920. */
  38921. length?: number;
  38922. /**
  38923. * Defines an optional offset (in seconds) inside the sound file
  38924. */
  38925. offset?: number;
  38926. /**
  38927. * If true, URLs will not be required to state the audio file codec to use.
  38928. */
  38929. skipCodecCheck?: boolean;
  38930. }
  38931. /**
  38932. * Defines a sound that can be played in the application.
  38933. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38935. */
  38936. export class Sound {
  38937. /**
  38938. * The name of the sound in the scene.
  38939. */
  38940. name: string;
  38941. /**
  38942. * Does the sound autoplay once loaded.
  38943. */
  38944. autoplay: boolean;
  38945. /**
  38946. * Does the sound loop after it finishes playing once.
  38947. */
  38948. loop: boolean;
  38949. /**
  38950. * Does the sound use a custom attenuation curve to simulate the falloff
  38951. * happening when the source gets further away from the camera.
  38952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38953. */
  38954. useCustomAttenuation: boolean;
  38955. /**
  38956. * The sound track id this sound belongs to.
  38957. */
  38958. soundTrackId: number;
  38959. /**
  38960. * Is this sound currently played.
  38961. */
  38962. isPlaying: boolean;
  38963. /**
  38964. * Is this sound currently paused.
  38965. */
  38966. isPaused: boolean;
  38967. /**
  38968. * Does this sound enables spatial sound.
  38969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38970. */
  38971. spatialSound: boolean;
  38972. /**
  38973. * Define the reference distance the sound should be heard perfectly.
  38974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38975. */
  38976. refDistance: number;
  38977. /**
  38978. * Define the roll off factor of spatial sounds.
  38979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38980. */
  38981. rolloffFactor: number;
  38982. /**
  38983. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38985. */
  38986. maxDistance: number;
  38987. /**
  38988. * Define the distance attenuation model the sound will follow.
  38989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38990. */
  38991. distanceModel: string;
  38992. /**
  38993. * @hidden
  38994. * Back Compat
  38995. **/
  38996. onended: () => any;
  38997. /**
  38998. * Observable event when the current playing sound finishes.
  38999. */
  39000. onEndedObservable: Observable<Sound>;
  39001. private _panningModel;
  39002. private _playbackRate;
  39003. private _streaming;
  39004. private _startTime;
  39005. private _startOffset;
  39006. private _position;
  39007. /** @hidden */
  39008. _positionInEmitterSpace: boolean;
  39009. private _localDirection;
  39010. private _volume;
  39011. private _isReadyToPlay;
  39012. private _isDirectional;
  39013. private _readyToPlayCallback;
  39014. private _audioBuffer;
  39015. private _soundSource;
  39016. private _streamingSource;
  39017. private _soundPanner;
  39018. private _soundGain;
  39019. private _inputAudioNode;
  39020. private _outputAudioNode;
  39021. private _coneInnerAngle;
  39022. private _coneOuterAngle;
  39023. private _coneOuterGain;
  39024. private _scene;
  39025. private _connectedTransformNode;
  39026. private _customAttenuationFunction;
  39027. private _registerFunc;
  39028. private _isOutputConnected;
  39029. private _htmlAudioElement;
  39030. private _urlType;
  39031. private _length?;
  39032. private _offset?;
  39033. /** @hidden */
  39034. static _SceneComponentInitialization: (scene: Scene) => void;
  39035. /**
  39036. * Create a sound and attach it to a scene
  39037. * @param name Name of your sound
  39038. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39039. * @param scene defines the scene the sound belongs to
  39040. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39041. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39042. */
  39043. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39044. /**
  39045. * Release the sound and its associated resources
  39046. */
  39047. dispose(): void;
  39048. /**
  39049. * Gets if the sounds is ready to be played or not.
  39050. * @returns true if ready, otherwise false
  39051. */
  39052. isReady(): boolean;
  39053. private _soundLoaded;
  39054. /**
  39055. * Sets the data of the sound from an audiobuffer
  39056. * @param audioBuffer The audioBuffer containing the data
  39057. */
  39058. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39059. /**
  39060. * Updates the current sounds options such as maxdistance, loop...
  39061. * @param options A JSON object containing values named as the object properties
  39062. */
  39063. updateOptions(options: ISoundOptions): void;
  39064. private _createSpatialParameters;
  39065. private _updateSpatialParameters;
  39066. /**
  39067. * Switch the panning model to HRTF:
  39068. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39070. */
  39071. switchPanningModelToHRTF(): void;
  39072. /**
  39073. * Switch the panning model to Equal Power:
  39074. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39076. */
  39077. switchPanningModelToEqualPower(): void;
  39078. private _switchPanningModel;
  39079. /**
  39080. * Connect this sound to a sound track audio node like gain...
  39081. * @param soundTrackAudioNode the sound track audio node to connect to
  39082. */
  39083. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39084. /**
  39085. * Transform this sound into a directional source
  39086. * @param coneInnerAngle Size of the inner cone in degree
  39087. * @param coneOuterAngle Size of the outer cone in degree
  39088. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39089. */
  39090. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39091. /**
  39092. * Gets or sets the inner angle for the directional cone.
  39093. */
  39094. get directionalConeInnerAngle(): number;
  39095. /**
  39096. * Gets or sets the inner angle for the directional cone.
  39097. */
  39098. set directionalConeInnerAngle(value: number);
  39099. /**
  39100. * Gets or sets the outer angle for the directional cone.
  39101. */
  39102. get directionalConeOuterAngle(): number;
  39103. /**
  39104. * Gets or sets the outer angle for the directional cone.
  39105. */
  39106. set directionalConeOuterAngle(value: number);
  39107. /**
  39108. * Sets the position of the emitter if spatial sound is enabled
  39109. * @param newPosition Defines the new posisiton
  39110. */
  39111. setPosition(newPosition: Vector3): void;
  39112. /**
  39113. * Sets the local direction of the emitter if spatial sound is enabled
  39114. * @param newLocalDirection Defines the new local direction
  39115. */
  39116. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39117. private _updateDirection;
  39118. /** @hidden */
  39119. updateDistanceFromListener(): void;
  39120. /**
  39121. * Sets a new custom attenuation function for the sound.
  39122. * @param callback Defines the function used for the attenuation
  39123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39124. */
  39125. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39126. /**
  39127. * Play the sound
  39128. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39129. * @param offset (optional) Start the sound at a specific time in seconds
  39130. * @param length (optional) Sound duration (in seconds)
  39131. */
  39132. play(time?: number, offset?: number, length?: number): void;
  39133. private _onended;
  39134. /**
  39135. * Stop the sound
  39136. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39137. */
  39138. stop(time?: number): void;
  39139. /**
  39140. * Put the sound in pause
  39141. */
  39142. pause(): void;
  39143. /**
  39144. * Sets a dedicated volume for this sounds
  39145. * @param newVolume Define the new volume of the sound
  39146. * @param time Define time for gradual change to new volume
  39147. */
  39148. setVolume(newVolume: number, time?: number): void;
  39149. /**
  39150. * Set the sound play back rate
  39151. * @param newPlaybackRate Define the playback rate the sound should be played at
  39152. */
  39153. setPlaybackRate(newPlaybackRate: number): void;
  39154. /**
  39155. * Gets the volume of the sound.
  39156. * @returns the volume of the sound
  39157. */
  39158. getVolume(): number;
  39159. /**
  39160. * Attach the sound to a dedicated mesh
  39161. * @param transformNode The transform node to connect the sound with
  39162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39163. */
  39164. attachToMesh(transformNode: TransformNode): void;
  39165. /**
  39166. * Detach the sound from the previously attached mesh
  39167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39168. */
  39169. detachFromMesh(): void;
  39170. private _onRegisterAfterWorldMatrixUpdate;
  39171. /**
  39172. * Clone the current sound in the scene.
  39173. * @returns the new sound clone
  39174. */
  39175. clone(): Nullable<Sound>;
  39176. /**
  39177. * Gets the current underlying audio buffer containing the data
  39178. * @returns the audio buffer
  39179. */
  39180. getAudioBuffer(): Nullable<AudioBuffer>;
  39181. /**
  39182. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39183. * @returns the source node
  39184. */
  39185. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39186. /**
  39187. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39188. * @returns the gain node
  39189. */
  39190. getSoundGain(): Nullable<GainNode>;
  39191. /**
  39192. * Serializes the Sound in a JSON representation
  39193. * @returns the JSON representation of the sound
  39194. */
  39195. serialize(): any;
  39196. /**
  39197. * Parse a JSON representation of a sound to innstantiate in a given scene
  39198. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39199. * @param scene Define the scene the new parsed sound should be created in
  39200. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39201. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39202. * @returns the newly parsed sound
  39203. */
  39204. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39205. }
  39206. }
  39207. declare module "babylonjs/Actions/directAudioActions" {
  39208. import { Action } from "babylonjs/Actions/action";
  39209. import { Condition } from "babylonjs/Actions/condition";
  39210. import { Sound } from "babylonjs/Audio/sound";
  39211. /**
  39212. * This defines an action helpful to play a defined sound on a triggered action.
  39213. */
  39214. export class PlaySoundAction extends Action {
  39215. private _sound;
  39216. /**
  39217. * Instantiate the action
  39218. * @param triggerOptions defines the trigger options
  39219. * @param sound defines the sound to play
  39220. * @param condition defines the trigger related conditions
  39221. */
  39222. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39223. /** @hidden */
  39224. _prepare(): void;
  39225. /**
  39226. * Execute the action and play the sound.
  39227. */
  39228. execute(): void;
  39229. /**
  39230. * Serializes the actions and its related information.
  39231. * @param parent defines the object to serialize in
  39232. * @returns the serialized object
  39233. */
  39234. serialize(parent: any): any;
  39235. }
  39236. /**
  39237. * This defines an action helpful to stop a defined sound on a triggered action.
  39238. */
  39239. export class StopSoundAction extends Action {
  39240. private _sound;
  39241. /**
  39242. * Instantiate the action
  39243. * @param triggerOptions defines the trigger options
  39244. * @param sound defines the sound to stop
  39245. * @param condition defines the trigger related conditions
  39246. */
  39247. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39248. /** @hidden */
  39249. _prepare(): void;
  39250. /**
  39251. * Execute the action and stop the sound.
  39252. */
  39253. execute(): void;
  39254. /**
  39255. * Serializes the actions and its related information.
  39256. * @param parent defines the object to serialize in
  39257. * @returns the serialized object
  39258. */
  39259. serialize(parent: any): any;
  39260. }
  39261. }
  39262. declare module "babylonjs/Actions/interpolateValueAction" {
  39263. import { Action } from "babylonjs/Actions/action";
  39264. import { Condition } from "babylonjs/Actions/condition";
  39265. import { Observable } from "babylonjs/Misc/observable";
  39266. /**
  39267. * This defines an action responsible to change the value of a property
  39268. * by interpolating between its current value and the newly set one once triggered.
  39269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39270. */
  39271. export class InterpolateValueAction extends Action {
  39272. /**
  39273. * Defines the path of the property where the value should be interpolated
  39274. */
  39275. propertyPath: string;
  39276. /**
  39277. * Defines the target value at the end of the interpolation.
  39278. */
  39279. value: any;
  39280. /**
  39281. * Defines the time it will take for the property to interpolate to the value.
  39282. */
  39283. duration: number;
  39284. /**
  39285. * Defines if the other scene animations should be stopped when the action has been triggered
  39286. */
  39287. stopOtherAnimations?: boolean;
  39288. /**
  39289. * Defines a callback raised once the interpolation animation has been done.
  39290. */
  39291. onInterpolationDone?: () => void;
  39292. /**
  39293. * Observable triggered once the interpolation animation has been done.
  39294. */
  39295. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39296. private _target;
  39297. private _effectiveTarget;
  39298. private _property;
  39299. /**
  39300. * Instantiate the action
  39301. * @param triggerOptions defines the trigger options
  39302. * @param target defines the object containing the value to interpolate
  39303. * @param propertyPath defines the path to the property in the target object
  39304. * @param value defines the target value at the end of the interpolation
  39305. * @param duration deines the time it will take for the property to interpolate to the value.
  39306. * @param condition defines the trigger related conditions
  39307. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39308. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39309. */
  39310. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39311. /** @hidden */
  39312. _prepare(): void;
  39313. /**
  39314. * Execute the action starts the value interpolation.
  39315. */
  39316. execute(): void;
  39317. /**
  39318. * Serializes the actions and its related information.
  39319. * @param parent defines the object to serialize in
  39320. * @returns the serialized object
  39321. */
  39322. serialize(parent: any): any;
  39323. }
  39324. }
  39325. declare module "babylonjs/Actions/index" {
  39326. export * from "babylonjs/Actions/abstractActionManager";
  39327. export * from "babylonjs/Actions/action";
  39328. export * from "babylonjs/Actions/actionEvent";
  39329. export * from "babylonjs/Actions/actionManager";
  39330. export * from "babylonjs/Actions/condition";
  39331. export * from "babylonjs/Actions/directActions";
  39332. export * from "babylonjs/Actions/directAudioActions";
  39333. export * from "babylonjs/Actions/interpolateValueAction";
  39334. }
  39335. declare module "babylonjs/Animations/index" {
  39336. export * from "babylonjs/Animations/animatable";
  39337. export * from "babylonjs/Animations/animation";
  39338. export * from "babylonjs/Animations/animationGroup";
  39339. export * from "babylonjs/Animations/animationPropertiesOverride";
  39340. export * from "babylonjs/Animations/easing";
  39341. export * from "babylonjs/Animations/runtimeAnimation";
  39342. export * from "babylonjs/Animations/animationEvent";
  39343. export * from "babylonjs/Animations/animationGroup";
  39344. export * from "babylonjs/Animations/animationKey";
  39345. export * from "babylonjs/Animations/animationRange";
  39346. export * from "babylonjs/Animations/animatable.interface";
  39347. }
  39348. declare module "babylonjs/Audio/soundTrack" {
  39349. import { Sound } from "babylonjs/Audio/sound";
  39350. import { Analyser } from "babylonjs/Audio/analyser";
  39351. import { Scene } from "babylonjs/scene";
  39352. /**
  39353. * Options allowed during the creation of a sound track.
  39354. */
  39355. export interface ISoundTrackOptions {
  39356. /**
  39357. * The volume the sound track should take during creation
  39358. */
  39359. volume?: number;
  39360. /**
  39361. * Define if the sound track is the main sound track of the scene
  39362. */
  39363. mainTrack?: boolean;
  39364. }
  39365. /**
  39366. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39367. * It will be also used in a future release to apply effects on a specific track.
  39368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39369. */
  39370. export class SoundTrack {
  39371. /**
  39372. * The unique identifier of the sound track in the scene.
  39373. */
  39374. id: number;
  39375. /**
  39376. * The list of sounds included in the sound track.
  39377. */
  39378. soundCollection: Array<Sound>;
  39379. private _outputAudioNode;
  39380. private _scene;
  39381. private _connectedAnalyser;
  39382. private _options;
  39383. private _isInitialized;
  39384. /**
  39385. * Creates a new sound track.
  39386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39387. * @param scene Define the scene the sound track belongs to
  39388. * @param options
  39389. */
  39390. constructor(scene: Scene, options?: ISoundTrackOptions);
  39391. private _initializeSoundTrackAudioGraph;
  39392. /**
  39393. * Release the sound track and its associated resources
  39394. */
  39395. dispose(): void;
  39396. /**
  39397. * Adds a sound to this sound track
  39398. * @param sound define the cound to add
  39399. * @ignoreNaming
  39400. */
  39401. AddSound(sound: Sound): void;
  39402. /**
  39403. * Removes a sound to this sound track
  39404. * @param sound define the cound to remove
  39405. * @ignoreNaming
  39406. */
  39407. RemoveSound(sound: Sound): void;
  39408. /**
  39409. * Set a global volume for the full sound track.
  39410. * @param newVolume Define the new volume of the sound track
  39411. */
  39412. setVolume(newVolume: number): void;
  39413. /**
  39414. * Switch the panning model to HRTF:
  39415. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39417. */
  39418. switchPanningModelToHRTF(): void;
  39419. /**
  39420. * Switch the panning model to Equal Power:
  39421. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39423. */
  39424. switchPanningModelToEqualPower(): void;
  39425. /**
  39426. * Connect the sound track to an audio analyser allowing some amazing
  39427. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39429. * @param analyser The analyser to connect to the engine
  39430. */
  39431. connectToAnalyser(analyser: Analyser): void;
  39432. }
  39433. }
  39434. declare module "babylonjs/Audio/audioSceneComponent" {
  39435. import { Sound } from "babylonjs/Audio/sound";
  39436. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39437. import { Nullable } from "babylonjs/types";
  39438. import { Vector3 } from "babylonjs/Maths/math.vector";
  39439. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39440. import { Scene } from "babylonjs/scene";
  39441. import { AbstractScene } from "babylonjs/abstractScene";
  39442. import "babylonjs/Audio/audioEngine";
  39443. module "babylonjs/abstractScene" {
  39444. interface AbstractScene {
  39445. /**
  39446. * The list of sounds used in the scene.
  39447. */
  39448. sounds: Nullable<Array<Sound>>;
  39449. }
  39450. }
  39451. module "babylonjs/scene" {
  39452. interface Scene {
  39453. /**
  39454. * @hidden
  39455. * Backing field
  39456. */
  39457. _mainSoundTrack: SoundTrack;
  39458. /**
  39459. * The main sound track played by the scene.
  39460. * It cotains your primary collection of sounds.
  39461. */
  39462. mainSoundTrack: SoundTrack;
  39463. /**
  39464. * The list of sound tracks added to the scene
  39465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39466. */
  39467. soundTracks: Nullable<Array<SoundTrack>>;
  39468. /**
  39469. * Gets a sound using a given name
  39470. * @param name defines the name to search for
  39471. * @return the found sound or null if not found at all.
  39472. */
  39473. getSoundByName(name: string): Nullable<Sound>;
  39474. /**
  39475. * Gets or sets if audio support is enabled
  39476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39477. */
  39478. audioEnabled: boolean;
  39479. /**
  39480. * Gets or sets if audio will be output to headphones
  39481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39482. */
  39483. headphone: boolean;
  39484. /**
  39485. * Gets or sets custom audio listener position provider
  39486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39487. */
  39488. audioListenerPositionProvider: Nullable<() => Vector3>;
  39489. /**
  39490. * Gets or sets a refresh rate when using 3D audio positioning
  39491. */
  39492. audioPositioningRefreshRate: number;
  39493. }
  39494. }
  39495. /**
  39496. * Defines the sound scene component responsible to manage any sounds
  39497. * in a given scene.
  39498. */
  39499. export class AudioSceneComponent implements ISceneSerializableComponent {
  39500. /**
  39501. * The component name helpfull to identify the component in the list of scene components.
  39502. */
  39503. readonly name: string;
  39504. /**
  39505. * The scene the component belongs to.
  39506. */
  39507. scene: Scene;
  39508. private _audioEnabled;
  39509. /**
  39510. * Gets whether audio is enabled or not.
  39511. * Please use related enable/disable method to switch state.
  39512. */
  39513. get audioEnabled(): boolean;
  39514. private _headphone;
  39515. /**
  39516. * Gets whether audio is outputing to headphone or not.
  39517. * Please use the according Switch methods to change output.
  39518. */
  39519. get headphone(): boolean;
  39520. /**
  39521. * Gets or sets a refresh rate when using 3D audio positioning
  39522. */
  39523. audioPositioningRefreshRate: number;
  39524. private _audioListenerPositionProvider;
  39525. /**
  39526. * Gets the current audio listener position provider
  39527. */
  39528. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39529. /**
  39530. * Sets a custom listener position for all sounds in the scene
  39531. * By default, this is the position of the first active camera
  39532. */
  39533. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39534. /**
  39535. * Creates a new instance of the component for the given scene
  39536. * @param scene Defines the scene to register the component in
  39537. */
  39538. constructor(scene: Scene);
  39539. /**
  39540. * Registers the component in a given scene
  39541. */
  39542. register(): void;
  39543. /**
  39544. * Rebuilds the elements related to this component in case of
  39545. * context lost for instance.
  39546. */
  39547. rebuild(): void;
  39548. /**
  39549. * Serializes the component data to the specified json object
  39550. * @param serializationObject The object to serialize to
  39551. */
  39552. serialize(serializationObject: any): void;
  39553. /**
  39554. * Adds all the elements from the container to the scene
  39555. * @param container the container holding the elements
  39556. */
  39557. addFromContainer(container: AbstractScene): void;
  39558. /**
  39559. * Removes all the elements in the container from the scene
  39560. * @param container contains the elements to remove
  39561. * @param dispose if the removed element should be disposed (default: false)
  39562. */
  39563. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39564. /**
  39565. * Disposes the component and the associated ressources.
  39566. */
  39567. dispose(): void;
  39568. /**
  39569. * Disables audio in the associated scene.
  39570. */
  39571. disableAudio(): void;
  39572. /**
  39573. * Enables audio in the associated scene.
  39574. */
  39575. enableAudio(): void;
  39576. /**
  39577. * Switch audio to headphone output.
  39578. */
  39579. switchAudioModeForHeadphones(): void;
  39580. /**
  39581. * Switch audio to normal speakers.
  39582. */
  39583. switchAudioModeForNormalSpeakers(): void;
  39584. private _cachedCameraDirection;
  39585. private _cachedCameraPosition;
  39586. private _lastCheck;
  39587. private _afterRender;
  39588. }
  39589. }
  39590. declare module "babylonjs/Audio/weightedsound" {
  39591. import { Sound } from "babylonjs/Audio/sound";
  39592. /**
  39593. * Wraps one or more Sound objects and selects one with random weight for playback.
  39594. */
  39595. export class WeightedSound {
  39596. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39597. loop: boolean;
  39598. private _coneInnerAngle;
  39599. private _coneOuterAngle;
  39600. private _volume;
  39601. /** A Sound is currently playing. */
  39602. isPlaying: boolean;
  39603. /** A Sound is currently paused. */
  39604. isPaused: boolean;
  39605. private _sounds;
  39606. private _weights;
  39607. private _currentIndex?;
  39608. /**
  39609. * Creates a new WeightedSound from the list of sounds given.
  39610. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39611. * @param sounds Array of Sounds that will be selected from.
  39612. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39613. */
  39614. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39615. /**
  39616. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39617. */
  39618. get directionalConeInnerAngle(): number;
  39619. /**
  39620. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39621. */
  39622. set directionalConeInnerAngle(value: number);
  39623. /**
  39624. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39625. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39626. */
  39627. get directionalConeOuterAngle(): number;
  39628. /**
  39629. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39630. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39631. */
  39632. set directionalConeOuterAngle(value: number);
  39633. /**
  39634. * Playback volume.
  39635. */
  39636. get volume(): number;
  39637. /**
  39638. * Playback volume.
  39639. */
  39640. set volume(value: number);
  39641. private _onended;
  39642. /**
  39643. * Suspend playback
  39644. */
  39645. pause(): void;
  39646. /**
  39647. * Stop playback
  39648. */
  39649. stop(): void;
  39650. /**
  39651. * Start playback.
  39652. * @param startOffset Position the clip head at a specific time in seconds.
  39653. */
  39654. play(startOffset?: number): void;
  39655. }
  39656. }
  39657. declare module "babylonjs/Audio/index" {
  39658. export * from "babylonjs/Audio/analyser";
  39659. export * from "babylonjs/Audio/audioEngine";
  39660. export * from "babylonjs/Audio/audioSceneComponent";
  39661. export * from "babylonjs/Audio/sound";
  39662. export * from "babylonjs/Audio/soundTrack";
  39663. export * from "babylonjs/Audio/weightedsound";
  39664. }
  39665. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39666. import { Behavior } from "babylonjs/Behaviors/behavior";
  39667. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39668. import { BackEase } from "babylonjs/Animations/easing";
  39669. /**
  39670. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39672. */
  39673. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39674. /**
  39675. * Gets the name of the behavior.
  39676. */
  39677. get name(): string;
  39678. /**
  39679. * The easing function used by animations
  39680. */
  39681. static EasingFunction: BackEase;
  39682. /**
  39683. * The easing mode used by animations
  39684. */
  39685. static EasingMode: number;
  39686. /**
  39687. * The duration of the animation, in milliseconds
  39688. */
  39689. transitionDuration: number;
  39690. /**
  39691. * Length of the distance animated by the transition when lower radius is reached
  39692. */
  39693. lowerRadiusTransitionRange: number;
  39694. /**
  39695. * Length of the distance animated by the transition when upper radius is reached
  39696. */
  39697. upperRadiusTransitionRange: number;
  39698. private _autoTransitionRange;
  39699. /**
  39700. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39701. */
  39702. get autoTransitionRange(): boolean;
  39703. /**
  39704. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39705. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39706. */
  39707. set autoTransitionRange(value: boolean);
  39708. private _attachedCamera;
  39709. private _onAfterCheckInputsObserver;
  39710. private _onMeshTargetChangedObserver;
  39711. /**
  39712. * Initializes the behavior.
  39713. */
  39714. init(): void;
  39715. /**
  39716. * Attaches the behavior to its arc rotate camera.
  39717. * @param camera Defines the camera to attach the behavior to
  39718. */
  39719. attach(camera: ArcRotateCamera): void;
  39720. /**
  39721. * Detaches the behavior from its current arc rotate camera.
  39722. */
  39723. detach(): void;
  39724. private _radiusIsAnimating;
  39725. private _radiusBounceTransition;
  39726. private _animatables;
  39727. private _cachedWheelPrecision;
  39728. /**
  39729. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39730. * @param radiusLimit The limit to check against.
  39731. * @return Bool to indicate if at limit.
  39732. */
  39733. private _isRadiusAtLimit;
  39734. /**
  39735. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39736. * @param radiusDelta The delta by which to animate to. Can be negative.
  39737. */
  39738. private _applyBoundRadiusAnimation;
  39739. /**
  39740. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39741. */
  39742. protected _clearAnimationLocks(): void;
  39743. /**
  39744. * Stops and removes all animations that have been applied to the camera
  39745. */
  39746. stopAllAnimations(): void;
  39747. }
  39748. }
  39749. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39750. import { Behavior } from "babylonjs/Behaviors/behavior";
  39751. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39752. import { ExponentialEase } from "babylonjs/Animations/easing";
  39753. import { Nullable } from "babylonjs/types";
  39754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39755. import { Vector3 } from "babylonjs/Maths/math.vector";
  39756. /**
  39757. * 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.
  39758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39759. */
  39760. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39761. /**
  39762. * Gets the name of the behavior.
  39763. */
  39764. get name(): string;
  39765. private _mode;
  39766. private _radiusScale;
  39767. private _positionScale;
  39768. private _defaultElevation;
  39769. private _elevationReturnTime;
  39770. private _elevationReturnWaitTime;
  39771. private _zoomStopsAnimation;
  39772. private _framingTime;
  39773. /**
  39774. * The easing function used by animations
  39775. */
  39776. static EasingFunction: ExponentialEase;
  39777. /**
  39778. * The easing mode used by animations
  39779. */
  39780. static EasingMode: number;
  39781. /**
  39782. * Sets the current mode used by the behavior
  39783. */
  39784. set mode(mode: number);
  39785. /**
  39786. * Gets current mode used by the behavior.
  39787. */
  39788. get mode(): number;
  39789. /**
  39790. * Sets the scale applied to the radius (1 by default)
  39791. */
  39792. set radiusScale(radius: number);
  39793. /**
  39794. * Gets the scale applied to the radius
  39795. */
  39796. get radiusScale(): number;
  39797. /**
  39798. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39799. */
  39800. set positionScale(scale: number);
  39801. /**
  39802. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39803. */
  39804. get positionScale(): number;
  39805. /**
  39806. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39807. * behaviour is triggered, in radians.
  39808. */
  39809. set defaultElevation(elevation: number);
  39810. /**
  39811. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39812. * behaviour is triggered, in radians.
  39813. */
  39814. get defaultElevation(): number;
  39815. /**
  39816. * Sets the time (in milliseconds) taken to return to the default beta position.
  39817. * Negative value indicates camera should not return to default.
  39818. */
  39819. set elevationReturnTime(speed: number);
  39820. /**
  39821. * Gets the time (in milliseconds) taken to return to the default beta position.
  39822. * Negative value indicates camera should not return to default.
  39823. */
  39824. get elevationReturnTime(): number;
  39825. /**
  39826. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39827. */
  39828. set elevationReturnWaitTime(time: number);
  39829. /**
  39830. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39831. */
  39832. get elevationReturnWaitTime(): number;
  39833. /**
  39834. * Sets the flag that indicates if user zooming should stop animation.
  39835. */
  39836. set zoomStopsAnimation(flag: boolean);
  39837. /**
  39838. * Gets the flag that indicates if user zooming should stop animation.
  39839. */
  39840. get zoomStopsAnimation(): boolean;
  39841. /**
  39842. * Sets the transition time when framing the mesh, in milliseconds
  39843. */
  39844. set framingTime(time: number);
  39845. /**
  39846. * Gets the transition time when framing the mesh, in milliseconds
  39847. */
  39848. get framingTime(): number;
  39849. /**
  39850. * Define if the behavior should automatically change the configured
  39851. * camera limits and sensibilities.
  39852. */
  39853. autoCorrectCameraLimitsAndSensibility: boolean;
  39854. private _onPrePointerObservableObserver;
  39855. private _onAfterCheckInputsObserver;
  39856. private _onMeshTargetChangedObserver;
  39857. private _attachedCamera;
  39858. private _isPointerDown;
  39859. private _lastInteractionTime;
  39860. /**
  39861. * Initializes the behavior.
  39862. */
  39863. init(): void;
  39864. /**
  39865. * Attaches the behavior to its arc rotate camera.
  39866. * @param camera Defines the camera to attach the behavior to
  39867. */
  39868. attach(camera: ArcRotateCamera): void;
  39869. /**
  39870. * Detaches the behavior from its current arc rotate camera.
  39871. */
  39872. detach(): void;
  39873. private _animatables;
  39874. private _betaIsAnimating;
  39875. private _betaTransition;
  39876. private _radiusTransition;
  39877. private _vectorTransition;
  39878. /**
  39879. * Targets the given mesh and updates zoom level accordingly.
  39880. * @param mesh The mesh to target.
  39881. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39882. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39883. */
  39884. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39885. /**
  39886. * Targets the given mesh with its children and updates zoom level accordingly.
  39887. * @param mesh The mesh to target.
  39888. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39889. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39890. */
  39891. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39892. /**
  39893. * Targets the given meshes with their children and updates zoom level accordingly.
  39894. * @param meshes The mesh to target.
  39895. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39896. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39897. */
  39898. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39899. /**
  39900. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39901. * @param minimumWorld Determines the smaller position of the bounding box extend
  39902. * @param maximumWorld Determines the bigger position of the bounding box extend
  39903. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39904. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39905. */
  39906. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39907. /**
  39908. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39909. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39910. * frustum width.
  39911. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39912. * to fully enclose the mesh in the viewing frustum.
  39913. */
  39914. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39915. /**
  39916. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39917. * is automatically returned to its default position (expected to be above ground plane).
  39918. */
  39919. private _maintainCameraAboveGround;
  39920. /**
  39921. * Returns the frustum slope based on the canvas ratio and camera FOV
  39922. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39923. */
  39924. private _getFrustumSlope;
  39925. /**
  39926. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39927. */
  39928. private _clearAnimationLocks;
  39929. /**
  39930. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39931. */
  39932. private _applyUserInteraction;
  39933. /**
  39934. * Stops and removes all animations that have been applied to the camera
  39935. */
  39936. stopAllAnimations(): void;
  39937. /**
  39938. * Gets a value indicating if the user is moving the camera
  39939. */
  39940. get isUserIsMoving(): boolean;
  39941. /**
  39942. * The camera can move all the way towards the mesh.
  39943. */
  39944. static IgnoreBoundsSizeMode: number;
  39945. /**
  39946. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39947. */
  39948. static FitFrustumSidesMode: number;
  39949. }
  39950. }
  39951. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39952. import { Nullable } from "babylonjs/types";
  39953. import { Camera } from "babylonjs/Cameras/camera";
  39954. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39955. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39956. /**
  39957. * Base class for Camera Pointer Inputs.
  39958. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39959. * for example usage.
  39960. */
  39961. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39962. /**
  39963. * Defines the camera the input is attached to.
  39964. */
  39965. abstract camera: Camera;
  39966. /**
  39967. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39968. */
  39969. protected _altKey: boolean;
  39970. protected _ctrlKey: boolean;
  39971. protected _metaKey: boolean;
  39972. protected _shiftKey: boolean;
  39973. /**
  39974. * Which mouse buttons were pressed at time of last mouse event.
  39975. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39976. */
  39977. protected _buttonsPressed: number;
  39978. /**
  39979. * Defines the buttons associated with the input to handle camera move.
  39980. */
  39981. buttons: number[];
  39982. /**
  39983. * Attach the input controls to a specific dom element to get the input from.
  39984. * @param element Defines the element the controls should be listened from
  39985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39986. */
  39987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39988. /**
  39989. * Detach the current controls from the specified dom element.
  39990. * @param element Defines the element to stop listening the inputs from
  39991. */
  39992. detachControl(element: Nullable<HTMLElement>): void;
  39993. /**
  39994. * Gets the class name of the current input.
  39995. * @returns the class name
  39996. */
  39997. getClassName(): string;
  39998. /**
  39999. * Get the friendly name associated with the input class.
  40000. * @returns the input friendly name
  40001. */
  40002. getSimpleName(): string;
  40003. /**
  40004. * Called on pointer POINTERDOUBLETAP event.
  40005. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40006. */
  40007. protected onDoubleTap(type: string): void;
  40008. /**
  40009. * Called on pointer POINTERMOVE event if only a single touch is active.
  40010. * Override this method to provide functionality.
  40011. */
  40012. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40013. /**
  40014. * Called on pointer POINTERMOVE event if multiple touches are active.
  40015. * Override this method to provide functionality.
  40016. */
  40017. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40018. /**
  40019. * Called on JS contextmenu event.
  40020. * Override this method to provide functionality.
  40021. */
  40022. protected onContextMenu(evt: PointerEvent): void;
  40023. /**
  40024. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40025. * press.
  40026. * Override this method to provide functionality.
  40027. */
  40028. protected onButtonDown(evt: PointerEvent): void;
  40029. /**
  40030. * Called each time a new POINTERUP event occurs. Ie, for each button
  40031. * release.
  40032. * Override this method to provide functionality.
  40033. */
  40034. protected onButtonUp(evt: PointerEvent): void;
  40035. /**
  40036. * Called when window becomes inactive.
  40037. * Override this method to provide functionality.
  40038. */
  40039. protected onLostFocus(): void;
  40040. private _pointerInput;
  40041. private _observer;
  40042. private _onLostFocus;
  40043. private pointA;
  40044. private pointB;
  40045. }
  40046. }
  40047. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40048. import { Nullable } from "babylonjs/types";
  40049. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40050. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40051. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40052. /**
  40053. * Manage the pointers inputs to control an arc rotate camera.
  40054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40055. */
  40056. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40057. /**
  40058. * Defines the camera the input is attached to.
  40059. */
  40060. camera: ArcRotateCamera;
  40061. /**
  40062. * Gets the class name of the current input.
  40063. * @returns the class name
  40064. */
  40065. getClassName(): string;
  40066. /**
  40067. * Defines the buttons associated with the input to handle camera move.
  40068. */
  40069. buttons: number[];
  40070. /**
  40071. * Defines the pointer angular sensibility along the X axis or how fast is
  40072. * the camera rotating.
  40073. */
  40074. angularSensibilityX: number;
  40075. /**
  40076. * Defines the pointer angular sensibility along the Y axis or how fast is
  40077. * the camera rotating.
  40078. */
  40079. angularSensibilityY: number;
  40080. /**
  40081. * Defines the pointer pinch precision or how fast is the camera zooming.
  40082. */
  40083. pinchPrecision: number;
  40084. /**
  40085. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40086. * from 0.
  40087. * It defines the percentage of current camera.radius to use as delta when
  40088. * pinch zoom is used.
  40089. */
  40090. pinchDeltaPercentage: number;
  40091. /**
  40092. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40093. * that any object in the plane at the camera's target point will scale
  40094. * perfectly with finger motion.
  40095. * Overrides pinchDeltaPercentage and pinchPrecision.
  40096. */
  40097. useNaturalPinchZoom: boolean;
  40098. /**
  40099. * Defines the pointer panning sensibility or how fast is the camera moving.
  40100. */
  40101. panningSensibility: number;
  40102. /**
  40103. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40104. */
  40105. multiTouchPanning: boolean;
  40106. /**
  40107. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40108. * zoom (pinch) through multitouch.
  40109. */
  40110. multiTouchPanAndZoom: boolean;
  40111. /**
  40112. * Revers pinch action direction.
  40113. */
  40114. pinchInwards: boolean;
  40115. private _isPanClick;
  40116. private _twoFingerActivityCount;
  40117. private _isPinching;
  40118. /**
  40119. * Called on pointer POINTERMOVE event if only a single touch is active.
  40120. */
  40121. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40122. /**
  40123. * Called on pointer POINTERDOUBLETAP event.
  40124. */
  40125. protected onDoubleTap(type: string): void;
  40126. /**
  40127. * Called on pointer POINTERMOVE event if multiple touches are active.
  40128. */
  40129. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40130. /**
  40131. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40132. * press.
  40133. */
  40134. protected onButtonDown(evt: PointerEvent): void;
  40135. /**
  40136. * Called each time a new POINTERUP event occurs. Ie, for each button
  40137. * release.
  40138. */
  40139. protected onButtonUp(evt: PointerEvent): void;
  40140. /**
  40141. * Called when window becomes inactive.
  40142. */
  40143. protected onLostFocus(): void;
  40144. }
  40145. }
  40146. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40147. import { Nullable } from "babylonjs/types";
  40148. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40149. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40150. /**
  40151. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40153. */
  40154. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40155. /**
  40156. * Defines the camera the input is attached to.
  40157. */
  40158. camera: ArcRotateCamera;
  40159. /**
  40160. * Defines the list of key codes associated with the up action (increase alpha)
  40161. */
  40162. keysUp: number[];
  40163. /**
  40164. * Defines the list of key codes associated with the down action (decrease alpha)
  40165. */
  40166. keysDown: number[];
  40167. /**
  40168. * Defines the list of key codes associated with the left action (increase beta)
  40169. */
  40170. keysLeft: number[];
  40171. /**
  40172. * Defines the list of key codes associated with the right action (decrease beta)
  40173. */
  40174. keysRight: number[];
  40175. /**
  40176. * Defines the list of key codes associated with the reset action.
  40177. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40178. */
  40179. keysReset: number[];
  40180. /**
  40181. * Defines the panning sensibility of the inputs.
  40182. * (How fast is the camera panning)
  40183. */
  40184. panningSensibility: number;
  40185. /**
  40186. * Defines the zooming sensibility of the inputs.
  40187. * (How fast is the camera zooming)
  40188. */
  40189. zoomingSensibility: number;
  40190. /**
  40191. * Defines whether maintaining the alt key down switch the movement mode from
  40192. * orientation to zoom.
  40193. */
  40194. useAltToZoom: boolean;
  40195. /**
  40196. * Rotation speed of the camera
  40197. */
  40198. angularSpeed: number;
  40199. private _keys;
  40200. private _ctrlPressed;
  40201. private _altPressed;
  40202. private _onCanvasBlurObserver;
  40203. private _onKeyboardObserver;
  40204. private _engine;
  40205. private _scene;
  40206. /**
  40207. * Attach the input controls to a specific dom element to get the input from.
  40208. * @param element Defines the element the controls should be listened from
  40209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40210. */
  40211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40212. /**
  40213. * Detach the current controls from the specified dom element.
  40214. * @param element Defines the element to stop listening the inputs from
  40215. */
  40216. detachControl(element: Nullable<HTMLElement>): void;
  40217. /**
  40218. * Update the current camera state depending on the inputs that have been used this frame.
  40219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40220. */
  40221. checkInputs(): void;
  40222. /**
  40223. * Gets the class name of the current intput.
  40224. * @returns the class name
  40225. */
  40226. getClassName(): string;
  40227. /**
  40228. * Get the friendly name associated with the input class.
  40229. * @returns the input friendly name
  40230. */
  40231. getSimpleName(): string;
  40232. }
  40233. }
  40234. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40235. import { Nullable } from "babylonjs/types";
  40236. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40238. /**
  40239. * Manage the mouse wheel inputs to control an arc rotate camera.
  40240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40241. */
  40242. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40243. /**
  40244. * Defines the camera the input is attached to.
  40245. */
  40246. camera: ArcRotateCamera;
  40247. /**
  40248. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40249. */
  40250. wheelPrecision: number;
  40251. /**
  40252. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40253. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40254. */
  40255. wheelDeltaPercentage: number;
  40256. private _wheel;
  40257. private _observer;
  40258. private computeDeltaFromMouseWheelLegacyEvent;
  40259. /**
  40260. * Attach the input controls to a specific dom element to get the input from.
  40261. * @param element Defines the element the controls should be listened from
  40262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40263. */
  40264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40265. /**
  40266. * Detach the current controls from the specified dom element.
  40267. * @param element Defines the element to stop listening the inputs from
  40268. */
  40269. detachControl(element: Nullable<HTMLElement>): void;
  40270. /**
  40271. * Gets the class name of the current intput.
  40272. * @returns the class name
  40273. */
  40274. getClassName(): string;
  40275. /**
  40276. * Get the friendly name associated with the input class.
  40277. * @returns the input friendly name
  40278. */
  40279. getSimpleName(): string;
  40280. }
  40281. }
  40282. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40283. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40284. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40285. /**
  40286. * Default Inputs manager for the ArcRotateCamera.
  40287. * It groups all the default supported inputs for ease of use.
  40288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40289. */
  40290. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40291. /**
  40292. * Instantiates a new ArcRotateCameraInputsManager.
  40293. * @param camera Defines the camera the inputs belong to
  40294. */
  40295. constructor(camera: ArcRotateCamera);
  40296. /**
  40297. * Add mouse wheel input support to the input manager.
  40298. * @returns the current input manager
  40299. */
  40300. addMouseWheel(): ArcRotateCameraInputsManager;
  40301. /**
  40302. * Add pointers input support to the input manager.
  40303. * @returns the current input manager
  40304. */
  40305. addPointers(): ArcRotateCameraInputsManager;
  40306. /**
  40307. * Add keyboard input support to the input manager.
  40308. * @returns the current input manager
  40309. */
  40310. addKeyboard(): ArcRotateCameraInputsManager;
  40311. }
  40312. }
  40313. declare module "babylonjs/Cameras/arcRotateCamera" {
  40314. import { Observable } from "babylonjs/Misc/observable";
  40315. import { Nullable } from "babylonjs/types";
  40316. import { Scene } from "babylonjs/scene";
  40317. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40319. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40320. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40321. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40322. import { Camera } from "babylonjs/Cameras/camera";
  40323. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40324. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40325. import { Collider } from "babylonjs/Collisions/collider";
  40326. /**
  40327. * This represents an orbital type of camera.
  40328. *
  40329. * 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.
  40330. * 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.
  40331. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40332. */
  40333. export class ArcRotateCamera extends TargetCamera {
  40334. /**
  40335. * Defines the rotation angle of the camera along the longitudinal axis.
  40336. */
  40337. alpha: number;
  40338. /**
  40339. * Defines the rotation angle of the camera along the latitudinal axis.
  40340. */
  40341. beta: number;
  40342. /**
  40343. * Defines the radius of the camera from it s target point.
  40344. */
  40345. radius: number;
  40346. protected _target: Vector3;
  40347. protected _targetHost: Nullable<AbstractMesh>;
  40348. /**
  40349. * Defines the target point of the camera.
  40350. * The camera looks towards it form the radius distance.
  40351. */
  40352. get target(): Vector3;
  40353. set target(value: Vector3);
  40354. /**
  40355. * Define the current local position of the camera in the scene
  40356. */
  40357. get position(): Vector3;
  40358. set position(newPosition: Vector3);
  40359. protected _upVector: Vector3;
  40360. protected _upToYMatrix: Matrix;
  40361. protected _YToUpMatrix: Matrix;
  40362. /**
  40363. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40364. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40365. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40366. */
  40367. set upVector(vec: Vector3);
  40368. get upVector(): Vector3;
  40369. /**
  40370. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40371. */
  40372. setMatUp(): void;
  40373. /**
  40374. * Current inertia value on the longitudinal axis.
  40375. * The bigger this number the longer it will take for the camera to stop.
  40376. */
  40377. inertialAlphaOffset: number;
  40378. /**
  40379. * Current inertia value on the latitudinal axis.
  40380. * The bigger this number the longer it will take for the camera to stop.
  40381. */
  40382. inertialBetaOffset: number;
  40383. /**
  40384. * Current inertia value on the radius axis.
  40385. * The bigger this number the longer it will take for the camera to stop.
  40386. */
  40387. inertialRadiusOffset: number;
  40388. /**
  40389. * Minimum allowed angle on the longitudinal axis.
  40390. * This can help limiting how the Camera is able to move in the scene.
  40391. */
  40392. lowerAlphaLimit: Nullable<number>;
  40393. /**
  40394. * Maximum allowed angle on the longitudinal axis.
  40395. * This can help limiting how the Camera is able to move in the scene.
  40396. */
  40397. upperAlphaLimit: Nullable<number>;
  40398. /**
  40399. * Minimum allowed angle on the latitudinal axis.
  40400. * This can help limiting how the Camera is able to move in the scene.
  40401. */
  40402. lowerBetaLimit: number;
  40403. /**
  40404. * Maximum allowed angle on the latitudinal axis.
  40405. * This can help limiting how the Camera is able to move in the scene.
  40406. */
  40407. upperBetaLimit: number;
  40408. /**
  40409. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40410. * This can help limiting how the Camera is able to move in the scene.
  40411. */
  40412. lowerRadiusLimit: Nullable<number>;
  40413. /**
  40414. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40415. * This can help limiting how the Camera is able to move in the scene.
  40416. */
  40417. upperRadiusLimit: Nullable<number>;
  40418. /**
  40419. * Defines the current inertia value used during panning of the camera along the X axis.
  40420. */
  40421. inertialPanningX: number;
  40422. /**
  40423. * Defines the current inertia value used during panning of the camera along the Y axis.
  40424. */
  40425. inertialPanningY: number;
  40426. /**
  40427. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40428. * Basically if your fingers moves away from more than this distance you will be considered
  40429. * in pinch mode.
  40430. */
  40431. pinchToPanMaxDistance: number;
  40432. /**
  40433. * Defines the maximum distance the camera can pan.
  40434. * This could help keeping the cammera always in your scene.
  40435. */
  40436. panningDistanceLimit: Nullable<number>;
  40437. /**
  40438. * Defines the target of the camera before paning.
  40439. */
  40440. panningOriginTarget: Vector3;
  40441. /**
  40442. * Defines the value of the inertia used during panning.
  40443. * 0 would mean stop inertia and one would mean no decelleration at all.
  40444. */
  40445. panningInertia: number;
  40446. /**
  40447. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40448. */
  40449. get angularSensibilityX(): number;
  40450. set angularSensibilityX(value: number);
  40451. /**
  40452. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40453. */
  40454. get angularSensibilityY(): number;
  40455. set angularSensibilityY(value: number);
  40456. /**
  40457. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40458. */
  40459. get pinchPrecision(): number;
  40460. set pinchPrecision(value: number);
  40461. /**
  40462. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40463. * It will be used instead of pinchDeltaPrecision if different from 0.
  40464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40465. */
  40466. get pinchDeltaPercentage(): number;
  40467. set pinchDeltaPercentage(value: number);
  40468. /**
  40469. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40470. * and pinch delta percentage.
  40471. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40472. * that any object in the plane at the camera's target point will scale
  40473. * perfectly with finger motion.
  40474. */
  40475. get useNaturalPinchZoom(): boolean;
  40476. set useNaturalPinchZoom(value: boolean);
  40477. /**
  40478. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40479. */
  40480. get panningSensibility(): number;
  40481. set panningSensibility(value: number);
  40482. /**
  40483. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40484. */
  40485. get keysUp(): number[];
  40486. set keysUp(value: number[]);
  40487. /**
  40488. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40489. */
  40490. get keysDown(): number[];
  40491. set keysDown(value: number[]);
  40492. /**
  40493. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40494. */
  40495. get keysLeft(): number[];
  40496. set keysLeft(value: number[]);
  40497. /**
  40498. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40499. */
  40500. get keysRight(): number[];
  40501. set keysRight(value: number[]);
  40502. /**
  40503. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40504. */
  40505. get wheelPrecision(): number;
  40506. set wheelPrecision(value: number);
  40507. /**
  40508. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40509. * It will be used instead of pinchDeltaPrecision if different from 0.
  40510. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40511. */
  40512. get wheelDeltaPercentage(): number;
  40513. set wheelDeltaPercentage(value: number);
  40514. /**
  40515. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40516. */
  40517. zoomOnFactor: number;
  40518. /**
  40519. * Defines a screen offset for the camera position.
  40520. */
  40521. targetScreenOffset: Vector2;
  40522. /**
  40523. * Allows the camera to be completely reversed.
  40524. * If false the camera can not arrive upside down.
  40525. */
  40526. allowUpsideDown: boolean;
  40527. /**
  40528. * Define if double tap/click is used to restore the previously saved state of the camera.
  40529. */
  40530. useInputToRestoreState: boolean;
  40531. /** @hidden */
  40532. _viewMatrix: Matrix;
  40533. /** @hidden */
  40534. _useCtrlForPanning: boolean;
  40535. /** @hidden */
  40536. _panningMouseButton: number;
  40537. /**
  40538. * Defines the input associated to the camera.
  40539. */
  40540. inputs: ArcRotateCameraInputsManager;
  40541. /** @hidden */
  40542. _reset: () => void;
  40543. /**
  40544. * Defines the allowed panning axis.
  40545. */
  40546. panningAxis: Vector3;
  40547. protected _localDirection: Vector3;
  40548. protected _transformedDirection: Vector3;
  40549. private _bouncingBehavior;
  40550. /**
  40551. * Gets the bouncing behavior of the camera if it has been enabled.
  40552. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40553. */
  40554. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40555. /**
  40556. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40557. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40558. */
  40559. get useBouncingBehavior(): boolean;
  40560. set useBouncingBehavior(value: boolean);
  40561. private _framingBehavior;
  40562. /**
  40563. * Gets the framing behavior of the camera if it has been enabled.
  40564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40565. */
  40566. get framingBehavior(): Nullable<FramingBehavior>;
  40567. /**
  40568. * Defines if the framing behavior of the camera is enabled on the camera.
  40569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40570. */
  40571. get useFramingBehavior(): boolean;
  40572. set useFramingBehavior(value: boolean);
  40573. private _autoRotationBehavior;
  40574. /**
  40575. * Gets the auto rotation behavior of the camera if it has been enabled.
  40576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40577. */
  40578. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40579. /**
  40580. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40581. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40582. */
  40583. get useAutoRotationBehavior(): boolean;
  40584. set useAutoRotationBehavior(value: boolean);
  40585. /**
  40586. * Observable triggered when the mesh target has been changed on the camera.
  40587. */
  40588. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40589. /**
  40590. * Event raised when the camera is colliding with a mesh.
  40591. */
  40592. onCollide: (collidedMesh: AbstractMesh) => void;
  40593. /**
  40594. * Defines whether the camera should check collision with the objects oh the scene.
  40595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40596. */
  40597. checkCollisions: boolean;
  40598. /**
  40599. * Defines the collision radius of the camera.
  40600. * This simulates a sphere around the camera.
  40601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40602. */
  40603. collisionRadius: Vector3;
  40604. protected _collider: Collider;
  40605. protected _previousPosition: Vector3;
  40606. protected _collisionVelocity: Vector3;
  40607. protected _newPosition: Vector3;
  40608. protected _previousAlpha: number;
  40609. protected _previousBeta: number;
  40610. protected _previousRadius: number;
  40611. protected _collisionTriggered: boolean;
  40612. protected _targetBoundingCenter: Nullable<Vector3>;
  40613. private _computationVector;
  40614. /**
  40615. * Instantiates a new ArcRotateCamera in a given scene
  40616. * @param name Defines the name of the camera
  40617. * @param alpha Defines the camera rotation along the logitudinal axis
  40618. * @param beta Defines the camera rotation along the latitudinal axis
  40619. * @param radius Defines the camera distance from its target
  40620. * @param target Defines the camera target
  40621. * @param scene Defines the scene the camera belongs to
  40622. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40623. */
  40624. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40625. /** @hidden */
  40626. _initCache(): void;
  40627. /** @hidden */
  40628. _updateCache(ignoreParentClass?: boolean): void;
  40629. protected _getTargetPosition(): Vector3;
  40630. private _storedAlpha;
  40631. private _storedBeta;
  40632. private _storedRadius;
  40633. private _storedTarget;
  40634. private _storedTargetScreenOffset;
  40635. /**
  40636. * Stores the current state of the camera (alpha, beta, radius and target)
  40637. * @returns the camera itself
  40638. */
  40639. storeState(): Camera;
  40640. /**
  40641. * @hidden
  40642. * Restored camera state. You must call storeState() first
  40643. */
  40644. _restoreStateValues(): boolean;
  40645. /** @hidden */
  40646. _isSynchronizedViewMatrix(): boolean;
  40647. /**
  40648. * Attached controls to the current camera.
  40649. * @param element Defines the element the controls should be listened from
  40650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40651. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40652. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40653. */
  40654. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40655. /**
  40656. * Detach the current controls from the camera.
  40657. * The camera will stop reacting to inputs.
  40658. * @param element Defines the element to stop listening the inputs from
  40659. */
  40660. detachControl(element: HTMLElement): void;
  40661. /** @hidden */
  40662. _checkInputs(): void;
  40663. protected _checkLimits(): void;
  40664. /**
  40665. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40666. */
  40667. rebuildAnglesAndRadius(): void;
  40668. /**
  40669. * Use a position to define the current camera related information like alpha, beta and radius
  40670. * @param position Defines the position to set the camera at
  40671. */
  40672. setPosition(position: Vector3): void;
  40673. /**
  40674. * Defines the target the camera should look at.
  40675. * This will automatically adapt alpha beta and radius to fit within the new target.
  40676. * @param target Defines the new target as a Vector or a mesh
  40677. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40678. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40679. */
  40680. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40681. /** @hidden */
  40682. _getViewMatrix(): Matrix;
  40683. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40684. /**
  40685. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40686. * @param meshes Defines the mesh to zoom on
  40687. * @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)
  40688. */
  40689. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40690. /**
  40691. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40692. * The target will be changed but the radius
  40693. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40694. * @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)
  40695. */
  40696. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40697. min: Vector3;
  40698. max: Vector3;
  40699. distance: number;
  40700. }, doNotUpdateMaxZ?: boolean): void;
  40701. /**
  40702. * @override
  40703. * Override Camera.createRigCamera
  40704. */
  40705. createRigCamera(name: string, cameraIndex: number): Camera;
  40706. /**
  40707. * @hidden
  40708. * @override
  40709. * Override Camera._updateRigCameras
  40710. */
  40711. _updateRigCameras(): void;
  40712. /**
  40713. * Destroy the camera and release the current resources hold by it.
  40714. */
  40715. dispose(): void;
  40716. /**
  40717. * Gets the current object class name.
  40718. * @return the class name
  40719. */
  40720. getClassName(): string;
  40721. }
  40722. }
  40723. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40724. import { Behavior } from "babylonjs/Behaviors/behavior";
  40725. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40726. /**
  40727. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40728. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40729. */
  40730. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40731. /**
  40732. * Gets the name of the behavior.
  40733. */
  40734. get name(): string;
  40735. private _zoomStopsAnimation;
  40736. private _idleRotationSpeed;
  40737. private _idleRotationWaitTime;
  40738. private _idleRotationSpinupTime;
  40739. /**
  40740. * Sets the flag that indicates if user zooming should stop animation.
  40741. */
  40742. set zoomStopsAnimation(flag: boolean);
  40743. /**
  40744. * Gets the flag that indicates if user zooming should stop animation.
  40745. */
  40746. get zoomStopsAnimation(): boolean;
  40747. /**
  40748. * Sets the default speed at which the camera rotates around the model.
  40749. */
  40750. set idleRotationSpeed(speed: number);
  40751. /**
  40752. * Gets the default speed at which the camera rotates around the model.
  40753. */
  40754. get idleRotationSpeed(): number;
  40755. /**
  40756. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40757. */
  40758. set idleRotationWaitTime(time: number);
  40759. /**
  40760. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40761. */
  40762. get idleRotationWaitTime(): number;
  40763. /**
  40764. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40765. */
  40766. set idleRotationSpinupTime(time: number);
  40767. /**
  40768. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40769. */
  40770. get idleRotationSpinupTime(): number;
  40771. /**
  40772. * Gets a value indicating if the camera is currently rotating because of this behavior
  40773. */
  40774. get rotationInProgress(): boolean;
  40775. private _onPrePointerObservableObserver;
  40776. private _onAfterCheckInputsObserver;
  40777. private _attachedCamera;
  40778. private _isPointerDown;
  40779. private _lastFrameTime;
  40780. private _lastInteractionTime;
  40781. private _cameraRotationSpeed;
  40782. /**
  40783. * Initializes the behavior.
  40784. */
  40785. init(): void;
  40786. /**
  40787. * Attaches the behavior to its arc rotate camera.
  40788. * @param camera Defines the camera to attach the behavior to
  40789. */
  40790. attach(camera: ArcRotateCamera): void;
  40791. /**
  40792. * Detaches the behavior from its current arc rotate camera.
  40793. */
  40794. detach(): void;
  40795. /**
  40796. * Returns true if user is scrolling.
  40797. * @return true if user is scrolling.
  40798. */
  40799. private _userIsZooming;
  40800. private _lastFrameRadius;
  40801. private _shouldAnimationStopForInteraction;
  40802. /**
  40803. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40804. */
  40805. private _applyUserInteraction;
  40806. private _userIsMoving;
  40807. }
  40808. }
  40809. declare module "babylonjs/Behaviors/Cameras/index" {
  40810. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40811. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40812. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40813. }
  40814. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40815. import { Mesh } from "babylonjs/Meshes/mesh";
  40816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40817. import { Behavior } from "babylonjs/Behaviors/behavior";
  40818. /**
  40819. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40820. */
  40821. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40822. private ui;
  40823. /**
  40824. * The name of the behavior
  40825. */
  40826. name: string;
  40827. /**
  40828. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40829. */
  40830. distanceAwayFromFace: number;
  40831. /**
  40832. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40833. */
  40834. distanceAwayFromBottomOfFace: number;
  40835. private _faceVectors;
  40836. private _target;
  40837. private _scene;
  40838. private _onRenderObserver;
  40839. private _tmpMatrix;
  40840. private _tmpVector;
  40841. /**
  40842. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40843. * @param ui The transform node that should be attched to the mesh
  40844. */
  40845. constructor(ui: TransformNode);
  40846. /**
  40847. * Initializes the behavior
  40848. */
  40849. init(): void;
  40850. private _closestFace;
  40851. private _zeroVector;
  40852. private _lookAtTmpMatrix;
  40853. private _lookAtToRef;
  40854. /**
  40855. * Attaches the AttachToBoxBehavior to the passed in mesh
  40856. * @param target The mesh that the specified node will be attached to
  40857. */
  40858. attach(target: Mesh): void;
  40859. /**
  40860. * Detaches the behavior from the mesh
  40861. */
  40862. detach(): void;
  40863. }
  40864. }
  40865. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40866. import { Behavior } from "babylonjs/Behaviors/behavior";
  40867. import { Mesh } from "babylonjs/Meshes/mesh";
  40868. /**
  40869. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40870. */
  40871. export class FadeInOutBehavior implements Behavior<Mesh> {
  40872. /**
  40873. * Time in milliseconds to delay before fading in (Default: 0)
  40874. */
  40875. delay: number;
  40876. /**
  40877. * Time in milliseconds for the mesh to fade in (Default: 300)
  40878. */
  40879. fadeInTime: number;
  40880. private _millisecondsPerFrame;
  40881. private _hovered;
  40882. private _hoverValue;
  40883. private _ownerNode;
  40884. /**
  40885. * Instatiates the FadeInOutBehavior
  40886. */
  40887. constructor();
  40888. /**
  40889. * The name of the behavior
  40890. */
  40891. get name(): string;
  40892. /**
  40893. * Initializes the behavior
  40894. */
  40895. init(): void;
  40896. /**
  40897. * Attaches the fade behavior on the passed in mesh
  40898. * @param ownerNode The mesh that will be faded in/out once attached
  40899. */
  40900. attach(ownerNode: Mesh): void;
  40901. /**
  40902. * Detaches the behavior from the mesh
  40903. */
  40904. detach(): void;
  40905. /**
  40906. * Triggers the mesh to begin fading in or out
  40907. * @param value if the object should fade in or out (true to fade in)
  40908. */
  40909. fadeIn(value: boolean): void;
  40910. private _update;
  40911. private _setAllVisibility;
  40912. }
  40913. }
  40914. declare module "babylonjs/Misc/pivotTools" {
  40915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40916. /**
  40917. * Class containing a set of static utilities functions for managing Pivots
  40918. * @hidden
  40919. */
  40920. export class PivotTools {
  40921. private static _PivotCached;
  40922. private static _OldPivotPoint;
  40923. private static _PivotTranslation;
  40924. private static _PivotTmpVector;
  40925. /** @hidden */
  40926. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40927. /** @hidden */
  40928. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40929. }
  40930. }
  40931. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40932. import { Scene } from "babylonjs/scene";
  40933. import { Vector4 } from "babylonjs/Maths/math.vector";
  40934. import { Mesh } from "babylonjs/Meshes/mesh";
  40935. import { Nullable } from "babylonjs/types";
  40936. import { Plane } from "babylonjs/Maths/math.plane";
  40937. /**
  40938. * Class containing static functions to help procedurally build meshes
  40939. */
  40940. export class PlaneBuilder {
  40941. /**
  40942. * Creates a plane mesh
  40943. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40944. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40945. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40949. * @param name defines the name of the mesh
  40950. * @param options defines the options used to create the mesh
  40951. * @param scene defines the hosting scene
  40952. * @returns the plane mesh
  40953. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40954. */
  40955. static CreatePlane(name: string, options: {
  40956. size?: number;
  40957. width?: number;
  40958. height?: number;
  40959. sideOrientation?: number;
  40960. frontUVs?: Vector4;
  40961. backUVs?: Vector4;
  40962. updatable?: boolean;
  40963. sourcePlane?: Plane;
  40964. }, scene?: Nullable<Scene>): Mesh;
  40965. }
  40966. }
  40967. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40968. import { Behavior } from "babylonjs/Behaviors/behavior";
  40969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40970. import { Observable } from "babylonjs/Misc/observable";
  40971. import { Vector3 } from "babylonjs/Maths/math.vector";
  40972. import { Ray } from "babylonjs/Culling/ray";
  40973. import "babylonjs/Meshes/Builders/planeBuilder";
  40974. /**
  40975. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40976. */
  40977. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40978. private static _AnyMouseID;
  40979. /**
  40980. * Abstract mesh the behavior is set on
  40981. */
  40982. attachedNode: AbstractMesh;
  40983. private _dragPlane;
  40984. private _scene;
  40985. private _pointerObserver;
  40986. private _beforeRenderObserver;
  40987. private static _planeScene;
  40988. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40989. /**
  40990. * 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)
  40991. */
  40992. maxDragAngle: number;
  40993. /**
  40994. * @hidden
  40995. */
  40996. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40997. /**
  40998. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40999. */
  41000. currentDraggingPointerID: number;
  41001. /**
  41002. * The last position where the pointer hit the drag plane in world space
  41003. */
  41004. lastDragPosition: Vector3;
  41005. /**
  41006. * If the behavior is currently in a dragging state
  41007. */
  41008. dragging: boolean;
  41009. /**
  41010. * 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)
  41011. */
  41012. dragDeltaRatio: number;
  41013. /**
  41014. * If the drag plane orientation should be updated during the dragging (Default: true)
  41015. */
  41016. updateDragPlane: boolean;
  41017. private _debugMode;
  41018. private _moving;
  41019. /**
  41020. * Fires each time the attached mesh is dragged with the pointer
  41021. * * delta between last drag position and current drag position in world space
  41022. * * dragDistance along the drag axis
  41023. * * dragPlaneNormal normal of the current drag plane used during the drag
  41024. * * dragPlanePoint in world space where the drag intersects the drag plane
  41025. */
  41026. onDragObservable: Observable<{
  41027. delta: Vector3;
  41028. dragPlanePoint: Vector3;
  41029. dragPlaneNormal: Vector3;
  41030. dragDistance: number;
  41031. pointerId: number;
  41032. }>;
  41033. /**
  41034. * Fires each time a drag begins (eg. mouse down on mesh)
  41035. */
  41036. onDragStartObservable: Observable<{
  41037. dragPlanePoint: Vector3;
  41038. pointerId: number;
  41039. }>;
  41040. /**
  41041. * Fires each time a drag ends (eg. mouse release after drag)
  41042. */
  41043. onDragEndObservable: Observable<{
  41044. dragPlanePoint: Vector3;
  41045. pointerId: number;
  41046. }>;
  41047. /**
  41048. * If the attached mesh should be moved when dragged
  41049. */
  41050. moveAttached: boolean;
  41051. /**
  41052. * If the drag behavior will react to drag events (Default: true)
  41053. */
  41054. enabled: boolean;
  41055. /**
  41056. * If pointer events should start and release the drag (Default: true)
  41057. */
  41058. startAndReleaseDragOnPointerEvents: boolean;
  41059. /**
  41060. * If camera controls should be detached during the drag
  41061. */
  41062. detachCameraControls: boolean;
  41063. /**
  41064. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41065. */
  41066. useObjectOrientationForDragging: boolean;
  41067. private _options;
  41068. /**
  41069. * Gets the options used by the behavior
  41070. */
  41071. get options(): {
  41072. dragAxis?: Vector3;
  41073. dragPlaneNormal?: Vector3;
  41074. };
  41075. /**
  41076. * Sets the options used by the behavior
  41077. */
  41078. set options(options: {
  41079. dragAxis?: Vector3;
  41080. dragPlaneNormal?: Vector3;
  41081. });
  41082. /**
  41083. * Creates a pointer drag behavior that can be attached to a mesh
  41084. * @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)
  41085. */
  41086. constructor(options?: {
  41087. dragAxis?: Vector3;
  41088. dragPlaneNormal?: Vector3;
  41089. });
  41090. /**
  41091. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41092. */
  41093. validateDrag: (targetPosition: Vector3) => boolean;
  41094. /**
  41095. * The name of the behavior
  41096. */
  41097. get name(): string;
  41098. /**
  41099. * Initializes the behavior
  41100. */
  41101. init(): void;
  41102. private _tmpVector;
  41103. private _alternatePickedPoint;
  41104. private _worldDragAxis;
  41105. private _targetPosition;
  41106. private _attachedElement;
  41107. /**
  41108. * Attaches the drag behavior the passed in mesh
  41109. * @param ownerNode The mesh that will be dragged around once attached
  41110. * @param predicate Predicate to use for pick filtering
  41111. */
  41112. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41113. /**
  41114. * Force relase the drag action by code.
  41115. */
  41116. releaseDrag(): void;
  41117. private _startDragRay;
  41118. private _lastPointerRay;
  41119. /**
  41120. * Simulates the start of a pointer drag event on the behavior
  41121. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41122. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41123. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41124. */
  41125. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41126. private _startDrag;
  41127. private _dragDelta;
  41128. private _moveDrag;
  41129. private _pickWithRayOnDragPlane;
  41130. private _pointA;
  41131. private _pointB;
  41132. private _pointC;
  41133. private _lineA;
  41134. private _lineB;
  41135. private _localAxis;
  41136. private _lookAt;
  41137. private _updateDragPlanePosition;
  41138. /**
  41139. * Detaches the behavior from the mesh
  41140. */
  41141. detach(): void;
  41142. }
  41143. }
  41144. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41145. import { Mesh } from "babylonjs/Meshes/mesh";
  41146. import { Behavior } from "babylonjs/Behaviors/behavior";
  41147. /**
  41148. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41149. */
  41150. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41151. private _dragBehaviorA;
  41152. private _dragBehaviorB;
  41153. private _startDistance;
  41154. private _initialScale;
  41155. private _targetScale;
  41156. private _ownerNode;
  41157. private _sceneRenderObserver;
  41158. /**
  41159. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41160. */
  41161. constructor();
  41162. /**
  41163. * The name of the behavior
  41164. */
  41165. get name(): string;
  41166. /**
  41167. * Initializes the behavior
  41168. */
  41169. init(): void;
  41170. private _getCurrentDistance;
  41171. /**
  41172. * Attaches the scale behavior the passed in mesh
  41173. * @param ownerNode The mesh that will be scaled around once attached
  41174. */
  41175. attach(ownerNode: Mesh): void;
  41176. /**
  41177. * Detaches the behavior from the mesh
  41178. */
  41179. detach(): void;
  41180. }
  41181. }
  41182. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41183. import { Behavior } from "babylonjs/Behaviors/behavior";
  41184. import { Mesh } from "babylonjs/Meshes/mesh";
  41185. import { Observable } from "babylonjs/Misc/observable";
  41186. /**
  41187. * 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
  41188. */
  41189. export class SixDofDragBehavior implements Behavior<Mesh> {
  41190. private static _virtualScene;
  41191. private _ownerNode;
  41192. private _sceneRenderObserver;
  41193. private _scene;
  41194. private _targetPosition;
  41195. private _virtualOriginMesh;
  41196. private _virtualDragMesh;
  41197. private _pointerObserver;
  41198. private _moving;
  41199. private _startingOrientation;
  41200. private _attachedElement;
  41201. /**
  41202. * 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)
  41203. */
  41204. private zDragFactor;
  41205. /**
  41206. * If the object should rotate to face the drag origin
  41207. */
  41208. rotateDraggedObject: boolean;
  41209. /**
  41210. * If the behavior is currently in a dragging state
  41211. */
  41212. dragging: boolean;
  41213. /**
  41214. * 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)
  41215. */
  41216. dragDeltaRatio: number;
  41217. /**
  41218. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41219. */
  41220. currentDraggingPointerID: number;
  41221. /**
  41222. * If camera controls should be detached during the drag
  41223. */
  41224. detachCameraControls: boolean;
  41225. /**
  41226. * Fires each time a drag starts
  41227. */
  41228. onDragStartObservable: Observable<{}>;
  41229. /**
  41230. * Fires each time a drag ends (eg. mouse release after drag)
  41231. */
  41232. onDragEndObservable: Observable<{}>;
  41233. /**
  41234. * 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
  41235. */
  41236. constructor();
  41237. /**
  41238. * The name of the behavior
  41239. */
  41240. get name(): string;
  41241. /**
  41242. * Initializes the behavior
  41243. */
  41244. init(): void;
  41245. /**
  41246. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41247. */
  41248. private get _pointerCamera();
  41249. /**
  41250. * Attaches the scale behavior the passed in mesh
  41251. * @param ownerNode The mesh that will be scaled around once attached
  41252. */
  41253. attach(ownerNode: Mesh): void;
  41254. /**
  41255. * Detaches the behavior from the mesh
  41256. */
  41257. detach(): void;
  41258. }
  41259. }
  41260. declare module "babylonjs/Behaviors/Meshes/index" {
  41261. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41262. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41263. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41264. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41265. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41266. }
  41267. declare module "babylonjs/Behaviors/index" {
  41268. export * from "babylonjs/Behaviors/behavior";
  41269. export * from "babylonjs/Behaviors/Cameras/index";
  41270. export * from "babylonjs/Behaviors/Meshes/index";
  41271. }
  41272. declare module "babylonjs/Bones/boneIKController" {
  41273. import { Bone } from "babylonjs/Bones/bone";
  41274. import { Vector3 } from "babylonjs/Maths/math.vector";
  41275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41276. import { Nullable } from "babylonjs/types";
  41277. /**
  41278. * Class used to apply inverse kinematics to bones
  41279. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41280. */
  41281. export class BoneIKController {
  41282. private static _tmpVecs;
  41283. private static _tmpQuat;
  41284. private static _tmpMats;
  41285. /**
  41286. * Gets or sets the target mesh
  41287. */
  41288. targetMesh: AbstractMesh;
  41289. /** Gets or sets the mesh used as pole */
  41290. poleTargetMesh: AbstractMesh;
  41291. /**
  41292. * Gets or sets the bone used as pole
  41293. */
  41294. poleTargetBone: Nullable<Bone>;
  41295. /**
  41296. * Gets or sets the target position
  41297. */
  41298. targetPosition: Vector3;
  41299. /**
  41300. * Gets or sets the pole target position
  41301. */
  41302. poleTargetPosition: Vector3;
  41303. /**
  41304. * Gets or sets the pole target local offset
  41305. */
  41306. poleTargetLocalOffset: Vector3;
  41307. /**
  41308. * Gets or sets the pole angle
  41309. */
  41310. poleAngle: number;
  41311. /**
  41312. * Gets or sets the mesh associated with the controller
  41313. */
  41314. mesh: AbstractMesh;
  41315. /**
  41316. * 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)
  41317. */
  41318. slerpAmount: number;
  41319. private _bone1Quat;
  41320. private _bone1Mat;
  41321. private _bone2Ang;
  41322. private _bone1;
  41323. private _bone2;
  41324. private _bone1Length;
  41325. private _bone2Length;
  41326. private _maxAngle;
  41327. private _maxReach;
  41328. private _rightHandedSystem;
  41329. private _bendAxis;
  41330. private _slerping;
  41331. private _adjustRoll;
  41332. /**
  41333. * Gets or sets maximum allowed angle
  41334. */
  41335. get maxAngle(): number;
  41336. set maxAngle(value: number);
  41337. /**
  41338. * Creates a new BoneIKController
  41339. * @param mesh defines the mesh to control
  41340. * @param bone defines the bone to control
  41341. * @param options defines options to set up the controller
  41342. */
  41343. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41344. targetMesh?: AbstractMesh;
  41345. poleTargetMesh?: AbstractMesh;
  41346. poleTargetBone?: Bone;
  41347. poleTargetLocalOffset?: Vector3;
  41348. poleAngle?: number;
  41349. bendAxis?: Vector3;
  41350. maxAngle?: number;
  41351. slerpAmount?: number;
  41352. });
  41353. private _setMaxAngle;
  41354. /**
  41355. * Force the controller to update the bones
  41356. */
  41357. update(): void;
  41358. }
  41359. }
  41360. declare module "babylonjs/Bones/boneLookController" {
  41361. import { Vector3 } from "babylonjs/Maths/math.vector";
  41362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41363. import { Bone } from "babylonjs/Bones/bone";
  41364. import { Space } from "babylonjs/Maths/math.axis";
  41365. /**
  41366. * Class used to make a bone look toward a point in space
  41367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41368. */
  41369. export class BoneLookController {
  41370. private static _tmpVecs;
  41371. private static _tmpQuat;
  41372. private static _tmpMats;
  41373. /**
  41374. * The target Vector3 that the bone will look at
  41375. */
  41376. target: Vector3;
  41377. /**
  41378. * The mesh that the bone is attached to
  41379. */
  41380. mesh: AbstractMesh;
  41381. /**
  41382. * The bone that will be looking to the target
  41383. */
  41384. bone: Bone;
  41385. /**
  41386. * The up axis of the coordinate system that is used when the bone is rotated
  41387. */
  41388. upAxis: Vector3;
  41389. /**
  41390. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41391. */
  41392. upAxisSpace: Space;
  41393. /**
  41394. * Used to make an adjustment to the yaw of the bone
  41395. */
  41396. adjustYaw: number;
  41397. /**
  41398. * Used to make an adjustment to the pitch of the bone
  41399. */
  41400. adjustPitch: number;
  41401. /**
  41402. * Used to make an adjustment to the roll of the bone
  41403. */
  41404. adjustRoll: number;
  41405. /**
  41406. * 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)
  41407. */
  41408. slerpAmount: number;
  41409. private _minYaw;
  41410. private _maxYaw;
  41411. private _minPitch;
  41412. private _maxPitch;
  41413. private _minYawSin;
  41414. private _minYawCos;
  41415. private _maxYawSin;
  41416. private _maxYawCos;
  41417. private _midYawConstraint;
  41418. private _minPitchTan;
  41419. private _maxPitchTan;
  41420. private _boneQuat;
  41421. private _slerping;
  41422. private _transformYawPitch;
  41423. private _transformYawPitchInv;
  41424. private _firstFrameSkipped;
  41425. private _yawRange;
  41426. private _fowardAxis;
  41427. /**
  41428. * Gets or sets the minimum yaw angle that the bone can look to
  41429. */
  41430. get minYaw(): number;
  41431. set minYaw(value: number);
  41432. /**
  41433. * Gets or sets the maximum yaw angle that the bone can look to
  41434. */
  41435. get maxYaw(): number;
  41436. set maxYaw(value: number);
  41437. /**
  41438. * Gets or sets the minimum pitch angle that the bone can look to
  41439. */
  41440. get minPitch(): number;
  41441. set minPitch(value: number);
  41442. /**
  41443. * Gets or sets the maximum pitch angle that the bone can look to
  41444. */
  41445. get maxPitch(): number;
  41446. set maxPitch(value: number);
  41447. /**
  41448. * Create a BoneLookController
  41449. * @param mesh the mesh that the bone belongs to
  41450. * @param bone the bone that will be looking to the target
  41451. * @param target the target Vector3 to look at
  41452. * @param options optional settings:
  41453. * * maxYaw: the maximum angle the bone will yaw to
  41454. * * minYaw: the minimum angle the bone will yaw to
  41455. * * maxPitch: the maximum angle the bone will pitch to
  41456. * * minPitch: the minimum angle the bone will yaw to
  41457. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41458. * * upAxis: the up axis of the coordinate system
  41459. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41460. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41461. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41462. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41463. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41464. * * adjustRoll: used to make an adjustment to the roll of the bone
  41465. **/
  41466. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41467. maxYaw?: number;
  41468. minYaw?: number;
  41469. maxPitch?: number;
  41470. minPitch?: number;
  41471. slerpAmount?: number;
  41472. upAxis?: Vector3;
  41473. upAxisSpace?: Space;
  41474. yawAxis?: Vector3;
  41475. pitchAxis?: Vector3;
  41476. adjustYaw?: number;
  41477. adjustPitch?: number;
  41478. adjustRoll?: number;
  41479. });
  41480. /**
  41481. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41482. */
  41483. update(): void;
  41484. private _getAngleDiff;
  41485. private _getAngleBetween;
  41486. private _isAngleBetween;
  41487. }
  41488. }
  41489. declare module "babylonjs/Bones/index" {
  41490. export * from "babylonjs/Bones/bone";
  41491. export * from "babylonjs/Bones/boneIKController";
  41492. export * from "babylonjs/Bones/boneLookController";
  41493. export * from "babylonjs/Bones/skeleton";
  41494. }
  41495. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41496. import { Nullable } from "babylonjs/types";
  41497. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41498. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41499. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41500. /**
  41501. * Manage the gamepad inputs to control an arc rotate camera.
  41502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41503. */
  41504. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41505. /**
  41506. * Defines the camera the input is attached to.
  41507. */
  41508. camera: ArcRotateCamera;
  41509. /**
  41510. * Defines the gamepad the input is gathering event from.
  41511. */
  41512. gamepad: Nullable<Gamepad>;
  41513. /**
  41514. * Defines the gamepad rotation sensiblity.
  41515. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41516. */
  41517. gamepadRotationSensibility: number;
  41518. /**
  41519. * Defines the gamepad move sensiblity.
  41520. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41521. */
  41522. gamepadMoveSensibility: number;
  41523. private _yAxisScale;
  41524. /**
  41525. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41526. */
  41527. get invertYAxis(): boolean;
  41528. set invertYAxis(value: boolean);
  41529. private _onGamepadConnectedObserver;
  41530. private _onGamepadDisconnectedObserver;
  41531. /**
  41532. * Attach the input controls to a specific dom element to get the input from.
  41533. * @param element Defines the element the controls should be listened from
  41534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41535. */
  41536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41537. /**
  41538. * Detach the current controls from the specified dom element.
  41539. * @param element Defines the element to stop listening the inputs from
  41540. */
  41541. detachControl(element: Nullable<HTMLElement>): void;
  41542. /**
  41543. * Update the current camera state depending on the inputs that have been used this frame.
  41544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41545. */
  41546. checkInputs(): void;
  41547. /**
  41548. * Gets the class name of the current intput.
  41549. * @returns the class name
  41550. */
  41551. getClassName(): string;
  41552. /**
  41553. * Get the friendly name associated with the input class.
  41554. * @returns the input friendly name
  41555. */
  41556. getSimpleName(): string;
  41557. }
  41558. }
  41559. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41560. import { Nullable } from "babylonjs/types";
  41561. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41563. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41564. interface ArcRotateCameraInputsManager {
  41565. /**
  41566. * Add orientation input support to the input manager.
  41567. * @returns the current input manager
  41568. */
  41569. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41570. }
  41571. }
  41572. /**
  41573. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41575. */
  41576. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41577. /**
  41578. * Defines the camera the input is attached to.
  41579. */
  41580. camera: ArcRotateCamera;
  41581. /**
  41582. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41583. */
  41584. alphaCorrection: number;
  41585. /**
  41586. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41587. */
  41588. gammaCorrection: number;
  41589. private _alpha;
  41590. private _gamma;
  41591. private _dirty;
  41592. private _deviceOrientationHandler;
  41593. /**
  41594. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41595. */
  41596. constructor();
  41597. /**
  41598. * Attach the input controls to a specific dom element to get the input from.
  41599. * @param element Defines the element the controls should be listened from
  41600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41601. */
  41602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41603. /** @hidden */
  41604. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41605. /**
  41606. * Update the current camera state depending on the inputs that have been used this frame.
  41607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41608. */
  41609. checkInputs(): void;
  41610. /**
  41611. * Detach the current controls from the specified dom element.
  41612. * @param element Defines the element to stop listening the inputs from
  41613. */
  41614. detachControl(element: Nullable<HTMLElement>): void;
  41615. /**
  41616. * Gets the class name of the current intput.
  41617. * @returns the class name
  41618. */
  41619. getClassName(): string;
  41620. /**
  41621. * Get the friendly name associated with the input class.
  41622. * @returns the input friendly name
  41623. */
  41624. getSimpleName(): string;
  41625. }
  41626. }
  41627. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41628. import { Nullable } from "babylonjs/types";
  41629. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41630. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41631. /**
  41632. * Listen to mouse events to control the camera.
  41633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41634. */
  41635. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41636. /**
  41637. * Defines the camera the input is attached to.
  41638. */
  41639. camera: FlyCamera;
  41640. /**
  41641. * Defines if touch is enabled. (Default is true.)
  41642. */
  41643. touchEnabled: boolean;
  41644. /**
  41645. * Defines the buttons associated with the input to handle camera rotation.
  41646. */
  41647. buttons: number[];
  41648. /**
  41649. * Assign buttons for Yaw control.
  41650. */
  41651. buttonsYaw: number[];
  41652. /**
  41653. * Assign buttons for Pitch control.
  41654. */
  41655. buttonsPitch: number[];
  41656. /**
  41657. * Assign buttons for Roll control.
  41658. */
  41659. buttonsRoll: number[];
  41660. /**
  41661. * Detect if any button is being pressed while mouse is moved.
  41662. * -1 = Mouse locked.
  41663. * 0 = Left button.
  41664. * 1 = Middle Button.
  41665. * 2 = Right Button.
  41666. */
  41667. activeButton: number;
  41668. /**
  41669. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41670. * Higher values reduce its sensitivity.
  41671. */
  41672. angularSensibility: number;
  41673. private _mousemoveCallback;
  41674. private _observer;
  41675. private _rollObserver;
  41676. private previousPosition;
  41677. private noPreventDefault;
  41678. private element;
  41679. /**
  41680. * Listen to mouse events to control the camera.
  41681. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41683. */
  41684. constructor(touchEnabled?: boolean);
  41685. /**
  41686. * Attach the mouse control to the HTML DOM element.
  41687. * @param element Defines the element that listens to the input events.
  41688. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41689. */
  41690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41691. /**
  41692. * Detach the current controls from the specified dom element.
  41693. * @param element Defines the element to stop listening the inputs from
  41694. */
  41695. detachControl(element: Nullable<HTMLElement>): void;
  41696. /**
  41697. * Gets the class name of the current input.
  41698. * @returns the class name.
  41699. */
  41700. getClassName(): string;
  41701. /**
  41702. * Get the friendly name associated with the input class.
  41703. * @returns the input's friendly name.
  41704. */
  41705. getSimpleName(): string;
  41706. private _pointerInput;
  41707. private _onMouseMove;
  41708. /**
  41709. * Rotate camera by mouse offset.
  41710. */
  41711. private rotateCamera;
  41712. }
  41713. }
  41714. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41715. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41716. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41717. /**
  41718. * Default Inputs manager for the FlyCamera.
  41719. * It groups all the default supported inputs for ease of use.
  41720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41721. */
  41722. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41723. /**
  41724. * Instantiates a new FlyCameraInputsManager.
  41725. * @param camera Defines the camera the inputs belong to.
  41726. */
  41727. constructor(camera: FlyCamera);
  41728. /**
  41729. * Add keyboard input support to the input manager.
  41730. * @returns the new FlyCameraKeyboardMoveInput().
  41731. */
  41732. addKeyboard(): FlyCameraInputsManager;
  41733. /**
  41734. * Add mouse input support to the input manager.
  41735. * @param touchEnabled Enable touch screen support.
  41736. * @returns the new FlyCameraMouseInput().
  41737. */
  41738. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41739. }
  41740. }
  41741. declare module "babylonjs/Cameras/flyCamera" {
  41742. import { Scene } from "babylonjs/scene";
  41743. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41745. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41746. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41747. /**
  41748. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41749. * such as in a 3D Space Shooter or a Flight Simulator.
  41750. */
  41751. export class FlyCamera extends TargetCamera {
  41752. /**
  41753. * Define the collision ellipsoid of the camera.
  41754. * This is helpful for simulating a camera body, like a player's body.
  41755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41756. */
  41757. ellipsoid: Vector3;
  41758. /**
  41759. * Define an offset for the position of the ellipsoid around the camera.
  41760. * This can be helpful if the camera is attached away from the player's body center,
  41761. * such as at its head.
  41762. */
  41763. ellipsoidOffset: Vector3;
  41764. /**
  41765. * Enable or disable collisions of the camera with the rest of the scene objects.
  41766. */
  41767. checkCollisions: boolean;
  41768. /**
  41769. * Enable or disable gravity on the camera.
  41770. */
  41771. applyGravity: boolean;
  41772. /**
  41773. * Define the current direction the camera is moving to.
  41774. */
  41775. cameraDirection: Vector3;
  41776. /**
  41777. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41778. * This overrides and empties cameraRotation.
  41779. */
  41780. rotationQuaternion: Quaternion;
  41781. /**
  41782. * Track Roll to maintain the wanted Rolling when looking around.
  41783. */
  41784. _trackRoll: number;
  41785. /**
  41786. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41787. */
  41788. rollCorrect: number;
  41789. /**
  41790. * Mimic a banked turn, Rolling the camera when Yawing.
  41791. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41792. */
  41793. bankedTurn: boolean;
  41794. /**
  41795. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41796. */
  41797. bankedTurnLimit: number;
  41798. /**
  41799. * Value of 0 disables the banked Roll.
  41800. * Value of 1 is equal to the Yaw angle in radians.
  41801. */
  41802. bankedTurnMultiplier: number;
  41803. /**
  41804. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41805. */
  41806. inputs: FlyCameraInputsManager;
  41807. /**
  41808. * Gets the input sensibility for mouse input.
  41809. * Higher values reduce sensitivity.
  41810. */
  41811. get angularSensibility(): number;
  41812. /**
  41813. * Sets the input sensibility for a mouse input.
  41814. * Higher values reduce sensitivity.
  41815. */
  41816. set angularSensibility(value: number);
  41817. /**
  41818. * Get the keys for camera movement forward.
  41819. */
  41820. get keysForward(): number[];
  41821. /**
  41822. * Set the keys for camera movement forward.
  41823. */
  41824. set keysForward(value: number[]);
  41825. /**
  41826. * Get the keys for camera movement backward.
  41827. */
  41828. get keysBackward(): number[];
  41829. set keysBackward(value: number[]);
  41830. /**
  41831. * Get the keys for camera movement up.
  41832. */
  41833. get keysUp(): number[];
  41834. /**
  41835. * Set the keys for camera movement up.
  41836. */
  41837. set keysUp(value: number[]);
  41838. /**
  41839. * Get the keys for camera movement down.
  41840. */
  41841. get keysDown(): number[];
  41842. /**
  41843. * Set the keys for camera movement down.
  41844. */
  41845. set keysDown(value: number[]);
  41846. /**
  41847. * Get the keys for camera movement left.
  41848. */
  41849. get keysLeft(): number[];
  41850. /**
  41851. * Set the keys for camera movement left.
  41852. */
  41853. set keysLeft(value: number[]);
  41854. /**
  41855. * Set the keys for camera movement right.
  41856. */
  41857. get keysRight(): number[];
  41858. /**
  41859. * Set the keys for camera movement right.
  41860. */
  41861. set keysRight(value: number[]);
  41862. /**
  41863. * Event raised when the camera collides with a mesh in the scene.
  41864. */
  41865. onCollide: (collidedMesh: AbstractMesh) => void;
  41866. private _collider;
  41867. private _needMoveForGravity;
  41868. private _oldPosition;
  41869. private _diffPosition;
  41870. private _newPosition;
  41871. /** @hidden */
  41872. _localDirection: Vector3;
  41873. /** @hidden */
  41874. _transformedDirection: Vector3;
  41875. /**
  41876. * Instantiates a FlyCamera.
  41877. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41878. * such as in a 3D Space Shooter or a Flight Simulator.
  41879. * @param name Define the name of the camera in the scene.
  41880. * @param position Define the starting position of the camera in the scene.
  41881. * @param scene Define the scene the camera belongs to.
  41882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41883. */
  41884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41885. /**
  41886. * Attach a control to the HTML DOM element.
  41887. * @param element Defines the element that listens to the input events.
  41888. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41889. */
  41890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41891. /**
  41892. * Detach a control from the HTML DOM element.
  41893. * The camera will stop reacting to that input.
  41894. * @param element Defines the element that listens to the input events.
  41895. */
  41896. detachControl(element: HTMLElement): void;
  41897. private _collisionMask;
  41898. /**
  41899. * Get the mask that the camera ignores in collision events.
  41900. */
  41901. get collisionMask(): number;
  41902. /**
  41903. * Set the mask that the camera ignores in collision events.
  41904. */
  41905. set collisionMask(mask: number);
  41906. /** @hidden */
  41907. _collideWithWorld(displacement: Vector3): void;
  41908. /** @hidden */
  41909. private _onCollisionPositionChange;
  41910. /** @hidden */
  41911. _checkInputs(): void;
  41912. /** @hidden */
  41913. _decideIfNeedsToMove(): boolean;
  41914. /** @hidden */
  41915. _updatePosition(): void;
  41916. /**
  41917. * Restore the Roll to its target value at the rate specified.
  41918. * @param rate - Higher means slower restoring.
  41919. * @hidden
  41920. */
  41921. restoreRoll(rate: number): void;
  41922. /**
  41923. * Destroy the camera and release the current resources held by it.
  41924. */
  41925. dispose(): void;
  41926. /**
  41927. * Get the current object class name.
  41928. * @returns the class name.
  41929. */
  41930. getClassName(): string;
  41931. }
  41932. }
  41933. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41934. import { Nullable } from "babylonjs/types";
  41935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41936. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41937. /**
  41938. * Listen to keyboard events to control the camera.
  41939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41940. */
  41941. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41942. /**
  41943. * Defines the camera the input is attached to.
  41944. */
  41945. camera: FlyCamera;
  41946. /**
  41947. * The list of keyboard keys used to control the forward move of the camera.
  41948. */
  41949. keysForward: number[];
  41950. /**
  41951. * The list of keyboard keys used to control the backward move of the camera.
  41952. */
  41953. keysBackward: number[];
  41954. /**
  41955. * The list of keyboard keys used to control the forward move of the camera.
  41956. */
  41957. keysUp: number[];
  41958. /**
  41959. * The list of keyboard keys used to control the backward move of the camera.
  41960. */
  41961. keysDown: number[];
  41962. /**
  41963. * The list of keyboard keys used to control the right strafe move of the camera.
  41964. */
  41965. keysRight: number[];
  41966. /**
  41967. * The list of keyboard keys used to control the left strafe move of the camera.
  41968. */
  41969. keysLeft: number[];
  41970. private _keys;
  41971. private _onCanvasBlurObserver;
  41972. private _onKeyboardObserver;
  41973. private _engine;
  41974. private _scene;
  41975. /**
  41976. * Attach the input controls to a specific dom element to get the input from.
  41977. * @param element Defines the element the controls should be listened from
  41978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41979. */
  41980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41981. /**
  41982. * Detach the current controls from the specified dom element.
  41983. * @param element Defines the element to stop listening the inputs from
  41984. */
  41985. detachControl(element: Nullable<HTMLElement>): void;
  41986. /**
  41987. * Gets the class name of the current intput.
  41988. * @returns the class name
  41989. */
  41990. getClassName(): string;
  41991. /** @hidden */
  41992. _onLostFocus(e: FocusEvent): void;
  41993. /**
  41994. * Get the friendly name associated with the input class.
  41995. * @returns the input friendly name
  41996. */
  41997. getSimpleName(): string;
  41998. /**
  41999. * Update the current camera state depending on the inputs that have been used this frame.
  42000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42001. */
  42002. checkInputs(): void;
  42003. }
  42004. }
  42005. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42006. import { Nullable } from "babylonjs/types";
  42007. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42008. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42009. /**
  42010. * Manage the mouse wheel inputs to control a follow camera.
  42011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42012. */
  42013. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42014. /**
  42015. * Defines the camera the input is attached to.
  42016. */
  42017. camera: FollowCamera;
  42018. /**
  42019. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42020. */
  42021. axisControlRadius: boolean;
  42022. /**
  42023. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42024. */
  42025. axisControlHeight: boolean;
  42026. /**
  42027. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42028. */
  42029. axisControlRotation: boolean;
  42030. /**
  42031. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42032. * relation to mouseWheel events.
  42033. */
  42034. wheelPrecision: number;
  42035. /**
  42036. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42037. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42038. */
  42039. wheelDeltaPercentage: number;
  42040. private _wheel;
  42041. private _observer;
  42042. /**
  42043. * Attach the input controls to a specific dom element to get the input from.
  42044. * @param element Defines the element the controls should be listened from
  42045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42046. */
  42047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42048. /**
  42049. * Detach the current controls from the specified dom element.
  42050. * @param element Defines the element to stop listening the inputs from
  42051. */
  42052. detachControl(element: Nullable<HTMLElement>): void;
  42053. /**
  42054. * Gets the class name of the current intput.
  42055. * @returns the class name
  42056. */
  42057. getClassName(): string;
  42058. /**
  42059. * Get the friendly name associated with the input class.
  42060. * @returns the input friendly name
  42061. */
  42062. getSimpleName(): string;
  42063. }
  42064. }
  42065. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42066. import { Nullable } from "babylonjs/types";
  42067. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42068. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42069. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42070. /**
  42071. * Manage the pointers inputs to control an follow camera.
  42072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42073. */
  42074. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42075. /**
  42076. * Defines the camera the input is attached to.
  42077. */
  42078. camera: FollowCamera;
  42079. /**
  42080. * Gets the class name of the current input.
  42081. * @returns the class name
  42082. */
  42083. getClassName(): string;
  42084. /**
  42085. * Defines the pointer angular sensibility along the X axis or how fast is
  42086. * the camera rotating.
  42087. * A negative number will reverse the axis direction.
  42088. */
  42089. angularSensibilityX: number;
  42090. /**
  42091. * Defines the pointer angular sensibility along the Y axis or how fast is
  42092. * the camera rotating.
  42093. * A negative number will reverse the axis direction.
  42094. */
  42095. angularSensibilityY: number;
  42096. /**
  42097. * Defines the pointer pinch precision or how fast is the camera zooming.
  42098. * A negative number will reverse the axis direction.
  42099. */
  42100. pinchPrecision: number;
  42101. /**
  42102. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42103. * from 0.
  42104. * It defines the percentage of current camera.radius to use as delta when
  42105. * pinch zoom is used.
  42106. */
  42107. pinchDeltaPercentage: number;
  42108. /**
  42109. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42110. */
  42111. axisXControlRadius: boolean;
  42112. /**
  42113. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42114. */
  42115. axisXControlHeight: boolean;
  42116. /**
  42117. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42118. */
  42119. axisXControlRotation: boolean;
  42120. /**
  42121. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42122. */
  42123. axisYControlRadius: boolean;
  42124. /**
  42125. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42126. */
  42127. axisYControlHeight: boolean;
  42128. /**
  42129. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42130. */
  42131. axisYControlRotation: boolean;
  42132. /**
  42133. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42134. */
  42135. axisPinchControlRadius: boolean;
  42136. /**
  42137. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42138. */
  42139. axisPinchControlHeight: boolean;
  42140. /**
  42141. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42142. */
  42143. axisPinchControlRotation: boolean;
  42144. /**
  42145. * Log error messages if basic misconfiguration has occurred.
  42146. */
  42147. warningEnable: boolean;
  42148. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42149. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42150. private _warningCounter;
  42151. private _warning;
  42152. }
  42153. }
  42154. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42155. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42156. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42157. /**
  42158. * Default Inputs manager for the FollowCamera.
  42159. * It groups all the default supported inputs for ease of use.
  42160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42161. */
  42162. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42163. /**
  42164. * Instantiates a new FollowCameraInputsManager.
  42165. * @param camera Defines the camera the inputs belong to
  42166. */
  42167. constructor(camera: FollowCamera);
  42168. /**
  42169. * Add keyboard input support to the input manager.
  42170. * @returns the current input manager
  42171. */
  42172. addKeyboard(): FollowCameraInputsManager;
  42173. /**
  42174. * Add mouse wheel input support to the input manager.
  42175. * @returns the current input manager
  42176. */
  42177. addMouseWheel(): FollowCameraInputsManager;
  42178. /**
  42179. * Add pointers input support to the input manager.
  42180. * @returns the current input manager
  42181. */
  42182. addPointers(): FollowCameraInputsManager;
  42183. /**
  42184. * Add orientation input support to the input manager.
  42185. * @returns the current input manager
  42186. */
  42187. addVRDeviceOrientation(): FollowCameraInputsManager;
  42188. }
  42189. }
  42190. declare module "babylonjs/Cameras/followCamera" {
  42191. import { Nullable } from "babylonjs/types";
  42192. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42193. import { Scene } from "babylonjs/scene";
  42194. import { Vector3 } from "babylonjs/Maths/math.vector";
  42195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42196. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42197. /**
  42198. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42199. * an arc rotate version arcFollowCamera are available.
  42200. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42201. */
  42202. export class FollowCamera extends TargetCamera {
  42203. /**
  42204. * Distance the follow camera should follow an object at
  42205. */
  42206. radius: number;
  42207. /**
  42208. * Minimum allowed distance of the camera to the axis of rotation
  42209. * (The camera can not get closer).
  42210. * This can help limiting how the Camera is able to move in the scene.
  42211. */
  42212. lowerRadiusLimit: Nullable<number>;
  42213. /**
  42214. * Maximum allowed distance of the camera to the axis of rotation
  42215. * (The camera can not get further).
  42216. * This can help limiting how the Camera is able to move in the scene.
  42217. */
  42218. upperRadiusLimit: Nullable<number>;
  42219. /**
  42220. * Define a rotation offset between the camera and the object it follows
  42221. */
  42222. rotationOffset: number;
  42223. /**
  42224. * Minimum allowed angle to camera position relative to target object.
  42225. * This can help limiting how the Camera is able to move in the scene.
  42226. */
  42227. lowerRotationOffsetLimit: Nullable<number>;
  42228. /**
  42229. * Maximum allowed angle to camera position relative to target object.
  42230. * This can help limiting how the Camera is able to move in the scene.
  42231. */
  42232. upperRotationOffsetLimit: Nullable<number>;
  42233. /**
  42234. * Define a height offset between the camera and the object it follows.
  42235. * It can help following an object from the top (like a car chaing a plane)
  42236. */
  42237. heightOffset: number;
  42238. /**
  42239. * Minimum allowed height of camera position relative to target object.
  42240. * This can help limiting how the Camera is able to move in the scene.
  42241. */
  42242. lowerHeightOffsetLimit: Nullable<number>;
  42243. /**
  42244. * Maximum allowed height of camera position relative to target object.
  42245. * This can help limiting how the Camera is able to move in the scene.
  42246. */
  42247. upperHeightOffsetLimit: Nullable<number>;
  42248. /**
  42249. * Define how fast the camera can accelerate to follow it s target.
  42250. */
  42251. cameraAcceleration: number;
  42252. /**
  42253. * Define the speed limit of the camera following an object.
  42254. */
  42255. maxCameraSpeed: number;
  42256. /**
  42257. * Define the target of the camera.
  42258. */
  42259. lockedTarget: Nullable<AbstractMesh>;
  42260. /**
  42261. * Defines the input associated with the camera.
  42262. */
  42263. inputs: FollowCameraInputsManager;
  42264. /**
  42265. * Instantiates the follow camera.
  42266. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42267. * @param name Define the name of the camera in the scene
  42268. * @param position Define the position of the camera
  42269. * @param scene Define the scene the camera belong to
  42270. * @param lockedTarget Define the target of the camera
  42271. */
  42272. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42273. private _follow;
  42274. /**
  42275. * Attached controls to the current camera.
  42276. * @param element Defines the element the controls should be listened from
  42277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42278. */
  42279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42280. /**
  42281. * Detach the current controls from the camera.
  42282. * The camera will stop reacting to inputs.
  42283. * @param element Defines the element to stop listening the inputs from
  42284. */
  42285. detachControl(element: HTMLElement): void;
  42286. /** @hidden */
  42287. _checkInputs(): void;
  42288. private _checkLimits;
  42289. /**
  42290. * Gets the camera class name.
  42291. * @returns the class name
  42292. */
  42293. getClassName(): string;
  42294. }
  42295. /**
  42296. * Arc Rotate version of the follow camera.
  42297. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42298. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42299. */
  42300. export class ArcFollowCamera extends TargetCamera {
  42301. /** The longitudinal angle of the camera */
  42302. alpha: number;
  42303. /** The latitudinal angle of the camera */
  42304. beta: number;
  42305. /** The radius of the camera from its target */
  42306. radius: number;
  42307. /** Define the camera target (the messh it should follow) */
  42308. target: Nullable<AbstractMesh>;
  42309. private _cartesianCoordinates;
  42310. /**
  42311. * Instantiates a new ArcFollowCamera
  42312. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42313. * @param name Define the name of the camera
  42314. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42315. * @param beta Define the rotation angle of the camera around the elevation axis
  42316. * @param radius Define the radius of the camera from its target point
  42317. * @param target Define the target of the camera
  42318. * @param scene Define the scene the camera belongs to
  42319. */
  42320. constructor(name: string,
  42321. /** The longitudinal angle of the camera */
  42322. alpha: number,
  42323. /** The latitudinal angle of the camera */
  42324. beta: number,
  42325. /** The radius of the camera from its target */
  42326. radius: number,
  42327. /** Define the camera target (the messh it should follow) */
  42328. target: Nullable<AbstractMesh>, scene: Scene);
  42329. private _follow;
  42330. /** @hidden */
  42331. _checkInputs(): void;
  42332. /**
  42333. * Returns the class name of the object.
  42334. * It is mostly used internally for serialization purposes.
  42335. */
  42336. getClassName(): string;
  42337. }
  42338. }
  42339. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42340. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42341. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42342. import { Nullable } from "babylonjs/types";
  42343. /**
  42344. * Manage the keyboard inputs to control the movement of a follow camera.
  42345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42346. */
  42347. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42348. /**
  42349. * Defines the camera the input is attached to.
  42350. */
  42351. camera: FollowCamera;
  42352. /**
  42353. * Defines the list of key codes associated with the up action (increase heightOffset)
  42354. */
  42355. keysHeightOffsetIncr: number[];
  42356. /**
  42357. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42358. */
  42359. keysHeightOffsetDecr: number[];
  42360. /**
  42361. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42362. */
  42363. keysHeightOffsetModifierAlt: boolean;
  42364. /**
  42365. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42366. */
  42367. keysHeightOffsetModifierCtrl: boolean;
  42368. /**
  42369. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42370. */
  42371. keysHeightOffsetModifierShift: boolean;
  42372. /**
  42373. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42374. */
  42375. keysRotationOffsetIncr: number[];
  42376. /**
  42377. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42378. */
  42379. keysRotationOffsetDecr: number[];
  42380. /**
  42381. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42382. */
  42383. keysRotationOffsetModifierAlt: boolean;
  42384. /**
  42385. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42386. */
  42387. keysRotationOffsetModifierCtrl: boolean;
  42388. /**
  42389. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42390. */
  42391. keysRotationOffsetModifierShift: boolean;
  42392. /**
  42393. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42394. */
  42395. keysRadiusIncr: number[];
  42396. /**
  42397. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42398. */
  42399. keysRadiusDecr: number[];
  42400. /**
  42401. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42402. */
  42403. keysRadiusModifierAlt: boolean;
  42404. /**
  42405. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42406. */
  42407. keysRadiusModifierCtrl: boolean;
  42408. /**
  42409. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42410. */
  42411. keysRadiusModifierShift: boolean;
  42412. /**
  42413. * Defines the rate of change of heightOffset.
  42414. */
  42415. heightSensibility: number;
  42416. /**
  42417. * Defines the rate of change of rotationOffset.
  42418. */
  42419. rotationSensibility: number;
  42420. /**
  42421. * Defines the rate of change of radius.
  42422. */
  42423. radiusSensibility: number;
  42424. private _keys;
  42425. private _ctrlPressed;
  42426. private _altPressed;
  42427. private _shiftPressed;
  42428. private _onCanvasBlurObserver;
  42429. private _onKeyboardObserver;
  42430. private _engine;
  42431. private _scene;
  42432. /**
  42433. * Attach the input controls to a specific dom element to get the input from.
  42434. * @param element Defines the element the controls should be listened from
  42435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42436. */
  42437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42438. /**
  42439. * Detach the current controls from the specified dom element.
  42440. * @param element Defines the element to stop listening the inputs from
  42441. */
  42442. detachControl(element: Nullable<HTMLElement>): void;
  42443. /**
  42444. * Update the current camera state depending on the inputs that have been used this frame.
  42445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42446. */
  42447. checkInputs(): void;
  42448. /**
  42449. * Gets the class name of the current input.
  42450. * @returns the class name
  42451. */
  42452. getClassName(): string;
  42453. /**
  42454. * Get the friendly name associated with the input class.
  42455. * @returns the input friendly name
  42456. */
  42457. getSimpleName(): string;
  42458. /**
  42459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42460. * allow modification of the heightOffset value.
  42461. */
  42462. private _modifierHeightOffset;
  42463. /**
  42464. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42465. * allow modification of the rotationOffset value.
  42466. */
  42467. private _modifierRotationOffset;
  42468. /**
  42469. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42470. * allow modification of the radius value.
  42471. */
  42472. private _modifierRadius;
  42473. }
  42474. }
  42475. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42476. import { Nullable } from "babylonjs/types";
  42477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42478. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42479. import { Observable } from "babylonjs/Misc/observable";
  42480. module "babylonjs/Cameras/freeCameraInputsManager" {
  42481. interface FreeCameraInputsManager {
  42482. /**
  42483. * @hidden
  42484. */
  42485. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42486. /**
  42487. * Add orientation input support to the input manager.
  42488. * @returns the current input manager
  42489. */
  42490. addDeviceOrientation(): FreeCameraInputsManager;
  42491. }
  42492. }
  42493. /**
  42494. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42495. * Screen rotation is taken into account.
  42496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42497. */
  42498. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42499. private _camera;
  42500. private _screenOrientationAngle;
  42501. private _constantTranform;
  42502. private _screenQuaternion;
  42503. private _alpha;
  42504. private _beta;
  42505. private _gamma;
  42506. /**
  42507. * Can be used to detect if a device orientation sensor is available on a device
  42508. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42509. * @returns a promise that will resolve on orientation change
  42510. */
  42511. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42512. /**
  42513. * @hidden
  42514. */
  42515. _onDeviceOrientationChangedObservable: Observable<void>;
  42516. /**
  42517. * Instantiates a new input
  42518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42519. */
  42520. constructor();
  42521. /**
  42522. * Define the camera controlled by the input.
  42523. */
  42524. get camera(): FreeCamera;
  42525. set camera(camera: FreeCamera);
  42526. /**
  42527. * Attach the input controls to a specific dom element to get the input from.
  42528. * @param element Defines the element the controls should be listened from
  42529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42530. */
  42531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42532. private _orientationChanged;
  42533. private _deviceOrientation;
  42534. /**
  42535. * Detach the current controls from the specified dom element.
  42536. * @param element Defines the element to stop listening the inputs from
  42537. */
  42538. detachControl(element: Nullable<HTMLElement>): void;
  42539. /**
  42540. * Update the current camera state depending on the inputs that have been used this frame.
  42541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42542. */
  42543. checkInputs(): void;
  42544. /**
  42545. * Gets the class name of the current intput.
  42546. * @returns the class name
  42547. */
  42548. getClassName(): string;
  42549. /**
  42550. * Get the friendly name associated with the input class.
  42551. * @returns the input friendly name
  42552. */
  42553. getSimpleName(): string;
  42554. }
  42555. }
  42556. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42557. import { Nullable } from "babylonjs/types";
  42558. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42559. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42560. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42561. /**
  42562. * Manage the gamepad inputs to control a free camera.
  42563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42564. */
  42565. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42566. /**
  42567. * Define the camera the input is attached to.
  42568. */
  42569. camera: FreeCamera;
  42570. /**
  42571. * Define the Gamepad controlling the input
  42572. */
  42573. gamepad: Nullable<Gamepad>;
  42574. /**
  42575. * Defines the gamepad rotation sensiblity.
  42576. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42577. */
  42578. gamepadAngularSensibility: number;
  42579. /**
  42580. * Defines the gamepad move sensiblity.
  42581. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42582. */
  42583. gamepadMoveSensibility: number;
  42584. private _yAxisScale;
  42585. /**
  42586. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42587. */
  42588. get invertYAxis(): boolean;
  42589. set invertYAxis(value: boolean);
  42590. private _onGamepadConnectedObserver;
  42591. private _onGamepadDisconnectedObserver;
  42592. private _cameraTransform;
  42593. private _deltaTransform;
  42594. private _vector3;
  42595. private _vector2;
  42596. /**
  42597. * Attach the input controls to a specific dom element to get the input from.
  42598. * @param element Defines the element the controls should be listened from
  42599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42600. */
  42601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42602. /**
  42603. * Detach the current controls from the specified dom element.
  42604. * @param element Defines the element to stop listening the inputs from
  42605. */
  42606. detachControl(element: Nullable<HTMLElement>): void;
  42607. /**
  42608. * Update the current camera state depending on the inputs that have been used this frame.
  42609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42610. */
  42611. checkInputs(): void;
  42612. /**
  42613. * Gets the class name of the current intput.
  42614. * @returns the class name
  42615. */
  42616. getClassName(): string;
  42617. /**
  42618. * Get the friendly name associated with the input class.
  42619. * @returns the input friendly name
  42620. */
  42621. getSimpleName(): string;
  42622. }
  42623. }
  42624. declare module "babylonjs/Misc/virtualJoystick" {
  42625. import { Nullable } from "babylonjs/types";
  42626. import { Vector3 } from "babylonjs/Maths/math.vector";
  42627. /**
  42628. * Defines the potential axis of a Joystick
  42629. */
  42630. export enum JoystickAxis {
  42631. /** X axis */
  42632. X = 0,
  42633. /** Y axis */
  42634. Y = 1,
  42635. /** Z axis */
  42636. Z = 2
  42637. }
  42638. /**
  42639. * Class used to define virtual joystick (used in touch mode)
  42640. */
  42641. export class VirtualJoystick {
  42642. /**
  42643. * Gets or sets a boolean indicating that left and right values must be inverted
  42644. */
  42645. reverseLeftRight: boolean;
  42646. /**
  42647. * Gets or sets a boolean indicating that up and down values must be inverted
  42648. */
  42649. reverseUpDown: boolean;
  42650. /**
  42651. * Gets the offset value for the position (ie. the change of the position value)
  42652. */
  42653. deltaPosition: Vector3;
  42654. /**
  42655. * Gets a boolean indicating if the virtual joystick was pressed
  42656. */
  42657. pressed: boolean;
  42658. /**
  42659. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42660. */
  42661. static Canvas: Nullable<HTMLCanvasElement>;
  42662. private static _globalJoystickIndex;
  42663. private static vjCanvasContext;
  42664. private static vjCanvasWidth;
  42665. private static vjCanvasHeight;
  42666. private static halfWidth;
  42667. private _action;
  42668. private _axisTargetedByLeftAndRight;
  42669. private _axisTargetedByUpAndDown;
  42670. private _joystickSensibility;
  42671. private _inversedSensibility;
  42672. private _joystickPointerID;
  42673. private _joystickColor;
  42674. private _joystickPointerPos;
  42675. private _joystickPreviousPointerPos;
  42676. private _joystickPointerStartPos;
  42677. private _deltaJoystickVector;
  42678. private _leftJoystick;
  42679. private _touches;
  42680. private _onPointerDownHandlerRef;
  42681. private _onPointerMoveHandlerRef;
  42682. private _onPointerUpHandlerRef;
  42683. private _onResize;
  42684. /**
  42685. * Creates a new virtual joystick
  42686. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42687. */
  42688. constructor(leftJoystick?: boolean);
  42689. /**
  42690. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42691. * @param newJoystickSensibility defines the new sensibility
  42692. */
  42693. setJoystickSensibility(newJoystickSensibility: number): void;
  42694. private _onPointerDown;
  42695. private _onPointerMove;
  42696. private _onPointerUp;
  42697. /**
  42698. * Change the color of the virtual joystick
  42699. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42700. */
  42701. setJoystickColor(newColor: string): void;
  42702. /**
  42703. * Defines a callback to call when the joystick is touched
  42704. * @param action defines the callback
  42705. */
  42706. setActionOnTouch(action: () => any): void;
  42707. /**
  42708. * Defines which axis you'd like to control for left & right
  42709. * @param axis defines the axis to use
  42710. */
  42711. setAxisForLeftRight(axis: JoystickAxis): void;
  42712. /**
  42713. * Defines which axis you'd like to control for up & down
  42714. * @param axis defines the axis to use
  42715. */
  42716. setAxisForUpDown(axis: JoystickAxis): void;
  42717. private _drawVirtualJoystick;
  42718. /**
  42719. * Release internal HTML canvas
  42720. */
  42721. releaseCanvas(): void;
  42722. }
  42723. }
  42724. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42725. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42726. import { Nullable } from "babylonjs/types";
  42727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42729. module "babylonjs/Cameras/freeCameraInputsManager" {
  42730. interface FreeCameraInputsManager {
  42731. /**
  42732. * Add virtual joystick input support to the input manager.
  42733. * @returns the current input manager
  42734. */
  42735. addVirtualJoystick(): FreeCameraInputsManager;
  42736. }
  42737. }
  42738. /**
  42739. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42741. */
  42742. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42743. /**
  42744. * Defines the camera the input is attached to.
  42745. */
  42746. camera: FreeCamera;
  42747. private _leftjoystick;
  42748. private _rightjoystick;
  42749. /**
  42750. * Gets the left stick of the virtual joystick.
  42751. * @returns The virtual Joystick
  42752. */
  42753. getLeftJoystick(): VirtualJoystick;
  42754. /**
  42755. * Gets the right stick of the virtual joystick.
  42756. * @returns The virtual Joystick
  42757. */
  42758. getRightJoystick(): VirtualJoystick;
  42759. /**
  42760. * Update the current camera state depending on the inputs that have been used this frame.
  42761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42762. */
  42763. checkInputs(): void;
  42764. /**
  42765. * Attach the input controls to a specific dom element to get the input from.
  42766. * @param element Defines the element the controls should be listened from
  42767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42768. */
  42769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42770. /**
  42771. * Detach the current controls from the specified dom element.
  42772. * @param element Defines the element to stop listening the inputs from
  42773. */
  42774. detachControl(element: Nullable<HTMLElement>): void;
  42775. /**
  42776. * Gets the class name of the current intput.
  42777. * @returns the class name
  42778. */
  42779. getClassName(): string;
  42780. /**
  42781. * Get the friendly name associated with the input class.
  42782. * @returns the input friendly name
  42783. */
  42784. getSimpleName(): string;
  42785. }
  42786. }
  42787. declare module "babylonjs/Cameras/Inputs/index" {
  42788. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42789. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42790. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42791. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42792. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42793. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42794. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42795. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42796. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42797. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42798. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42799. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42800. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42801. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42802. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42803. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42804. }
  42805. declare module "babylonjs/Cameras/touchCamera" {
  42806. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42807. import { Scene } from "babylonjs/scene";
  42808. import { Vector3 } from "babylonjs/Maths/math.vector";
  42809. /**
  42810. * This represents a FPS type of camera controlled by touch.
  42811. * This is like a universal camera minus the Gamepad controls.
  42812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42813. */
  42814. export class TouchCamera extends FreeCamera {
  42815. /**
  42816. * Defines the touch sensibility for rotation.
  42817. * The higher the faster.
  42818. */
  42819. get touchAngularSensibility(): number;
  42820. set touchAngularSensibility(value: number);
  42821. /**
  42822. * Defines the touch sensibility for move.
  42823. * The higher the faster.
  42824. */
  42825. get touchMoveSensibility(): number;
  42826. set touchMoveSensibility(value: number);
  42827. /**
  42828. * Instantiates a new touch camera.
  42829. * This represents a FPS type of camera controlled by touch.
  42830. * This is like a universal camera minus the Gamepad controls.
  42831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42832. * @param name Define the name of the camera in the scene
  42833. * @param position Define the start position of the camera in the scene
  42834. * @param scene Define the scene the camera belongs to
  42835. */
  42836. constructor(name: string, position: Vector3, scene: Scene);
  42837. /**
  42838. * Gets the current object class name.
  42839. * @return the class name
  42840. */
  42841. getClassName(): string;
  42842. /** @hidden */
  42843. _setupInputs(): void;
  42844. }
  42845. }
  42846. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42848. import { Scene } from "babylonjs/scene";
  42849. import { Vector3 } from "babylonjs/Maths/math.vector";
  42850. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42851. import { Axis } from "babylonjs/Maths/math.axis";
  42852. /**
  42853. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42854. * being tilted forward or back and left or right.
  42855. */
  42856. export class DeviceOrientationCamera extends FreeCamera {
  42857. private _initialQuaternion;
  42858. private _quaternionCache;
  42859. private _tmpDragQuaternion;
  42860. private _disablePointerInputWhenUsingDeviceOrientation;
  42861. /**
  42862. * Creates a new device orientation camera
  42863. * @param name The name of the camera
  42864. * @param position The start position camera
  42865. * @param scene The scene the camera belongs to
  42866. */
  42867. constructor(name: string, position: Vector3, scene: Scene);
  42868. /**
  42869. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42870. */
  42871. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42872. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42873. private _dragFactor;
  42874. /**
  42875. * Enabled turning on the y axis when the orientation sensor is active
  42876. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42877. */
  42878. enableHorizontalDragging(dragFactor?: number): void;
  42879. /**
  42880. * Gets the current instance class name ("DeviceOrientationCamera").
  42881. * This helps avoiding instanceof at run time.
  42882. * @returns the class name
  42883. */
  42884. getClassName(): string;
  42885. /**
  42886. * @hidden
  42887. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42888. */
  42889. _checkInputs(): void;
  42890. /**
  42891. * Reset the camera to its default orientation on the specified axis only.
  42892. * @param axis The axis to reset
  42893. */
  42894. resetToCurrentRotation(axis?: Axis): void;
  42895. }
  42896. }
  42897. declare module "babylonjs/Gamepads/xboxGamepad" {
  42898. import { Observable } from "babylonjs/Misc/observable";
  42899. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42900. /**
  42901. * Defines supported buttons for XBox360 compatible gamepads
  42902. */
  42903. export enum Xbox360Button {
  42904. /** A */
  42905. A = 0,
  42906. /** B */
  42907. B = 1,
  42908. /** X */
  42909. X = 2,
  42910. /** Y */
  42911. Y = 3,
  42912. /** Left button */
  42913. LB = 4,
  42914. /** Right button */
  42915. RB = 5,
  42916. /** Back */
  42917. Back = 8,
  42918. /** Start */
  42919. Start = 9,
  42920. /** Left stick */
  42921. LeftStick = 10,
  42922. /** Right stick */
  42923. RightStick = 11
  42924. }
  42925. /** Defines values for XBox360 DPad */
  42926. export enum Xbox360Dpad {
  42927. /** Up */
  42928. Up = 12,
  42929. /** Down */
  42930. Down = 13,
  42931. /** Left */
  42932. Left = 14,
  42933. /** Right */
  42934. Right = 15
  42935. }
  42936. /**
  42937. * Defines a XBox360 gamepad
  42938. */
  42939. export class Xbox360Pad extends Gamepad {
  42940. private _leftTrigger;
  42941. private _rightTrigger;
  42942. private _onlefttriggerchanged;
  42943. private _onrighttriggerchanged;
  42944. private _onbuttondown;
  42945. private _onbuttonup;
  42946. private _ondpaddown;
  42947. private _ondpadup;
  42948. /** Observable raised when a button is pressed */
  42949. onButtonDownObservable: Observable<Xbox360Button>;
  42950. /** Observable raised when a button is released */
  42951. onButtonUpObservable: Observable<Xbox360Button>;
  42952. /** Observable raised when a pad is pressed */
  42953. onPadDownObservable: Observable<Xbox360Dpad>;
  42954. /** Observable raised when a pad is released */
  42955. onPadUpObservable: Observable<Xbox360Dpad>;
  42956. private _buttonA;
  42957. private _buttonB;
  42958. private _buttonX;
  42959. private _buttonY;
  42960. private _buttonBack;
  42961. private _buttonStart;
  42962. private _buttonLB;
  42963. private _buttonRB;
  42964. private _buttonLeftStick;
  42965. private _buttonRightStick;
  42966. private _dPadUp;
  42967. private _dPadDown;
  42968. private _dPadLeft;
  42969. private _dPadRight;
  42970. private _isXboxOnePad;
  42971. /**
  42972. * Creates a new XBox360 gamepad object
  42973. * @param id defines the id of this gamepad
  42974. * @param index defines its index
  42975. * @param gamepad defines the internal HTML gamepad object
  42976. * @param xboxOne defines if it is a XBox One gamepad
  42977. */
  42978. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42979. /**
  42980. * Defines the callback to call when left trigger is pressed
  42981. * @param callback defines the callback to use
  42982. */
  42983. onlefttriggerchanged(callback: (value: number) => void): void;
  42984. /**
  42985. * Defines the callback to call when right trigger is pressed
  42986. * @param callback defines the callback to use
  42987. */
  42988. onrighttriggerchanged(callback: (value: number) => void): void;
  42989. /**
  42990. * Gets the left trigger value
  42991. */
  42992. get leftTrigger(): number;
  42993. /**
  42994. * Sets the left trigger value
  42995. */
  42996. set leftTrigger(newValue: number);
  42997. /**
  42998. * Gets the right trigger value
  42999. */
  43000. get rightTrigger(): number;
  43001. /**
  43002. * Sets the right trigger value
  43003. */
  43004. set rightTrigger(newValue: number);
  43005. /**
  43006. * Defines the callback to call when a button is pressed
  43007. * @param callback defines the callback to use
  43008. */
  43009. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43010. /**
  43011. * Defines the callback to call when a button is released
  43012. * @param callback defines the callback to use
  43013. */
  43014. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43015. /**
  43016. * Defines the callback to call when a pad is pressed
  43017. * @param callback defines the callback to use
  43018. */
  43019. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43020. /**
  43021. * Defines the callback to call when a pad is released
  43022. * @param callback defines the callback to use
  43023. */
  43024. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43025. private _setButtonValue;
  43026. private _setDPadValue;
  43027. /**
  43028. * Gets the value of the `A` button
  43029. */
  43030. get buttonA(): number;
  43031. /**
  43032. * Sets the value of the `A` button
  43033. */
  43034. set buttonA(value: number);
  43035. /**
  43036. * Gets the value of the `B` button
  43037. */
  43038. get buttonB(): number;
  43039. /**
  43040. * Sets the value of the `B` button
  43041. */
  43042. set buttonB(value: number);
  43043. /**
  43044. * Gets the value of the `X` button
  43045. */
  43046. get buttonX(): number;
  43047. /**
  43048. * Sets the value of the `X` button
  43049. */
  43050. set buttonX(value: number);
  43051. /**
  43052. * Gets the value of the `Y` button
  43053. */
  43054. get buttonY(): number;
  43055. /**
  43056. * Sets the value of the `Y` button
  43057. */
  43058. set buttonY(value: number);
  43059. /**
  43060. * Gets the value of the `Start` button
  43061. */
  43062. get buttonStart(): number;
  43063. /**
  43064. * Sets the value of the `Start` button
  43065. */
  43066. set buttonStart(value: number);
  43067. /**
  43068. * Gets the value of the `Back` button
  43069. */
  43070. get buttonBack(): number;
  43071. /**
  43072. * Sets the value of the `Back` button
  43073. */
  43074. set buttonBack(value: number);
  43075. /**
  43076. * Gets the value of the `Left` button
  43077. */
  43078. get buttonLB(): number;
  43079. /**
  43080. * Sets the value of the `Left` button
  43081. */
  43082. set buttonLB(value: number);
  43083. /**
  43084. * Gets the value of the `Right` button
  43085. */
  43086. get buttonRB(): number;
  43087. /**
  43088. * Sets the value of the `Right` button
  43089. */
  43090. set buttonRB(value: number);
  43091. /**
  43092. * Gets the value of the Left joystick
  43093. */
  43094. get buttonLeftStick(): number;
  43095. /**
  43096. * Sets the value of the Left joystick
  43097. */
  43098. set buttonLeftStick(value: number);
  43099. /**
  43100. * Gets the value of the Right joystick
  43101. */
  43102. get buttonRightStick(): number;
  43103. /**
  43104. * Sets the value of the Right joystick
  43105. */
  43106. set buttonRightStick(value: number);
  43107. /**
  43108. * Gets the value of D-pad up
  43109. */
  43110. get dPadUp(): number;
  43111. /**
  43112. * Sets the value of D-pad up
  43113. */
  43114. set dPadUp(value: number);
  43115. /**
  43116. * Gets the value of D-pad down
  43117. */
  43118. get dPadDown(): number;
  43119. /**
  43120. * Sets the value of D-pad down
  43121. */
  43122. set dPadDown(value: number);
  43123. /**
  43124. * Gets the value of D-pad left
  43125. */
  43126. get dPadLeft(): number;
  43127. /**
  43128. * Sets the value of D-pad left
  43129. */
  43130. set dPadLeft(value: number);
  43131. /**
  43132. * Gets the value of D-pad right
  43133. */
  43134. get dPadRight(): number;
  43135. /**
  43136. * Sets the value of D-pad right
  43137. */
  43138. set dPadRight(value: number);
  43139. /**
  43140. * Force the gamepad to synchronize with device values
  43141. */
  43142. update(): void;
  43143. /**
  43144. * Disposes the gamepad
  43145. */
  43146. dispose(): void;
  43147. }
  43148. }
  43149. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43150. import { Observable } from "babylonjs/Misc/observable";
  43151. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43152. /**
  43153. * Defines supported buttons for DualShock compatible gamepads
  43154. */
  43155. export enum DualShockButton {
  43156. /** Cross */
  43157. Cross = 0,
  43158. /** Circle */
  43159. Circle = 1,
  43160. /** Square */
  43161. Square = 2,
  43162. /** Triangle */
  43163. Triangle = 3,
  43164. /** L1 */
  43165. L1 = 4,
  43166. /** R1 */
  43167. R1 = 5,
  43168. /** Share */
  43169. Share = 8,
  43170. /** Options */
  43171. Options = 9,
  43172. /** Left stick */
  43173. LeftStick = 10,
  43174. /** Right stick */
  43175. RightStick = 11
  43176. }
  43177. /** Defines values for DualShock DPad */
  43178. export enum DualShockDpad {
  43179. /** Up */
  43180. Up = 12,
  43181. /** Down */
  43182. Down = 13,
  43183. /** Left */
  43184. Left = 14,
  43185. /** Right */
  43186. Right = 15
  43187. }
  43188. /**
  43189. * Defines a DualShock gamepad
  43190. */
  43191. export class DualShockPad extends Gamepad {
  43192. private _leftTrigger;
  43193. private _rightTrigger;
  43194. private _onlefttriggerchanged;
  43195. private _onrighttriggerchanged;
  43196. private _onbuttondown;
  43197. private _onbuttonup;
  43198. private _ondpaddown;
  43199. private _ondpadup;
  43200. /** Observable raised when a button is pressed */
  43201. onButtonDownObservable: Observable<DualShockButton>;
  43202. /** Observable raised when a button is released */
  43203. onButtonUpObservable: Observable<DualShockButton>;
  43204. /** Observable raised when a pad is pressed */
  43205. onPadDownObservable: Observable<DualShockDpad>;
  43206. /** Observable raised when a pad is released */
  43207. onPadUpObservable: Observable<DualShockDpad>;
  43208. private _buttonCross;
  43209. private _buttonCircle;
  43210. private _buttonSquare;
  43211. private _buttonTriangle;
  43212. private _buttonShare;
  43213. private _buttonOptions;
  43214. private _buttonL1;
  43215. private _buttonR1;
  43216. private _buttonLeftStick;
  43217. private _buttonRightStick;
  43218. private _dPadUp;
  43219. private _dPadDown;
  43220. private _dPadLeft;
  43221. private _dPadRight;
  43222. /**
  43223. * Creates a new DualShock gamepad object
  43224. * @param id defines the id of this gamepad
  43225. * @param index defines its index
  43226. * @param gamepad defines the internal HTML gamepad object
  43227. */
  43228. constructor(id: string, index: number, gamepad: any);
  43229. /**
  43230. * Defines the callback to call when left trigger is pressed
  43231. * @param callback defines the callback to use
  43232. */
  43233. onlefttriggerchanged(callback: (value: number) => void): void;
  43234. /**
  43235. * Defines the callback to call when right trigger is pressed
  43236. * @param callback defines the callback to use
  43237. */
  43238. onrighttriggerchanged(callback: (value: number) => void): void;
  43239. /**
  43240. * Gets the left trigger value
  43241. */
  43242. get leftTrigger(): number;
  43243. /**
  43244. * Sets the left trigger value
  43245. */
  43246. set leftTrigger(newValue: number);
  43247. /**
  43248. * Gets the right trigger value
  43249. */
  43250. get rightTrigger(): number;
  43251. /**
  43252. * Sets the right trigger value
  43253. */
  43254. set rightTrigger(newValue: number);
  43255. /**
  43256. * Defines the callback to call when a button is pressed
  43257. * @param callback defines the callback to use
  43258. */
  43259. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43260. /**
  43261. * Defines the callback to call when a button is released
  43262. * @param callback defines the callback to use
  43263. */
  43264. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43265. /**
  43266. * Defines the callback to call when a pad is pressed
  43267. * @param callback defines the callback to use
  43268. */
  43269. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43270. /**
  43271. * Defines the callback to call when a pad is released
  43272. * @param callback defines the callback to use
  43273. */
  43274. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43275. private _setButtonValue;
  43276. private _setDPadValue;
  43277. /**
  43278. * Gets the value of the `Cross` button
  43279. */
  43280. get buttonCross(): number;
  43281. /**
  43282. * Sets the value of the `Cross` button
  43283. */
  43284. set buttonCross(value: number);
  43285. /**
  43286. * Gets the value of the `Circle` button
  43287. */
  43288. get buttonCircle(): number;
  43289. /**
  43290. * Sets the value of the `Circle` button
  43291. */
  43292. set buttonCircle(value: number);
  43293. /**
  43294. * Gets the value of the `Square` button
  43295. */
  43296. get buttonSquare(): number;
  43297. /**
  43298. * Sets the value of the `Square` button
  43299. */
  43300. set buttonSquare(value: number);
  43301. /**
  43302. * Gets the value of the `Triangle` button
  43303. */
  43304. get buttonTriangle(): number;
  43305. /**
  43306. * Sets the value of the `Triangle` button
  43307. */
  43308. set buttonTriangle(value: number);
  43309. /**
  43310. * Gets the value of the `Options` button
  43311. */
  43312. get buttonOptions(): number;
  43313. /**
  43314. * Sets the value of the `Options` button
  43315. */
  43316. set buttonOptions(value: number);
  43317. /**
  43318. * Gets the value of the `Share` button
  43319. */
  43320. get buttonShare(): number;
  43321. /**
  43322. * Sets the value of the `Share` button
  43323. */
  43324. set buttonShare(value: number);
  43325. /**
  43326. * Gets the value of the `L1` button
  43327. */
  43328. get buttonL1(): number;
  43329. /**
  43330. * Sets the value of the `L1` button
  43331. */
  43332. set buttonL1(value: number);
  43333. /**
  43334. * Gets the value of the `R1` button
  43335. */
  43336. get buttonR1(): number;
  43337. /**
  43338. * Sets the value of the `R1` button
  43339. */
  43340. set buttonR1(value: number);
  43341. /**
  43342. * Gets the value of the Left joystick
  43343. */
  43344. get buttonLeftStick(): number;
  43345. /**
  43346. * Sets the value of the Left joystick
  43347. */
  43348. set buttonLeftStick(value: number);
  43349. /**
  43350. * Gets the value of the Right joystick
  43351. */
  43352. get buttonRightStick(): number;
  43353. /**
  43354. * Sets the value of the Right joystick
  43355. */
  43356. set buttonRightStick(value: number);
  43357. /**
  43358. * Gets the value of D-pad up
  43359. */
  43360. get dPadUp(): number;
  43361. /**
  43362. * Sets the value of D-pad up
  43363. */
  43364. set dPadUp(value: number);
  43365. /**
  43366. * Gets the value of D-pad down
  43367. */
  43368. get dPadDown(): number;
  43369. /**
  43370. * Sets the value of D-pad down
  43371. */
  43372. set dPadDown(value: number);
  43373. /**
  43374. * Gets the value of D-pad left
  43375. */
  43376. get dPadLeft(): number;
  43377. /**
  43378. * Sets the value of D-pad left
  43379. */
  43380. set dPadLeft(value: number);
  43381. /**
  43382. * Gets the value of D-pad right
  43383. */
  43384. get dPadRight(): number;
  43385. /**
  43386. * Sets the value of D-pad right
  43387. */
  43388. set dPadRight(value: number);
  43389. /**
  43390. * Force the gamepad to synchronize with device values
  43391. */
  43392. update(): void;
  43393. /**
  43394. * Disposes the gamepad
  43395. */
  43396. dispose(): void;
  43397. }
  43398. }
  43399. declare module "babylonjs/Gamepads/gamepadManager" {
  43400. import { Observable } from "babylonjs/Misc/observable";
  43401. import { Nullable } from "babylonjs/types";
  43402. import { Scene } from "babylonjs/scene";
  43403. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43404. /**
  43405. * Manager for handling gamepads
  43406. */
  43407. export class GamepadManager {
  43408. private _scene?;
  43409. private _babylonGamepads;
  43410. private _oneGamepadConnected;
  43411. /** @hidden */
  43412. _isMonitoring: boolean;
  43413. private _gamepadEventSupported;
  43414. private _gamepadSupport?;
  43415. /**
  43416. * observable to be triggered when the gamepad controller has been connected
  43417. */
  43418. onGamepadConnectedObservable: Observable<Gamepad>;
  43419. /**
  43420. * observable to be triggered when the gamepad controller has been disconnected
  43421. */
  43422. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43423. private _onGamepadConnectedEvent;
  43424. private _onGamepadDisconnectedEvent;
  43425. /**
  43426. * Initializes the gamepad manager
  43427. * @param _scene BabylonJS scene
  43428. */
  43429. constructor(_scene?: Scene | undefined);
  43430. /**
  43431. * The gamepads in the game pad manager
  43432. */
  43433. get gamepads(): Gamepad[];
  43434. /**
  43435. * Get the gamepad controllers based on type
  43436. * @param type The type of gamepad controller
  43437. * @returns Nullable gamepad
  43438. */
  43439. getGamepadByType(type?: number): Nullable<Gamepad>;
  43440. /**
  43441. * Disposes the gamepad manager
  43442. */
  43443. dispose(): void;
  43444. private _addNewGamepad;
  43445. private _startMonitoringGamepads;
  43446. private _stopMonitoringGamepads;
  43447. /** @hidden */
  43448. _checkGamepadsStatus(): void;
  43449. private _updateGamepadObjects;
  43450. }
  43451. }
  43452. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43453. import { Nullable } from "babylonjs/types";
  43454. import { Scene } from "babylonjs/scene";
  43455. import { ISceneComponent } from "babylonjs/sceneComponent";
  43456. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43457. module "babylonjs/scene" {
  43458. interface Scene {
  43459. /** @hidden */
  43460. _gamepadManager: Nullable<GamepadManager>;
  43461. /**
  43462. * Gets the gamepad manager associated with the scene
  43463. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43464. */
  43465. gamepadManager: GamepadManager;
  43466. }
  43467. }
  43468. module "babylonjs/Cameras/freeCameraInputsManager" {
  43469. /**
  43470. * Interface representing a free camera inputs manager
  43471. */
  43472. interface FreeCameraInputsManager {
  43473. /**
  43474. * Adds gamepad input support to the FreeCameraInputsManager.
  43475. * @returns the FreeCameraInputsManager
  43476. */
  43477. addGamepad(): FreeCameraInputsManager;
  43478. }
  43479. }
  43480. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43481. /**
  43482. * Interface representing an arc rotate camera inputs manager
  43483. */
  43484. interface ArcRotateCameraInputsManager {
  43485. /**
  43486. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43487. * @returns the camera inputs manager
  43488. */
  43489. addGamepad(): ArcRotateCameraInputsManager;
  43490. }
  43491. }
  43492. /**
  43493. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43494. */
  43495. export class GamepadSystemSceneComponent implements ISceneComponent {
  43496. /**
  43497. * The component name helpfull to identify the component in the list of scene components.
  43498. */
  43499. readonly name: string;
  43500. /**
  43501. * The scene the component belongs to.
  43502. */
  43503. scene: Scene;
  43504. /**
  43505. * Creates a new instance of the component for the given scene
  43506. * @param scene Defines the scene to register the component in
  43507. */
  43508. constructor(scene: Scene);
  43509. /**
  43510. * Registers the component in a given scene
  43511. */
  43512. register(): void;
  43513. /**
  43514. * Rebuilds the elements related to this component in case of
  43515. * context lost for instance.
  43516. */
  43517. rebuild(): void;
  43518. /**
  43519. * Disposes the component and the associated ressources
  43520. */
  43521. dispose(): void;
  43522. private _beforeCameraUpdate;
  43523. }
  43524. }
  43525. declare module "babylonjs/Cameras/universalCamera" {
  43526. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43527. import { Scene } from "babylonjs/scene";
  43528. import { Vector3 } from "babylonjs/Maths/math.vector";
  43529. import "babylonjs/Gamepads/gamepadSceneComponent";
  43530. /**
  43531. * 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,
  43532. * which still works and will still be found in many Playgrounds.
  43533. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43534. */
  43535. export class UniversalCamera extends TouchCamera {
  43536. /**
  43537. * Defines the gamepad rotation sensiblity.
  43538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43539. */
  43540. get gamepadAngularSensibility(): number;
  43541. set gamepadAngularSensibility(value: number);
  43542. /**
  43543. * Defines the gamepad move sensiblity.
  43544. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43545. */
  43546. get gamepadMoveSensibility(): number;
  43547. set gamepadMoveSensibility(value: number);
  43548. /**
  43549. * 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,
  43550. * which still works and will still be found in many Playgrounds.
  43551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43552. * @param name Define the name of the camera in the scene
  43553. * @param position Define the start position of the camera in the scene
  43554. * @param scene Define the scene the camera belongs to
  43555. */
  43556. constructor(name: string, position: Vector3, scene: Scene);
  43557. /**
  43558. * Gets the current object class name.
  43559. * @return the class name
  43560. */
  43561. getClassName(): string;
  43562. }
  43563. }
  43564. declare module "babylonjs/Cameras/gamepadCamera" {
  43565. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43566. import { Scene } from "babylonjs/scene";
  43567. import { Vector3 } from "babylonjs/Maths/math.vector";
  43568. /**
  43569. * This represents a FPS type of camera. This is only here for back compat purpose.
  43570. * Please use the UniversalCamera instead as both are identical.
  43571. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43572. */
  43573. export class GamepadCamera extends UniversalCamera {
  43574. /**
  43575. * Instantiates a new Gamepad Camera
  43576. * This represents a FPS type of camera. This is only here for back compat purpose.
  43577. * Please use the UniversalCamera instead as both are identical.
  43578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43579. * @param name Define the name of the camera in the scene
  43580. * @param position Define the start position of the camera in the scene
  43581. * @param scene Define the scene the camera belongs to
  43582. */
  43583. constructor(name: string, position: Vector3, scene: Scene);
  43584. /**
  43585. * Gets the current object class name.
  43586. * @return the class name
  43587. */
  43588. getClassName(): string;
  43589. }
  43590. }
  43591. declare module "babylonjs/Shaders/pass.fragment" {
  43592. /** @hidden */
  43593. export var passPixelShader: {
  43594. name: string;
  43595. shader: string;
  43596. };
  43597. }
  43598. declare module "babylonjs/Shaders/passCube.fragment" {
  43599. /** @hidden */
  43600. export var passCubePixelShader: {
  43601. name: string;
  43602. shader: string;
  43603. };
  43604. }
  43605. declare module "babylonjs/PostProcesses/passPostProcess" {
  43606. import { Nullable } from "babylonjs/types";
  43607. import { Camera } from "babylonjs/Cameras/camera";
  43608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43609. import { Engine } from "babylonjs/Engines/engine";
  43610. import "babylonjs/Shaders/pass.fragment";
  43611. import "babylonjs/Shaders/passCube.fragment";
  43612. /**
  43613. * PassPostProcess which produces an output the same as it's input
  43614. */
  43615. export class PassPostProcess extends PostProcess {
  43616. /**
  43617. * Creates the PassPostProcess
  43618. * @param name The name of the effect.
  43619. * @param options The required width/height ratio to downsize to before computing the render pass.
  43620. * @param camera The camera to apply the render pass to.
  43621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43622. * @param engine The engine which the post process will be applied. (default: current engine)
  43623. * @param reusable If the post process can be reused on the same frame. (default: false)
  43624. * @param textureType The type of texture to be used when performing the post processing.
  43625. * @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)
  43626. */
  43627. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43628. }
  43629. /**
  43630. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43631. */
  43632. export class PassCubePostProcess extends PostProcess {
  43633. private _face;
  43634. /**
  43635. * Gets or sets the cube face to display.
  43636. * * 0 is +X
  43637. * * 1 is -X
  43638. * * 2 is +Y
  43639. * * 3 is -Y
  43640. * * 4 is +Z
  43641. * * 5 is -Z
  43642. */
  43643. get face(): number;
  43644. set face(value: number);
  43645. /**
  43646. * Creates the PassCubePostProcess
  43647. * @param name The name of the effect.
  43648. * @param options The required width/height ratio to downsize to before computing the render pass.
  43649. * @param camera The camera to apply the render pass to.
  43650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43651. * @param engine The engine which the post process will be applied. (default: current engine)
  43652. * @param reusable If the post process can be reused on the same frame. (default: false)
  43653. * @param textureType The type of texture to be used when performing the post processing.
  43654. * @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)
  43655. */
  43656. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43657. }
  43658. }
  43659. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43660. /** @hidden */
  43661. export var anaglyphPixelShader: {
  43662. name: string;
  43663. shader: string;
  43664. };
  43665. }
  43666. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43667. import { Engine } from "babylonjs/Engines/engine";
  43668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43669. import { Camera } from "babylonjs/Cameras/camera";
  43670. import "babylonjs/Shaders/anaglyph.fragment";
  43671. /**
  43672. * Postprocess used to generate anaglyphic rendering
  43673. */
  43674. export class AnaglyphPostProcess extends PostProcess {
  43675. private _passedProcess;
  43676. /**
  43677. * Creates a new AnaglyphPostProcess
  43678. * @param name defines postprocess name
  43679. * @param options defines creation options or target ratio scale
  43680. * @param rigCameras defines cameras using this postprocess
  43681. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43682. * @param engine defines hosting engine
  43683. * @param reusable defines if the postprocess will be reused multiple times per frame
  43684. */
  43685. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43686. }
  43687. }
  43688. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43689. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43690. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43691. import { Scene } from "babylonjs/scene";
  43692. import { Vector3 } from "babylonjs/Maths/math.vector";
  43693. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43694. /**
  43695. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43696. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43697. */
  43698. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43699. /**
  43700. * Creates a new AnaglyphArcRotateCamera
  43701. * @param name defines camera name
  43702. * @param alpha defines alpha angle (in radians)
  43703. * @param beta defines beta angle (in radians)
  43704. * @param radius defines radius
  43705. * @param target defines camera target
  43706. * @param interaxialDistance defines distance between each color axis
  43707. * @param scene defines the hosting scene
  43708. */
  43709. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43710. /**
  43711. * Gets camera class name
  43712. * @returns AnaglyphArcRotateCamera
  43713. */
  43714. getClassName(): string;
  43715. }
  43716. }
  43717. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43718. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43719. import { Scene } from "babylonjs/scene";
  43720. import { Vector3 } from "babylonjs/Maths/math.vector";
  43721. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43722. /**
  43723. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43724. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43725. */
  43726. export class AnaglyphFreeCamera extends FreeCamera {
  43727. /**
  43728. * Creates a new AnaglyphFreeCamera
  43729. * @param name defines camera name
  43730. * @param position defines initial position
  43731. * @param interaxialDistance defines distance between each color axis
  43732. * @param scene defines the hosting scene
  43733. */
  43734. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43735. /**
  43736. * Gets camera class name
  43737. * @returns AnaglyphFreeCamera
  43738. */
  43739. getClassName(): string;
  43740. }
  43741. }
  43742. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43743. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43744. import { Scene } from "babylonjs/scene";
  43745. import { Vector3 } from "babylonjs/Maths/math.vector";
  43746. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43747. /**
  43748. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43749. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43750. */
  43751. export class AnaglyphGamepadCamera extends GamepadCamera {
  43752. /**
  43753. * Creates a new AnaglyphGamepadCamera
  43754. * @param name defines camera name
  43755. * @param position defines initial position
  43756. * @param interaxialDistance defines distance between each color axis
  43757. * @param scene defines the hosting scene
  43758. */
  43759. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43760. /**
  43761. * Gets camera class name
  43762. * @returns AnaglyphGamepadCamera
  43763. */
  43764. getClassName(): string;
  43765. }
  43766. }
  43767. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43768. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43769. import { Scene } from "babylonjs/scene";
  43770. import { Vector3 } from "babylonjs/Maths/math.vector";
  43771. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43772. /**
  43773. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43774. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43775. */
  43776. export class AnaglyphUniversalCamera extends UniversalCamera {
  43777. /**
  43778. * Creates a new AnaglyphUniversalCamera
  43779. * @param name defines camera name
  43780. * @param position defines initial position
  43781. * @param interaxialDistance defines distance between each color axis
  43782. * @param scene defines the hosting scene
  43783. */
  43784. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43785. /**
  43786. * Gets camera class name
  43787. * @returns AnaglyphUniversalCamera
  43788. */
  43789. getClassName(): string;
  43790. }
  43791. }
  43792. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43793. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43794. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43795. import { Scene } from "babylonjs/scene";
  43796. import { Vector3 } from "babylonjs/Maths/math.vector";
  43797. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43798. /**
  43799. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43800. * @see http://doc.babylonjs.com/features/cameras
  43801. */
  43802. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43803. /**
  43804. * Creates a new StereoscopicArcRotateCamera
  43805. * @param name defines camera name
  43806. * @param alpha defines alpha angle (in radians)
  43807. * @param beta defines beta angle (in radians)
  43808. * @param radius defines radius
  43809. * @param target defines camera target
  43810. * @param interaxialDistance defines distance between each color axis
  43811. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43812. * @param scene defines the hosting scene
  43813. */
  43814. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43815. /**
  43816. * Gets camera class name
  43817. * @returns StereoscopicArcRotateCamera
  43818. */
  43819. getClassName(): string;
  43820. }
  43821. }
  43822. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43824. import { Scene } from "babylonjs/scene";
  43825. import { Vector3 } from "babylonjs/Maths/math.vector";
  43826. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43827. /**
  43828. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43829. * @see http://doc.babylonjs.com/features/cameras
  43830. */
  43831. export class StereoscopicFreeCamera extends FreeCamera {
  43832. /**
  43833. * Creates a new StereoscopicFreeCamera
  43834. * @param name defines camera name
  43835. * @param position defines initial position
  43836. * @param interaxialDistance defines distance between each color axis
  43837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43838. * @param scene defines the hosting scene
  43839. */
  43840. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43841. /**
  43842. * Gets camera class name
  43843. * @returns StereoscopicFreeCamera
  43844. */
  43845. getClassName(): string;
  43846. }
  43847. }
  43848. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43849. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43850. import { Scene } from "babylonjs/scene";
  43851. import { Vector3 } from "babylonjs/Maths/math.vector";
  43852. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43853. /**
  43854. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43855. * @see http://doc.babylonjs.com/features/cameras
  43856. */
  43857. export class StereoscopicGamepadCamera extends GamepadCamera {
  43858. /**
  43859. * Creates a new StereoscopicGamepadCamera
  43860. * @param name defines camera name
  43861. * @param position defines initial position
  43862. * @param interaxialDistance defines distance between each color axis
  43863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43864. * @param scene defines the hosting scene
  43865. */
  43866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43867. /**
  43868. * Gets camera class name
  43869. * @returns StereoscopicGamepadCamera
  43870. */
  43871. getClassName(): string;
  43872. }
  43873. }
  43874. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43875. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43876. import { Scene } from "babylonjs/scene";
  43877. import { Vector3 } from "babylonjs/Maths/math.vector";
  43878. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43879. /**
  43880. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43881. * @see http://doc.babylonjs.com/features/cameras
  43882. */
  43883. export class StereoscopicUniversalCamera extends UniversalCamera {
  43884. /**
  43885. * Creates a new StereoscopicUniversalCamera
  43886. * @param name defines camera name
  43887. * @param position defines initial position
  43888. * @param interaxialDistance defines distance between each color axis
  43889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43890. * @param scene defines the hosting scene
  43891. */
  43892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43893. /**
  43894. * Gets camera class name
  43895. * @returns StereoscopicUniversalCamera
  43896. */
  43897. getClassName(): string;
  43898. }
  43899. }
  43900. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43901. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43902. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43903. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43904. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43905. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43906. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43907. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43908. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43909. }
  43910. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43911. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43912. import { Scene } from "babylonjs/scene";
  43913. import { Vector3 } from "babylonjs/Maths/math.vector";
  43914. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43915. /**
  43916. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43917. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43918. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43919. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43920. */
  43921. export class VirtualJoysticksCamera extends FreeCamera {
  43922. /**
  43923. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43924. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43925. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43926. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43927. * @param name Define the name of the camera in the scene
  43928. * @param position Define the start position of the camera in the scene
  43929. * @param scene Define the scene the camera belongs to
  43930. */
  43931. constructor(name: string, position: Vector3, scene: Scene);
  43932. /**
  43933. * Gets the current object class name.
  43934. * @return the class name
  43935. */
  43936. getClassName(): string;
  43937. }
  43938. }
  43939. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43940. import { Matrix } from "babylonjs/Maths/math.vector";
  43941. /**
  43942. * This represents all the required metrics to create a VR camera.
  43943. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43944. */
  43945. export class VRCameraMetrics {
  43946. /**
  43947. * Define the horizontal resolution off the screen.
  43948. */
  43949. hResolution: number;
  43950. /**
  43951. * Define the vertical resolution off the screen.
  43952. */
  43953. vResolution: number;
  43954. /**
  43955. * Define the horizontal screen size.
  43956. */
  43957. hScreenSize: number;
  43958. /**
  43959. * Define the vertical screen size.
  43960. */
  43961. vScreenSize: number;
  43962. /**
  43963. * Define the vertical screen center position.
  43964. */
  43965. vScreenCenter: number;
  43966. /**
  43967. * Define the distance of the eyes to the screen.
  43968. */
  43969. eyeToScreenDistance: number;
  43970. /**
  43971. * Define the distance between both lenses
  43972. */
  43973. lensSeparationDistance: number;
  43974. /**
  43975. * Define the distance between both viewer's eyes.
  43976. */
  43977. interpupillaryDistance: number;
  43978. /**
  43979. * Define the distortion factor of the VR postprocess.
  43980. * Please, touch with care.
  43981. */
  43982. distortionK: number[];
  43983. /**
  43984. * Define the chromatic aberration correction factors for the VR post process.
  43985. */
  43986. chromaAbCorrection: number[];
  43987. /**
  43988. * Define the scale factor of the post process.
  43989. * The smaller the better but the slower.
  43990. */
  43991. postProcessScaleFactor: number;
  43992. /**
  43993. * Define an offset for the lens center.
  43994. */
  43995. lensCenterOffset: number;
  43996. /**
  43997. * Define if the current vr camera should compensate the distortion of the lense or not.
  43998. */
  43999. compensateDistortion: boolean;
  44000. /**
  44001. * Defines if multiview should be enabled when rendering (Default: false)
  44002. */
  44003. multiviewEnabled: boolean;
  44004. /**
  44005. * Gets the rendering aspect ratio based on the provided resolutions.
  44006. */
  44007. get aspectRatio(): number;
  44008. /**
  44009. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44010. */
  44011. get aspectRatioFov(): number;
  44012. /**
  44013. * @hidden
  44014. */
  44015. get leftHMatrix(): Matrix;
  44016. /**
  44017. * @hidden
  44018. */
  44019. get rightHMatrix(): Matrix;
  44020. /**
  44021. * @hidden
  44022. */
  44023. get leftPreViewMatrix(): Matrix;
  44024. /**
  44025. * @hidden
  44026. */
  44027. get rightPreViewMatrix(): Matrix;
  44028. /**
  44029. * Get the default VRMetrics based on the most generic setup.
  44030. * @returns the default vr metrics
  44031. */
  44032. static GetDefault(): VRCameraMetrics;
  44033. }
  44034. }
  44035. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44036. /** @hidden */
  44037. export var vrDistortionCorrectionPixelShader: {
  44038. name: string;
  44039. shader: string;
  44040. };
  44041. }
  44042. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44043. import { Camera } from "babylonjs/Cameras/camera";
  44044. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44045. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44046. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44047. /**
  44048. * VRDistortionCorrectionPostProcess used for mobile VR
  44049. */
  44050. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44051. private _isRightEye;
  44052. private _distortionFactors;
  44053. private _postProcessScaleFactor;
  44054. private _lensCenterOffset;
  44055. private _scaleIn;
  44056. private _scaleFactor;
  44057. private _lensCenter;
  44058. /**
  44059. * Initializes the VRDistortionCorrectionPostProcess
  44060. * @param name The name of the effect.
  44061. * @param camera The camera to apply the render pass to.
  44062. * @param isRightEye If this is for the right eye distortion
  44063. * @param vrMetrics All the required metrics for the VR camera
  44064. */
  44065. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44066. }
  44067. }
  44068. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44069. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44070. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44071. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44072. import { Scene } from "babylonjs/scene";
  44073. import { Vector3 } from "babylonjs/Maths/math.vector";
  44074. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44075. import "babylonjs/Cameras/RigModes/vrRigMode";
  44076. /**
  44077. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44078. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44079. */
  44080. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44081. /**
  44082. * Creates a new VRDeviceOrientationArcRotateCamera
  44083. * @param name defines camera name
  44084. * @param alpha defines the camera rotation along the logitudinal axis
  44085. * @param beta defines the camera rotation along the latitudinal axis
  44086. * @param radius defines the camera distance from its target
  44087. * @param target defines the camera target
  44088. * @param scene defines the scene the camera belongs to
  44089. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44090. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44091. */
  44092. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44093. /**
  44094. * Gets camera class name
  44095. * @returns VRDeviceOrientationArcRotateCamera
  44096. */
  44097. getClassName(): string;
  44098. }
  44099. }
  44100. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44101. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44103. import { Scene } from "babylonjs/scene";
  44104. import { Vector3 } from "babylonjs/Maths/math.vector";
  44105. import "babylonjs/Cameras/RigModes/vrRigMode";
  44106. /**
  44107. * Camera used to simulate VR rendering (based on FreeCamera)
  44108. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44109. */
  44110. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44111. /**
  44112. * Creates a new VRDeviceOrientationFreeCamera
  44113. * @param name defines camera name
  44114. * @param position defines the start position of the camera
  44115. * @param scene defines the scene the camera belongs to
  44116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44118. */
  44119. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44120. /**
  44121. * Gets camera class name
  44122. * @returns VRDeviceOrientationFreeCamera
  44123. */
  44124. getClassName(): string;
  44125. }
  44126. }
  44127. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44128. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44129. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44130. import { Scene } from "babylonjs/scene";
  44131. import { Vector3 } from "babylonjs/Maths/math.vector";
  44132. import "babylonjs/Gamepads/gamepadSceneComponent";
  44133. /**
  44134. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44135. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44136. */
  44137. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44138. /**
  44139. * Creates a new VRDeviceOrientationGamepadCamera
  44140. * @param name defines camera name
  44141. * @param position defines the start position of the camera
  44142. * @param scene defines the scene the camera belongs to
  44143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44145. */
  44146. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44147. /**
  44148. * Gets camera class name
  44149. * @returns VRDeviceOrientationGamepadCamera
  44150. */
  44151. getClassName(): string;
  44152. }
  44153. }
  44154. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44155. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44156. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44157. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44158. /** @hidden */
  44159. export var imageProcessingPixelShader: {
  44160. name: string;
  44161. shader: string;
  44162. };
  44163. }
  44164. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44165. import { Nullable } from "babylonjs/types";
  44166. import { Color4 } from "babylonjs/Maths/math.color";
  44167. import { Camera } from "babylonjs/Cameras/camera";
  44168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44170. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44172. import { Engine } from "babylonjs/Engines/engine";
  44173. import "babylonjs/Shaders/imageProcessing.fragment";
  44174. import "babylonjs/Shaders/postprocess.vertex";
  44175. /**
  44176. * ImageProcessingPostProcess
  44177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44178. */
  44179. export class ImageProcessingPostProcess extends PostProcess {
  44180. /**
  44181. * Default configuration related to image processing available in the PBR Material.
  44182. */
  44183. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44184. /**
  44185. * Gets the image processing configuration used either in this material.
  44186. */
  44187. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44188. /**
  44189. * Sets the Default image processing configuration used either in the this material.
  44190. *
  44191. * If sets to null, the scene one is in use.
  44192. */
  44193. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44194. /**
  44195. * Keep track of the image processing observer to allow dispose and replace.
  44196. */
  44197. private _imageProcessingObserver;
  44198. /**
  44199. * Attaches a new image processing configuration to the PBR Material.
  44200. * @param configuration
  44201. */
  44202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44203. /**
  44204. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44205. */
  44206. get colorCurves(): Nullable<ColorCurves>;
  44207. /**
  44208. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44209. */
  44210. set colorCurves(value: Nullable<ColorCurves>);
  44211. /**
  44212. * Gets wether the color curves effect is enabled.
  44213. */
  44214. get colorCurvesEnabled(): boolean;
  44215. /**
  44216. * Sets wether the color curves effect is enabled.
  44217. */
  44218. set colorCurvesEnabled(value: boolean);
  44219. /**
  44220. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44221. */
  44222. get colorGradingTexture(): Nullable<BaseTexture>;
  44223. /**
  44224. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44225. */
  44226. set colorGradingTexture(value: Nullable<BaseTexture>);
  44227. /**
  44228. * Gets wether the color grading effect is enabled.
  44229. */
  44230. get colorGradingEnabled(): boolean;
  44231. /**
  44232. * Gets wether the color grading effect is enabled.
  44233. */
  44234. set colorGradingEnabled(value: boolean);
  44235. /**
  44236. * Gets exposure used in the effect.
  44237. */
  44238. get exposure(): number;
  44239. /**
  44240. * Sets exposure used in the effect.
  44241. */
  44242. set exposure(value: number);
  44243. /**
  44244. * Gets wether tonemapping is enabled or not.
  44245. */
  44246. get toneMappingEnabled(): boolean;
  44247. /**
  44248. * Sets wether tonemapping is enabled or not
  44249. */
  44250. set toneMappingEnabled(value: boolean);
  44251. /**
  44252. * Gets the type of tone mapping effect.
  44253. */
  44254. get toneMappingType(): number;
  44255. /**
  44256. * Sets the type of tone mapping effect.
  44257. */
  44258. set toneMappingType(value: number);
  44259. /**
  44260. * Gets contrast used in the effect.
  44261. */
  44262. get contrast(): number;
  44263. /**
  44264. * Sets contrast used in the effect.
  44265. */
  44266. set contrast(value: number);
  44267. /**
  44268. * Gets Vignette stretch size.
  44269. */
  44270. get vignetteStretch(): number;
  44271. /**
  44272. * Sets Vignette stretch size.
  44273. */
  44274. set vignetteStretch(value: number);
  44275. /**
  44276. * Gets Vignette centre X Offset.
  44277. */
  44278. get vignetteCentreX(): number;
  44279. /**
  44280. * Sets Vignette centre X Offset.
  44281. */
  44282. set vignetteCentreX(value: number);
  44283. /**
  44284. * Gets Vignette centre Y Offset.
  44285. */
  44286. get vignetteCentreY(): number;
  44287. /**
  44288. * Sets Vignette centre Y Offset.
  44289. */
  44290. set vignetteCentreY(value: number);
  44291. /**
  44292. * Gets Vignette weight or intensity of the vignette effect.
  44293. */
  44294. get vignetteWeight(): number;
  44295. /**
  44296. * Sets Vignette weight or intensity of the vignette effect.
  44297. */
  44298. set vignetteWeight(value: number);
  44299. /**
  44300. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44301. * if vignetteEnabled is set to true.
  44302. */
  44303. get vignetteColor(): Color4;
  44304. /**
  44305. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44306. * if vignetteEnabled is set to true.
  44307. */
  44308. set vignetteColor(value: Color4);
  44309. /**
  44310. * Gets Camera field of view used by the Vignette effect.
  44311. */
  44312. get vignetteCameraFov(): number;
  44313. /**
  44314. * Sets Camera field of view used by the Vignette effect.
  44315. */
  44316. set vignetteCameraFov(value: number);
  44317. /**
  44318. * Gets the vignette blend mode allowing different kind of effect.
  44319. */
  44320. get vignetteBlendMode(): number;
  44321. /**
  44322. * Sets the vignette blend mode allowing different kind of effect.
  44323. */
  44324. set vignetteBlendMode(value: number);
  44325. /**
  44326. * Gets wether the vignette effect is enabled.
  44327. */
  44328. get vignetteEnabled(): boolean;
  44329. /**
  44330. * Sets wether the vignette effect is enabled.
  44331. */
  44332. set vignetteEnabled(value: boolean);
  44333. private _fromLinearSpace;
  44334. /**
  44335. * Gets wether the input of the processing is in Gamma or Linear Space.
  44336. */
  44337. get fromLinearSpace(): boolean;
  44338. /**
  44339. * Sets wether the input of the processing is in Gamma or Linear Space.
  44340. */
  44341. set fromLinearSpace(value: boolean);
  44342. /**
  44343. * Defines cache preventing GC.
  44344. */
  44345. private _defines;
  44346. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44347. /**
  44348. * "ImageProcessingPostProcess"
  44349. * @returns "ImageProcessingPostProcess"
  44350. */
  44351. getClassName(): string;
  44352. protected _updateParameters(): void;
  44353. dispose(camera?: Camera): void;
  44354. }
  44355. }
  44356. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44357. import { Scene } from "babylonjs/scene";
  44358. import { Color3 } from "babylonjs/Maths/math.color";
  44359. import { Mesh } from "babylonjs/Meshes/mesh";
  44360. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44361. import { Nullable } from "babylonjs/types";
  44362. /**
  44363. * Class containing static functions to help procedurally build meshes
  44364. */
  44365. export class GroundBuilder {
  44366. /**
  44367. * Creates a ground mesh
  44368. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44369. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44371. * @param name defines the name of the mesh
  44372. * @param options defines the options used to create the mesh
  44373. * @param scene defines the hosting scene
  44374. * @returns the ground mesh
  44375. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44376. */
  44377. static CreateGround(name: string, options: {
  44378. width?: number;
  44379. height?: number;
  44380. subdivisions?: number;
  44381. subdivisionsX?: number;
  44382. subdivisionsY?: number;
  44383. updatable?: boolean;
  44384. }, scene: any): Mesh;
  44385. /**
  44386. * Creates a tiled ground mesh
  44387. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44388. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44389. * * 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
  44390. * * 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
  44391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44392. * @param name defines the name of the mesh
  44393. * @param options defines the options used to create the mesh
  44394. * @param scene defines the hosting scene
  44395. * @returns the tiled ground mesh
  44396. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44397. */
  44398. static CreateTiledGround(name: string, options: {
  44399. xmin: number;
  44400. zmin: number;
  44401. xmax: number;
  44402. zmax: number;
  44403. subdivisions?: {
  44404. w: number;
  44405. h: number;
  44406. };
  44407. precision?: {
  44408. w: number;
  44409. h: number;
  44410. };
  44411. updatable?: boolean;
  44412. }, scene?: Nullable<Scene>): Mesh;
  44413. /**
  44414. * Creates a ground mesh from a height map
  44415. * * The parameter `url` sets the URL of the height map image resource.
  44416. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44417. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44418. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44419. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44420. * * 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.
  44421. * * 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).
  44422. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44424. * @param name defines the name of the mesh
  44425. * @param url defines the url to the height map
  44426. * @param options defines the options used to create the mesh
  44427. * @param scene defines the hosting scene
  44428. * @returns the ground mesh
  44429. * @see https://doc.babylonjs.com/babylon101/height_map
  44430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44431. */
  44432. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44433. width?: number;
  44434. height?: number;
  44435. subdivisions?: number;
  44436. minHeight?: number;
  44437. maxHeight?: number;
  44438. colorFilter?: Color3;
  44439. alphaFilter?: number;
  44440. updatable?: boolean;
  44441. onReady?: (mesh: GroundMesh) => void;
  44442. }, scene?: Nullable<Scene>): GroundMesh;
  44443. }
  44444. }
  44445. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44446. import { Vector4 } from "babylonjs/Maths/math.vector";
  44447. import { Mesh } from "babylonjs/Meshes/mesh";
  44448. /**
  44449. * Class containing static functions to help procedurally build meshes
  44450. */
  44451. export class TorusBuilder {
  44452. /**
  44453. * Creates a torus mesh
  44454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44460. * @param name defines the name of the mesh
  44461. * @param options defines the options used to create the mesh
  44462. * @param scene defines the hosting scene
  44463. * @returns the torus mesh
  44464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44465. */
  44466. static CreateTorus(name: string, options: {
  44467. diameter?: number;
  44468. thickness?: number;
  44469. tessellation?: number;
  44470. updatable?: boolean;
  44471. sideOrientation?: number;
  44472. frontUVs?: Vector4;
  44473. backUVs?: Vector4;
  44474. }, scene: any): Mesh;
  44475. }
  44476. }
  44477. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44478. import { Vector4 } from "babylonjs/Maths/math.vector";
  44479. import { Color4 } from "babylonjs/Maths/math.color";
  44480. import { Mesh } from "babylonjs/Meshes/mesh";
  44481. /**
  44482. * Class containing static functions to help procedurally build meshes
  44483. */
  44484. export class CylinderBuilder {
  44485. /**
  44486. * Creates a cylinder or a cone mesh
  44487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44489. * * 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.
  44490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44494. * * 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).
  44495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44496. * * 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).
  44497. * * 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
  44498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44499. * * 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
  44500. * * 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.
  44501. * * If `enclose` is false, a ring surface is one element.
  44502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44503. * * 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
  44504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44507. * @param name defines the name of the mesh
  44508. * @param options defines the options used to create the mesh
  44509. * @param scene defines the hosting scene
  44510. * @returns the cylinder mesh
  44511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44512. */
  44513. static CreateCylinder(name: string, options: {
  44514. height?: number;
  44515. diameterTop?: number;
  44516. diameterBottom?: number;
  44517. diameter?: number;
  44518. tessellation?: number;
  44519. subdivisions?: number;
  44520. arc?: number;
  44521. faceColors?: Color4[];
  44522. faceUV?: Vector4[];
  44523. updatable?: boolean;
  44524. hasRings?: boolean;
  44525. enclose?: boolean;
  44526. cap?: number;
  44527. sideOrientation?: number;
  44528. frontUVs?: Vector4;
  44529. backUVs?: Vector4;
  44530. }, scene: any): Mesh;
  44531. }
  44532. }
  44533. declare module "babylonjs/XR/webXRTypes" {
  44534. import { Nullable } from "babylonjs/types";
  44535. import { IDisposable } from "babylonjs/scene";
  44536. /**
  44537. * States of the webXR experience
  44538. */
  44539. export enum WebXRState {
  44540. /**
  44541. * Transitioning to being in XR mode
  44542. */
  44543. ENTERING_XR = 0,
  44544. /**
  44545. * Transitioning to non XR mode
  44546. */
  44547. EXITING_XR = 1,
  44548. /**
  44549. * In XR mode and presenting
  44550. */
  44551. IN_XR = 2,
  44552. /**
  44553. * Not entered XR mode
  44554. */
  44555. NOT_IN_XR = 3
  44556. }
  44557. /**
  44558. * Abstraction of the XR render target
  44559. */
  44560. export interface WebXRRenderTarget extends IDisposable {
  44561. /**
  44562. * xrpresent context of the canvas which can be used to display/mirror xr content
  44563. */
  44564. canvasContext: WebGLRenderingContext;
  44565. /**
  44566. * xr layer for the canvas
  44567. */
  44568. xrLayer: Nullable<XRWebGLLayer>;
  44569. /**
  44570. * Initializes the xr layer for the session
  44571. * @param xrSession xr session
  44572. * @returns a promise that will resolve once the XR Layer has been created
  44573. */
  44574. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44575. }
  44576. }
  44577. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44578. import { Nullable } from "babylonjs/types";
  44579. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44580. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44581. /**
  44582. * COnfiguration object for WebXR output canvas
  44583. */
  44584. export class WebXRManagedOutputCanvasOptions {
  44585. /**
  44586. * An optional canvas in case you wish to create it yourself and provide it here.
  44587. * If not provided, a new canvas will be created
  44588. */
  44589. canvasElement?: HTMLCanvasElement;
  44590. /**
  44591. * Options for this XR Layer output
  44592. */
  44593. canvasOptions?: XRWebGLLayerOptions;
  44594. /**
  44595. * CSS styling for a newly created canvas (if not provided)
  44596. */
  44597. newCanvasCssStyle?: string;
  44598. /**
  44599. * Get the default values of the configuration object
  44600. * @returns default values of this configuration object
  44601. */
  44602. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44603. }
  44604. /**
  44605. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44606. */
  44607. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44608. private _options;
  44609. private _canvas;
  44610. private _engine;
  44611. /**
  44612. * Rendering context of the canvas which can be used to display/mirror xr content
  44613. */
  44614. canvasContext: WebGLRenderingContext;
  44615. /**
  44616. * xr layer for the canvas
  44617. */
  44618. xrLayer: Nullable<XRWebGLLayer>;
  44619. /**
  44620. * Initializes the canvas to be added/removed upon entering/exiting xr
  44621. * @param _xrSessionManager The XR Session manager
  44622. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44623. */
  44624. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44625. /**
  44626. * Disposes of the object
  44627. */
  44628. dispose(): void;
  44629. /**
  44630. * Initializes the xr layer for the session
  44631. * @param xrSession xr session
  44632. * @returns a promise that will resolve once the XR Layer has been created
  44633. */
  44634. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44635. private _addCanvas;
  44636. private _removeCanvas;
  44637. private _setManagedOutputCanvas;
  44638. }
  44639. }
  44640. declare module "babylonjs/XR/webXRSessionManager" {
  44641. import { Observable } from "babylonjs/Misc/observable";
  44642. import { Nullable } from "babylonjs/types";
  44643. import { IDisposable, Scene } from "babylonjs/scene";
  44644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44645. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44646. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44647. /**
  44648. * Manages an XRSession to work with Babylon's engine
  44649. * @see https://doc.babylonjs.com/how_to/webxr
  44650. */
  44651. export class WebXRSessionManager implements IDisposable {
  44652. /** The scene which the session should be created for */
  44653. scene: Scene;
  44654. private _referenceSpace;
  44655. private _rttProvider;
  44656. private _sessionEnded;
  44657. private _xrNavigator;
  44658. private baseLayer;
  44659. /**
  44660. * The base reference space from which the session started. good if you want to reset your
  44661. * reference space
  44662. */
  44663. baseReferenceSpace: XRReferenceSpace;
  44664. /**
  44665. * Current XR frame
  44666. */
  44667. currentFrame: Nullable<XRFrame>;
  44668. /** WebXR timestamp updated every frame */
  44669. currentTimestamp: number;
  44670. /**
  44671. * Used just in case of a failure to initialize an immersive session.
  44672. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44673. */
  44674. defaultHeightCompensation: number;
  44675. /**
  44676. * Fires every time a new xrFrame arrives which can be used to update the camera
  44677. */
  44678. onXRFrameObservable: Observable<XRFrame>;
  44679. /**
  44680. * Fires when the reference space changed
  44681. */
  44682. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44683. /**
  44684. * Fires when the xr session is ended either by the device or manually done
  44685. */
  44686. onXRSessionEnded: Observable<any>;
  44687. /**
  44688. * Fires when the xr session is ended either by the device or manually done
  44689. */
  44690. onXRSessionInit: Observable<XRSession>;
  44691. /**
  44692. * Underlying xr session
  44693. */
  44694. session: XRSession;
  44695. /**
  44696. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44697. * or get the offset the player is currently at.
  44698. */
  44699. viewerReferenceSpace: XRReferenceSpace;
  44700. /**
  44701. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44702. * @param scene The scene which the session should be created for
  44703. */
  44704. constructor(
  44705. /** The scene which the session should be created for */
  44706. scene: Scene);
  44707. /**
  44708. * The current reference space used in this session. This reference space can constantly change!
  44709. * It is mainly used to offset the camera's position.
  44710. */
  44711. get referenceSpace(): XRReferenceSpace;
  44712. /**
  44713. * Set a new reference space and triggers the observable
  44714. */
  44715. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44716. /**
  44717. * Disposes of the session manager
  44718. */
  44719. dispose(): void;
  44720. /**
  44721. * Stops the xrSession and restores the render loop
  44722. * @returns Promise which resolves after it exits XR
  44723. */
  44724. exitXRAsync(): Promise<void>;
  44725. /**
  44726. * Gets the correct render target texture to be rendered this frame for this eye
  44727. * @param eye the eye for which to get the render target
  44728. * @returns the render target for the specified eye
  44729. */
  44730. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44731. /**
  44732. * Creates a WebXRRenderTarget object for the XR session
  44733. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44734. * @param options optional options to provide when creating a new render target
  44735. * @returns a WebXR render target to which the session can render
  44736. */
  44737. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44738. /**
  44739. * Initializes the manager
  44740. * After initialization enterXR can be called to start an XR session
  44741. * @returns Promise which resolves after it is initialized
  44742. */
  44743. initializeAsync(): Promise<void>;
  44744. /**
  44745. * Initializes an xr session
  44746. * @param xrSessionMode mode to initialize
  44747. * @param xrSessionInit defines optional and required values to pass to the session builder
  44748. * @returns a promise which will resolve once the session has been initialized
  44749. */
  44750. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44751. /**
  44752. * Checks if a session would be supported for the creation options specified
  44753. * @param sessionMode session mode to check if supported eg. immersive-vr
  44754. * @returns A Promise that resolves to true if supported and false if not
  44755. */
  44756. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44757. /**
  44758. * Resets the reference space to the one started the session
  44759. */
  44760. resetReferenceSpace(): void;
  44761. /**
  44762. * Starts rendering to the xr layer
  44763. */
  44764. runXRRenderLoop(): void;
  44765. /**
  44766. * Sets the reference space on the xr session
  44767. * @param referenceSpaceType space to set
  44768. * @returns a promise that will resolve once the reference space has been set
  44769. */
  44770. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44771. /**
  44772. * Updates the render state of the session
  44773. * @param state state to set
  44774. * @returns a promise that resolves once the render state has been updated
  44775. */
  44776. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44777. /**
  44778. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44779. * @param sessionMode defines the session to test
  44780. * @returns a promise with boolean as final value
  44781. */
  44782. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44783. private _createRenderTargetTexture;
  44784. }
  44785. }
  44786. declare module "babylonjs/XR/webXRCamera" {
  44787. import { Scene } from "babylonjs/scene";
  44788. import { Camera } from "babylonjs/Cameras/camera";
  44789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44790. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44791. /**
  44792. * WebXR Camera which holds the views for the xrSession
  44793. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44794. */
  44795. export class WebXRCamera extends FreeCamera {
  44796. private _xrSessionManager;
  44797. private _firstFrame;
  44798. private _referenceQuaternion;
  44799. private _referencedPosition;
  44800. private _xrInvPositionCache;
  44801. private _xrInvQuaternionCache;
  44802. /**
  44803. * Should position compensation execute on first frame.
  44804. * This is used when copying the position from a native (non XR) camera
  44805. */
  44806. compensateOnFirstFrame: boolean;
  44807. /**
  44808. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44809. * @param name the name of the camera
  44810. * @param scene the scene to add the camera to
  44811. * @param _xrSessionManager a constructed xr session manager
  44812. */
  44813. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44814. /**
  44815. * Return the user's height, unrelated to the current ground.
  44816. * This will be the y position of this camera, when ground level is 0.
  44817. */
  44818. get realWorldHeight(): number;
  44819. /** @hidden */
  44820. _updateForDualEyeDebugging(): void;
  44821. /**
  44822. * Sets this camera's transformation based on a non-vr camera
  44823. * @param otherCamera the non-vr camera to copy the transformation from
  44824. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44825. */
  44826. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44827. /**
  44828. * Gets the current instance class name ("WebXRCamera").
  44829. * @returns the class name
  44830. */
  44831. getClassName(): string;
  44832. private _updateFromXRSession;
  44833. private _updateNumberOfRigCameras;
  44834. private _updateReferenceSpace;
  44835. private _updateReferenceSpaceOffset;
  44836. }
  44837. }
  44838. declare module "babylonjs/XR/webXRFeaturesManager" {
  44839. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44840. import { IDisposable } from "babylonjs/scene";
  44841. /**
  44842. * Defining the interface required for a (webxr) feature
  44843. */
  44844. export interface IWebXRFeature extends IDisposable {
  44845. /**
  44846. * Is this feature attached
  44847. */
  44848. attached: boolean;
  44849. /**
  44850. * Should auto-attach be disabled?
  44851. */
  44852. disableAutoAttach: boolean;
  44853. /**
  44854. * Attach the feature to the session
  44855. * Will usually be called by the features manager
  44856. *
  44857. * @param force should attachment be forced (even when already attached)
  44858. * @returns true if successful.
  44859. */
  44860. attach(force?: boolean): boolean;
  44861. /**
  44862. * Detach the feature from the session
  44863. * Will usually be called by the features manager
  44864. *
  44865. * @returns true if successful.
  44866. */
  44867. detach(): boolean;
  44868. }
  44869. /**
  44870. * A list of the currently available features without referencing them
  44871. */
  44872. export class WebXRFeatureName {
  44873. /**
  44874. * The name of the anchor system feature
  44875. */
  44876. static ANCHOR_SYSTEM: string;
  44877. /**
  44878. * The name of the background remover feature
  44879. */
  44880. static BACKGROUND_REMOVER: string;
  44881. /**
  44882. * The name of the hit test feature
  44883. */
  44884. static HIT_TEST: string;
  44885. /**
  44886. * physics impostors for xr controllers feature
  44887. */
  44888. static PHYSICS_CONTROLLERS: string;
  44889. /**
  44890. * The name of the plane detection feature
  44891. */
  44892. static PLANE_DETECTION: string;
  44893. /**
  44894. * The name of the pointer selection feature
  44895. */
  44896. static POINTER_SELECTION: string;
  44897. /**
  44898. * The name of the teleportation feature
  44899. */
  44900. static TELEPORTATION: string;
  44901. }
  44902. /**
  44903. * Defining the constructor of a feature. Used to register the modules.
  44904. */
  44905. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44906. /**
  44907. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44908. * It is mainly used in AR sessions.
  44909. *
  44910. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44911. */
  44912. export class WebXRFeaturesManager implements IDisposable {
  44913. private _xrSessionManager;
  44914. private static readonly _AvailableFeatures;
  44915. private _features;
  44916. /**
  44917. * constructs a new features manages.
  44918. *
  44919. * @param _xrSessionManager an instance of WebXRSessionManager
  44920. */
  44921. constructor(_xrSessionManager: WebXRSessionManager);
  44922. /**
  44923. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44924. * Mainly used internally.
  44925. *
  44926. * @param featureName the name of the feature to register
  44927. * @param constructorFunction the function used to construct the module
  44928. * @param version the (babylon) version of the module
  44929. * @param stable is that a stable version of this module
  44930. */
  44931. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44932. /**
  44933. * Returns a constructor of a specific feature.
  44934. *
  44935. * @param featureName the name of the feature to construct
  44936. * @param version the version of the feature to load
  44937. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44938. * @param options optional options provided to the module.
  44939. * @returns a function that, when called, will return a new instance of this feature
  44940. */
  44941. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44942. /**
  44943. * Can be used to return the list of features currently registered
  44944. *
  44945. * @returns an Array of available features
  44946. */
  44947. static GetAvailableFeatures(): string[];
  44948. /**
  44949. * Gets the versions available for a specific feature
  44950. * @param featureName the name of the feature
  44951. * @returns an array with the available versions
  44952. */
  44953. static GetAvailableVersions(featureName: string): string[];
  44954. /**
  44955. * Return the latest unstable version of this feature
  44956. * @param featureName the name of the feature to search
  44957. * @returns the version number. if not found will return -1
  44958. */
  44959. static GetLatestVersionOfFeature(featureName: string): number;
  44960. /**
  44961. * Return the latest stable version of this feature
  44962. * @param featureName the name of the feature to search
  44963. * @returns the version number. if not found will return -1
  44964. */
  44965. static GetStableVersionOfFeature(featureName: string): number;
  44966. /**
  44967. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44968. * Can be used during a session to start a feature
  44969. * @param featureName the name of feature to attach
  44970. */
  44971. attachFeature(featureName: string): void;
  44972. /**
  44973. * Can be used inside a session or when the session ends to detach a specific feature
  44974. * @param featureName the name of the feature to detach
  44975. */
  44976. detachFeature(featureName: string): void;
  44977. /**
  44978. * Used to disable an already-enabled feature
  44979. * The feature will be disposed and will be recreated once enabled.
  44980. * @param featureName the feature to disable
  44981. * @returns true if disable was successful
  44982. */
  44983. disableFeature(featureName: string | {
  44984. Name: string;
  44985. }): boolean;
  44986. /**
  44987. * dispose this features manager
  44988. */
  44989. dispose(): void;
  44990. /**
  44991. * 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.
  44992. * 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.
  44993. *
  44994. * @param featureName the name of the feature to load or the class of the feature
  44995. * @param version optional version to load. if not provided the latest version will be enabled
  44996. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44997. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44998. * @returns a new constructed feature or throws an error if feature not found.
  44999. */
  45000. enableFeature(featureName: string | {
  45001. Name: string;
  45002. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45003. /**
  45004. * get the implementation of an enabled feature.
  45005. * @param featureName the name of the feature to load
  45006. * @returns the feature class, if found
  45007. */
  45008. getEnabledFeature(featureName: string): IWebXRFeature;
  45009. /**
  45010. * Get the list of enabled features
  45011. * @returns an array of enabled features
  45012. */
  45013. getEnabledFeatures(): string[];
  45014. }
  45015. }
  45016. declare module "babylonjs/XR/webXRExperienceHelper" {
  45017. import { Observable } from "babylonjs/Misc/observable";
  45018. import { IDisposable, Scene } from "babylonjs/scene";
  45019. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45020. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45021. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45022. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45023. /**
  45024. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45025. * @see https://doc.babylonjs.com/how_to/webxr
  45026. */
  45027. export class WebXRExperienceHelper implements IDisposable {
  45028. private scene;
  45029. private _nonVRCamera;
  45030. private _originalSceneAutoClear;
  45031. private _supported;
  45032. /**
  45033. * Camera used to render xr content
  45034. */
  45035. camera: WebXRCamera;
  45036. /** A features manager for this xr session */
  45037. featuresManager: WebXRFeaturesManager;
  45038. /**
  45039. * Observers registered here will be triggered after the camera's initial transformation is set
  45040. * This can be used to set a different ground level or an extra rotation.
  45041. *
  45042. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45043. * to the position set after this observable is done executing.
  45044. */
  45045. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45046. /**
  45047. * Fires when the state of the experience helper has changed
  45048. */
  45049. onStateChangedObservable: Observable<WebXRState>;
  45050. /** Session manager used to keep track of xr session */
  45051. sessionManager: WebXRSessionManager;
  45052. /**
  45053. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45054. */
  45055. state: WebXRState;
  45056. /**
  45057. * Creates a WebXRExperienceHelper
  45058. * @param scene The scene the helper should be created in
  45059. */
  45060. private constructor();
  45061. /**
  45062. * Creates the experience helper
  45063. * @param scene the scene to attach the experience helper to
  45064. * @returns a promise for the experience helper
  45065. */
  45066. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45067. /**
  45068. * Disposes of the experience helper
  45069. */
  45070. dispose(): void;
  45071. /**
  45072. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45073. * @param sessionMode options for the XR session
  45074. * @param referenceSpaceType frame of reference of the XR session
  45075. * @param renderTarget the output canvas that will be used to enter XR mode
  45076. * @returns promise that resolves after xr mode has entered
  45077. */
  45078. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  45079. /**
  45080. * Exits XR mode and returns the scene to its original state
  45081. * @returns promise that resolves after xr mode has exited
  45082. */
  45083. exitXRAsync(): Promise<void>;
  45084. private _nonXRToXRCamera;
  45085. private _setState;
  45086. }
  45087. }
  45088. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45089. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45090. import { Observable } from "babylonjs/Misc/observable";
  45091. import { IDisposable } from "babylonjs/scene";
  45092. /**
  45093. * X-Y values for axes in WebXR
  45094. */
  45095. export interface IWebXRMotionControllerAxesValue {
  45096. /**
  45097. * The value of the x axis
  45098. */
  45099. x: number;
  45100. /**
  45101. * The value of the y-axis
  45102. */
  45103. y: number;
  45104. }
  45105. /**
  45106. * changed / previous values for the values of this component
  45107. */
  45108. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45109. /**
  45110. * current (this frame) value
  45111. */
  45112. current: T;
  45113. /**
  45114. * previous (last change) value
  45115. */
  45116. previous: T;
  45117. }
  45118. /**
  45119. * Represents changes in the component between current frame and last values recorded
  45120. */
  45121. export interface IWebXRMotionControllerComponentChanges {
  45122. /**
  45123. * will be populated with previous and current values if axes changed
  45124. */
  45125. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45126. /**
  45127. * will be populated with previous and current values if pressed changed
  45128. */
  45129. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45130. /**
  45131. * will be populated with previous and current values if touched changed
  45132. */
  45133. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45134. /**
  45135. * will be populated with previous and current values if value changed
  45136. */
  45137. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45138. }
  45139. /**
  45140. * This class represents a single component (for example button or thumbstick) of a motion controller
  45141. */
  45142. export class WebXRControllerComponent implements IDisposable {
  45143. /**
  45144. * the id of this component
  45145. */
  45146. id: string;
  45147. /**
  45148. * the type of the component
  45149. */
  45150. type: MotionControllerComponentType;
  45151. private _buttonIndex;
  45152. private _axesIndices;
  45153. private _axes;
  45154. private _changes;
  45155. private _currentValue;
  45156. private _hasChanges;
  45157. private _pressed;
  45158. private _touched;
  45159. /**
  45160. * button component type
  45161. */
  45162. static BUTTON_TYPE: MotionControllerComponentType;
  45163. /**
  45164. * squeeze component type
  45165. */
  45166. static SQUEEZE_TYPE: MotionControllerComponentType;
  45167. /**
  45168. * Thumbstick component type
  45169. */
  45170. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45171. /**
  45172. * Touchpad component type
  45173. */
  45174. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45175. /**
  45176. * trigger component type
  45177. */
  45178. static TRIGGER_TYPE: MotionControllerComponentType;
  45179. /**
  45180. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45181. * the axes data changes
  45182. */
  45183. onAxisValueChangedObservable: Observable<{
  45184. x: number;
  45185. y: number;
  45186. }>;
  45187. /**
  45188. * Observers registered here will be triggered when the state of a button changes
  45189. * State change is either pressed / touched / value
  45190. */
  45191. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45192. /**
  45193. * Creates a new component for a motion controller.
  45194. * It is created by the motion controller itself
  45195. *
  45196. * @param id the id of this component
  45197. * @param type the type of the component
  45198. * @param _buttonIndex index in the buttons array of the gamepad
  45199. * @param _axesIndices indices of the values in the axes array of the gamepad
  45200. */
  45201. constructor(
  45202. /**
  45203. * the id of this component
  45204. */
  45205. id: string,
  45206. /**
  45207. * the type of the component
  45208. */
  45209. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45210. /**
  45211. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45212. */
  45213. get axes(): IWebXRMotionControllerAxesValue;
  45214. /**
  45215. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45216. */
  45217. get changes(): IWebXRMotionControllerComponentChanges;
  45218. /**
  45219. * Return whether or not the component changed the last frame
  45220. */
  45221. get hasChanges(): boolean;
  45222. /**
  45223. * is the button currently pressed
  45224. */
  45225. get pressed(): boolean;
  45226. /**
  45227. * is the button currently touched
  45228. */
  45229. get touched(): boolean;
  45230. /**
  45231. * Get the current value of this component
  45232. */
  45233. get value(): number;
  45234. /**
  45235. * Dispose this component
  45236. */
  45237. dispose(): void;
  45238. /**
  45239. * Are there axes correlating to this component
  45240. * @return true is axes data is available
  45241. */
  45242. isAxes(): boolean;
  45243. /**
  45244. * Is this component a button (hence - pressable)
  45245. * @returns true if can be pressed
  45246. */
  45247. isButton(): boolean;
  45248. /**
  45249. * update this component using the gamepad object it is in. Called on every frame
  45250. * @param nativeController the native gamepad controller object
  45251. */
  45252. update(nativeController: IMinimalMotionControllerObject): void;
  45253. }
  45254. }
  45255. declare module "babylonjs/Loading/sceneLoader" {
  45256. import { Observable } from "babylonjs/Misc/observable";
  45257. import { Nullable } from "babylonjs/types";
  45258. import { Scene } from "babylonjs/scene";
  45259. import { Engine } from "babylonjs/Engines/engine";
  45260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45261. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45262. import { AssetContainer } from "babylonjs/assetContainer";
  45263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45264. import { Skeleton } from "babylonjs/Bones/skeleton";
  45265. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45266. import { WebRequest } from "babylonjs/Misc/webRequest";
  45267. /**
  45268. * Class used to represent data loading progression
  45269. */
  45270. export class SceneLoaderProgressEvent {
  45271. /** defines if data length to load can be evaluated */
  45272. readonly lengthComputable: boolean;
  45273. /** defines the loaded data length */
  45274. readonly loaded: number;
  45275. /** defines the data length to load */
  45276. readonly total: number;
  45277. /**
  45278. * Create a new progress event
  45279. * @param lengthComputable defines if data length to load can be evaluated
  45280. * @param loaded defines the loaded data length
  45281. * @param total defines the data length to load
  45282. */
  45283. constructor(
  45284. /** defines if data length to load can be evaluated */
  45285. lengthComputable: boolean,
  45286. /** defines the loaded data length */
  45287. loaded: number,
  45288. /** defines the data length to load */
  45289. total: number);
  45290. /**
  45291. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45292. * @param event defines the source event
  45293. * @returns a new SceneLoaderProgressEvent
  45294. */
  45295. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45296. }
  45297. /**
  45298. * Interface used by SceneLoader plugins to define supported file extensions
  45299. */
  45300. export interface ISceneLoaderPluginExtensions {
  45301. /**
  45302. * Defines the list of supported extensions
  45303. */
  45304. [extension: string]: {
  45305. isBinary: boolean;
  45306. };
  45307. }
  45308. /**
  45309. * Interface used by SceneLoader plugin factory
  45310. */
  45311. export interface ISceneLoaderPluginFactory {
  45312. /**
  45313. * Defines the name of the factory
  45314. */
  45315. name: string;
  45316. /**
  45317. * Function called to create a new plugin
  45318. * @return the new plugin
  45319. */
  45320. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45321. /**
  45322. * The callback that returns true if the data can be directly loaded.
  45323. * @param data string containing the file data
  45324. * @returns if the data can be loaded directly
  45325. */
  45326. canDirectLoad?(data: string): boolean;
  45327. }
  45328. /**
  45329. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45330. */
  45331. export interface ISceneLoaderPluginBase {
  45332. /**
  45333. * The friendly name of this plugin.
  45334. */
  45335. name: string;
  45336. /**
  45337. * The file extensions supported by this plugin.
  45338. */
  45339. extensions: string | ISceneLoaderPluginExtensions;
  45340. /**
  45341. * The callback called when loading from a url.
  45342. * @param scene scene loading this url
  45343. * @param url url to load
  45344. * @param onSuccess callback called when the file successfully loads
  45345. * @param onProgress callback called while file is loading (if the server supports this mode)
  45346. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45347. * @param onError callback called when the file fails to load
  45348. * @returns a file request object
  45349. */
  45350. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45351. /**
  45352. * The callback called when loading from a file object.
  45353. * @param scene scene loading this file
  45354. * @param file defines the file to load
  45355. * @param onSuccess defines the callback to call when data is loaded
  45356. * @param onProgress defines the callback to call during loading process
  45357. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45358. * @param onError defines the callback to call when an error occurs
  45359. * @returns a file request object
  45360. */
  45361. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45362. /**
  45363. * The callback that returns true if the data can be directly loaded.
  45364. * @param data string containing the file data
  45365. * @returns if the data can be loaded directly
  45366. */
  45367. canDirectLoad?(data: string): boolean;
  45368. /**
  45369. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45370. * @param scene scene loading this data
  45371. * @param data string containing the data
  45372. * @returns data to pass to the plugin
  45373. */
  45374. directLoad?(scene: Scene, data: string): any;
  45375. /**
  45376. * The callback that allows custom handling of the root url based on the response url.
  45377. * @param rootUrl the original root url
  45378. * @param responseURL the response url if available
  45379. * @returns the new root url
  45380. */
  45381. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45382. }
  45383. /**
  45384. * Interface used to define a SceneLoader plugin
  45385. */
  45386. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45387. /**
  45388. * Import meshes into a scene.
  45389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45390. * @param scene The scene to import into
  45391. * @param data The data to import
  45392. * @param rootUrl The root url for scene and resources
  45393. * @param meshes The meshes array to import into
  45394. * @param particleSystems The particle systems array to import into
  45395. * @param skeletons The skeletons array to import into
  45396. * @param onError The callback when import fails
  45397. * @returns True if successful or false otherwise
  45398. */
  45399. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45400. /**
  45401. * Load into a scene.
  45402. * @param scene The scene to load into
  45403. * @param data The data to import
  45404. * @param rootUrl The root url for scene and resources
  45405. * @param onError The callback when import fails
  45406. * @returns True if successful or false otherwise
  45407. */
  45408. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45409. /**
  45410. * Load into an asset container.
  45411. * @param scene The scene to load into
  45412. * @param data The data to import
  45413. * @param rootUrl The root url for scene and resources
  45414. * @param onError The callback when import fails
  45415. * @returns The loaded asset container
  45416. */
  45417. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45418. }
  45419. /**
  45420. * Interface used to define an async SceneLoader plugin
  45421. */
  45422. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45423. /**
  45424. * Import meshes into a scene.
  45425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45426. * @param scene The scene to import into
  45427. * @param data The data to import
  45428. * @param rootUrl The root url for scene and resources
  45429. * @param onProgress The callback when the load progresses
  45430. * @param fileName Defines the name of the file to load
  45431. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45432. */
  45433. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45434. meshes: AbstractMesh[];
  45435. particleSystems: IParticleSystem[];
  45436. skeletons: Skeleton[];
  45437. animationGroups: AnimationGroup[];
  45438. }>;
  45439. /**
  45440. * Load into a scene.
  45441. * @param scene The scene to load into
  45442. * @param data The data to import
  45443. * @param rootUrl The root url for scene and resources
  45444. * @param onProgress The callback when the load progresses
  45445. * @param fileName Defines the name of the file to load
  45446. * @returns Nothing
  45447. */
  45448. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45449. /**
  45450. * Load into an asset container.
  45451. * @param scene The scene to load into
  45452. * @param data The data to import
  45453. * @param rootUrl The root url for scene and resources
  45454. * @param onProgress The callback when the load progresses
  45455. * @param fileName Defines the name of the file to load
  45456. * @returns The loaded asset container
  45457. */
  45458. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45459. }
  45460. /**
  45461. * Mode that determines how to handle old animation groups before loading new ones.
  45462. */
  45463. export enum SceneLoaderAnimationGroupLoadingMode {
  45464. /**
  45465. * Reset all old animations to initial state then dispose them.
  45466. */
  45467. Clean = 0,
  45468. /**
  45469. * Stop all old animations.
  45470. */
  45471. Stop = 1,
  45472. /**
  45473. * Restart old animations from first frame.
  45474. */
  45475. Sync = 2,
  45476. /**
  45477. * Old animations remains untouched.
  45478. */
  45479. NoSync = 3
  45480. }
  45481. /**
  45482. * Class used to load scene from various file formats using registered plugins
  45483. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45484. */
  45485. export class SceneLoader {
  45486. /**
  45487. * No logging while loading
  45488. */
  45489. static readonly NO_LOGGING: number;
  45490. /**
  45491. * Minimal logging while loading
  45492. */
  45493. static readonly MINIMAL_LOGGING: number;
  45494. /**
  45495. * Summary logging while loading
  45496. */
  45497. static readonly SUMMARY_LOGGING: number;
  45498. /**
  45499. * Detailled logging while loading
  45500. */
  45501. static readonly DETAILED_LOGGING: number;
  45502. /**
  45503. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45504. */
  45505. static get ForceFullSceneLoadingForIncremental(): boolean;
  45506. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45507. /**
  45508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45509. */
  45510. static get ShowLoadingScreen(): boolean;
  45511. static set ShowLoadingScreen(value: boolean);
  45512. /**
  45513. * Defines the current logging level (while loading the scene)
  45514. * @ignorenaming
  45515. */
  45516. static get loggingLevel(): number;
  45517. static set loggingLevel(value: number);
  45518. /**
  45519. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45520. */
  45521. static get CleanBoneMatrixWeights(): boolean;
  45522. static set CleanBoneMatrixWeights(value: boolean);
  45523. /**
  45524. * Event raised when a plugin is used to load a scene
  45525. */
  45526. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45527. private static _registeredPlugins;
  45528. private static _getDefaultPlugin;
  45529. private static _getPluginForExtension;
  45530. private static _getPluginForDirectLoad;
  45531. private static _getPluginForFilename;
  45532. private static _getDirectLoad;
  45533. private static _loadData;
  45534. private static _getFileInfo;
  45535. /**
  45536. * Gets a plugin that can load the given extension
  45537. * @param extension defines the extension to load
  45538. * @returns a plugin or null if none works
  45539. */
  45540. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45541. /**
  45542. * Gets a boolean indicating that the given extension can be loaded
  45543. * @param extension defines the extension to load
  45544. * @returns true if the extension is supported
  45545. */
  45546. static IsPluginForExtensionAvailable(extension: string): boolean;
  45547. /**
  45548. * Adds a new plugin to the list of registered plugins
  45549. * @param plugin defines the plugin to add
  45550. */
  45551. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45552. /**
  45553. * Import meshes into a scene
  45554. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45555. * @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)
  45556. * @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)
  45557. * @param scene the instance of BABYLON.Scene to append to
  45558. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45559. * @param onProgress a callback with a progress event for each file being loaded
  45560. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45561. * @param pluginExtension the extension used to determine the plugin
  45562. * @returns The loaded plugin
  45563. */
  45564. 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>;
  45565. /**
  45566. * Import meshes into a scene
  45567. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45568. * @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)
  45569. * @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)
  45570. * @param scene the instance of BABYLON.Scene to append to
  45571. * @param onProgress a callback with a progress event for each file being loaded
  45572. * @param pluginExtension the extension used to determine the plugin
  45573. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45574. */
  45575. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45576. meshes: AbstractMesh[];
  45577. particleSystems: IParticleSystem[];
  45578. skeletons: Skeleton[];
  45579. animationGroups: AnimationGroup[];
  45580. }>;
  45581. /**
  45582. * Load a scene
  45583. * @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)
  45584. * @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)
  45585. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45586. * @param onSuccess a callback with the scene when import succeeds
  45587. * @param onProgress a callback with a progress event for each file being loaded
  45588. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45589. * @param pluginExtension the extension used to determine the plugin
  45590. * @returns The loaded plugin
  45591. */
  45592. 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>;
  45593. /**
  45594. * Load a scene
  45595. * @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)
  45596. * @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)
  45597. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45598. * @param onProgress a callback with a progress event for each file being loaded
  45599. * @param pluginExtension the extension used to determine the plugin
  45600. * @returns The loaded scene
  45601. */
  45602. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45603. /**
  45604. * Append a scene
  45605. * @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)
  45606. * @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)
  45607. * @param scene is the instance of BABYLON.Scene to append to
  45608. * @param onSuccess a callback with the scene when import succeeds
  45609. * @param onProgress a callback with a progress event for each file being loaded
  45610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45611. * @param pluginExtension the extension used to determine the plugin
  45612. * @returns The loaded plugin
  45613. */
  45614. 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>;
  45615. /**
  45616. * Append a scene
  45617. * @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)
  45618. * @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)
  45619. * @param scene is the instance of BABYLON.Scene to append to
  45620. * @param onProgress a callback with a progress event for each file being loaded
  45621. * @param pluginExtension the extension used to determine the plugin
  45622. * @returns The given scene
  45623. */
  45624. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45625. /**
  45626. * Load a scene into an asset container
  45627. * @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)
  45628. * @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)
  45629. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45630. * @param onSuccess a callback with the scene when import succeeds
  45631. * @param onProgress a callback with a progress event for each file being loaded
  45632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45633. * @param pluginExtension the extension used to determine the plugin
  45634. * @returns The loaded plugin
  45635. */
  45636. 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>;
  45637. /**
  45638. * Load a scene into an asset container
  45639. * @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)
  45640. * @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)
  45641. * @param scene is the instance of Scene to append to
  45642. * @param onProgress a callback with a progress event for each file being loaded
  45643. * @param pluginExtension the extension used to determine the plugin
  45644. * @returns The loaded asset container
  45645. */
  45646. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45647. /**
  45648. * Import animations from a file into a scene
  45649. * @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)
  45650. * @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)
  45651. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45652. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45653. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45654. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45655. * @param onSuccess a callback with the scene when import succeeds
  45656. * @param onProgress a callback with a progress event for each file being loaded
  45657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45658. */
  45659. 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;
  45660. /**
  45661. * Import animations from a file into a scene
  45662. * @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)
  45663. * @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)
  45664. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45665. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45666. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45667. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45668. * @param onSuccess a callback with the scene when import succeeds
  45669. * @param onProgress a callback with a progress event for each file being loaded
  45670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45671. * @returns the updated scene with imported animations
  45672. */
  45673. 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>;
  45674. }
  45675. }
  45676. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45677. import { IDisposable, Scene } from "babylonjs/scene";
  45678. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45679. import { Observable } from "babylonjs/Misc/observable";
  45680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45681. import { Nullable } from "babylonjs/types";
  45682. /**
  45683. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45684. */
  45685. export type MotionControllerHandedness = "none" | "left" | "right";
  45686. /**
  45687. * The type of components available in motion controllers.
  45688. * This is not the name of the component.
  45689. */
  45690. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45691. /**
  45692. * The state of a controller component
  45693. */
  45694. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45695. /**
  45696. * The schema of motion controller layout.
  45697. * No object will be initialized using this interface
  45698. * This is used just to define the profile.
  45699. */
  45700. export interface IMotionControllerLayout {
  45701. /**
  45702. * Path to load the assets. Usually relative to the base path
  45703. */
  45704. assetPath: string;
  45705. /**
  45706. * Available components (unsorted)
  45707. */
  45708. components: {
  45709. /**
  45710. * A map of component Ids
  45711. */
  45712. [componentId: string]: {
  45713. /**
  45714. * The type of input the component outputs
  45715. */
  45716. type: MotionControllerComponentType;
  45717. /**
  45718. * The indices of this component in the gamepad object
  45719. */
  45720. gamepadIndices: {
  45721. /**
  45722. * Index of button
  45723. */
  45724. button?: number;
  45725. /**
  45726. * If available, index of x-axis
  45727. */
  45728. xAxis?: number;
  45729. /**
  45730. * If available, index of y-axis
  45731. */
  45732. yAxis?: number;
  45733. };
  45734. /**
  45735. * The mesh's root node name
  45736. */
  45737. rootNodeName: string;
  45738. /**
  45739. * Animation definitions for this model
  45740. */
  45741. visualResponses: {
  45742. [stateKey: string]: {
  45743. /**
  45744. * What property will be animated
  45745. */
  45746. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45747. /**
  45748. * What states influence this visual response
  45749. */
  45750. states: MotionControllerComponentStateType[];
  45751. /**
  45752. * Type of animation - movement or visibility
  45753. */
  45754. valueNodeProperty: "transform" | "visibility";
  45755. /**
  45756. * Base node name to move. Its position will be calculated according to the min and max nodes
  45757. */
  45758. valueNodeName?: string;
  45759. /**
  45760. * Minimum movement node
  45761. */
  45762. minNodeName?: string;
  45763. /**
  45764. * Max movement node
  45765. */
  45766. maxNodeName?: string;
  45767. };
  45768. };
  45769. /**
  45770. * If touch enabled, what is the name of node to display user feedback
  45771. */
  45772. touchPointNodeName?: string;
  45773. };
  45774. };
  45775. /**
  45776. * Is it xr standard mapping or not
  45777. */
  45778. gamepadMapping: "" | "xr-standard";
  45779. /**
  45780. * Base root node of this entire model
  45781. */
  45782. rootNodeName: string;
  45783. /**
  45784. * Defines the main button component id
  45785. */
  45786. selectComponentId: string;
  45787. }
  45788. /**
  45789. * A definition for the layout map in the input profile
  45790. */
  45791. export interface IMotionControllerLayoutMap {
  45792. /**
  45793. * Layouts with handedness type as a key
  45794. */
  45795. [handedness: string]: IMotionControllerLayout;
  45796. }
  45797. /**
  45798. * The XR Input profile schema
  45799. * Profiles can be found here:
  45800. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45801. */
  45802. export interface IMotionControllerProfile {
  45803. /**
  45804. * fallback profiles for this profileId
  45805. */
  45806. fallbackProfileIds: string[];
  45807. /**
  45808. * The layout map, with handedness as key
  45809. */
  45810. layouts: IMotionControllerLayoutMap;
  45811. /**
  45812. * The id of this profile
  45813. * correlates to the profile(s) in the xrInput.profiles array
  45814. */
  45815. profileId: string;
  45816. }
  45817. /**
  45818. * A helper-interface for the 3 meshes needed for controller button animation
  45819. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45820. */
  45821. export interface IMotionControllerButtonMeshMap {
  45822. /**
  45823. * the mesh that defines the pressed value mesh position.
  45824. * This is used to find the max-position of this button
  45825. */
  45826. pressedMesh: AbstractMesh;
  45827. /**
  45828. * the mesh that defines the unpressed value mesh position.
  45829. * This is used to find the min (or initial) position of this button
  45830. */
  45831. unpressedMesh: AbstractMesh;
  45832. /**
  45833. * The mesh that will be changed when value changes
  45834. */
  45835. valueMesh: AbstractMesh;
  45836. }
  45837. /**
  45838. * A helper-interface for the 3 meshes needed for controller axis animation.
  45839. * This will be expanded when touchpad animations are fully supported
  45840. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45841. */
  45842. export interface IMotionControllerMeshMap {
  45843. /**
  45844. * the mesh that defines the maximum value mesh position.
  45845. */
  45846. maxMesh?: AbstractMesh;
  45847. /**
  45848. * the mesh that defines the minimum value mesh position.
  45849. */
  45850. minMesh?: AbstractMesh;
  45851. /**
  45852. * The mesh that will be changed when axis value changes
  45853. */
  45854. valueMesh: AbstractMesh;
  45855. }
  45856. /**
  45857. * The elements needed for change-detection of the gamepad objects in motion controllers
  45858. */
  45859. export interface IMinimalMotionControllerObject {
  45860. /**
  45861. * Available axes of this controller
  45862. */
  45863. axes: number[];
  45864. /**
  45865. * An array of available buttons
  45866. */
  45867. buttons: Array<{
  45868. /**
  45869. * Value of the button/trigger
  45870. */
  45871. value: number;
  45872. /**
  45873. * If the button/trigger is currently touched
  45874. */
  45875. touched: boolean;
  45876. /**
  45877. * If the button/trigger is currently pressed
  45878. */
  45879. pressed: boolean;
  45880. }>;
  45881. /**
  45882. * EXPERIMENTAL haptic support.
  45883. */
  45884. hapticActuators?: Array<{
  45885. pulse: (value: number, duration: number) => Promise<boolean>;
  45886. }>;
  45887. }
  45888. /**
  45889. * An Abstract Motion controller
  45890. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45891. * Each component has an observable to check for changes in value and state
  45892. */
  45893. export abstract class WebXRAbstractMotionController implements IDisposable {
  45894. protected scene: Scene;
  45895. protected layout: IMotionControllerLayout;
  45896. /**
  45897. * The gamepad object correlating to this controller
  45898. */
  45899. gamepadObject: IMinimalMotionControllerObject;
  45900. /**
  45901. * handedness (left/right/none) of this controller
  45902. */
  45903. handedness: MotionControllerHandedness;
  45904. private _initComponent;
  45905. private _modelReady;
  45906. /**
  45907. * A map of components (WebXRControllerComponent) in this motion controller
  45908. * Components have a ComponentType and can also have both button and axis definitions
  45909. */
  45910. readonly components: {
  45911. [id: string]: WebXRControllerComponent;
  45912. };
  45913. /**
  45914. * Disable the model's animation. Can be set at any time.
  45915. */
  45916. disableAnimation: boolean;
  45917. /**
  45918. * Observers registered here will be triggered when the model of this controller is done loading
  45919. */
  45920. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45921. /**
  45922. * The profile id of this motion controller
  45923. */
  45924. abstract profileId: string;
  45925. /**
  45926. * The root mesh of the model. It is null if the model was not yet initialized
  45927. */
  45928. rootMesh: Nullable<AbstractMesh>;
  45929. /**
  45930. * constructs a new abstract motion controller
  45931. * @param scene the scene to which the model of the controller will be added
  45932. * @param layout The profile layout to load
  45933. * @param gamepadObject The gamepad object correlating to this controller
  45934. * @param handedness handedness (left/right/none) of this controller
  45935. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45936. */
  45937. constructor(scene: Scene, layout: IMotionControllerLayout,
  45938. /**
  45939. * The gamepad object correlating to this controller
  45940. */
  45941. gamepadObject: IMinimalMotionControllerObject,
  45942. /**
  45943. * handedness (left/right/none) of this controller
  45944. */
  45945. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  45946. /**
  45947. * Dispose this controller, the model mesh and all its components
  45948. */
  45949. dispose(): void;
  45950. /**
  45951. * Returns all components of specific type
  45952. * @param type the type to search for
  45953. * @return an array of components with this type
  45954. */
  45955. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45956. /**
  45957. * get a component based an its component id as defined in layout.components
  45958. * @param id the id of the component
  45959. * @returns the component correlates to the id or undefined if not found
  45960. */
  45961. getComponent(id: string): WebXRControllerComponent;
  45962. /**
  45963. * Get the list of components available in this motion controller
  45964. * @returns an array of strings correlating to available components
  45965. */
  45966. getComponentIds(): string[];
  45967. /**
  45968. * Get the first component of specific type
  45969. * @param type type of component to find
  45970. * @return a controller component or null if not found
  45971. */
  45972. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45973. /**
  45974. * Get the main (Select) component of this controller as defined in the layout
  45975. * @returns the main component of this controller
  45976. */
  45977. getMainComponent(): WebXRControllerComponent;
  45978. /**
  45979. * Loads the model correlating to this controller
  45980. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45981. * @returns A promise fulfilled with the result of the model loading
  45982. */
  45983. loadModel(): Promise<boolean>;
  45984. /**
  45985. * Update this model using the current XRFrame
  45986. * @param xrFrame the current xr frame to use and update the model
  45987. */
  45988. updateFromXRFrame(xrFrame: XRFrame): void;
  45989. /**
  45990. * Backwards compatibility due to a deeply-integrated typo
  45991. */
  45992. get handness(): XREye;
  45993. /**
  45994. * Pulse (vibrate) this controller
  45995. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  45996. * Consecutive calls to this function will cancel the last pulse call
  45997. *
  45998. * @param value the strength of the pulse in 0.0...1.0 range
  45999. * @param duration Duration of the pulse in milliseconds
  46000. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46001. * @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
  46002. */
  46003. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46004. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46005. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46006. /**
  46007. * Moves the axis on the controller mesh based on its current state
  46008. * @param axis the index of the axis
  46009. * @param axisValue the value of the axis which determines the meshes new position
  46010. * @hidden
  46011. */
  46012. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46013. /**
  46014. * Update the model itself with the current frame data
  46015. * @param xrFrame the frame to use for updating the model mesh
  46016. */
  46017. protected updateModel(xrFrame: XRFrame): void;
  46018. /**
  46019. * Get the filename and path for this controller's model
  46020. * @returns a map of filename and path
  46021. */
  46022. protected abstract _getFilenameAndPath(): {
  46023. filename: string;
  46024. path: string;
  46025. };
  46026. /**
  46027. * This function is called before the mesh is loaded. It checks for loading constraints.
  46028. * For example, this function can check if the GLB loader is available
  46029. * If this function returns false, the generic controller will be loaded instead
  46030. * @returns Is the client ready to load the mesh
  46031. */
  46032. protected abstract _getModelLoadingConstraints(): boolean;
  46033. /**
  46034. * This function will be called after the model was successfully loaded and can be used
  46035. * for mesh transformations before it is available for the user
  46036. * @param meshes the loaded meshes
  46037. */
  46038. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46039. /**
  46040. * Set the root mesh for this controller. Important for the WebXR controller class
  46041. * @param meshes the loaded meshes
  46042. */
  46043. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46044. /**
  46045. * A function executed each frame that updates the mesh (if needed)
  46046. * @param xrFrame the current xrFrame
  46047. */
  46048. protected abstract _updateModel(xrFrame: XRFrame): void;
  46049. private _getGenericFilenameAndPath;
  46050. private _getGenericParentMesh;
  46051. }
  46052. }
  46053. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46054. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46056. import { Scene } from "babylonjs/scene";
  46057. /**
  46058. * A generic trigger-only motion controller for WebXR
  46059. */
  46060. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46061. /**
  46062. * Static version of the profile id of this controller
  46063. */
  46064. static ProfileId: string;
  46065. profileId: string;
  46066. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46067. protected _getFilenameAndPath(): {
  46068. filename: string;
  46069. path: string;
  46070. };
  46071. protected _getModelLoadingConstraints(): boolean;
  46072. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46073. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46074. protected _updateModel(): void;
  46075. }
  46076. }
  46077. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46078. import { Vector4 } from "babylonjs/Maths/math.vector";
  46079. import { Mesh } from "babylonjs/Meshes/mesh";
  46080. import { Scene } from "babylonjs/scene";
  46081. import { Nullable } from "babylonjs/types";
  46082. /**
  46083. * Class containing static functions to help procedurally build meshes
  46084. */
  46085. export class SphereBuilder {
  46086. /**
  46087. * Creates a sphere mesh
  46088. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46089. * * 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`)
  46090. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46091. * * 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
  46092. * * 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)
  46093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46096. * @param name defines the name of the mesh
  46097. * @param options defines the options used to create the mesh
  46098. * @param scene defines the hosting scene
  46099. * @returns the sphere mesh
  46100. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46101. */
  46102. static CreateSphere(name: string, options: {
  46103. segments?: number;
  46104. diameter?: number;
  46105. diameterX?: number;
  46106. diameterY?: number;
  46107. diameterZ?: number;
  46108. arc?: number;
  46109. slice?: number;
  46110. sideOrientation?: number;
  46111. frontUVs?: Vector4;
  46112. backUVs?: Vector4;
  46113. updatable?: boolean;
  46114. }, scene?: Nullable<Scene>): Mesh;
  46115. }
  46116. }
  46117. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46119. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46120. import { Scene } from "babylonjs/scene";
  46121. /**
  46122. * A profiled motion controller has its profile loaded from an online repository.
  46123. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46124. */
  46125. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46126. private _repositoryUrl;
  46127. private _buttonMeshMapping;
  46128. private _touchDots;
  46129. /**
  46130. * The profile ID of this controller. Will be populated when the controller initializes.
  46131. */
  46132. profileId: string;
  46133. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46134. dispose(): void;
  46135. protected _getFilenameAndPath(): {
  46136. filename: string;
  46137. path: string;
  46138. };
  46139. protected _getModelLoadingConstraints(): boolean;
  46140. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46141. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46142. protected _updateModel(_xrFrame: XRFrame): void;
  46143. }
  46144. }
  46145. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46146. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46147. import { Scene } from "babylonjs/scene";
  46148. /**
  46149. * A construction function type to create a new controller based on an xrInput object
  46150. */
  46151. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46152. /**
  46153. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46154. *
  46155. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46156. * it should be replaced with auto-loaded controllers.
  46157. *
  46158. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46159. */
  46160. export class WebXRMotionControllerManager {
  46161. private static _AvailableControllers;
  46162. private static _Fallbacks;
  46163. private static _ProfileLoadingPromises;
  46164. private static _ProfilesList;
  46165. /**
  46166. * The base URL of the online controller repository. Can be changed at any time.
  46167. */
  46168. static BaseRepositoryUrl: string;
  46169. /**
  46170. * Which repository gets priority - local or online
  46171. */
  46172. static PrioritizeOnlineRepository: boolean;
  46173. /**
  46174. * Use the online repository, or use only locally-defined controllers
  46175. */
  46176. static UseOnlineRepository: boolean;
  46177. /**
  46178. * Clear the cache used for profile loading and reload when requested again
  46179. */
  46180. static ClearProfilesCache(): void;
  46181. /**
  46182. * Register the default fallbacks.
  46183. * This function is called automatically when this file is imported.
  46184. */
  46185. static DefaultFallbacks(): void;
  46186. /**
  46187. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46188. * @param profileId the profile to which a fallback needs to be found
  46189. * @return an array with corresponding fallback profiles
  46190. */
  46191. static FindFallbackWithProfileId(profileId: string): string[];
  46192. /**
  46193. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46194. * The order of search:
  46195. *
  46196. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46197. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46198. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46199. * 4) return the generic trigger controller if none were found
  46200. *
  46201. * @param xrInput the xrInput to which a new controller is initialized
  46202. * @param scene the scene to which the model will be added
  46203. * @param forceProfile force a certain profile for this controller
  46204. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46205. */
  46206. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46207. /**
  46208. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46209. *
  46210. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46211. *
  46212. * @param type the profile type to register
  46213. * @param constructFunction the function to be called when loading this profile
  46214. */
  46215. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46216. /**
  46217. * Register a fallback to a specific profile.
  46218. * @param profileId the profileId that will receive the fallbacks
  46219. * @param fallbacks A list of fallback profiles
  46220. */
  46221. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46222. /**
  46223. * Will update the list of profiles available in the repository
  46224. * @return a promise that resolves to a map of profiles available online
  46225. */
  46226. static UpdateProfilesList(): Promise<{
  46227. [profile: string]: string;
  46228. }>;
  46229. private static _LoadProfileFromRepository;
  46230. private static _LoadProfilesFromAvailableControllers;
  46231. }
  46232. }
  46233. declare module "babylonjs/XR/webXRInputSource" {
  46234. import { Observable } from "babylonjs/Misc/observable";
  46235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46236. import { Ray } from "babylonjs/Culling/ray";
  46237. import { Scene } from "babylonjs/scene";
  46238. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46239. /**
  46240. * Configuration options for the WebXR controller creation
  46241. */
  46242. export interface IWebXRControllerOptions {
  46243. /**
  46244. * Should the controller mesh be animated when a user interacts with it
  46245. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46246. */
  46247. disableMotionControllerAnimation?: boolean;
  46248. /**
  46249. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46250. */
  46251. doNotLoadControllerMesh?: boolean;
  46252. /**
  46253. * Force a specific controller type for this controller.
  46254. * This can be used when creating your own profile or when testing different controllers
  46255. */
  46256. forceControllerProfile?: string;
  46257. /**
  46258. * Defines a rendering group ID for meshes that will be loaded.
  46259. * This is for the default controllers only.
  46260. */
  46261. renderingGroupId?: number;
  46262. }
  46263. /**
  46264. * Represents an XR controller
  46265. */
  46266. export class WebXRInputSource {
  46267. private _scene;
  46268. /** The underlying input source for the controller */
  46269. inputSource: XRInputSource;
  46270. private _options;
  46271. private _tmpQuaternion;
  46272. private _tmpVector;
  46273. private _uniqueId;
  46274. /**
  46275. * 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
  46276. */
  46277. grip?: AbstractMesh;
  46278. /**
  46279. * If available, this is the gamepad object related to this controller.
  46280. * Using this object it is possible to get click events and trackpad changes of the
  46281. * webxr controller that is currently being used.
  46282. */
  46283. motionController?: WebXRAbstractMotionController;
  46284. /**
  46285. * Event that fires when the controller is removed/disposed.
  46286. * The object provided as event data is this controller, after associated assets were disposed.
  46287. * uniqueId is still available.
  46288. */
  46289. onDisposeObservable: Observable<WebXRInputSource>;
  46290. /**
  46291. * Will be triggered when the mesh associated with the motion controller is done loading.
  46292. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46293. * A shortened version of controller -> motion controller -> on mesh loaded.
  46294. */
  46295. onMeshLoadedObservable: Observable<AbstractMesh>;
  46296. /**
  46297. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46298. */
  46299. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46300. /**
  46301. * Pointer which can be used to select objects or attach a visible laser to
  46302. */
  46303. pointer: AbstractMesh;
  46304. /**
  46305. * Creates the controller
  46306. * @see https://doc.babylonjs.com/how_to/webxr
  46307. * @param _scene the scene which the controller should be associated to
  46308. * @param inputSource the underlying input source for the controller
  46309. * @param _options options for this controller creation
  46310. */
  46311. constructor(_scene: Scene,
  46312. /** The underlying input source for the controller */
  46313. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46314. /**
  46315. * Get this controllers unique id
  46316. */
  46317. get uniqueId(): string;
  46318. /**
  46319. * Disposes of the object
  46320. */
  46321. dispose(): void;
  46322. /**
  46323. * Gets a world space ray coming from the pointer or grip
  46324. * @param result the resulting ray
  46325. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46326. */
  46327. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46328. /**
  46329. * Updates the controller pose based on the given XRFrame
  46330. * @param xrFrame xr frame to update the pose with
  46331. * @param referenceSpace reference space to use
  46332. */
  46333. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46334. }
  46335. }
  46336. declare module "babylonjs/XR/webXRInput" {
  46337. import { Observable } from "babylonjs/Misc/observable";
  46338. import { IDisposable } from "babylonjs/scene";
  46339. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46340. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46341. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46342. /**
  46343. * The schema for initialization options of the XR Input class
  46344. */
  46345. export interface IWebXRInputOptions {
  46346. /**
  46347. * If set to true no model will be automatically loaded
  46348. */
  46349. doNotLoadControllerMeshes?: boolean;
  46350. /**
  46351. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46352. * If not found, the xr input profile data will be used.
  46353. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46354. */
  46355. forceInputProfile?: string;
  46356. /**
  46357. * Do not send a request to the controller repository to load the profile.
  46358. *
  46359. * Instead, use the controllers available in babylon itself.
  46360. */
  46361. disableOnlineControllerRepository?: boolean;
  46362. /**
  46363. * A custom URL for the controllers repository
  46364. */
  46365. customControllersRepositoryURL?: string;
  46366. /**
  46367. * Should the controller model's components not move according to the user input
  46368. */
  46369. disableControllerAnimation?: boolean;
  46370. /**
  46371. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46372. */
  46373. controllerOptions?: IWebXRControllerOptions;
  46374. }
  46375. /**
  46376. * XR input used to track XR inputs such as controllers/rays
  46377. */
  46378. export class WebXRInput implements IDisposable {
  46379. /**
  46380. * the xr session manager for this session
  46381. */
  46382. xrSessionManager: WebXRSessionManager;
  46383. /**
  46384. * the WebXR camera for this session. Mainly used for teleportation
  46385. */
  46386. xrCamera: WebXRCamera;
  46387. private readonly options;
  46388. /**
  46389. * XR controllers being tracked
  46390. */
  46391. controllers: Array<WebXRInputSource>;
  46392. private _frameObserver;
  46393. private _sessionEndedObserver;
  46394. private _sessionInitObserver;
  46395. /**
  46396. * Event when a controller has been connected/added
  46397. */
  46398. onControllerAddedObservable: Observable<WebXRInputSource>;
  46399. /**
  46400. * Event when a controller has been removed/disconnected
  46401. */
  46402. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46403. /**
  46404. * Initializes the WebXRInput
  46405. * @param xrSessionManager the xr session manager for this session
  46406. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46407. * @param options = initialization options for this xr input
  46408. */
  46409. constructor(
  46410. /**
  46411. * the xr session manager for this session
  46412. */
  46413. xrSessionManager: WebXRSessionManager,
  46414. /**
  46415. * the WebXR camera for this session. Mainly used for teleportation
  46416. */
  46417. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46418. private _onInputSourcesChange;
  46419. private _addAndRemoveControllers;
  46420. /**
  46421. * Disposes of the object
  46422. */
  46423. dispose(): void;
  46424. }
  46425. }
  46426. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46427. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46428. import { Observable, EventState } from "babylonjs/Misc/observable";
  46429. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46430. /**
  46431. * This is the base class for all WebXR features.
  46432. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46433. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46434. */
  46435. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46436. protected _xrSessionManager: WebXRSessionManager;
  46437. private _attached;
  46438. private _removeOnDetach;
  46439. /**
  46440. * Should auto-attach be disabled?
  46441. */
  46442. disableAutoAttach: boolean;
  46443. /**
  46444. * Construct a new (abstract) WebXR feature
  46445. * @param _xrSessionManager the xr session manager for this feature
  46446. */
  46447. constructor(_xrSessionManager: WebXRSessionManager);
  46448. /**
  46449. * Is this feature attached
  46450. */
  46451. get attached(): boolean;
  46452. /**
  46453. * attach this feature
  46454. *
  46455. * @param force should attachment be forced (even when already attached)
  46456. * @returns true if successful, false is failed or already attached
  46457. */
  46458. attach(force?: boolean): boolean;
  46459. /**
  46460. * detach this feature.
  46461. *
  46462. * @returns true if successful, false if failed or already detached
  46463. */
  46464. detach(): boolean;
  46465. /**
  46466. * Dispose this feature and all of the resources attached
  46467. */
  46468. dispose(): void;
  46469. /**
  46470. * This is used to register callbacks that will automatically be removed when detach is called.
  46471. * @param observable the observable to which the observer will be attached
  46472. * @param callback the callback to register
  46473. */
  46474. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46475. /**
  46476. * Code in this function will be executed on each xrFrame received from the browser.
  46477. * This function will not execute after the feature is detached.
  46478. * @param _xrFrame the current frame
  46479. */
  46480. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46481. }
  46482. }
  46483. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46484. import { IDisposable, Scene } from "babylonjs/scene";
  46485. import { Nullable } from "babylonjs/types";
  46486. import { Observable } from "babylonjs/Misc/observable";
  46487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46488. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46489. import { Camera } from "babylonjs/Cameras/camera";
  46490. /**
  46491. * Renders a layer on top of an existing scene
  46492. */
  46493. export class UtilityLayerRenderer implements IDisposable {
  46494. /** the original scene that will be rendered on top of */
  46495. originalScene: Scene;
  46496. private _pointerCaptures;
  46497. private _lastPointerEvents;
  46498. private static _DefaultUtilityLayer;
  46499. private static _DefaultKeepDepthUtilityLayer;
  46500. private _sharedGizmoLight;
  46501. private _renderCamera;
  46502. /**
  46503. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46504. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46505. * @returns the camera that is used when rendering the utility layer
  46506. */
  46507. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46508. /**
  46509. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46510. * @param cam the camera that should be used when rendering the utility layer
  46511. */
  46512. setRenderCamera(cam: Nullable<Camera>): void;
  46513. /**
  46514. * @hidden
  46515. * Light which used by gizmos to get light shading
  46516. */
  46517. _getSharedGizmoLight(): HemisphericLight;
  46518. /**
  46519. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46520. */
  46521. pickUtilitySceneFirst: boolean;
  46522. /**
  46523. * 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)
  46524. */
  46525. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46526. /**
  46527. * 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)
  46528. */
  46529. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46530. /**
  46531. * The scene that is rendered on top of the original scene
  46532. */
  46533. utilityLayerScene: Scene;
  46534. /**
  46535. * If the utility layer should automatically be rendered on top of existing scene
  46536. */
  46537. shouldRender: boolean;
  46538. /**
  46539. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46540. */
  46541. onlyCheckPointerDownEvents: boolean;
  46542. /**
  46543. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46544. */
  46545. processAllEvents: boolean;
  46546. /**
  46547. * Observable raised when the pointer move from the utility layer scene to the main scene
  46548. */
  46549. onPointerOutObservable: Observable<number>;
  46550. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46551. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46552. private _afterRenderObserver;
  46553. private _sceneDisposeObserver;
  46554. private _originalPointerObserver;
  46555. /**
  46556. * Instantiates a UtilityLayerRenderer
  46557. * @param originalScene the original scene that will be rendered on top of
  46558. * @param handleEvents boolean indicating if the utility layer should handle events
  46559. */
  46560. constructor(
  46561. /** the original scene that will be rendered on top of */
  46562. originalScene: Scene, handleEvents?: boolean);
  46563. private _notifyObservers;
  46564. /**
  46565. * Renders the utility layers scene on top of the original scene
  46566. */
  46567. render(): void;
  46568. /**
  46569. * Disposes of the renderer
  46570. */
  46571. dispose(): void;
  46572. private _updateCamera;
  46573. }
  46574. }
  46575. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46576. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46578. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46579. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46580. import { Scene } from "babylonjs/scene";
  46581. import { Nullable } from "babylonjs/types";
  46582. import { Color3 } from "babylonjs/Maths/math.color";
  46583. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46584. /**
  46585. * Options interface for the pointer selection module
  46586. */
  46587. export interface IWebXRControllerPointerSelectionOptions {
  46588. /**
  46589. * if provided, this scene will be used to render meshes.
  46590. */
  46591. customUtilityLayerScene?: Scene;
  46592. /**
  46593. * 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)
  46594. * If not disabled, the last picked point will be used to execute a pointer up event
  46595. * If disabled, pointer up event will be triggered right after the pointer down event.
  46596. * Used in screen and gaze target ray mode only
  46597. */
  46598. disablePointerUpOnTouchOut: boolean;
  46599. /**
  46600. * For gaze mode (time to select instead of press)
  46601. */
  46602. forceGazeMode: boolean;
  46603. /**
  46604. * 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
  46605. * to start a new countdown to the pointer down event.
  46606. * Defaults to 1.
  46607. */
  46608. gazeModePointerMovedFactor?: number;
  46609. /**
  46610. * Different button type to use instead of the main component
  46611. */
  46612. overrideButtonId?: string;
  46613. /**
  46614. * use this rendering group id for the meshes (optional)
  46615. */
  46616. renderingGroupId?: number;
  46617. /**
  46618. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46619. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46620. * 3000 means 3 seconds between pointing at something and selecting it
  46621. */
  46622. timeToSelect?: number;
  46623. /**
  46624. * Should meshes created here be added to a utility layer or the main scene
  46625. */
  46626. useUtilityLayer?: boolean;
  46627. /**
  46628. * the xr input to use with this pointer selection
  46629. */
  46630. xrInput: WebXRInput;
  46631. }
  46632. /**
  46633. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46634. */
  46635. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46636. private readonly _options;
  46637. private static _idCounter;
  46638. private _attachController;
  46639. private _controllers;
  46640. private _scene;
  46641. private _tmpVectorForPickCompare;
  46642. /**
  46643. * The module's name
  46644. */
  46645. static readonly Name: string;
  46646. /**
  46647. * The (Babylon) version of this module.
  46648. * This is an integer representing the implementation version.
  46649. * This number does not correspond to the WebXR specs version
  46650. */
  46651. static readonly Version: number;
  46652. /**
  46653. * Disable lighting on the laser pointer (so it will always be visible)
  46654. */
  46655. disablePointerLighting: boolean;
  46656. /**
  46657. * Disable lighting on the selection mesh (so it will always be visible)
  46658. */
  46659. disableSelectionMeshLighting: boolean;
  46660. /**
  46661. * Should the laser pointer be displayed
  46662. */
  46663. displayLaserPointer: boolean;
  46664. /**
  46665. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46666. */
  46667. displaySelectionMesh: boolean;
  46668. /**
  46669. * This color will be set to the laser pointer when selection is triggered
  46670. */
  46671. laserPointerPickedColor: Color3;
  46672. /**
  46673. * Default color of the laser pointer
  46674. */
  46675. lasterPointerDefaultColor: Color3;
  46676. /**
  46677. * default color of the selection ring
  46678. */
  46679. selectionMeshDefaultColor: Color3;
  46680. /**
  46681. * This color will be applied to the selection ring when selection is triggered
  46682. */
  46683. selectionMeshPickedColor: Color3;
  46684. /**
  46685. * Optional filter to be used for ray selection. This predicate shares behavior with
  46686. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46687. */
  46688. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46689. /**
  46690. * constructs a new background remover module
  46691. * @param _xrSessionManager the session manager for this module
  46692. * @param _options read-only options to be used in this module
  46693. */
  46694. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46695. /**
  46696. * attach this feature
  46697. * Will usually be called by the features manager
  46698. *
  46699. * @returns true if successful.
  46700. */
  46701. attach(): boolean;
  46702. /**
  46703. * detach this feature.
  46704. * Will usually be called by the features manager
  46705. *
  46706. * @returns true if successful.
  46707. */
  46708. detach(): boolean;
  46709. /**
  46710. * Will get the mesh under a specific pointer.
  46711. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46712. * @param controllerId the controllerId to check
  46713. * @returns The mesh under pointer or null if no mesh is under the pointer
  46714. */
  46715. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46716. /**
  46717. * Get the xr controller that correlates to the pointer id in the pointer event
  46718. *
  46719. * @param id the pointer id to search for
  46720. * @returns the controller that correlates to this id or null if not found
  46721. */
  46722. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46723. protected _onXRFrame(_xrFrame: XRFrame): void;
  46724. private _attachGazeMode;
  46725. private _attachScreenRayMode;
  46726. private _attachTrackedPointerRayMode;
  46727. private _convertNormalToDirectionOfRay;
  46728. private _detachController;
  46729. private _generateNewMeshPair;
  46730. private _pickingMoved;
  46731. private _updatePointerDistance;
  46732. }
  46733. }
  46734. declare module "babylonjs/XR/webXREnterExitUI" {
  46735. import { Nullable } from "babylonjs/types";
  46736. import { Observable } from "babylonjs/Misc/observable";
  46737. import { IDisposable, Scene } from "babylonjs/scene";
  46738. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46739. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46740. /**
  46741. * Button which can be used to enter a different mode of XR
  46742. */
  46743. export class WebXREnterExitUIButton {
  46744. /** button element */
  46745. element: HTMLElement;
  46746. /** XR initialization options for the button */
  46747. sessionMode: XRSessionMode;
  46748. /** Reference space type */
  46749. referenceSpaceType: XRReferenceSpaceType;
  46750. /**
  46751. * Creates a WebXREnterExitUIButton
  46752. * @param element button element
  46753. * @param sessionMode XR initialization session mode
  46754. * @param referenceSpaceType the type of reference space to be used
  46755. */
  46756. constructor(
  46757. /** button element */
  46758. element: HTMLElement,
  46759. /** XR initialization options for the button */
  46760. sessionMode: XRSessionMode,
  46761. /** Reference space type */
  46762. referenceSpaceType: XRReferenceSpaceType);
  46763. /**
  46764. * Extendable function which can be used to update the button's visuals when the state changes
  46765. * @param activeButton the current active button in the UI
  46766. */
  46767. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46768. }
  46769. /**
  46770. * Options to create the webXR UI
  46771. */
  46772. export class WebXREnterExitUIOptions {
  46773. /**
  46774. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46775. */
  46776. customButtons?: Array<WebXREnterExitUIButton>;
  46777. /**
  46778. * A reference space type to use when creating the default button.
  46779. * Default is local-floor
  46780. */
  46781. referenceSpaceType?: XRReferenceSpaceType;
  46782. /**
  46783. * Context to enter xr with
  46784. */
  46785. renderTarget?: Nullable<WebXRRenderTarget>;
  46786. /**
  46787. * A session mode to use when creating the default button.
  46788. * Default is immersive-vr
  46789. */
  46790. sessionMode?: XRSessionMode;
  46791. }
  46792. /**
  46793. * UI to allow the user to enter/exit XR mode
  46794. */
  46795. export class WebXREnterExitUI implements IDisposable {
  46796. private scene;
  46797. /** version of the options passed to this UI */
  46798. options: WebXREnterExitUIOptions;
  46799. private _activeButton;
  46800. private _buttons;
  46801. private _overlay;
  46802. /**
  46803. * Fired every time the active button is changed.
  46804. *
  46805. * When xr is entered via a button that launches xr that button will be the callback parameter
  46806. *
  46807. * When exiting xr the callback parameter will be null)
  46808. */
  46809. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46810. /**
  46811. *
  46812. * @param scene babylon scene object to use
  46813. * @param options (read-only) version of the options passed to this UI
  46814. */
  46815. private constructor();
  46816. /**
  46817. * Creates UI to allow the user to enter/exit XR mode
  46818. * @param scene the scene to add the ui to
  46819. * @param helper the xr experience helper to enter/exit xr with
  46820. * @param options options to configure the UI
  46821. * @returns the created ui
  46822. */
  46823. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46824. /**
  46825. * Disposes of the XR UI component
  46826. */
  46827. dispose(): void;
  46828. private _updateButtons;
  46829. }
  46830. }
  46831. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46832. import { Vector3 } from "babylonjs/Maths/math.vector";
  46833. import { Color4 } from "babylonjs/Maths/math.color";
  46834. import { Nullable } from "babylonjs/types";
  46835. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46836. import { Scene } from "babylonjs/scene";
  46837. /**
  46838. * Class containing static functions to help procedurally build meshes
  46839. */
  46840. export class LinesBuilder {
  46841. /**
  46842. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46843. * * 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
  46844. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46845. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46846. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46847. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46848. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46849. * * 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
  46850. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46853. * @param name defines the name of the new line system
  46854. * @param options defines the options used to create the line system
  46855. * @param scene defines the hosting scene
  46856. * @returns a new line system mesh
  46857. */
  46858. static CreateLineSystem(name: string, options: {
  46859. lines: Vector3[][];
  46860. updatable?: boolean;
  46861. instance?: Nullable<LinesMesh>;
  46862. colors?: Nullable<Color4[][]>;
  46863. useVertexAlpha?: boolean;
  46864. }, scene: Nullable<Scene>): LinesMesh;
  46865. /**
  46866. * Creates a line mesh
  46867. * 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
  46868. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46869. * * The parameter `points` is an array successive Vector3
  46870. * * 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
  46871. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46872. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46873. * * When updating an instance, remember that only point positions can change, not the number of points
  46874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46876. * @param name defines the name of the new line system
  46877. * @param options defines the options used to create the line system
  46878. * @param scene defines the hosting scene
  46879. * @returns a new line mesh
  46880. */
  46881. static CreateLines(name: string, options: {
  46882. points: Vector3[];
  46883. updatable?: boolean;
  46884. instance?: Nullable<LinesMesh>;
  46885. colors?: Color4[];
  46886. useVertexAlpha?: boolean;
  46887. }, scene?: Nullable<Scene>): LinesMesh;
  46888. /**
  46889. * Creates a dashed line mesh
  46890. * * 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
  46891. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46892. * * The parameter `points` is an array successive Vector3
  46893. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46894. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46895. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46896. * * 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
  46897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46898. * * When updating an instance, remember that only point positions can change, not the number of points
  46899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46900. * @param name defines the name of the mesh
  46901. * @param options defines the options used to create the mesh
  46902. * @param scene defines the hosting scene
  46903. * @returns the dashed line mesh
  46904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46905. */
  46906. static CreateDashedLines(name: string, options: {
  46907. points: Vector3[];
  46908. dashSize?: number;
  46909. gapSize?: number;
  46910. dashNb?: number;
  46911. updatable?: boolean;
  46912. instance?: LinesMesh;
  46913. useVertexAlpha?: boolean;
  46914. }, scene?: Nullable<Scene>): LinesMesh;
  46915. }
  46916. }
  46917. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46918. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46919. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46920. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46922. import { Vector3 } from "babylonjs/Maths/math.vector";
  46923. import { Material } from "babylonjs/Materials/material";
  46924. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46925. import { Scene } from "babylonjs/scene";
  46926. /**
  46927. * The options container for the teleportation module
  46928. */
  46929. export interface IWebXRTeleportationOptions {
  46930. /**
  46931. * if provided, this scene will be used to render meshes.
  46932. */
  46933. customUtilityLayerScene?: Scene;
  46934. /**
  46935. * Values to configure the default target mesh
  46936. */
  46937. defaultTargetMeshOptions?: {
  46938. /**
  46939. * Fill color of the teleportation area
  46940. */
  46941. teleportationFillColor?: string;
  46942. /**
  46943. * Border color for the teleportation area
  46944. */
  46945. teleportationBorderColor?: string;
  46946. /**
  46947. * Disable the mesh's animation sequence
  46948. */
  46949. disableAnimation?: boolean;
  46950. /**
  46951. * Disable lighting on the material or the ring and arrow
  46952. */
  46953. disableLighting?: boolean;
  46954. /**
  46955. * Override the default material of the torus and arrow
  46956. */
  46957. torusArrowMaterial?: Material;
  46958. };
  46959. /**
  46960. * A list of meshes to use as floor meshes.
  46961. * Meshes can be added and removed after initializing the feature using the
  46962. * addFloorMesh and removeFloorMesh functions
  46963. * If empty, rotation will still work
  46964. */
  46965. floorMeshes?: AbstractMesh[];
  46966. /**
  46967. * use this rendering group id for the meshes (optional)
  46968. */
  46969. renderingGroupId?: number;
  46970. /**
  46971. * Should teleportation move only to snap points
  46972. */
  46973. snapPointsOnly?: boolean;
  46974. /**
  46975. * An array of points to which the teleportation will snap to.
  46976. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46977. */
  46978. snapPositions?: Vector3[];
  46979. /**
  46980. * How close should the teleportation ray be in order to snap to position.
  46981. * Default to 0.8 units (meters)
  46982. */
  46983. snapToPositionRadius?: number;
  46984. /**
  46985. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46986. * If you want to support rotation, make sure your mesh has a direction indicator.
  46987. *
  46988. * When left untouched, the default mesh will be initialized.
  46989. */
  46990. teleportationTargetMesh?: AbstractMesh;
  46991. /**
  46992. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46993. */
  46994. timeToTeleport?: number;
  46995. /**
  46996. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46997. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46998. */
  46999. useMainComponentOnly?: boolean;
  47000. /**
  47001. * Should meshes created here be added to a utility layer or the main scene
  47002. */
  47003. useUtilityLayer?: boolean;
  47004. /**
  47005. * Babylon XR Input class for controller
  47006. */
  47007. xrInput: WebXRInput;
  47008. }
  47009. /**
  47010. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47011. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47012. * the input of the attached controllers.
  47013. */
  47014. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47015. private _options;
  47016. private _controllers;
  47017. private _currentTeleportationControllerId;
  47018. private _floorMeshes;
  47019. private _quadraticBezierCurve;
  47020. private _selectionFeature;
  47021. private _snapToPositions;
  47022. private _snappedToPoint;
  47023. private _teleportationRingMaterial?;
  47024. private _tmpRay;
  47025. private _tmpVector;
  47026. /**
  47027. * The module's name
  47028. */
  47029. static readonly Name: string;
  47030. /**
  47031. * The (Babylon) version of this module.
  47032. * This is an integer representing the implementation version.
  47033. * This number does not correspond to the webxr specs version
  47034. */
  47035. static readonly Version: number;
  47036. /**
  47037. * Is movement backwards enabled
  47038. */
  47039. backwardsMovementEnabled: boolean;
  47040. /**
  47041. * Distance to travel when moving backwards
  47042. */
  47043. backwardsTeleportationDistance: number;
  47044. /**
  47045. * The distance from the user to the inspection point in the direction of the controller
  47046. * A higher number will allow the user to move further
  47047. * defaults to 5 (meters, in xr units)
  47048. */
  47049. parabolicCheckRadius: number;
  47050. /**
  47051. * Should the module support parabolic ray on top of direct ray
  47052. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47053. * Very helpful when moving between floors / different heights
  47054. */
  47055. parabolicRayEnabled: boolean;
  47056. /**
  47057. * How much rotation should be applied when rotating right and left
  47058. */
  47059. rotationAngle: number;
  47060. /**
  47061. * Is rotation enabled when moving forward?
  47062. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47063. */
  47064. rotationEnabled: boolean;
  47065. /**
  47066. * constructs a new anchor system
  47067. * @param _xrSessionManager an instance of WebXRSessionManager
  47068. * @param _options configuration object for this feature
  47069. */
  47070. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47071. /**
  47072. * Get the snapPointsOnly flag
  47073. */
  47074. get snapPointsOnly(): boolean;
  47075. /**
  47076. * Sets the snapPointsOnly flag
  47077. * @param snapToPoints should teleportation be exclusively to snap points
  47078. */
  47079. set snapPointsOnly(snapToPoints: boolean);
  47080. /**
  47081. * Add a new mesh to the floor meshes array
  47082. * @param mesh the mesh to use as floor mesh
  47083. */
  47084. addFloorMesh(mesh: AbstractMesh): void;
  47085. /**
  47086. * Add a new snap-to point to fix teleportation to this position
  47087. * @param newSnapPoint The new Snap-To point
  47088. */
  47089. addSnapPoint(newSnapPoint: Vector3): void;
  47090. attach(): boolean;
  47091. detach(): boolean;
  47092. dispose(): void;
  47093. /**
  47094. * Remove a mesh from the floor meshes array
  47095. * @param mesh the mesh to remove
  47096. */
  47097. removeFloorMesh(mesh: AbstractMesh): void;
  47098. /**
  47099. * Remove a mesh from the floor meshes array using its name
  47100. * @param name the mesh name to remove
  47101. */
  47102. removeFloorMeshByName(name: string): void;
  47103. /**
  47104. * 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
  47105. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47106. * @returns was the point found and removed or not
  47107. */
  47108. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47109. /**
  47110. * This function sets a selection feature that will be disabled when
  47111. * the forward ray is shown and will be reattached when hidden.
  47112. * This is used to remove the selection rays when moving.
  47113. * @param selectionFeature the feature to disable when forward movement is enabled
  47114. */
  47115. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47116. protected _onXRFrame(_xrFrame: XRFrame): void;
  47117. private _attachController;
  47118. private _createDefaultTargetMesh;
  47119. private _detachController;
  47120. private _findClosestSnapPointWithRadius;
  47121. private _setTargetMeshPosition;
  47122. private _setTargetMeshVisibility;
  47123. private _showParabolicPath;
  47124. private _teleportForward;
  47125. }
  47126. }
  47127. declare module "babylonjs/XR/webXRDefaultExperience" {
  47128. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47129. import { Scene } from "babylonjs/scene";
  47130. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47131. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47132. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47133. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47135. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47136. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47137. /**
  47138. * Options for the default xr helper
  47139. */
  47140. export class WebXRDefaultExperienceOptions {
  47141. /**
  47142. * Enable or disable default UI to enter XR
  47143. */
  47144. disableDefaultUI?: boolean;
  47145. /**
  47146. * Should teleportation not initialize. defaults to false.
  47147. */
  47148. disableTeleportation?: boolean;
  47149. /**
  47150. * Floor meshes that will be used for teleport
  47151. */
  47152. floorMeshes?: Array<AbstractMesh>;
  47153. /**
  47154. * If set to true, the first frame will not be used to reset position
  47155. * The first frame is mainly used when copying transformation from the old camera
  47156. * Mainly used in AR
  47157. */
  47158. ignoreNativeCameraTransformation?: boolean;
  47159. /**
  47160. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47161. */
  47162. inputOptions?: IWebXRInputOptions;
  47163. /**
  47164. * optional configuration for the output canvas
  47165. */
  47166. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47167. /**
  47168. * optional UI options. This can be used among other to change session mode and reference space type
  47169. */
  47170. uiOptions?: WebXREnterExitUIOptions;
  47171. /**
  47172. * When loading teleportation and pointer select, use stable versions instead of latest.
  47173. */
  47174. useStablePlugins?: boolean;
  47175. /**
  47176. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47177. */
  47178. renderingGroupId?: number;
  47179. }
  47180. /**
  47181. * Default experience which provides a similar setup to the previous webVRExperience
  47182. */
  47183. export class WebXRDefaultExperience {
  47184. /**
  47185. * Base experience
  47186. */
  47187. baseExperience: WebXRExperienceHelper;
  47188. /**
  47189. * Enables ui for entering/exiting xr
  47190. */
  47191. enterExitUI: WebXREnterExitUI;
  47192. /**
  47193. * Input experience extension
  47194. */
  47195. input: WebXRInput;
  47196. /**
  47197. * Enables laser pointer and selection
  47198. */
  47199. pointerSelection: WebXRControllerPointerSelection;
  47200. /**
  47201. * Default target xr should render to
  47202. */
  47203. renderTarget: WebXRRenderTarget;
  47204. /**
  47205. * Enables teleportation
  47206. */
  47207. teleportation: WebXRMotionControllerTeleportation;
  47208. private constructor();
  47209. /**
  47210. * Creates the default xr experience
  47211. * @param scene scene
  47212. * @param options options for basic configuration
  47213. * @returns resulting WebXRDefaultExperience
  47214. */
  47215. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47216. /**
  47217. * DIsposes of the experience helper
  47218. */
  47219. dispose(): void;
  47220. }
  47221. }
  47222. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47223. import { Observable } from "babylonjs/Misc/observable";
  47224. import { Nullable } from "babylonjs/types";
  47225. import { Camera } from "babylonjs/Cameras/camera";
  47226. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47227. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47228. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47229. import { Scene } from "babylonjs/scene";
  47230. import { Vector3 } from "babylonjs/Maths/math.vector";
  47231. import { Color3 } from "babylonjs/Maths/math.color";
  47232. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47234. import { Mesh } from "babylonjs/Meshes/mesh";
  47235. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47236. import { EasingFunction } from "babylonjs/Animations/easing";
  47237. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47238. import "babylonjs/Meshes/Builders/groundBuilder";
  47239. import "babylonjs/Meshes/Builders/torusBuilder";
  47240. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47241. import "babylonjs/Gamepads/gamepadSceneComponent";
  47242. import "babylonjs/Animations/animatable";
  47243. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47244. /**
  47245. * Options to modify the vr teleportation behavior.
  47246. */
  47247. export interface VRTeleportationOptions {
  47248. /**
  47249. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47250. */
  47251. floorMeshName?: string;
  47252. /**
  47253. * A list of meshes to be used as the teleportation floor. (default: empty)
  47254. */
  47255. floorMeshes?: Mesh[];
  47256. /**
  47257. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47258. */
  47259. teleportationMode?: number;
  47260. /**
  47261. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47262. */
  47263. teleportationTime?: number;
  47264. /**
  47265. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47266. */
  47267. teleportationSpeed?: number;
  47268. /**
  47269. * The easing function used in the animation or null for Linear. (default CircleEase)
  47270. */
  47271. easingFunction?: EasingFunction;
  47272. }
  47273. /**
  47274. * Options to modify the vr experience helper's behavior.
  47275. */
  47276. export interface VRExperienceHelperOptions extends WebVROptions {
  47277. /**
  47278. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47279. */
  47280. createDeviceOrientationCamera?: boolean;
  47281. /**
  47282. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47283. */
  47284. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47285. /**
  47286. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47287. */
  47288. laserToggle?: boolean;
  47289. /**
  47290. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47291. */
  47292. floorMeshes?: Mesh[];
  47293. /**
  47294. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47295. */
  47296. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47297. /**
  47298. * Defines if WebXR should be used instead of WebVR (if available)
  47299. */
  47300. useXR?: boolean;
  47301. }
  47302. /**
  47303. * Event containing information after VR has been entered
  47304. */
  47305. export class OnAfterEnteringVRObservableEvent {
  47306. /**
  47307. * If entering vr was successful
  47308. */
  47309. success: boolean;
  47310. }
  47311. /**
  47312. * Helps to quickly add VR support to an existing scene.
  47313. * See http://doc.babylonjs.com/how_to/webvr_helper
  47314. */
  47315. export class VRExperienceHelper {
  47316. /** Options to modify the vr experience helper's behavior. */
  47317. webVROptions: VRExperienceHelperOptions;
  47318. private _scene;
  47319. private _position;
  47320. private _btnVR;
  47321. private _btnVRDisplayed;
  47322. private _webVRsupported;
  47323. private _webVRready;
  47324. private _webVRrequesting;
  47325. private _webVRpresenting;
  47326. private _hasEnteredVR;
  47327. private _fullscreenVRpresenting;
  47328. private _inputElement;
  47329. private _webVRCamera;
  47330. private _vrDeviceOrientationCamera;
  47331. private _deviceOrientationCamera;
  47332. private _existingCamera;
  47333. private _onKeyDown;
  47334. private _onVrDisplayPresentChange;
  47335. private _onVRDisplayChanged;
  47336. private _onVRRequestPresentStart;
  47337. private _onVRRequestPresentComplete;
  47338. /**
  47339. * 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)
  47340. */
  47341. enableGazeEvenWhenNoPointerLock: boolean;
  47342. /**
  47343. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47344. */
  47345. exitVROnDoubleTap: boolean;
  47346. /**
  47347. * Observable raised right before entering VR.
  47348. */
  47349. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47350. /**
  47351. * Observable raised when entering VR has completed.
  47352. */
  47353. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47354. /**
  47355. * Observable raised when exiting VR.
  47356. */
  47357. onExitingVRObservable: Observable<VRExperienceHelper>;
  47358. /**
  47359. * Observable raised when controller mesh is loaded.
  47360. */
  47361. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47362. /** Return this.onEnteringVRObservable
  47363. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47364. */
  47365. get onEnteringVR(): Observable<VRExperienceHelper>;
  47366. /** Return this.onExitingVRObservable
  47367. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47368. */
  47369. get onExitingVR(): Observable<VRExperienceHelper>;
  47370. /** Return this.onControllerMeshLoadedObservable
  47371. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47372. */
  47373. get onControllerMeshLoaded(): Observable<WebVRController>;
  47374. private _rayLength;
  47375. private _useCustomVRButton;
  47376. private _teleportationRequested;
  47377. private _teleportActive;
  47378. private _floorMeshName;
  47379. private _floorMeshesCollection;
  47380. private _teleportationMode;
  47381. private _teleportationTime;
  47382. private _teleportationSpeed;
  47383. private _teleportationEasing;
  47384. private _rotationAllowed;
  47385. private _teleportBackwardsVector;
  47386. private _teleportationTarget;
  47387. private _isDefaultTeleportationTarget;
  47388. private _postProcessMove;
  47389. private _teleportationFillColor;
  47390. private _teleportationBorderColor;
  47391. private _rotationAngle;
  47392. private _haloCenter;
  47393. private _cameraGazer;
  47394. private _padSensibilityUp;
  47395. private _padSensibilityDown;
  47396. private _leftController;
  47397. private _rightController;
  47398. private _gazeColor;
  47399. private _laserColor;
  47400. private _pickedLaserColor;
  47401. private _pickedGazeColor;
  47402. /**
  47403. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47404. */
  47405. onNewMeshSelected: Observable<AbstractMesh>;
  47406. /**
  47407. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47408. * This observable will provide the mesh and the controller used to select the mesh
  47409. */
  47410. onMeshSelectedWithController: Observable<{
  47411. mesh: AbstractMesh;
  47412. controller: WebVRController;
  47413. }>;
  47414. /**
  47415. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47416. */
  47417. onNewMeshPicked: Observable<PickingInfo>;
  47418. private _circleEase;
  47419. /**
  47420. * Observable raised before camera teleportation
  47421. */
  47422. onBeforeCameraTeleport: Observable<Vector3>;
  47423. /**
  47424. * Observable raised after camera teleportation
  47425. */
  47426. onAfterCameraTeleport: Observable<Vector3>;
  47427. /**
  47428. * Observable raised when current selected mesh gets unselected
  47429. */
  47430. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47431. private _raySelectionPredicate;
  47432. /**
  47433. * To be optionaly changed by user to define custom ray selection
  47434. */
  47435. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47436. /**
  47437. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47438. */
  47439. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47440. /**
  47441. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47442. */
  47443. teleportationEnabled: boolean;
  47444. private _defaultHeight;
  47445. private _teleportationInitialized;
  47446. private _interactionsEnabled;
  47447. private _interactionsRequested;
  47448. private _displayGaze;
  47449. private _displayLaserPointer;
  47450. /**
  47451. * The mesh used to display where the user is going to teleport.
  47452. */
  47453. get teleportationTarget(): Mesh;
  47454. /**
  47455. * Sets the mesh to be used to display where the user is going to teleport.
  47456. */
  47457. set teleportationTarget(value: Mesh);
  47458. /**
  47459. * 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
  47460. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47461. * See http://doc.babylonjs.com/resources/baking_transformations
  47462. */
  47463. get gazeTrackerMesh(): Mesh;
  47464. set gazeTrackerMesh(value: Mesh);
  47465. /**
  47466. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47467. */
  47468. updateGazeTrackerScale: boolean;
  47469. /**
  47470. * If the gaze trackers color should be updated when selecting meshes
  47471. */
  47472. updateGazeTrackerColor: boolean;
  47473. /**
  47474. * If the controller laser color should be updated when selecting meshes
  47475. */
  47476. updateControllerLaserColor: boolean;
  47477. /**
  47478. * The gaze tracking mesh corresponding to the left controller
  47479. */
  47480. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47481. /**
  47482. * The gaze tracking mesh corresponding to the right controller
  47483. */
  47484. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47485. /**
  47486. * If the ray of the gaze should be displayed.
  47487. */
  47488. get displayGaze(): boolean;
  47489. /**
  47490. * Sets if the ray of the gaze should be displayed.
  47491. */
  47492. set displayGaze(value: boolean);
  47493. /**
  47494. * If the ray of the LaserPointer should be displayed.
  47495. */
  47496. get displayLaserPointer(): boolean;
  47497. /**
  47498. * Sets if the ray of the LaserPointer should be displayed.
  47499. */
  47500. set displayLaserPointer(value: boolean);
  47501. /**
  47502. * The deviceOrientationCamera used as the camera when not in VR.
  47503. */
  47504. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47505. /**
  47506. * Based on the current WebVR support, returns the current VR camera used.
  47507. */
  47508. get currentVRCamera(): Nullable<Camera>;
  47509. /**
  47510. * The webVRCamera which is used when in VR.
  47511. */
  47512. get webVRCamera(): WebVRFreeCamera;
  47513. /**
  47514. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47515. */
  47516. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47517. /**
  47518. * The html button that is used to trigger entering into VR.
  47519. */
  47520. get vrButton(): Nullable<HTMLButtonElement>;
  47521. private get _teleportationRequestInitiated();
  47522. /**
  47523. * Defines whether or not Pointer lock should be requested when switching to
  47524. * full screen.
  47525. */
  47526. requestPointerLockOnFullScreen: boolean;
  47527. /**
  47528. * If asking to force XR, this will be populated with the default xr experience
  47529. */
  47530. xr: WebXRDefaultExperience;
  47531. /**
  47532. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47533. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47534. */
  47535. xrTestDone: boolean;
  47536. /**
  47537. * Instantiates a VRExperienceHelper.
  47538. * Helps to quickly add VR support to an existing scene.
  47539. * @param scene The scene the VRExperienceHelper belongs to.
  47540. * @param webVROptions Options to modify the vr experience helper's behavior.
  47541. */
  47542. constructor(scene: Scene,
  47543. /** Options to modify the vr experience helper's behavior. */
  47544. webVROptions?: VRExperienceHelperOptions);
  47545. private completeVRInit;
  47546. private _onDefaultMeshLoaded;
  47547. private _onResize;
  47548. private _onFullscreenChange;
  47549. /**
  47550. * Gets a value indicating if we are currently in VR mode.
  47551. */
  47552. get isInVRMode(): boolean;
  47553. private onVrDisplayPresentChange;
  47554. private onVRDisplayChanged;
  47555. private moveButtonToBottomRight;
  47556. private displayVRButton;
  47557. private updateButtonVisibility;
  47558. private _cachedAngularSensibility;
  47559. /**
  47560. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47561. * Otherwise, will use the fullscreen API.
  47562. */
  47563. enterVR(): void;
  47564. /**
  47565. * Attempt to exit VR, or fullscreen.
  47566. */
  47567. exitVR(): void;
  47568. /**
  47569. * The position of the vr experience helper.
  47570. */
  47571. get position(): Vector3;
  47572. /**
  47573. * Sets the position of the vr experience helper.
  47574. */
  47575. set position(value: Vector3);
  47576. /**
  47577. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47578. */
  47579. enableInteractions(): void;
  47580. private get _noControllerIsActive();
  47581. private beforeRender;
  47582. private _isTeleportationFloor;
  47583. /**
  47584. * Adds a floor mesh to be used for teleportation.
  47585. * @param floorMesh the mesh to be used for teleportation.
  47586. */
  47587. addFloorMesh(floorMesh: Mesh): void;
  47588. /**
  47589. * Removes a floor mesh from being used for teleportation.
  47590. * @param floorMesh the mesh to be removed.
  47591. */
  47592. removeFloorMesh(floorMesh: Mesh): void;
  47593. /**
  47594. * Enables interactions and teleportation using the VR controllers and gaze.
  47595. * @param vrTeleportationOptions options to modify teleportation behavior.
  47596. */
  47597. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47598. private _onNewGamepadConnected;
  47599. private _tryEnableInteractionOnController;
  47600. private _onNewGamepadDisconnected;
  47601. private _enableInteractionOnController;
  47602. private _checkTeleportWithRay;
  47603. private _checkRotate;
  47604. private _checkTeleportBackwards;
  47605. private _enableTeleportationOnController;
  47606. private _createTeleportationCircles;
  47607. private _displayTeleportationTarget;
  47608. private _hideTeleportationTarget;
  47609. private _rotateCamera;
  47610. private _moveTeleportationSelectorTo;
  47611. private _workingVector;
  47612. private _workingQuaternion;
  47613. private _workingMatrix;
  47614. /**
  47615. * Time Constant Teleportation Mode
  47616. */
  47617. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47618. /**
  47619. * Speed Constant Teleportation Mode
  47620. */
  47621. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47622. /**
  47623. * Teleports the users feet to the desired location
  47624. * @param location The location where the user's feet should be placed
  47625. */
  47626. teleportCamera(location: Vector3): void;
  47627. private _convertNormalToDirectionOfRay;
  47628. private _castRayAndSelectObject;
  47629. private _notifySelectedMeshUnselected;
  47630. /**
  47631. * Permanently set new colors for the laser pointer
  47632. * @param color the new laser color
  47633. * @param pickedColor the new laser color when picked mesh detected
  47634. */
  47635. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47636. /**
  47637. * Set lighting enabled / disabled on the laser pointer of both controllers
  47638. * @param enabled should the lighting be enabled on the laser pointer
  47639. */
  47640. setLaserLightingState(enabled?: boolean): void;
  47641. /**
  47642. * Permanently set new colors for the gaze pointer
  47643. * @param color the new gaze color
  47644. * @param pickedColor the new gaze color when picked mesh detected
  47645. */
  47646. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47647. /**
  47648. * Sets the color of the laser ray from the vr controllers.
  47649. * @param color new color for the ray.
  47650. */
  47651. changeLaserColor(color: Color3): void;
  47652. /**
  47653. * Sets the color of the ray from the vr headsets gaze.
  47654. * @param color new color for the ray.
  47655. */
  47656. changeGazeColor(color: Color3): void;
  47657. /**
  47658. * Exits VR and disposes of the vr experience helper
  47659. */
  47660. dispose(): void;
  47661. /**
  47662. * Gets the name of the VRExperienceHelper class
  47663. * @returns "VRExperienceHelper"
  47664. */
  47665. getClassName(): string;
  47666. }
  47667. }
  47668. declare module "babylonjs/Cameras/VR/index" {
  47669. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47670. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47671. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47672. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47673. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47674. export * from "babylonjs/Cameras/VR/webVRCamera";
  47675. }
  47676. declare module "babylonjs/Cameras/RigModes/index" {
  47677. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47678. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47679. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47680. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47681. }
  47682. declare module "babylonjs/Cameras/index" {
  47683. export * from "babylonjs/Cameras/Inputs/index";
  47684. export * from "babylonjs/Cameras/cameraInputsManager";
  47685. export * from "babylonjs/Cameras/camera";
  47686. export * from "babylonjs/Cameras/targetCamera";
  47687. export * from "babylonjs/Cameras/freeCamera";
  47688. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47689. export * from "babylonjs/Cameras/touchCamera";
  47690. export * from "babylonjs/Cameras/arcRotateCamera";
  47691. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47692. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47693. export * from "babylonjs/Cameras/flyCamera";
  47694. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47695. export * from "babylonjs/Cameras/followCamera";
  47696. export * from "babylonjs/Cameras/followCameraInputsManager";
  47697. export * from "babylonjs/Cameras/gamepadCamera";
  47698. export * from "babylonjs/Cameras/Stereoscopic/index";
  47699. export * from "babylonjs/Cameras/universalCamera";
  47700. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47701. export * from "babylonjs/Cameras/VR/index";
  47702. export * from "babylonjs/Cameras/RigModes/index";
  47703. }
  47704. declare module "babylonjs/Collisions/index" {
  47705. export * from "babylonjs/Collisions/collider";
  47706. export * from "babylonjs/Collisions/collisionCoordinator";
  47707. export * from "babylonjs/Collisions/pickingInfo";
  47708. export * from "babylonjs/Collisions/intersectionInfo";
  47709. export * from "babylonjs/Collisions/meshCollisionData";
  47710. }
  47711. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47712. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47713. import { Vector3 } from "babylonjs/Maths/math.vector";
  47714. import { Ray } from "babylonjs/Culling/ray";
  47715. import { Plane } from "babylonjs/Maths/math.plane";
  47716. /**
  47717. * Contains an array of blocks representing the octree
  47718. */
  47719. export interface IOctreeContainer<T> {
  47720. /**
  47721. * Blocks within the octree
  47722. */
  47723. blocks: Array<OctreeBlock<T>>;
  47724. }
  47725. /**
  47726. * Class used to store a cell in an octree
  47727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47728. */
  47729. export class OctreeBlock<T> {
  47730. /**
  47731. * Gets the content of the current block
  47732. */
  47733. entries: T[];
  47734. /**
  47735. * Gets the list of block children
  47736. */
  47737. blocks: Array<OctreeBlock<T>>;
  47738. private _depth;
  47739. private _maxDepth;
  47740. private _capacity;
  47741. private _minPoint;
  47742. private _maxPoint;
  47743. private _boundingVectors;
  47744. private _creationFunc;
  47745. /**
  47746. * Creates a new block
  47747. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47748. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47749. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47750. * @param depth defines the current depth of this block in the octree
  47751. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47752. * @param creationFunc defines a callback to call when an element is added to the block
  47753. */
  47754. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47755. /**
  47756. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47757. */
  47758. get capacity(): number;
  47759. /**
  47760. * Gets the minimum vector (in world space) of the block's bounding box
  47761. */
  47762. get minPoint(): Vector3;
  47763. /**
  47764. * Gets the maximum vector (in world space) of the block's bounding box
  47765. */
  47766. get maxPoint(): Vector3;
  47767. /**
  47768. * Add a new element to this block
  47769. * @param entry defines the element to add
  47770. */
  47771. addEntry(entry: T): void;
  47772. /**
  47773. * Remove an element from this block
  47774. * @param entry defines the element to remove
  47775. */
  47776. removeEntry(entry: T): void;
  47777. /**
  47778. * Add an array of elements to this block
  47779. * @param entries defines the array of elements to add
  47780. */
  47781. addEntries(entries: T[]): void;
  47782. /**
  47783. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47784. * @param frustumPlanes defines the frustum planes to test
  47785. * @param selection defines the array to store current content if selection is positive
  47786. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47787. */
  47788. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47789. /**
  47790. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47791. * @param sphereCenter defines the bounding sphere center
  47792. * @param sphereRadius defines the bounding sphere radius
  47793. * @param selection defines the array to store current content if selection is positive
  47794. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47795. */
  47796. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47797. /**
  47798. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47799. * @param ray defines the ray to test with
  47800. * @param selection defines the array to store current content if selection is positive
  47801. */
  47802. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47803. /**
  47804. * Subdivide the content into child blocks (this block will then be empty)
  47805. */
  47806. createInnerBlocks(): void;
  47807. /**
  47808. * @hidden
  47809. */
  47810. 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;
  47811. }
  47812. }
  47813. declare module "babylonjs/Culling/Octrees/octree" {
  47814. import { SmartArray } from "babylonjs/Misc/smartArray";
  47815. import { Vector3 } from "babylonjs/Maths/math.vector";
  47816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47818. import { Ray } from "babylonjs/Culling/ray";
  47819. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47820. import { Plane } from "babylonjs/Maths/math.plane";
  47821. /**
  47822. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47823. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47824. */
  47825. export class Octree<T> {
  47826. /** 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.) */
  47827. maxDepth: number;
  47828. /**
  47829. * Blocks within the octree containing objects
  47830. */
  47831. blocks: Array<OctreeBlock<T>>;
  47832. /**
  47833. * Content stored in the octree
  47834. */
  47835. dynamicContent: T[];
  47836. private _maxBlockCapacity;
  47837. private _selectionContent;
  47838. private _creationFunc;
  47839. /**
  47840. * Creates a octree
  47841. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47842. * @param creationFunc function to be used to instatiate the octree
  47843. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47844. * @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.)
  47845. */
  47846. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47847. /** 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.) */
  47848. maxDepth?: number);
  47849. /**
  47850. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47851. * @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);
  47852. * @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);
  47853. * @param entries meshes to be added to the octree blocks
  47854. */
  47855. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47856. /**
  47857. * Adds a mesh to the octree
  47858. * @param entry Mesh to add to the octree
  47859. */
  47860. addMesh(entry: T): void;
  47861. /**
  47862. * Remove an element from the octree
  47863. * @param entry defines the element to remove
  47864. */
  47865. removeMesh(entry: T): void;
  47866. /**
  47867. * Selects an array of meshes within the frustum
  47868. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47869. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47870. * @returns array of meshes within the frustum
  47871. */
  47872. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47873. /**
  47874. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47875. * @param sphereCenter defines the bounding sphere center
  47876. * @param sphereRadius defines the bounding sphere radius
  47877. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47878. * @returns an array of objects that intersect the sphere
  47879. */
  47880. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47881. /**
  47882. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47883. * @param ray defines the ray to test with
  47884. * @returns array of intersected objects
  47885. */
  47886. intersectsRay(ray: Ray): SmartArray<T>;
  47887. /**
  47888. * Adds a mesh into the octree block if it intersects the block
  47889. */
  47890. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47891. /**
  47892. * Adds a submesh into the octree block if it intersects the block
  47893. */
  47894. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47895. }
  47896. }
  47897. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47898. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47899. import { Scene } from "babylonjs/scene";
  47900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47902. import { Ray } from "babylonjs/Culling/ray";
  47903. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47904. import { Collider } from "babylonjs/Collisions/collider";
  47905. module "babylonjs/scene" {
  47906. interface Scene {
  47907. /**
  47908. * @hidden
  47909. * Backing Filed
  47910. */
  47911. _selectionOctree: Octree<AbstractMesh>;
  47912. /**
  47913. * Gets the octree used to boost mesh selection (picking)
  47914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47915. */
  47916. selectionOctree: Octree<AbstractMesh>;
  47917. /**
  47918. * Creates or updates the octree used to boost selection (picking)
  47919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47920. * @param maxCapacity defines the maximum capacity per leaf
  47921. * @param maxDepth defines the maximum depth of the octree
  47922. * @returns an octree of AbstractMesh
  47923. */
  47924. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47925. }
  47926. }
  47927. module "babylonjs/Meshes/abstractMesh" {
  47928. interface AbstractMesh {
  47929. /**
  47930. * @hidden
  47931. * Backing Field
  47932. */
  47933. _submeshesOctree: Octree<SubMesh>;
  47934. /**
  47935. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47936. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47937. * @param maxCapacity defines the maximum size of each block (64 by default)
  47938. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47939. * @returns the new octree
  47940. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47942. */
  47943. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47944. }
  47945. }
  47946. /**
  47947. * Defines the octree scene component responsible to manage any octrees
  47948. * in a given scene.
  47949. */
  47950. export class OctreeSceneComponent {
  47951. /**
  47952. * The component name help to identify the component in the list of scene components.
  47953. */
  47954. readonly name: string;
  47955. /**
  47956. * The scene the component belongs to.
  47957. */
  47958. scene: Scene;
  47959. /**
  47960. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47961. */
  47962. readonly checksIsEnabled: boolean;
  47963. /**
  47964. * Creates a new instance of the component for the given scene
  47965. * @param scene Defines the scene to register the component in
  47966. */
  47967. constructor(scene: Scene);
  47968. /**
  47969. * Registers the component in a given scene
  47970. */
  47971. register(): void;
  47972. /**
  47973. * Return the list of active meshes
  47974. * @returns the list of active meshes
  47975. */
  47976. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47977. /**
  47978. * Return the list of active sub meshes
  47979. * @param mesh The mesh to get the candidates sub meshes from
  47980. * @returns the list of active sub meshes
  47981. */
  47982. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47983. private _tempRay;
  47984. /**
  47985. * Return the list of sub meshes intersecting with a given local ray
  47986. * @param mesh defines the mesh to find the submesh for
  47987. * @param localRay defines the ray in local space
  47988. * @returns the list of intersecting sub meshes
  47989. */
  47990. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47991. /**
  47992. * Return the list of sub meshes colliding with a collider
  47993. * @param mesh defines the mesh to find the submesh for
  47994. * @param collider defines the collider to evaluate the collision against
  47995. * @returns the list of colliding sub meshes
  47996. */
  47997. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47998. /**
  47999. * Rebuilds the elements related to this component in case of
  48000. * context lost for instance.
  48001. */
  48002. rebuild(): void;
  48003. /**
  48004. * Disposes the component and the associated ressources.
  48005. */
  48006. dispose(): void;
  48007. }
  48008. }
  48009. declare module "babylonjs/Culling/Octrees/index" {
  48010. export * from "babylonjs/Culling/Octrees/octree";
  48011. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48012. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48013. }
  48014. declare module "babylonjs/Culling/index" {
  48015. export * from "babylonjs/Culling/boundingBox";
  48016. export * from "babylonjs/Culling/boundingInfo";
  48017. export * from "babylonjs/Culling/boundingSphere";
  48018. export * from "babylonjs/Culling/Octrees/index";
  48019. export * from "babylonjs/Culling/ray";
  48020. }
  48021. declare module "babylonjs/Gizmos/gizmo" {
  48022. import { Nullable } from "babylonjs/types";
  48023. import { IDisposable } from "babylonjs/scene";
  48024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48025. import { Mesh } from "babylonjs/Meshes/mesh";
  48026. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48027. /**
  48028. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48029. */
  48030. export class Gizmo implements IDisposable {
  48031. /** The utility layer the gizmo will be added to */
  48032. gizmoLayer: UtilityLayerRenderer;
  48033. /**
  48034. * The root mesh of the gizmo
  48035. */
  48036. _rootMesh: Mesh;
  48037. private _attachedMesh;
  48038. /**
  48039. * Ratio for the scale of the gizmo (Default: 1)
  48040. */
  48041. scaleRatio: number;
  48042. /**
  48043. * If a custom mesh has been set (Default: false)
  48044. */
  48045. protected _customMeshSet: boolean;
  48046. /**
  48047. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48048. * * When set, interactions will be enabled
  48049. */
  48050. get attachedMesh(): Nullable<AbstractMesh>;
  48051. set attachedMesh(value: Nullable<AbstractMesh>);
  48052. /**
  48053. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48054. * @param mesh The mesh to replace the default mesh of the gizmo
  48055. */
  48056. setCustomMesh(mesh: Mesh): void;
  48057. /**
  48058. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48059. */
  48060. updateGizmoRotationToMatchAttachedMesh: boolean;
  48061. /**
  48062. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48063. */
  48064. updateGizmoPositionToMatchAttachedMesh: boolean;
  48065. /**
  48066. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48067. */
  48068. updateScale: boolean;
  48069. protected _interactionsEnabled: boolean;
  48070. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48071. private _beforeRenderObserver;
  48072. private _tempVector;
  48073. /**
  48074. * Creates a gizmo
  48075. * @param gizmoLayer The utility layer the gizmo will be added to
  48076. */
  48077. constructor(
  48078. /** The utility layer the gizmo will be added to */
  48079. gizmoLayer?: UtilityLayerRenderer);
  48080. /**
  48081. * Updates the gizmo to match the attached mesh's position/rotation
  48082. */
  48083. protected _update(): void;
  48084. /**
  48085. * Disposes of the gizmo
  48086. */
  48087. dispose(): void;
  48088. }
  48089. }
  48090. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48091. import { Observable } from "babylonjs/Misc/observable";
  48092. import { Nullable } from "babylonjs/types";
  48093. import { Vector3 } from "babylonjs/Maths/math.vector";
  48094. import { Color3 } from "babylonjs/Maths/math.color";
  48095. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48097. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48098. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48099. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48100. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48101. import { Scene } from "babylonjs/scene";
  48102. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48103. /**
  48104. * Single plane drag gizmo
  48105. */
  48106. export class PlaneDragGizmo extends Gizmo {
  48107. /**
  48108. * Drag behavior responsible for the gizmos dragging interactions
  48109. */
  48110. dragBehavior: PointerDragBehavior;
  48111. private _pointerObserver;
  48112. /**
  48113. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48114. */
  48115. snapDistance: number;
  48116. /**
  48117. * Event that fires each time the gizmo snaps to a new location.
  48118. * * snapDistance is the the change in distance
  48119. */
  48120. onSnapObservable: Observable<{
  48121. snapDistance: number;
  48122. }>;
  48123. private _plane;
  48124. private _coloredMaterial;
  48125. private _hoverMaterial;
  48126. private _isEnabled;
  48127. private _parent;
  48128. /** @hidden */
  48129. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48130. /** @hidden */
  48131. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48132. /**
  48133. * Creates a PlaneDragGizmo
  48134. * @param gizmoLayer The utility layer the gizmo will be added to
  48135. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48136. * @param color The color of the gizmo
  48137. */
  48138. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48139. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48140. /**
  48141. * If the gizmo is enabled
  48142. */
  48143. set isEnabled(value: boolean);
  48144. get isEnabled(): boolean;
  48145. /**
  48146. * Disposes of the gizmo
  48147. */
  48148. dispose(): void;
  48149. }
  48150. }
  48151. declare module "babylonjs/Gizmos/positionGizmo" {
  48152. import { Observable } from "babylonjs/Misc/observable";
  48153. import { Nullable } from "babylonjs/types";
  48154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48155. import { Mesh } from "babylonjs/Meshes/mesh";
  48156. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48157. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48158. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48159. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48160. /**
  48161. * Gizmo that enables dragging a mesh along 3 axis
  48162. */
  48163. export class PositionGizmo extends Gizmo {
  48164. /**
  48165. * Internal gizmo used for interactions on the x axis
  48166. */
  48167. xGizmo: AxisDragGizmo;
  48168. /**
  48169. * Internal gizmo used for interactions on the y axis
  48170. */
  48171. yGizmo: AxisDragGizmo;
  48172. /**
  48173. * Internal gizmo used for interactions on the z axis
  48174. */
  48175. zGizmo: AxisDragGizmo;
  48176. /**
  48177. * Internal gizmo used for interactions on the yz plane
  48178. */
  48179. xPlaneGizmo: PlaneDragGizmo;
  48180. /**
  48181. * Internal gizmo used for interactions on the xz plane
  48182. */
  48183. yPlaneGizmo: PlaneDragGizmo;
  48184. /**
  48185. * Internal gizmo used for interactions on the xy plane
  48186. */
  48187. zPlaneGizmo: PlaneDragGizmo;
  48188. /**
  48189. * private variables
  48190. */
  48191. private _meshAttached;
  48192. private _updateGizmoRotationToMatchAttachedMesh;
  48193. private _snapDistance;
  48194. private _scaleRatio;
  48195. /** Fires an event when any of it's sub gizmos are dragged */
  48196. onDragStartObservable: Observable<unknown>;
  48197. /** Fires an event when any of it's sub gizmos are released from dragging */
  48198. onDragEndObservable: Observable<unknown>;
  48199. /**
  48200. * If set to true, planar drag is enabled
  48201. */
  48202. private _planarGizmoEnabled;
  48203. get attachedMesh(): Nullable<AbstractMesh>;
  48204. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48205. /**
  48206. * Creates a PositionGizmo
  48207. * @param gizmoLayer The utility layer the gizmo will be added to
  48208. */
  48209. constructor(gizmoLayer?: UtilityLayerRenderer);
  48210. /**
  48211. * If the planar drag gizmo is enabled
  48212. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48213. */
  48214. set planarGizmoEnabled(value: boolean);
  48215. get planarGizmoEnabled(): boolean;
  48216. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48217. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48218. /**
  48219. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48220. */
  48221. set snapDistance(value: number);
  48222. get snapDistance(): number;
  48223. /**
  48224. * Ratio for the scale of the gizmo (Default: 1)
  48225. */
  48226. set scaleRatio(value: number);
  48227. get scaleRatio(): number;
  48228. /**
  48229. * Disposes of the gizmo
  48230. */
  48231. dispose(): void;
  48232. /**
  48233. * CustomMeshes are not supported by this gizmo
  48234. * @param mesh The mesh to replace the default mesh of the gizmo
  48235. */
  48236. setCustomMesh(mesh: Mesh): void;
  48237. }
  48238. }
  48239. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48240. import { Observable } from "babylonjs/Misc/observable";
  48241. import { Nullable } from "babylonjs/types";
  48242. import { Vector3 } from "babylonjs/Maths/math.vector";
  48243. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48245. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48246. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48247. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48248. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48249. import { Scene } from "babylonjs/scene";
  48250. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48251. import { Color3 } from "babylonjs/Maths/math.color";
  48252. /**
  48253. * Single axis drag gizmo
  48254. */
  48255. export class AxisDragGizmo extends Gizmo {
  48256. /**
  48257. * Drag behavior responsible for the gizmos dragging interactions
  48258. */
  48259. dragBehavior: PointerDragBehavior;
  48260. private _pointerObserver;
  48261. /**
  48262. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48263. */
  48264. snapDistance: number;
  48265. /**
  48266. * Event that fires each time the gizmo snaps to a new location.
  48267. * * snapDistance is the the change in distance
  48268. */
  48269. onSnapObservable: Observable<{
  48270. snapDistance: number;
  48271. }>;
  48272. private _isEnabled;
  48273. private _parent;
  48274. private _arrow;
  48275. private _coloredMaterial;
  48276. private _hoverMaterial;
  48277. /** @hidden */
  48278. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48279. /** @hidden */
  48280. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48281. /**
  48282. * Creates an AxisDragGizmo
  48283. * @param gizmoLayer The utility layer the gizmo will be added to
  48284. * @param dragAxis The axis which the gizmo will be able to drag on
  48285. * @param color The color of the gizmo
  48286. */
  48287. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48288. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48289. /**
  48290. * If the gizmo is enabled
  48291. */
  48292. set isEnabled(value: boolean);
  48293. get isEnabled(): boolean;
  48294. /**
  48295. * Disposes of the gizmo
  48296. */
  48297. dispose(): void;
  48298. }
  48299. }
  48300. declare module "babylonjs/Debug/axesViewer" {
  48301. import { Vector3 } from "babylonjs/Maths/math.vector";
  48302. import { Nullable } from "babylonjs/types";
  48303. import { Scene } from "babylonjs/scene";
  48304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48305. /**
  48306. * The Axes viewer will show 3 axes in a specific point in space
  48307. */
  48308. export class AxesViewer {
  48309. private _xAxis;
  48310. private _yAxis;
  48311. private _zAxis;
  48312. private _scaleLinesFactor;
  48313. private _instanced;
  48314. /**
  48315. * Gets the hosting scene
  48316. */
  48317. scene: Scene;
  48318. /**
  48319. * Gets or sets a number used to scale line length
  48320. */
  48321. scaleLines: number;
  48322. /** Gets the node hierarchy used to render x-axis */
  48323. get xAxis(): TransformNode;
  48324. /** Gets the node hierarchy used to render y-axis */
  48325. get yAxis(): TransformNode;
  48326. /** Gets the node hierarchy used to render z-axis */
  48327. get zAxis(): TransformNode;
  48328. /**
  48329. * Creates a new AxesViewer
  48330. * @param scene defines the hosting scene
  48331. * @param scaleLines defines a number used to scale line length (1 by default)
  48332. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48333. * @param xAxis defines the node hierarchy used to render the x-axis
  48334. * @param yAxis defines the node hierarchy used to render the y-axis
  48335. * @param zAxis defines the node hierarchy used to render the z-axis
  48336. */
  48337. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48338. /**
  48339. * Force the viewer to update
  48340. * @param position defines the position of the viewer
  48341. * @param xaxis defines the x axis of the viewer
  48342. * @param yaxis defines the y axis of the viewer
  48343. * @param zaxis defines the z axis of the viewer
  48344. */
  48345. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48346. /**
  48347. * Creates an instance of this axes viewer.
  48348. * @returns a new axes viewer with instanced meshes
  48349. */
  48350. createInstance(): AxesViewer;
  48351. /** Releases resources */
  48352. dispose(): void;
  48353. private static _SetRenderingGroupId;
  48354. }
  48355. }
  48356. declare module "babylonjs/Debug/boneAxesViewer" {
  48357. import { Nullable } from "babylonjs/types";
  48358. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48359. import { Vector3 } from "babylonjs/Maths/math.vector";
  48360. import { Mesh } from "babylonjs/Meshes/mesh";
  48361. import { Bone } from "babylonjs/Bones/bone";
  48362. import { Scene } from "babylonjs/scene";
  48363. /**
  48364. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48365. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48366. */
  48367. export class BoneAxesViewer extends AxesViewer {
  48368. /**
  48369. * Gets or sets the target mesh where to display the axes viewer
  48370. */
  48371. mesh: Nullable<Mesh>;
  48372. /**
  48373. * Gets or sets the target bone where to display the axes viewer
  48374. */
  48375. bone: Nullable<Bone>;
  48376. /** Gets current position */
  48377. pos: Vector3;
  48378. /** Gets direction of X axis */
  48379. xaxis: Vector3;
  48380. /** Gets direction of Y axis */
  48381. yaxis: Vector3;
  48382. /** Gets direction of Z axis */
  48383. zaxis: Vector3;
  48384. /**
  48385. * Creates a new BoneAxesViewer
  48386. * @param scene defines the hosting scene
  48387. * @param bone defines the target bone
  48388. * @param mesh defines the target mesh
  48389. * @param scaleLines defines a scaling factor for line length (1 by default)
  48390. */
  48391. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48392. /**
  48393. * Force the viewer to update
  48394. */
  48395. update(): void;
  48396. /** Releases resources */
  48397. dispose(): void;
  48398. }
  48399. }
  48400. declare module "babylonjs/Debug/debugLayer" {
  48401. import { Scene } from "babylonjs/scene";
  48402. /**
  48403. * Interface used to define scene explorer extensibility option
  48404. */
  48405. export interface IExplorerExtensibilityOption {
  48406. /**
  48407. * Define the option label
  48408. */
  48409. label: string;
  48410. /**
  48411. * Defines the action to execute on click
  48412. */
  48413. action: (entity: any) => void;
  48414. }
  48415. /**
  48416. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48417. */
  48418. export interface IExplorerExtensibilityGroup {
  48419. /**
  48420. * Defines a predicate to test if a given type mut be extended
  48421. */
  48422. predicate: (entity: any) => boolean;
  48423. /**
  48424. * Gets the list of options added to a type
  48425. */
  48426. entries: IExplorerExtensibilityOption[];
  48427. }
  48428. /**
  48429. * Interface used to define the options to use to create the Inspector
  48430. */
  48431. export interface IInspectorOptions {
  48432. /**
  48433. * Display in overlay mode (default: false)
  48434. */
  48435. overlay?: boolean;
  48436. /**
  48437. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48438. */
  48439. globalRoot?: HTMLElement;
  48440. /**
  48441. * Display the Scene explorer
  48442. */
  48443. showExplorer?: boolean;
  48444. /**
  48445. * Display the property inspector
  48446. */
  48447. showInspector?: boolean;
  48448. /**
  48449. * Display in embed mode (both panes on the right)
  48450. */
  48451. embedMode?: boolean;
  48452. /**
  48453. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48454. */
  48455. handleResize?: boolean;
  48456. /**
  48457. * Allow the panes to popup (default: true)
  48458. */
  48459. enablePopup?: boolean;
  48460. /**
  48461. * Allow the panes to be closed by users (default: true)
  48462. */
  48463. enableClose?: boolean;
  48464. /**
  48465. * Optional list of extensibility entries
  48466. */
  48467. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48468. /**
  48469. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48470. */
  48471. inspectorURL?: string;
  48472. /**
  48473. * Optional initial tab (default to DebugLayerTab.Properties)
  48474. */
  48475. initialTab?: DebugLayerTab;
  48476. }
  48477. module "babylonjs/scene" {
  48478. interface Scene {
  48479. /**
  48480. * @hidden
  48481. * Backing field
  48482. */
  48483. _debugLayer: DebugLayer;
  48484. /**
  48485. * Gets the debug layer (aka Inspector) associated with the scene
  48486. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48487. */
  48488. debugLayer: DebugLayer;
  48489. }
  48490. }
  48491. /**
  48492. * Enum of inspector action tab
  48493. */
  48494. export enum DebugLayerTab {
  48495. /**
  48496. * Properties tag (default)
  48497. */
  48498. Properties = 0,
  48499. /**
  48500. * Debug tab
  48501. */
  48502. Debug = 1,
  48503. /**
  48504. * Statistics tab
  48505. */
  48506. Statistics = 2,
  48507. /**
  48508. * Tools tab
  48509. */
  48510. Tools = 3,
  48511. /**
  48512. * Settings tab
  48513. */
  48514. Settings = 4
  48515. }
  48516. /**
  48517. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48518. * what is happening in your scene
  48519. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48520. */
  48521. export class DebugLayer {
  48522. /**
  48523. * Define the url to get the inspector script from.
  48524. * By default it uses the babylonjs CDN.
  48525. * @ignoreNaming
  48526. */
  48527. static InspectorURL: string;
  48528. private _scene;
  48529. private BJSINSPECTOR;
  48530. private _onPropertyChangedObservable?;
  48531. /**
  48532. * Observable triggered when a property is changed through the inspector.
  48533. */
  48534. get onPropertyChangedObservable(): any;
  48535. /**
  48536. * Instantiates a new debug layer.
  48537. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48538. * what is happening in your scene
  48539. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48540. * @param scene Defines the scene to inspect
  48541. */
  48542. constructor(scene: Scene);
  48543. /** Creates the inspector window. */
  48544. private _createInspector;
  48545. /**
  48546. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48547. * @param entity defines the entity to select
  48548. * @param lineContainerTitle defines the specific block to highlight
  48549. */
  48550. select(entity: any, lineContainerTitle?: string): void;
  48551. /** Get the inspector from bundle or global */
  48552. private _getGlobalInspector;
  48553. /**
  48554. * Get if the inspector is visible or not.
  48555. * @returns true if visible otherwise, false
  48556. */
  48557. isVisible(): boolean;
  48558. /**
  48559. * Hide the inspector and close its window.
  48560. */
  48561. hide(): void;
  48562. /**
  48563. * Launch the debugLayer.
  48564. * @param config Define the configuration of the inspector
  48565. * @return a promise fulfilled when the debug layer is visible
  48566. */
  48567. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48568. }
  48569. }
  48570. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48571. import { Nullable } from "babylonjs/types";
  48572. import { Scene } from "babylonjs/scene";
  48573. import { Vector4 } from "babylonjs/Maths/math.vector";
  48574. import { Color4 } from "babylonjs/Maths/math.color";
  48575. import { Mesh } from "babylonjs/Meshes/mesh";
  48576. /**
  48577. * Class containing static functions to help procedurally build meshes
  48578. */
  48579. export class BoxBuilder {
  48580. /**
  48581. * Creates a box mesh
  48582. * * The parameter `size` sets the size (float) of each box side (default 1)
  48583. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48584. * * 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)
  48585. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48589. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48590. * @param name defines the name of the mesh
  48591. * @param options defines the options used to create the mesh
  48592. * @param scene defines the hosting scene
  48593. * @returns the box mesh
  48594. */
  48595. static CreateBox(name: string, options: {
  48596. size?: number;
  48597. width?: number;
  48598. height?: number;
  48599. depth?: number;
  48600. faceUV?: Vector4[];
  48601. faceColors?: Color4[];
  48602. sideOrientation?: number;
  48603. frontUVs?: Vector4;
  48604. backUVs?: Vector4;
  48605. wrap?: boolean;
  48606. topBaseAt?: number;
  48607. bottomBaseAt?: number;
  48608. updatable?: boolean;
  48609. }, scene?: Nullable<Scene>): Mesh;
  48610. }
  48611. }
  48612. declare module "babylonjs/Debug/physicsViewer" {
  48613. import { Nullable } from "babylonjs/types";
  48614. import { Scene } from "babylonjs/scene";
  48615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48616. import { Mesh } from "babylonjs/Meshes/mesh";
  48617. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48618. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48619. /**
  48620. * Used to show the physics impostor around the specific mesh
  48621. */
  48622. export class PhysicsViewer {
  48623. /** @hidden */
  48624. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48625. /** @hidden */
  48626. protected _meshes: Array<Nullable<AbstractMesh>>;
  48627. /** @hidden */
  48628. protected _scene: Nullable<Scene>;
  48629. /** @hidden */
  48630. protected _numMeshes: number;
  48631. /** @hidden */
  48632. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48633. private _renderFunction;
  48634. private _utilityLayer;
  48635. private _debugBoxMesh;
  48636. private _debugSphereMesh;
  48637. private _debugCylinderMesh;
  48638. private _debugMaterial;
  48639. private _debugMeshMeshes;
  48640. /**
  48641. * Creates a new PhysicsViewer
  48642. * @param scene defines the hosting scene
  48643. */
  48644. constructor(scene: Scene);
  48645. /** @hidden */
  48646. protected _updateDebugMeshes(): void;
  48647. /**
  48648. * Renders a specified physic impostor
  48649. * @param impostor defines the impostor to render
  48650. * @param targetMesh defines the mesh represented by the impostor
  48651. * @returns the new debug mesh used to render the impostor
  48652. */
  48653. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48654. /**
  48655. * Hides a specified physic impostor
  48656. * @param impostor defines the impostor to hide
  48657. */
  48658. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48659. private _getDebugMaterial;
  48660. private _getDebugBoxMesh;
  48661. private _getDebugSphereMesh;
  48662. private _getDebugCylinderMesh;
  48663. private _getDebugMeshMesh;
  48664. private _getDebugMesh;
  48665. /** Releases all resources */
  48666. dispose(): void;
  48667. }
  48668. }
  48669. declare module "babylonjs/Debug/rayHelper" {
  48670. import { Nullable } from "babylonjs/types";
  48671. import { Ray } from "babylonjs/Culling/ray";
  48672. import { Vector3 } from "babylonjs/Maths/math.vector";
  48673. import { Color3 } from "babylonjs/Maths/math.color";
  48674. import { Scene } from "babylonjs/scene";
  48675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48676. import "babylonjs/Meshes/Builders/linesBuilder";
  48677. /**
  48678. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48679. * in order to better appreciate the issue one might have.
  48680. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48681. */
  48682. export class RayHelper {
  48683. /**
  48684. * Defines the ray we are currently tryin to visualize.
  48685. */
  48686. ray: Nullable<Ray>;
  48687. private _renderPoints;
  48688. private _renderLine;
  48689. private _renderFunction;
  48690. private _scene;
  48691. private _updateToMeshFunction;
  48692. private _attachedToMesh;
  48693. private _meshSpaceDirection;
  48694. private _meshSpaceOrigin;
  48695. /**
  48696. * Helper function to create a colored helper in a scene in one line.
  48697. * @param ray Defines the ray we are currently tryin to visualize
  48698. * @param scene Defines the scene the ray is used in
  48699. * @param color Defines the color we want to see the ray in
  48700. * @returns The newly created ray helper.
  48701. */
  48702. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48703. /**
  48704. * Instantiate a new ray helper.
  48705. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48706. * in order to better appreciate the issue one might have.
  48707. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48708. * @param ray Defines the ray we are currently tryin to visualize
  48709. */
  48710. constructor(ray: Ray);
  48711. /**
  48712. * Shows the ray we are willing to debug.
  48713. * @param scene Defines the scene the ray needs to be rendered in
  48714. * @param color Defines the color the ray needs to be rendered in
  48715. */
  48716. show(scene: Scene, color?: Color3): void;
  48717. /**
  48718. * Hides the ray we are debugging.
  48719. */
  48720. hide(): void;
  48721. private _render;
  48722. /**
  48723. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48724. * @param mesh Defines the mesh we want the helper attached to
  48725. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48726. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48727. * @param length Defines the length of the ray
  48728. */
  48729. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48730. /**
  48731. * Detach the ray helper from the mesh it has previously been attached to.
  48732. */
  48733. detachFromMesh(): void;
  48734. private _updateToMesh;
  48735. /**
  48736. * Dispose the helper and release its associated resources.
  48737. */
  48738. dispose(): void;
  48739. }
  48740. }
  48741. declare module "babylonjs/Debug/skeletonViewer" {
  48742. import { Color3 } from "babylonjs/Maths/math.color";
  48743. import { Scene } from "babylonjs/scene";
  48744. import { Nullable } from "babylonjs/types";
  48745. import { Skeleton } from "babylonjs/Bones/skeleton";
  48746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48747. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48748. /**
  48749. * Class used to render a debug view of a given skeleton
  48750. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48751. */
  48752. export class SkeletonViewer {
  48753. /** defines the skeleton to render */
  48754. skeleton: Skeleton;
  48755. /** defines the mesh attached to the skeleton */
  48756. mesh: AbstractMesh;
  48757. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48758. autoUpdateBonesMatrices: boolean;
  48759. /** defines the rendering group id to use with the viewer */
  48760. renderingGroupId: number;
  48761. /** Gets or sets the color used to render the skeleton */
  48762. color: Color3;
  48763. private _scene;
  48764. private _debugLines;
  48765. private _debugMesh;
  48766. private _isEnabled;
  48767. private _renderFunction;
  48768. private _utilityLayer;
  48769. /**
  48770. * Returns the mesh used to render the bones
  48771. */
  48772. get debugMesh(): Nullable<LinesMesh>;
  48773. /**
  48774. * Creates a new SkeletonViewer
  48775. * @param skeleton defines the skeleton to render
  48776. * @param mesh defines the mesh attached to the skeleton
  48777. * @param scene defines the hosting scene
  48778. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48779. * @param renderingGroupId defines the rendering group id to use with the viewer
  48780. */
  48781. constructor(
  48782. /** defines the skeleton to render */
  48783. skeleton: Skeleton,
  48784. /** defines the mesh attached to the skeleton */
  48785. mesh: AbstractMesh, scene: Scene,
  48786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48787. autoUpdateBonesMatrices?: boolean,
  48788. /** defines the rendering group id to use with the viewer */
  48789. renderingGroupId?: number);
  48790. /** Gets or sets a boolean indicating if the viewer is enabled */
  48791. set isEnabled(value: boolean);
  48792. get isEnabled(): boolean;
  48793. private _getBonePosition;
  48794. private _getLinesForBonesWithLength;
  48795. private _getLinesForBonesNoLength;
  48796. /** Update the viewer to sync with current skeleton state */
  48797. update(): void;
  48798. /** Release associated resources */
  48799. dispose(): void;
  48800. }
  48801. }
  48802. declare module "babylonjs/Debug/index" {
  48803. export * from "babylonjs/Debug/axesViewer";
  48804. export * from "babylonjs/Debug/boneAxesViewer";
  48805. export * from "babylonjs/Debug/debugLayer";
  48806. export * from "babylonjs/Debug/physicsViewer";
  48807. export * from "babylonjs/Debug/rayHelper";
  48808. export * from "babylonjs/Debug/skeletonViewer";
  48809. }
  48810. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48811. import { Observable } from "babylonjs/Misc/observable";
  48812. import { Engine } from "babylonjs/Engines/engine";
  48813. import { IDisposable } from "babylonjs/scene";
  48814. import { Nullable } from "babylonjs/types";
  48815. /**
  48816. * This class will take all inputs from Keyboard, Pointer, and
  48817. * any Gamepads and provide a polling system that all devices
  48818. * will use. This class assumes that there will only be one
  48819. * pointer device and one keyboard.
  48820. */
  48821. export class DeviceInputSystem implements IDisposable {
  48822. /** POINTER_DEVICE */
  48823. static readonly POINTER_DEVICE: string;
  48824. /** KEYBOARD_DEVICE */
  48825. static readonly KEYBOARD_DEVICE: string;
  48826. /**
  48827. * Observable to be triggered when a device is connected
  48828. */
  48829. onDeviceConnectedObservable: Observable<string>;
  48830. /**
  48831. * Observable to be triggered when a device is disconnected
  48832. */
  48833. onDeviceDisconnectedObservable: Observable<string>;
  48834. private _inputs;
  48835. private _gamepads;
  48836. private _keyboardActive;
  48837. private _pointerActive;
  48838. private _elementToAttachTo;
  48839. private _keyboardDownEvent;
  48840. private _keyboardUpEvent;
  48841. private _pointerMoveEvent;
  48842. private _pointerDownEvent;
  48843. private _pointerUpEvent;
  48844. private _gamepadConnectedEvent;
  48845. private _gamepadDisconnectedEvent;
  48846. private static _MAX_KEYCODES;
  48847. private static _MAX_POINTER_INPUTS;
  48848. /**
  48849. * Default Constructor
  48850. * @param engine - engine to pull input element from
  48851. */
  48852. constructor(engine: Engine);
  48853. /**
  48854. * Checks for current device input value, given an id and input index
  48855. * @param deviceName Id of connected device
  48856. * @param inputIndex Index of device input
  48857. * @returns Current value of input
  48858. */
  48859. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48860. /**
  48861. * Dispose of all the eventlisteners and clears the observables
  48862. */
  48863. dispose(): void;
  48864. /**
  48865. * Add device and inputs to device map
  48866. * @param deviceName Assigned name of device (may be SN)
  48867. * @param numberOfInputs Number of input entries to create for given device
  48868. */
  48869. private _registerDevice;
  48870. /**
  48871. * Given a specific device name, remove that device from the device map
  48872. * @param deviceName Name of device to be removed
  48873. */
  48874. private _unregisterDevice;
  48875. /**
  48876. * Handle all actions that come from keyboard interaction
  48877. */
  48878. private _handleKeyActions;
  48879. /**
  48880. * Handle all actions that come from pointer interaction
  48881. */
  48882. private _handlePointerActions;
  48883. /**
  48884. * Handle all actions that come from gamepad interaction
  48885. */
  48886. private _handleGamepadActions;
  48887. /**
  48888. * Update all non-event based devices with each frame
  48889. */
  48890. private _updateDevice;
  48891. }
  48892. }
  48893. declare module "babylonjs/DeviceInput/index" {
  48894. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48895. }
  48896. declare module "babylonjs/Engines/nullEngine" {
  48897. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48898. import { Engine } from "babylonjs/Engines/engine";
  48899. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48902. import { Effect } from "babylonjs/Materials/effect";
  48903. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48904. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48905. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48906. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48907. /**
  48908. * Options to create the null engine
  48909. */
  48910. export class NullEngineOptions {
  48911. /**
  48912. * Render width (Default: 512)
  48913. */
  48914. renderWidth: number;
  48915. /**
  48916. * Render height (Default: 256)
  48917. */
  48918. renderHeight: number;
  48919. /**
  48920. * Texture size (Default: 512)
  48921. */
  48922. textureSize: number;
  48923. /**
  48924. * If delta time between frames should be constant
  48925. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48926. */
  48927. deterministicLockstep: boolean;
  48928. /**
  48929. * Maximum about of steps between frames (Default: 4)
  48930. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48931. */
  48932. lockstepMaxSteps: number;
  48933. }
  48934. /**
  48935. * The null engine class provides support for headless version of babylon.js.
  48936. * This can be used in server side scenario or for testing purposes
  48937. */
  48938. export class NullEngine extends Engine {
  48939. private _options;
  48940. /**
  48941. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48943. * @returns true if engine is in deterministic lock step mode
  48944. */
  48945. isDeterministicLockStep(): boolean;
  48946. /**
  48947. * Gets the max steps when engine is running in deterministic lock step
  48948. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48949. * @returns the max steps
  48950. */
  48951. getLockstepMaxSteps(): number;
  48952. /**
  48953. * Gets the current hardware scaling level.
  48954. * By default the hardware scaling level is computed from the window device ratio.
  48955. * 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.
  48956. * @returns a number indicating the current hardware scaling level
  48957. */
  48958. getHardwareScalingLevel(): number;
  48959. constructor(options?: NullEngineOptions);
  48960. /**
  48961. * Creates a vertex buffer
  48962. * @param vertices the data for the vertex buffer
  48963. * @returns the new WebGL static buffer
  48964. */
  48965. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48966. /**
  48967. * Creates a new index buffer
  48968. * @param indices defines the content of the index buffer
  48969. * @param updatable defines if the index buffer must be updatable
  48970. * @returns a new webGL buffer
  48971. */
  48972. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48973. /**
  48974. * Clear the current render buffer or the current render target (if any is set up)
  48975. * @param color defines the color to use
  48976. * @param backBuffer defines if the back buffer must be cleared
  48977. * @param depth defines if the depth buffer must be cleared
  48978. * @param stencil defines if the stencil buffer must be cleared
  48979. */
  48980. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48981. /**
  48982. * Gets the current render width
  48983. * @param useScreen defines if screen size must be used (or the current render target if any)
  48984. * @returns a number defining the current render width
  48985. */
  48986. getRenderWidth(useScreen?: boolean): number;
  48987. /**
  48988. * Gets the current render height
  48989. * @param useScreen defines if screen size must be used (or the current render target if any)
  48990. * @returns a number defining the current render height
  48991. */
  48992. getRenderHeight(useScreen?: boolean): number;
  48993. /**
  48994. * Set the WebGL's viewport
  48995. * @param viewport defines the viewport element to be used
  48996. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48997. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48998. */
  48999. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  49000. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  49001. /**
  49002. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  49003. * @param pipelineContext defines the pipeline context to use
  49004. * @param uniformsNames defines the list of uniform names
  49005. * @returns an array of webGL uniform locations
  49006. */
  49007. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49008. /**
  49009. * Gets the lsit of active attributes for a given webGL program
  49010. * @param pipelineContext defines the pipeline context to use
  49011. * @param attributesNames defines the list of attribute names to get
  49012. * @returns an array of indices indicating the offset of each attribute
  49013. */
  49014. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49015. /**
  49016. * Binds an effect to the webGL context
  49017. * @param effect defines the effect to bind
  49018. */
  49019. bindSamplers(effect: Effect): void;
  49020. /**
  49021. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49022. * @param effect defines the effect to activate
  49023. */
  49024. enableEffect(effect: Effect): void;
  49025. /**
  49026. * Set various states to the webGL context
  49027. * @param culling defines backface culling state
  49028. * @param zOffset defines the value to apply to zOffset (0 by default)
  49029. * @param force defines if states must be applied even if cache is up to date
  49030. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49031. */
  49032. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49033. /**
  49034. * Set the value of an uniform to an array of int32
  49035. * @param uniform defines the webGL uniform location where to store the value
  49036. * @param array defines the array of int32 to store
  49037. */
  49038. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49039. /**
  49040. * Set the value of an uniform to an array of int32 (stored as vec2)
  49041. * @param uniform defines the webGL uniform location where to store the value
  49042. * @param array defines the array of int32 to store
  49043. */
  49044. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49045. /**
  49046. * Set the value of an uniform to an array of int32 (stored as vec3)
  49047. * @param uniform defines the webGL uniform location where to store the value
  49048. * @param array defines the array of int32 to store
  49049. */
  49050. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49051. /**
  49052. * Set the value of an uniform to an array of int32 (stored as vec4)
  49053. * @param uniform defines the webGL uniform location where to store the value
  49054. * @param array defines the array of int32 to store
  49055. */
  49056. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49057. /**
  49058. * Set the value of an uniform to an array of float32
  49059. * @param uniform defines the webGL uniform location where to store the value
  49060. * @param array defines the array of float32 to store
  49061. */
  49062. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49063. /**
  49064. * Set the value of an uniform to an array of float32 (stored as vec2)
  49065. * @param uniform defines the webGL uniform location where to store the value
  49066. * @param array defines the array of float32 to store
  49067. */
  49068. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49069. /**
  49070. * Set the value of an uniform to an array of float32 (stored as vec3)
  49071. * @param uniform defines the webGL uniform location where to store the value
  49072. * @param array defines the array of float32 to store
  49073. */
  49074. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49075. /**
  49076. * Set the value of an uniform to an array of float32 (stored as vec4)
  49077. * @param uniform defines the webGL uniform location where to store the value
  49078. * @param array defines the array of float32 to store
  49079. */
  49080. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49081. /**
  49082. * Set the value of an uniform to an array of number
  49083. * @param uniform defines the webGL uniform location where to store the value
  49084. * @param array defines the array of number to store
  49085. */
  49086. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49087. /**
  49088. * Set the value of an uniform to an array of number (stored as vec2)
  49089. * @param uniform defines the webGL uniform location where to store the value
  49090. * @param array defines the array of number to store
  49091. */
  49092. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49093. /**
  49094. * Set the value of an uniform to an array of number (stored as vec3)
  49095. * @param uniform defines the webGL uniform location where to store the value
  49096. * @param array defines the array of number to store
  49097. */
  49098. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49099. /**
  49100. * Set the value of an uniform to an array of number (stored as vec4)
  49101. * @param uniform defines the webGL uniform location where to store the value
  49102. * @param array defines the array of number to store
  49103. */
  49104. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49105. /**
  49106. * Set the value of an uniform to an array of float32 (stored as matrices)
  49107. * @param uniform defines the webGL uniform location where to store the value
  49108. * @param matrices defines the array of float32 to store
  49109. */
  49110. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49111. /**
  49112. * Set the value of an uniform to a matrix (3x3)
  49113. * @param uniform defines the webGL uniform location where to store the value
  49114. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49115. */
  49116. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49117. /**
  49118. * Set the value of an uniform to a matrix (2x2)
  49119. * @param uniform defines the webGL uniform location where to store the value
  49120. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49121. */
  49122. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49123. /**
  49124. * Set the value of an uniform to a number (float)
  49125. * @param uniform defines the webGL uniform location where to store the value
  49126. * @param value defines the float number to store
  49127. */
  49128. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49129. /**
  49130. * Set the value of an uniform to a vec2
  49131. * @param uniform defines the webGL uniform location where to store the value
  49132. * @param x defines the 1st component of the value
  49133. * @param y defines the 2nd component of the value
  49134. */
  49135. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49136. /**
  49137. * Set the value of an uniform to a vec3
  49138. * @param uniform defines the webGL uniform location where to store the value
  49139. * @param x defines the 1st component of the value
  49140. * @param y defines the 2nd component of the value
  49141. * @param z defines the 3rd component of the value
  49142. */
  49143. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49144. /**
  49145. * Set the value of an uniform to a boolean
  49146. * @param uniform defines the webGL uniform location where to store the value
  49147. * @param bool defines the boolean to store
  49148. */
  49149. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49150. /**
  49151. * Set the value of an uniform to a vec4
  49152. * @param uniform defines the webGL uniform location where to store the value
  49153. * @param x defines the 1st component of the value
  49154. * @param y defines the 2nd component of the value
  49155. * @param z defines the 3rd component of the value
  49156. * @param w defines the 4th component of the value
  49157. */
  49158. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49159. /**
  49160. * Sets the current alpha mode
  49161. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49162. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49164. */
  49165. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49166. /**
  49167. * Bind webGl buffers directly to the webGL context
  49168. * @param vertexBuffers defines the vertex buffer to bind
  49169. * @param indexBuffer defines the index buffer to bind
  49170. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49171. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49172. * @param effect defines the effect associated with the vertex buffer
  49173. */
  49174. bindBuffers(vertexBuffers: {
  49175. [key: string]: VertexBuffer;
  49176. }, indexBuffer: DataBuffer, effect: Effect): void;
  49177. /**
  49178. * Force the entire cache to be cleared
  49179. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49180. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49181. */
  49182. wipeCaches(bruteForce?: boolean): void;
  49183. /**
  49184. * Send a draw order
  49185. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49186. * @param indexStart defines the starting index
  49187. * @param indexCount defines the number of index to draw
  49188. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49189. */
  49190. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49191. /**
  49192. * Draw a list of indexed primitives
  49193. * @param fillMode defines the primitive to use
  49194. * @param indexStart defines the starting index
  49195. * @param indexCount defines the number of index to draw
  49196. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49197. */
  49198. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49199. /**
  49200. * Draw a list of unindexed primitives
  49201. * @param fillMode defines the primitive to use
  49202. * @param verticesStart defines the index of first vertex to draw
  49203. * @param verticesCount defines the count of vertices to draw
  49204. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49205. */
  49206. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49207. /** @hidden */
  49208. _createTexture(): WebGLTexture;
  49209. /** @hidden */
  49210. _releaseTexture(texture: InternalTexture): void;
  49211. /**
  49212. * Usually called from Texture.ts.
  49213. * Passed information to create a WebGLTexture
  49214. * @param urlArg defines a value which contains one of the following:
  49215. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49216. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49217. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49219. * @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)
  49220. * @param scene needed for loading to the correct scene
  49221. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49222. * @param onLoad optional callback to be called upon successful completion
  49223. * @param onError optional callback to be called upon failure
  49224. * @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
  49225. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49226. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49227. * @param forcedExtension defines the extension to use to pick the right loader
  49228. * @param mimeType defines an optional mime type
  49229. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49230. */
  49231. 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;
  49232. /**
  49233. * Creates a new render target texture
  49234. * @param size defines the size of the texture
  49235. * @param options defines the options used to create the texture
  49236. * @returns a new render target texture stored in an InternalTexture
  49237. */
  49238. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49239. /**
  49240. * Update the sampling mode of a given texture
  49241. * @param samplingMode defines the required sampling mode
  49242. * @param texture defines the texture to update
  49243. */
  49244. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49245. /**
  49246. * Binds the frame buffer to the specified texture.
  49247. * @param texture The texture to render to or null for the default canvas
  49248. * @param faceIndex The face of the texture to render to in case of cube texture
  49249. * @param requiredWidth The width of the target to render to
  49250. * @param requiredHeight The height of the target to render to
  49251. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49252. * @param lodLevel defines le lod level to bind to the frame buffer
  49253. */
  49254. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49255. /**
  49256. * Unbind the current render target texture from the webGL context
  49257. * @param texture defines the render target texture to unbind
  49258. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49259. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49260. */
  49261. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49262. /**
  49263. * Creates a dynamic vertex buffer
  49264. * @param vertices the data for the dynamic vertex buffer
  49265. * @returns the new WebGL dynamic buffer
  49266. */
  49267. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49268. /**
  49269. * Update the content of a dynamic texture
  49270. * @param texture defines the texture to update
  49271. * @param canvas defines the canvas containing the source
  49272. * @param invertY defines if data must be stored with Y axis inverted
  49273. * @param premulAlpha defines if alpha is stored as premultiplied
  49274. * @param format defines the format of the data
  49275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49276. */
  49277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49278. /**
  49279. * Gets a boolean indicating if all created effects are ready
  49280. * @returns true if all effects are ready
  49281. */
  49282. areAllEffectsReady(): boolean;
  49283. /**
  49284. * @hidden
  49285. * Get the current error code of the webGL context
  49286. * @returns the error code
  49287. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49288. */
  49289. getError(): number;
  49290. /** @hidden */
  49291. _getUnpackAlignement(): number;
  49292. /** @hidden */
  49293. _unpackFlipY(value: boolean): void;
  49294. /**
  49295. * Update a dynamic index buffer
  49296. * @param indexBuffer defines the target index buffer
  49297. * @param indices defines the data to update
  49298. * @param offset defines the offset in the target index buffer where update should start
  49299. */
  49300. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49301. /**
  49302. * Updates a dynamic vertex buffer.
  49303. * @param vertexBuffer the vertex buffer to update
  49304. * @param vertices the data used to update the vertex buffer
  49305. * @param byteOffset the byte offset of the data (optional)
  49306. * @param byteLength the byte length of the data (optional)
  49307. */
  49308. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49309. /** @hidden */
  49310. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49311. /** @hidden */
  49312. _bindTexture(channel: number, texture: InternalTexture): void;
  49313. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49314. /**
  49315. * 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
  49316. */
  49317. releaseEffects(): void;
  49318. displayLoadingUI(): void;
  49319. hideLoadingUI(): void;
  49320. /** @hidden */
  49321. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49322. /** @hidden */
  49323. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49324. /** @hidden */
  49325. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49326. /** @hidden */
  49327. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49328. }
  49329. }
  49330. declare module "babylonjs/Instrumentation/timeToken" {
  49331. import { Nullable } from "babylonjs/types";
  49332. /**
  49333. * @hidden
  49334. **/
  49335. export class _TimeToken {
  49336. _startTimeQuery: Nullable<WebGLQuery>;
  49337. _endTimeQuery: Nullable<WebGLQuery>;
  49338. _timeElapsedQuery: Nullable<WebGLQuery>;
  49339. _timeElapsedQueryEnded: boolean;
  49340. }
  49341. }
  49342. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49343. import { Nullable, int } from "babylonjs/types";
  49344. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49345. /** @hidden */
  49346. export class _OcclusionDataStorage {
  49347. /** @hidden */
  49348. occlusionInternalRetryCounter: number;
  49349. /** @hidden */
  49350. isOcclusionQueryInProgress: boolean;
  49351. /** @hidden */
  49352. isOccluded: boolean;
  49353. /** @hidden */
  49354. occlusionRetryCount: number;
  49355. /** @hidden */
  49356. occlusionType: number;
  49357. /** @hidden */
  49358. occlusionQueryAlgorithmType: number;
  49359. }
  49360. module "babylonjs/Engines/engine" {
  49361. interface Engine {
  49362. /**
  49363. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49364. * @return the new query
  49365. */
  49366. createQuery(): WebGLQuery;
  49367. /**
  49368. * Delete and release a webGL query
  49369. * @param query defines the query to delete
  49370. * @return the current engine
  49371. */
  49372. deleteQuery(query: WebGLQuery): Engine;
  49373. /**
  49374. * Check if a given query has resolved and got its value
  49375. * @param query defines the query to check
  49376. * @returns true if the query got its value
  49377. */
  49378. isQueryResultAvailable(query: WebGLQuery): boolean;
  49379. /**
  49380. * Gets the value of a given query
  49381. * @param query defines the query to check
  49382. * @returns the value of the query
  49383. */
  49384. getQueryResult(query: WebGLQuery): number;
  49385. /**
  49386. * Initiates an occlusion query
  49387. * @param algorithmType defines the algorithm to use
  49388. * @param query defines the query to use
  49389. * @returns the current engine
  49390. * @see http://doc.babylonjs.com/features/occlusionquery
  49391. */
  49392. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49393. /**
  49394. * Ends an occlusion query
  49395. * @see http://doc.babylonjs.com/features/occlusionquery
  49396. * @param algorithmType defines the algorithm to use
  49397. * @returns the current engine
  49398. */
  49399. endOcclusionQuery(algorithmType: number): Engine;
  49400. /**
  49401. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49402. * Please note that only one query can be issued at a time
  49403. * @returns a time token used to track the time span
  49404. */
  49405. startTimeQuery(): Nullable<_TimeToken>;
  49406. /**
  49407. * Ends a time query
  49408. * @param token defines the token used to measure the time span
  49409. * @returns the time spent (in ns)
  49410. */
  49411. endTimeQuery(token: _TimeToken): int;
  49412. /** @hidden */
  49413. _currentNonTimestampToken: Nullable<_TimeToken>;
  49414. /** @hidden */
  49415. _createTimeQuery(): WebGLQuery;
  49416. /** @hidden */
  49417. _deleteTimeQuery(query: WebGLQuery): void;
  49418. /** @hidden */
  49419. _getGlAlgorithmType(algorithmType: number): number;
  49420. /** @hidden */
  49421. _getTimeQueryResult(query: WebGLQuery): any;
  49422. /** @hidden */
  49423. _getTimeQueryAvailability(query: WebGLQuery): any;
  49424. }
  49425. }
  49426. module "babylonjs/Meshes/abstractMesh" {
  49427. interface AbstractMesh {
  49428. /**
  49429. * Backing filed
  49430. * @hidden
  49431. */
  49432. __occlusionDataStorage: _OcclusionDataStorage;
  49433. /**
  49434. * Access property
  49435. * @hidden
  49436. */
  49437. _occlusionDataStorage: _OcclusionDataStorage;
  49438. /**
  49439. * 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.
  49440. * The default value is -1 which means don't break the query and wait till the result
  49441. * @see http://doc.babylonjs.com/features/occlusionquery
  49442. */
  49443. occlusionRetryCount: number;
  49444. /**
  49445. * 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:
  49446. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49447. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49448. * * 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.
  49449. * @see http://doc.babylonjs.com/features/occlusionquery
  49450. */
  49451. occlusionType: number;
  49452. /**
  49453. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49454. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49455. * * 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.
  49456. * @see http://doc.babylonjs.com/features/occlusionquery
  49457. */
  49458. occlusionQueryAlgorithmType: number;
  49459. /**
  49460. * 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
  49461. * @see http://doc.babylonjs.com/features/occlusionquery
  49462. */
  49463. isOccluded: boolean;
  49464. /**
  49465. * Flag to check the progress status of the query
  49466. * @see http://doc.babylonjs.com/features/occlusionquery
  49467. */
  49468. isOcclusionQueryInProgress: boolean;
  49469. }
  49470. }
  49471. }
  49472. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49473. import { Nullable } from "babylonjs/types";
  49474. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49475. /** @hidden */
  49476. export var _forceTransformFeedbackToBundle: boolean;
  49477. module "babylonjs/Engines/engine" {
  49478. interface Engine {
  49479. /**
  49480. * Creates a webGL transform feedback object
  49481. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49482. * @returns the webGL transform feedback object
  49483. */
  49484. createTransformFeedback(): WebGLTransformFeedback;
  49485. /**
  49486. * Delete a webGL transform feedback object
  49487. * @param value defines the webGL transform feedback object to delete
  49488. */
  49489. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49490. /**
  49491. * Bind a webGL transform feedback object to the webgl context
  49492. * @param value defines the webGL transform feedback object to bind
  49493. */
  49494. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49495. /**
  49496. * Begins a transform feedback operation
  49497. * @param usePoints defines if points or triangles must be used
  49498. */
  49499. beginTransformFeedback(usePoints: boolean): void;
  49500. /**
  49501. * Ends a transform feedback operation
  49502. */
  49503. endTransformFeedback(): void;
  49504. /**
  49505. * Specify the varyings to use with transform feedback
  49506. * @param program defines the associated webGL program
  49507. * @param value defines the list of strings representing the varying names
  49508. */
  49509. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49510. /**
  49511. * Bind a webGL buffer for a transform feedback operation
  49512. * @param value defines the webGL buffer to bind
  49513. */
  49514. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49515. }
  49516. }
  49517. }
  49518. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49519. import { Scene } from "babylonjs/scene";
  49520. import { Engine } from "babylonjs/Engines/engine";
  49521. import { Texture } from "babylonjs/Materials/Textures/texture";
  49522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49523. import "babylonjs/Engines/Extensions/engine.multiRender";
  49524. /**
  49525. * Creation options of the multi render target texture.
  49526. */
  49527. export interface IMultiRenderTargetOptions {
  49528. /**
  49529. * Define if the texture needs to create mip maps after render.
  49530. */
  49531. generateMipMaps?: boolean;
  49532. /**
  49533. * Define the types of all the draw buffers we want to create
  49534. */
  49535. types?: number[];
  49536. /**
  49537. * Define the sampling modes of all the draw buffers we want to create
  49538. */
  49539. samplingModes?: number[];
  49540. /**
  49541. * Define if a depth buffer is required
  49542. */
  49543. generateDepthBuffer?: boolean;
  49544. /**
  49545. * Define if a stencil buffer is required
  49546. */
  49547. generateStencilBuffer?: boolean;
  49548. /**
  49549. * Define if a depth texture is required instead of a depth buffer
  49550. */
  49551. generateDepthTexture?: boolean;
  49552. /**
  49553. * Define the number of desired draw buffers
  49554. */
  49555. textureCount?: number;
  49556. /**
  49557. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49558. */
  49559. doNotChangeAspectRatio?: boolean;
  49560. /**
  49561. * Define the default type of the buffers we are creating
  49562. */
  49563. defaultType?: number;
  49564. }
  49565. /**
  49566. * A multi render target, like a render target provides the ability to render to a texture.
  49567. * Unlike the render target, it can render to several draw buffers in one draw.
  49568. * This is specially interesting in deferred rendering or for any effects requiring more than
  49569. * just one color from a single pass.
  49570. */
  49571. export class MultiRenderTarget extends RenderTargetTexture {
  49572. private _internalTextures;
  49573. private _textures;
  49574. private _multiRenderTargetOptions;
  49575. /**
  49576. * Get if draw buffers are currently supported by the used hardware and browser.
  49577. */
  49578. get isSupported(): boolean;
  49579. /**
  49580. * Get the list of textures generated by the multi render target.
  49581. */
  49582. get textures(): Texture[];
  49583. /**
  49584. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49585. */
  49586. get depthTexture(): Texture;
  49587. /**
  49588. * Set the wrapping mode on U of all the textures we are rendering to.
  49589. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49590. */
  49591. set wrapU(wrap: number);
  49592. /**
  49593. * Set the wrapping mode on V of all the textures we are rendering to.
  49594. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49595. */
  49596. set wrapV(wrap: number);
  49597. /**
  49598. * Instantiate a new multi render target texture.
  49599. * A multi render target, like a render target provides the ability to render to a texture.
  49600. * Unlike the render target, it can render to several draw buffers in one draw.
  49601. * This is specially interesting in deferred rendering or for any effects requiring more than
  49602. * just one color from a single pass.
  49603. * @param name Define the name of the texture
  49604. * @param size Define the size of the buffers to render to
  49605. * @param count Define the number of target we are rendering into
  49606. * @param scene Define the scene the texture belongs to
  49607. * @param options Define the options used to create the multi render target
  49608. */
  49609. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49610. /** @hidden */
  49611. _rebuild(): void;
  49612. private _createInternalTextures;
  49613. private _createTextures;
  49614. /**
  49615. * Define the number of samples used if MSAA is enabled.
  49616. */
  49617. get samples(): number;
  49618. set samples(value: number);
  49619. /**
  49620. * Resize all the textures in the multi render target.
  49621. * Be carrefull as it will recreate all the data in the new texture.
  49622. * @param size Define the new size
  49623. */
  49624. resize(size: any): void;
  49625. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49626. /**
  49627. * Dispose the render targets and their associated resources
  49628. */
  49629. dispose(): void;
  49630. /**
  49631. * Release all the underlying texture used as draw buffers.
  49632. */
  49633. releaseInternalTextures(): void;
  49634. }
  49635. }
  49636. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49638. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49639. import { Nullable } from "babylonjs/types";
  49640. module "babylonjs/Engines/thinEngine" {
  49641. interface ThinEngine {
  49642. /**
  49643. * Unbind a list of render target textures from the webGL context
  49644. * This is used only when drawBuffer extension or webGL2 are active
  49645. * @param textures defines the render target textures to unbind
  49646. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49647. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49648. */
  49649. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49650. /**
  49651. * Create a multi render target texture
  49652. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49653. * @param size defines the size of the texture
  49654. * @param options defines the creation options
  49655. * @returns the cube texture as an InternalTexture
  49656. */
  49657. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49658. /**
  49659. * Update the sample count for a given multiple render target texture
  49660. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49661. * @param textures defines the textures to update
  49662. * @param samples defines the sample count to set
  49663. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49664. */
  49665. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49666. }
  49667. }
  49668. }
  49669. declare module "babylonjs/Engines/Extensions/engine.views" {
  49670. import { Camera } from "babylonjs/Cameras/camera";
  49671. import { Nullable } from "babylonjs/types";
  49672. /**
  49673. * Class used to define an additional view for the engine
  49674. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49675. */
  49676. export class EngineView {
  49677. /** Defines the canvas where to render the view */
  49678. target: HTMLCanvasElement;
  49679. /** Defines an optional camera used to render the view (will use active camera else) */
  49680. camera?: Camera;
  49681. }
  49682. module "babylonjs/Engines/engine" {
  49683. interface Engine {
  49684. /**
  49685. * Gets or sets the HTML element to use for attaching events
  49686. */
  49687. inputElement: Nullable<HTMLElement>;
  49688. /**
  49689. * Gets the current engine view
  49690. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49691. */
  49692. activeView: Nullable<EngineView>;
  49693. /** Gets or sets the list of views */
  49694. views: EngineView[];
  49695. /**
  49696. * Register a new child canvas
  49697. * @param canvas defines the canvas to register
  49698. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49699. * @returns the associated view
  49700. */
  49701. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49702. /**
  49703. * Remove a registered child canvas
  49704. * @param canvas defines the canvas to remove
  49705. * @returns the current engine
  49706. */
  49707. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49708. }
  49709. }
  49710. }
  49711. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49712. import { Nullable } from "babylonjs/types";
  49713. module "babylonjs/Engines/engine" {
  49714. interface Engine {
  49715. /** @hidden */
  49716. _excludedCompressedTextures: string[];
  49717. /** @hidden */
  49718. _textureFormatInUse: string;
  49719. /**
  49720. * Gets the list of texture formats supported
  49721. */
  49722. readonly texturesSupported: Array<string>;
  49723. /**
  49724. * Gets the texture format in use
  49725. */
  49726. readonly textureFormatInUse: Nullable<string>;
  49727. /**
  49728. * Set the compressed texture extensions or file names to skip.
  49729. *
  49730. * @param skippedFiles defines the list of those texture files you want to skip
  49731. * Example: [".dds", ".env", "myfile.png"]
  49732. */
  49733. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49734. /**
  49735. * Set the compressed texture format to use, based on the formats you have, and the formats
  49736. * supported by the hardware / browser.
  49737. *
  49738. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49739. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49740. * to API arguments needed to compressed textures. This puts the burden on the container
  49741. * generator to house the arcane code for determining these for current & future formats.
  49742. *
  49743. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49744. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49745. *
  49746. * Note: The result of this call is not taken into account when a texture is base64.
  49747. *
  49748. * @param formatsAvailable defines the list of those format families you have created
  49749. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49750. *
  49751. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49752. * @returns The extension selected.
  49753. */
  49754. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49755. }
  49756. }
  49757. }
  49758. declare module "babylonjs/Engines/Extensions/index" {
  49759. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49760. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49761. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49762. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49763. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49764. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49765. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49766. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49767. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49768. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49769. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49770. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49771. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49772. export * from "babylonjs/Engines/Extensions/engine.views";
  49773. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49774. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49775. }
  49776. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49777. import { Nullable } from "babylonjs/types";
  49778. /**
  49779. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49780. */
  49781. export interface CubeMapInfo {
  49782. /**
  49783. * The pixel array for the front face.
  49784. * This is stored in format, left to right, up to down format.
  49785. */
  49786. front: Nullable<ArrayBufferView>;
  49787. /**
  49788. * The pixel array for the back face.
  49789. * This is stored in format, left to right, up to down format.
  49790. */
  49791. back: Nullable<ArrayBufferView>;
  49792. /**
  49793. * The pixel array for the left face.
  49794. * This is stored in format, left to right, up to down format.
  49795. */
  49796. left: Nullable<ArrayBufferView>;
  49797. /**
  49798. * The pixel array for the right face.
  49799. * This is stored in format, left to right, up to down format.
  49800. */
  49801. right: Nullable<ArrayBufferView>;
  49802. /**
  49803. * The pixel array for the up face.
  49804. * This is stored in format, left to right, up to down format.
  49805. */
  49806. up: Nullable<ArrayBufferView>;
  49807. /**
  49808. * The pixel array for the down face.
  49809. * This is stored in format, left to right, up to down format.
  49810. */
  49811. down: Nullable<ArrayBufferView>;
  49812. /**
  49813. * The size of the cubemap stored.
  49814. *
  49815. * Each faces will be size * size pixels.
  49816. */
  49817. size: number;
  49818. /**
  49819. * The format of the texture.
  49820. *
  49821. * RGBA, RGB.
  49822. */
  49823. format: number;
  49824. /**
  49825. * The type of the texture data.
  49826. *
  49827. * UNSIGNED_INT, FLOAT.
  49828. */
  49829. type: number;
  49830. /**
  49831. * Specifies whether the texture is in gamma space.
  49832. */
  49833. gammaSpace: boolean;
  49834. }
  49835. /**
  49836. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49837. */
  49838. export class PanoramaToCubeMapTools {
  49839. private static FACE_FRONT;
  49840. private static FACE_BACK;
  49841. private static FACE_RIGHT;
  49842. private static FACE_LEFT;
  49843. private static FACE_DOWN;
  49844. private static FACE_UP;
  49845. /**
  49846. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49847. *
  49848. * @param float32Array The source data.
  49849. * @param inputWidth The width of the input panorama.
  49850. * @param inputHeight The height of the input panorama.
  49851. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49852. * @return The cubemap data
  49853. */
  49854. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49855. private static CreateCubemapTexture;
  49856. private static CalcProjectionSpherical;
  49857. }
  49858. }
  49859. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49862. import { Nullable } from "babylonjs/types";
  49863. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49864. /**
  49865. * Helper class dealing with the extraction of spherical polynomial dataArray
  49866. * from a cube map.
  49867. */
  49868. export class CubeMapToSphericalPolynomialTools {
  49869. private static FileFaces;
  49870. /**
  49871. * Converts a texture to the according Spherical Polynomial data.
  49872. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49873. *
  49874. * @param texture The texture to extract the information from.
  49875. * @return The Spherical Polynomial data.
  49876. */
  49877. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49878. /**
  49879. * Converts a cubemap to the according Spherical Polynomial data.
  49880. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49881. *
  49882. * @param cubeInfo The Cube map to extract the information from.
  49883. * @return The Spherical Polynomial data.
  49884. */
  49885. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49886. }
  49887. }
  49888. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49889. import { Nullable } from "babylonjs/types";
  49890. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49891. module "babylonjs/Materials/Textures/baseTexture" {
  49892. interface BaseTexture {
  49893. /**
  49894. * Get the polynomial representation of the texture data.
  49895. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49896. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49897. */
  49898. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49899. }
  49900. }
  49901. }
  49902. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49904. /** @hidden */
  49905. export var rgbdEncodePixelShader: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49912. /** @hidden */
  49913. export var rgbdDecodePixelShader: {
  49914. name: string;
  49915. shader: string;
  49916. };
  49917. }
  49918. declare module "babylonjs/Misc/environmentTextureTools" {
  49919. import { Nullable } from "babylonjs/types";
  49920. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49922. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49923. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49924. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49925. import "babylonjs/Shaders/rgbdEncode.fragment";
  49926. import "babylonjs/Shaders/rgbdDecode.fragment";
  49927. /**
  49928. * Raw texture data and descriptor sufficient for WebGL texture upload
  49929. */
  49930. export interface EnvironmentTextureInfo {
  49931. /**
  49932. * Version of the environment map
  49933. */
  49934. version: number;
  49935. /**
  49936. * Width of image
  49937. */
  49938. width: number;
  49939. /**
  49940. * Irradiance information stored in the file.
  49941. */
  49942. irradiance: any;
  49943. /**
  49944. * Specular information stored in the file.
  49945. */
  49946. specular: any;
  49947. }
  49948. /**
  49949. * Defines One Image in the file. It requires only the position in the file
  49950. * as well as the length.
  49951. */
  49952. interface BufferImageData {
  49953. /**
  49954. * Length of the image data.
  49955. */
  49956. length: number;
  49957. /**
  49958. * Position of the data from the null terminator delimiting the end of the JSON.
  49959. */
  49960. position: number;
  49961. }
  49962. /**
  49963. * Defines the specular data enclosed in the file.
  49964. * This corresponds to the version 1 of the data.
  49965. */
  49966. export interface EnvironmentTextureSpecularInfoV1 {
  49967. /**
  49968. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49969. */
  49970. specularDataPosition?: number;
  49971. /**
  49972. * This contains all the images data needed to reconstruct the cubemap.
  49973. */
  49974. mipmaps: Array<BufferImageData>;
  49975. /**
  49976. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49977. */
  49978. lodGenerationScale: number;
  49979. }
  49980. /**
  49981. * Sets of helpers addressing the serialization and deserialization of environment texture
  49982. * stored in a BabylonJS env file.
  49983. * Those files are usually stored as .env files.
  49984. */
  49985. export class EnvironmentTextureTools {
  49986. /**
  49987. * Magic number identifying the env file.
  49988. */
  49989. private static _MagicBytes;
  49990. /**
  49991. * Gets the environment info from an env file.
  49992. * @param data The array buffer containing the .env bytes.
  49993. * @returns the environment file info (the json header) if successfully parsed.
  49994. */
  49995. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49996. /**
  49997. * Creates an environment texture from a loaded cube texture.
  49998. * @param texture defines the cube texture to convert in env file
  49999. * @return a promise containing the environment data if succesfull.
  50000. */
  50001. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  50002. /**
  50003. * Creates a JSON representation of the spherical data.
  50004. * @param texture defines the texture containing the polynomials
  50005. * @return the JSON representation of the spherical info
  50006. */
  50007. private static _CreateEnvTextureIrradiance;
  50008. /**
  50009. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50010. * @param data the image data
  50011. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50012. * @return the views described by info providing access to the underlying buffer
  50013. */
  50014. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50015. /**
  50016. * Uploads the texture info contained in the env file to the GPU.
  50017. * @param texture defines the internal texture to upload to
  50018. * @param data defines the data to load
  50019. * @param info defines the texture info retrieved through the GetEnvInfo method
  50020. * @returns a promise
  50021. */
  50022. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50023. private static _OnImageReadyAsync;
  50024. /**
  50025. * Uploads the levels of image data to the GPU.
  50026. * @param texture defines the internal texture to upload to
  50027. * @param imageData defines the array buffer views of image data [mipmap][face]
  50028. * @returns a promise
  50029. */
  50030. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50031. /**
  50032. * Uploads spherical polynomials information to the texture.
  50033. * @param texture defines the texture we are trying to upload the information to
  50034. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50035. */
  50036. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50037. /** @hidden */
  50038. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50039. }
  50040. }
  50041. declare module "babylonjs/Maths/math.vertexFormat" {
  50042. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50043. /**
  50044. * Contains position and normal vectors for a vertex
  50045. */
  50046. export class PositionNormalVertex {
  50047. /** the position of the vertex (defaut: 0,0,0) */
  50048. position: Vector3;
  50049. /** the normal of the vertex (defaut: 0,1,0) */
  50050. normal: Vector3;
  50051. /**
  50052. * Creates a PositionNormalVertex
  50053. * @param position the position of the vertex (defaut: 0,0,0)
  50054. * @param normal the normal of the vertex (defaut: 0,1,0)
  50055. */
  50056. constructor(
  50057. /** the position of the vertex (defaut: 0,0,0) */
  50058. position?: Vector3,
  50059. /** the normal of the vertex (defaut: 0,1,0) */
  50060. normal?: Vector3);
  50061. /**
  50062. * Clones the PositionNormalVertex
  50063. * @returns the cloned PositionNormalVertex
  50064. */
  50065. clone(): PositionNormalVertex;
  50066. }
  50067. /**
  50068. * Contains position, normal and uv vectors for a vertex
  50069. */
  50070. export class PositionNormalTextureVertex {
  50071. /** the position of the vertex (defaut: 0,0,0) */
  50072. position: Vector3;
  50073. /** the normal of the vertex (defaut: 0,1,0) */
  50074. normal: Vector3;
  50075. /** the uv of the vertex (default: 0,0) */
  50076. uv: Vector2;
  50077. /**
  50078. * Creates a PositionNormalTextureVertex
  50079. * @param position the position of the vertex (defaut: 0,0,0)
  50080. * @param normal the normal of the vertex (defaut: 0,1,0)
  50081. * @param uv the uv of the vertex (default: 0,0)
  50082. */
  50083. constructor(
  50084. /** the position of the vertex (defaut: 0,0,0) */
  50085. position?: Vector3,
  50086. /** the normal of the vertex (defaut: 0,1,0) */
  50087. normal?: Vector3,
  50088. /** the uv of the vertex (default: 0,0) */
  50089. uv?: Vector2);
  50090. /**
  50091. * Clones the PositionNormalTextureVertex
  50092. * @returns the cloned PositionNormalTextureVertex
  50093. */
  50094. clone(): PositionNormalTextureVertex;
  50095. }
  50096. }
  50097. declare module "babylonjs/Maths/math" {
  50098. export * from "babylonjs/Maths/math.axis";
  50099. export * from "babylonjs/Maths/math.color";
  50100. export * from "babylonjs/Maths/math.constants";
  50101. export * from "babylonjs/Maths/math.frustum";
  50102. export * from "babylonjs/Maths/math.path";
  50103. export * from "babylonjs/Maths/math.plane";
  50104. export * from "babylonjs/Maths/math.size";
  50105. export * from "babylonjs/Maths/math.vector";
  50106. export * from "babylonjs/Maths/math.vertexFormat";
  50107. export * from "babylonjs/Maths/math.viewport";
  50108. }
  50109. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50110. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50111. /** @hidden */
  50112. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50113. private _genericAttributeLocation;
  50114. private _varyingLocationCount;
  50115. private _varyingLocationMap;
  50116. private _replacements;
  50117. private _textureCount;
  50118. private _uniforms;
  50119. lineProcessor(line: string): string;
  50120. attributeProcessor(attribute: string): string;
  50121. varyingProcessor(varying: string, isFragment: boolean): string;
  50122. uniformProcessor(uniform: string): string;
  50123. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50124. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50125. }
  50126. }
  50127. declare module "babylonjs/Engines/nativeEngine" {
  50128. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50129. import { Engine } from "babylonjs/Engines/engine";
  50130. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50133. import { Effect } from "babylonjs/Materials/effect";
  50134. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50135. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50136. import { IColor4Like } from "babylonjs/Maths/math.like";
  50137. import { Scene } from "babylonjs/scene";
  50138. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50139. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50140. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50141. /**
  50142. * Container for accessors for natively-stored mesh data buffers.
  50143. */
  50144. class NativeDataBuffer extends DataBuffer {
  50145. /**
  50146. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50147. */
  50148. nativeIndexBuffer?: any;
  50149. /**
  50150. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50151. */
  50152. nativeVertexBuffer?: any;
  50153. }
  50154. /** @hidden */
  50155. class NativeTexture extends InternalTexture {
  50156. getInternalTexture(): InternalTexture;
  50157. getViewCount(): number;
  50158. }
  50159. /** @hidden */
  50160. export class NativeEngine extends Engine {
  50161. private readonly _native;
  50162. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50163. private readonly INVALID_HANDLE;
  50164. getHardwareScalingLevel(): number;
  50165. constructor();
  50166. dispose(): void;
  50167. /**
  50168. * Can be used to override the current requestAnimationFrame requester.
  50169. * @hidden
  50170. */
  50171. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50172. /**
  50173. * Override default engine behavior.
  50174. * @param color
  50175. * @param backBuffer
  50176. * @param depth
  50177. * @param stencil
  50178. */
  50179. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50180. /**
  50181. * Gets host document
  50182. * @returns the host document object
  50183. */
  50184. getHostDocument(): Nullable<Document>;
  50185. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50186. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50187. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50188. recordVertexArrayObject(vertexBuffers: {
  50189. [key: string]: VertexBuffer;
  50190. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50191. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50192. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50193. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50194. /**
  50195. * Draw a list of indexed primitives
  50196. * @param fillMode defines the primitive to use
  50197. * @param indexStart defines the starting index
  50198. * @param indexCount defines the number of index to draw
  50199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50200. */
  50201. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50202. /**
  50203. * Draw a list of unindexed primitives
  50204. * @param fillMode defines the primitive to use
  50205. * @param verticesStart defines the index of first vertex to draw
  50206. * @param verticesCount defines the count of vertices to draw
  50207. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50208. */
  50209. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50210. createPipelineContext(): IPipelineContext;
  50211. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50212. /** @hidden */
  50213. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50214. /** @hidden */
  50215. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50216. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50217. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50218. protected _setProgram(program: WebGLProgram): void;
  50219. _releaseEffect(effect: Effect): void;
  50220. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50221. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50223. bindSamplers(effect: Effect): void;
  50224. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50225. getRenderWidth(useScreen?: boolean): number;
  50226. getRenderHeight(useScreen?: boolean): number;
  50227. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50229. /**
  50230. * Set the z offset to apply to current rendering
  50231. * @param value defines the offset to apply
  50232. */
  50233. setZOffset(value: number): void;
  50234. /**
  50235. * Gets the current value of the zOffset
  50236. * @returns the current zOffset state
  50237. */
  50238. getZOffset(): number;
  50239. /**
  50240. * Enable or disable depth buffering
  50241. * @param enable defines the state to set
  50242. */
  50243. setDepthBuffer(enable: boolean): void;
  50244. /**
  50245. * Gets a boolean indicating if depth writing is enabled
  50246. * @returns the current depth writing state
  50247. */
  50248. getDepthWrite(): boolean;
  50249. /**
  50250. * Enable or disable depth writing
  50251. * @param enable defines the state to set
  50252. */
  50253. setDepthWrite(enable: boolean): void;
  50254. /**
  50255. * Enable or disable color writing
  50256. * @param enable defines the state to set
  50257. */
  50258. setColorWrite(enable: boolean): void;
  50259. /**
  50260. * Gets a boolean indicating if color writing is enabled
  50261. * @returns the current color writing state
  50262. */
  50263. getColorWrite(): boolean;
  50264. /**
  50265. * Sets alpha constants used by some alpha blending modes
  50266. * @param r defines the red component
  50267. * @param g defines the green component
  50268. * @param b defines the blue component
  50269. * @param a defines the alpha component
  50270. */
  50271. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50272. /**
  50273. * Sets the current alpha mode
  50274. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50275. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50277. */
  50278. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50279. /**
  50280. * Gets the current alpha mode
  50281. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50282. * @returns the current alpha mode
  50283. */
  50284. getAlphaMode(): number;
  50285. setInt(uniform: WebGLUniformLocation, int: number): void;
  50286. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50287. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50288. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50289. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50290. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50291. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50292. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50293. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50294. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50295. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50297. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50298. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50299. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50300. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50301. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50302. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50303. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50304. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50305. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50306. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50307. wipeCaches(bruteForce?: boolean): void;
  50308. _createTexture(): WebGLTexture;
  50309. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50310. /**
  50311. * Usually called from Texture.ts.
  50312. * Passed information to create a WebGLTexture
  50313. * @param url defines a value which contains one of the following:
  50314. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50315. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50316. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50317. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50318. * @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)
  50319. * @param scene needed for loading to the correct scene
  50320. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50321. * @param onLoad optional callback to be called upon successful completion
  50322. * @param onError optional callback to be called upon failure
  50323. * @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
  50324. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50325. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50326. * @param forcedExtension defines the extension to use to pick the right loader
  50327. * @param mimeType defines an optional mime type
  50328. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50329. */
  50330. 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;
  50331. /**
  50332. * Creates a cube texture
  50333. * @param rootUrl defines the url where the files to load is located
  50334. * @param scene defines the current scene
  50335. * @param files defines the list of files to load (1 per face)
  50336. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50337. * @param onLoad defines an optional callback raised when the texture is loaded
  50338. * @param onError defines an optional callback raised if there is an issue to load the texture
  50339. * @param format defines the format of the data
  50340. * @param forcedExtension defines the extension to use to pick the right loader
  50341. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50342. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50343. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50344. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50345. * @returns the cube texture as an InternalTexture
  50346. */
  50347. 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;
  50348. private _getSamplingFilter;
  50349. private static _GetNativeTextureFormat;
  50350. createRenderTargetTexture(size: number | {
  50351. width: number;
  50352. height: number;
  50353. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50354. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50355. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50356. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50357. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50358. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50359. /**
  50360. * Updates a dynamic vertex buffer.
  50361. * @param vertexBuffer the vertex buffer to update
  50362. * @param data the data used to update the vertex buffer
  50363. * @param byteOffset the byte offset of the data (optional)
  50364. * @param byteLength the byte length of the data (optional)
  50365. */
  50366. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50367. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50368. private _updateAnisotropicLevel;
  50369. private _getAddressMode;
  50370. /** @hidden */
  50371. _bindTexture(channel: number, texture: InternalTexture): void;
  50372. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50373. releaseEffects(): void;
  50374. /** @hidden */
  50375. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50376. /** @hidden */
  50377. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50378. /** @hidden */
  50379. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50380. /** @hidden */
  50381. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50382. }
  50383. }
  50384. declare module "babylonjs/Engines/index" {
  50385. export * from "babylonjs/Engines/constants";
  50386. export * from "babylonjs/Engines/engineCapabilities";
  50387. export * from "babylonjs/Engines/instancingAttributeInfo";
  50388. export * from "babylonjs/Engines/thinEngine";
  50389. export * from "babylonjs/Engines/engine";
  50390. export * from "babylonjs/Engines/engineStore";
  50391. export * from "babylonjs/Engines/nullEngine";
  50392. export * from "babylonjs/Engines/Extensions/index";
  50393. export * from "babylonjs/Engines/IPipelineContext";
  50394. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50395. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50396. export * from "babylonjs/Engines/nativeEngine";
  50397. }
  50398. declare module "babylonjs/Events/clipboardEvents" {
  50399. /**
  50400. * Gather the list of clipboard event types as constants.
  50401. */
  50402. export class ClipboardEventTypes {
  50403. /**
  50404. * The clipboard event is fired when a copy command is active (pressed).
  50405. */
  50406. static readonly COPY: number;
  50407. /**
  50408. * The clipboard event is fired when a cut command is active (pressed).
  50409. */
  50410. static readonly CUT: number;
  50411. /**
  50412. * The clipboard event is fired when a paste command is active (pressed).
  50413. */
  50414. static readonly PASTE: number;
  50415. }
  50416. /**
  50417. * This class is used to store clipboard related info for the onClipboardObservable event.
  50418. */
  50419. export class ClipboardInfo {
  50420. /**
  50421. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50422. */
  50423. type: number;
  50424. /**
  50425. * Defines the related dom event
  50426. */
  50427. event: ClipboardEvent;
  50428. /**
  50429. *Creates an instance of ClipboardInfo.
  50430. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50431. * @param event Defines the related dom event
  50432. */
  50433. constructor(
  50434. /**
  50435. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50436. */
  50437. type: number,
  50438. /**
  50439. * Defines the related dom event
  50440. */
  50441. event: ClipboardEvent);
  50442. /**
  50443. * Get the clipboard event's type from the keycode.
  50444. * @param keyCode Defines the keyCode for the current keyboard event.
  50445. * @return {number}
  50446. */
  50447. static GetTypeFromCharacter(keyCode: number): number;
  50448. }
  50449. }
  50450. declare module "babylonjs/Events/index" {
  50451. export * from "babylonjs/Events/keyboardEvents";
  50452. export * from "babylonjs/Events/pointerEvents";
  50453. export * from "babylonjs/Events/clipboardEvents";
  50454. }
  50455. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50456. import { Scene } from "babylonjs/scene";
  50457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50458. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50459. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50460. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50461. /**
  50462. * Google Daydream controller
  50463. */
  50464. export class DaydreamController extends WebVRController {
  50465. /**
  50466. * Base Url for the controller model.
  50467. */
  50468. static MODEL_BASE_URL: string;
  50469. /**
  50470. * File name for the controller model.
  50471. */
  50472. static MODEL_FILENAME: string;
  50473. /**
  50474. * Gamepad Id prefix used to identify Daydream Controller.
  50475. */
  50476. static readonly GAMEPAD_ID_PREFIX: string;
  50477. /**
  50478. * Creates a new DaydreamController from a gamepad
  50479. * @param vrGamepad the gamepad that the controller should be created from
  50480. */
  50481. constructor(vrGamepad: any);
  50482. /**
  50483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50484. * @param scene scene in which to add meshes
  50485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50486. */
  50487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50488. /**
  50489. * Called once for each button that changed state since the last frame
  50490. * @param buttonIdx Which button index changed
  50491. * @param state New state of the button
  50492. * @param changes Which properties on the state changed since last frame
  50493. */
  50494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50495. }
  50496. }
  50497. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50498. import { Scene } from "babylonjs/scene";
  50499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50500. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50501. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50502. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50503. /**
  50504. * Gear VR Controller
  50505. */
  50506. export class GearVRController extends WebVRController {
  50507. /**
  50508. * Base Url for the controller model.
  50509. */
  50510. static MODEL_BASE_URL: string;
  50511. /**
  50512. * File name for the controller model.
  50513. */
  50514. static MODEL_FILENAME: string;
  50515. /**
  50516. * Gamepad Id prefix used to identify this controller.
  50517. */
  50518. static readonly GAMEPAD_ID_PREFIX: string;
  50519. private readonly _buttonIndexToObservableNameMap;
  50520. /**
  50521. * Creates a new GearVRController from a gamepad
  50522. * @param vrGamepad the gamepad that the controller should be created from
  50523. */
  50524. constructor(vrGamepad: any);
  50525. /**
  50526. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50527. * @param scene scene in which to add meshes
  50528. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50529. */
  50530. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50531. /**
  50532. * Called once for each button that changed state since the last frame
  50533. * @param buttonIdx Which button index changed
  50534. * @param state New state of the button
  50535. * @param changes Which properties on the state changed since last frame
  50536. */
  50537. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50538. }
  50539. }
  50540. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50541. import { Scene } from "babylonjs/scene";
  50542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50543. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50544. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50545. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50546. /**
  50547. * Generic Controller
  50548. */
  50549. export class GenericController extends WebVRController {
  50550. /**
  50551. * Base Url for the controller model.
  50552. */
  50553. static readonly MODEL_BASE_URL: string;
  50554. /**
  50555. * File name for the controller model.
  50556. */
  50557. static readonly MODEL_FILENAME: string;
  50558. /**
  50559. * Creates a new GenericController from a gamepad
  50560. * @param vrGamepad the gamepad that the controller should be created from
  50561. */
  50562. constructor(vrGamepad: any);
  50563. /**
  50564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50565. * @param scene scene in which to add meshes
  50566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50567. */
  50568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50569. /**
  50570. * Called once for each button that changed state since the last frame
  50571. * @param buttonIdx Which button index changed
  50572. * @param state New state of the button
  50573. * @param changes Which properties on the state changed since last frame
  50574. */
  50575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50576. }
  50577. }
  50578. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50579. import { Observable } from "babylonjs/Misc/observable";
  50580. import { Scene } from "babylonjs/scene";
  50581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50582. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50583. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50584. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50585. /**
  50586. * Oculus Touch Controller
  50587. */
  50588. export class OculusTouchController extends WebVRController {
  50589. /**
  50590. * Base Url for the controller model.
  50591. */
  50592. static MODEL_BASE_URL: string;
  50593. /**
  50594. * File name for the left controller model.
  50595. */
  50596. static MODEL_LEFT_FILENAME: string;
  50597. /**
  50598. * File name for the right controller model.
  50599. */
  50600. static MODEL_RIGHT_FILENAME: string;
  50601. /**
  50602. * Base Url for the Quest controller model.
  50603. */
  50604. static QUEST_MODEL_BASE_URL: string;
  50605. /**
  50606. * @hidden
  50607. * If the controllers are running on a device that needs the updated Quest controller models
  50608. */
  50609. static _IsQuest: boolean;
  50610. /**
  50611. * Fired when the secondary trigger on this controller is modified
  50612. */
  50613. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50614. /**
  50615. * Fired when the thumb rest on this controller is modified
  50616. */
  50617. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50618. /**
  50619. * Creates a new OculusTouchController from a gamepad
  50620. * @param vrGamepad the gamepad that the controller should be created from
  50621. */
  50622. constructor(vrGamepad: any);
  50623. /**
  50624. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50625. * @param scene scene in which to add meshes
  50626. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50627. */
  50628. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50629. /**
  50630. * Fired when the A button on this controller is modified
  50631. */
  50632. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50633. /**
  50634. * Fired when the B button on this controller is modified
  50635. */
  50636. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50637. /**
  50638. * Fired when the X button on this controller is modified
  50639. */
  50640. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50641. /**
  50642. * Fired when the Y button on this controller is modified
  50643. */
  50644. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50645. /**
  50646. * Called once for each button that changed state since the last frame
  50647. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50648. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50649. * 2) secondary trigger (same)
  50650. * 3) A (right) X (left), touch, pressed = value
  50651. * 4) B / Y
  50652. * 5) thumb rest
  50653. * @param buttonIdx Which button index changed
  50654. * @param state New state of the button
  50655. * @param changes Which properties on the state changed since last frame
  50656. */
  50657. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50658. }
  50659. }
  50660. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50661. import { Scene } from "babylonjs/scene";
  50662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50663. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50664. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50665. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50666. import { Observable } from "babylonjs/Misc/observable";
  50667. /**
  50668. * Vive Controller
  50669. */
  50670. export class ViveController extends WebVRController {
  50671. /**
  50672. * Base Url for the controller model.
  50673. */
  50674. static MODEL_BASE_URL: string;
  50675. /**
  50676. * File name for the controller model.
  50677. */
  50678. static MODEL_FILENAME: string;
  50679. /**
  50680. * Creates a new ViveController from a gamepad
  50681. * @param vrGamepad the gamepad that the controller should be created from
  50682. */
  50683. constructor(vrGamepad: any);
  50684. /**
  50685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50686. * @param scene scene in which to add meshes
  50687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50688. */
  50689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50690. /**
  50691. * Fired when the left button on this controller is modified
  50692. */
  50693. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50694. /**
  50695. * Fired when the right button on this controller is modified
  50696. */
  50697. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50698. /**
  50699. * Fired when the menu button on this controller is modified
  50700. */
  50701. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50702. /**
  50703. * Called once for each button that changed state since the last frame
  50704. * Vive mapping:
  50705. * 0: touchpad
  50706. * 1: trigger
  50707. * 2: left AND right buttons
  50708. * 3: menu button
  50709. * @param buttonIdx Which button index changed
  50710. * @param state New state of the button
  50711. * @param changes Which properties on the state changed since last frame
  50712. */
  50713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50714. }
  50715. }
  50716. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50717. import { Observable } from "babylonjs/Misc/observable";
  50718. import { Scene } from "babylonjs/scene";
  50719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50720. import { Ray } from "babylonjs/Culling/ray";
  50721. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50722. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50723. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50724. /**
  50725. * Defines the WindowsMotionController object that the state of the windows motion controller
  50726. */
  50727. export class WindowsMotionController extends WebVRController {
  50728. /**
  50729. * The base url used to load the left and right controller models
  50730. */
  50731. static MODEL_BASE_URL: string;
  50732. /**
  50733. * The name of the left controller model file
  50734. */
  50735. static MODEL_LEFT_FILENAME: string;
  50736. /**
  50737. * The name of the right controller model file
  50738. */
  50739. static MODEL_RIGHT_FILENAME: string;
  50740. /**
  50741. * The controller name prefix for this controller type
  50742. */
  50743. static readonly GAMEPAD_ID_PREFIX: string;
  50744. /**
  50745. * The controller id pattern for this controller type
  50746. */
  50747. private static readonly GAMEPAD_ID_PATTERN;
  50748. private _loadedMeshInfo;
  50749. protected readonly _mapping: {
  50750. buttons: string[];
  50751. buttonMeshNames: {
  50752. trigger: string;
  50753. menu: string;
  50754. grip: string;
  50755. thumbstick: string;
  50756. trackpad: string;
  50757. };
  50758. buttonObservableNames: {
  50759. trigger: string;
  50760. menu: string;
  50761. grip: string;
  50762. thumbstick: string;
  50763. trackpad: string;
  50764. };
  50765. axisMeshNames: string[];
  50766. pointingPoseMeshName: string;
  50767. };
  50768. /**
  50769. * Fired when the trackpad on this controller is clicked
  50770. */
  50771. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50772. /**
  50773. * Fired when the trackpad on this controller is modified
  50774. */
  50775. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50776. /**
  50777. * The current x and y values of this controller's trackpad
  50778. */
  50779. trackpad: StickValues;
  50780. /**
  50781. * Creates a new WindowsMotionController from a gamepad
  50782. * @param vrGamepad the gamepad that the controller should be created from
  50783. */
  50784. constructor(vrGamepad: any);
  50785. /**
  50786. * Fired when the trigger on this controller is modified
  50787. */
  50788. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50789. /**
  50790. * Fired when the menu button on this controller is modified
  50791. */
  50792. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50793. /**
  50794. * Fired when the grip button on this controller is modified
  50795. */
  50796. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50797. /**
  50798. * Fired when the thumbstick button on this controller is modified
  50799. */
  50800. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50801. /**
  50802. * Fired when the touchpad button on this controller is modified
  50803. */
  50804. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50805. /**
  50806. * Fired when the touchpad values on this controller are modified
  50807. */
  50808. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50809. protected _updateTrackpad(): void;
  50810. /**
  50811. * Called once per frame by the engine.
  50812. */
  50813. update(): void;
  50814. /**
  50815. * Called once for each button that changed state since the last frame
  50816. * @param buttonIdx Which button index changed
  50817. * @param state New state of the button
  50818. * @param changes Which properties on the state changed since last frame
  50819. */
  50820. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50821. /**
  50822. * Moves the buttons on the controller mesh based on their current state
  50823. * @param buttonName the name of the button to move
  50824. * @param buttonValue the value of the button which determines the buttons new position
  50825. */
  50826. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50827. /**
  50828. * Moves the axis on the controller mesh based on its current state
  50829. * @param axis the index of the axis
  50830. * @param axisValue the value of the axis which determines the meshes new position
  50831. * @hidden
  50832. */
  50833. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50834. /**
  50835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50836. * @param scene scene in which to add meshes
  50837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50838. */
  50839. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50840. /**
  50841. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50842. * can be transformed by button presses and axes values, based on this._mapping.
  50843. *
  50844. * @param scene scene in which the meshes exist
  50845. * @param meshes list of meshes that make up the controller model to process
  50846. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50847. */
  50848. private processModel;
  50849. private createMeshInfo;
  50850. /**
  50851. * Gets the ray of the controller in the direction the controller is pointing
  50852. * @param length the length the resulting ray should be
  50853. * @returns a ray in the direction the controller is pointing
  50854. */
  50855. getForwardRay(length?: number): Ray;
  50856. /**
  50857. * Disposes of the controller
  50858. */
  50859. dispose(): void;
  50860. }
  50861. /**
  50862. * This class represents a new windows motion controller in XR.
  50863. */
  50864. export class XRWindowsMotionController extends WindowsMotionController {
  50865. /**
  50866. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50867. */
  50868. protected readonly _mapping: {
  50869. buttons: string[];
  50870. buttonMeshNames: {
  50871. trigger: string;
  50872. menu: string;
  50873. grip: string;
  50874. thumbstick: string;
  50875. trackpad: string;
  50876. };
  50877. buttonObservableNames: {
  50878. trigger: string;
  50879. menu: string;
  50880. grip: string;
  50881. thumbstick: string;
  50882. trackpad: string;
  50883. };
  50884. axisMeshNames: string[];
  50885. pointingPoseMeshName: string;
  50886. };
  50887. /**
  50888. * Construct a new XR-Based windows motion controller
  50889. *
  50890. * @param gamepadInfo the gamepad object from the browser
  50891. */
  50892. constructor(gamepadInfo: any);
  50893. /**
  50894. * holds the thumbstick values (X,Y)
  50895. */
  50896. thumbstickValues: StickValues;
  50897. /**
  50898. * Fired when the thumbstick on this controller is clicked
  50899. */
  50900. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50901. /**
  50902. * Fired when the thumbstick on this controller is modified
  50903. */
  50904. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50905. /**
  50906. * Fired when the touchpad button on this controller is modified
  50907. */
  50908. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50909. /**
  50910. * Fired when the touchpad values on this controller are modified
  50911. */
  50912. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50913. /**
  50914. * Fired when the thumbstick button on this controller is modified
  50915. * here to prevent breaking changes
  50916. */
  50917. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50918. /**
  50919. * updating the thumbstick(!) and not the trackpad.
  50920. * This is named this way due to the difference between WebVR and XR and to avoid
  50921. * changing the parent class.
  50922. */
  50923. protected _updateTrackpad(): void;
  50924. /**
  50925. * Disposes the class with joy
  50926. */
  50927. dispose(): void;
  50928. }
  50929. }
  50930. declare module "babylonjs/Gamepads/Controllers/index" {
  50931. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50932. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50933. export * from "babylonjs/Gamepads/Controllers/genericController";
  50934. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50935. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50936. export * from "babylonjs/Gamepads/Controllers/viveController";
  50937. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50938. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50939. }
  50940. declare module "babylonjs/Gamepads/index" {
  50941. export * from "babylonjs/Gamepads/Controllers/index";
  50942. export * from "babylonjs/Gamepads/gamepad";
  50943. export * from "babylonjs/Gamepads/gamepadManager";
  50944. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50945. export * from "babylonjs/Gamepads/xboxGamepad";
  50946. export * from "babylonjs/Gamepads/dualShockGamepad";
  50947. }
  50948. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50949. import { Scene } from "babylonjs/scene";
  50950. import { Vector4 } from "babylonjs/Maths/math.vector";
  50951. import { Color4 } from "babylonjs/Maths/math.color";
  50952. import { Mesh } from "babylonjs/Meshes/mesh";
  50953. import { Nullable } from "babylonjs/types";
  50954. /**
  50955. * Class containing static functions to help procedurally build meshes
  50956. */
  50957. export class PolyhedronBuilder {
  50958. /**
  50959. * Creates a polyhedron mesh
  50960. * * 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
  50961. * * The parameter `size` (positive float, default 1) sets the polygon size
  50962. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50963. * * 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`
  50964. * * 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
  50965. * * 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)`)
  50966. * * 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
  50967. * * 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
  50968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50971. * @param name defines the name of the mesh
  50972. * @param options defines the options used to create the mesh
  50973. * @param scene defines the hosting scene
  50974. * @returns the polyhedron mesh
  50975. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50976. */
  50977. static CreatePolyhedron(name: string, options: {
  50978. type?: number;
  50979. size?: number;
  50980. sizeX?: number;
  50981. sizeY?: number;
  50982. sizeZ?: number;
  50983. custom?: any;
  50984. faceUV?: Vector4[];
  50985. faceColors?: Color4[];
  50986. flat?: boolean;
  50987. updatable?: boolean;
  50988. sideOrientation?: number;
  50989. frontUVs?: Vector4;
  50990. backUVs?: Vector4;
  50991. }, scene?: Nullable<Scene>): Mesh;
  50992. }
  50993. }
  50994. declare module "babylonjs/Gizmos/scaleGizmo" {
  50995. import { Observable } from "babylonjs/Misc/observable";
  50996. import { Nullable } from "babylonjs/types";
  50997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50999. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  51000. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51001. /**
  51002. * Gizmo that enables scaling a mesh along 3 axis
  51003. */
  51004. export class ScaleGizmo extends Gizmo {
  51005. /**
  51006. * Internal gizmo used for interactions on the x axis
  51007. */
  51008. xGizmo: AxisScaleGizmo;
  51009. /**
  51010. * Internal gizmo used for interactions on the y axis
  51011. */
  51012. yGizmo: AxisScaleGizmo;
  51013. /**
  51014. * Internal gizmo used for interactions on the z axis
  51015. */
  51016. zGizmo: AxisScaleGizmo;
  51017. /**
  51018. * Internal gizmo used to scale all axis equally
  51019. */
  51020. uniformScaleGizmo: AxisScaleGizmo;
  51021. private _meshAttached;
  51022. private _updateGizmoRotationToMatchAttachedMesh;
  51023. private _snapDistance;
  51024. private _scaleRatio;
  51025. private _uniformScalingMesh;
  51026. private _octahedron;
  51027. private _sensitivity;
  51028. /** Fires an event when any of it's sub gizmos are dragged */
  51029. onDragStartObservable: Observable<unknown>;
  51030. /** Fires an event when any of it's sub gizmos are released from dragging */
  51031. onDragEndObservable: Observable<unknown>;
  51032. get attachedMesh(): Nullable<AbstractMesh>;
  51033. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51034. /**
  51035. * Creates a ScaleGizmo
  51036. * @param gizmoLayer The utility layer the gizmo will be added to
  51037. */
  51038. constructor(gizmoLayer?: UtilityLayerRenderer);
  51039. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51040. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51041. /**
  51042. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51043. */
  51044. set snapDistance(value: number);
  51045. get snapDistance(): number;
  51046. /**
  51047. * Ratio for the scale of the gizmo (Default: 1)
  51048. */
  51049. set scaleRatio(value: number);
  51050. get scaleRatio(): number;
  51051. /**
  51052. * Sensitivity factor for dragging (Default: 1)
  51053. */
  51054. set sensitivity(value: number);
  51055. get sensitivity(): number;
  51056. /**
  51057. * Disposes of the gizmo
  51058. */
  51059. dispose(): void;
  51060. }
  51061. }
  51062. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51063. import { Observable } from "babylonjs/Misc/observable";
  51064. import { Nullable } from "babylonjs/types";
  51065. import { Vector3 } from "babylonjs/Maths/math.vector";
  51066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51067. import { Mesh } from "babylonjs/Meshes/mesh";
  51068. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51069. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51070. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51071. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51072. import { Color3 } from "babylonjs/Maths/math.color";
  51073. /**
  51074. * Single axis scale gizmo
  51075. */
  51076. export class AxisScaleGizmo extends Gizmo {
  51077. /**
  51078. * Drag behavior responsible for the gizmos dragging interactions
  51079. */
  51080. dragBehavior: PointerDragBehavior;
  51081. private _pointerObserver;
  51082. /**
  51083. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51084. */
  51085. snapDistance: number;
  51086. /**
  51087. * Event that fires each time the gizmo snaps to a new location.
  51088. * * snapDistance is the the change in distance
  51089. */
  51090. onSnapObservable: Observable<{
  51091. snapDistance: number;
  51092. }>;
  51093. /**
  51094. * If the scaling operation should be done on all axis (default: false)
  51095. */
  51096. uniformScaling: boolean;
  51097. /**
  51098. * Custom sensitivity value for the drag strength
  51099. */
  51100. sensitivity: number;
  51101. private _isEnabled;
  51102. private _parent;
  51103. private _arrow;
  51104. private _coloredMaterial;
  51105. private _hoverMaterial;
  51106. /**
  51107. * Creates an AxisScaleGizmo
  51108. * @param gizmoLayer The utility layer the gizmo will be added to
  51109. * @param dragAxis The axis which the gizmo will be able to scale on
  51110. * @param color The color of the gizmo
  51111. */
  51112. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51114. /**
  51115. * If the gizmo is enabled
  51116. */
  51117. set isEnabled(value: boolean);
  51118. get isEnabled(): boolean;
  51119. /**
  51120. * Disposes of the gizmo
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51125. * @param mesh The mesh to replace the default mesh of the gizmo
  51126. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51127. */
  51128. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51129. }
  51130. }
  51131. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51132. import { Observable } from "babylonjs/Misc/observable";
  51133. import { Nullable } from "babylonjs/types";
  51134. import { Vector3 } from "babylonjs/Maths/math.vector";
  51135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51136. import { Mesh } from "babylonjs/Meshes/mesh";
  51137. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51138. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51139. import { Color3 } from "babylonjs/Maths/math.color";
  51140. import "babylonjs/Meshes/Builders/boxBuilder";
  51141. /**
  51142. * Bounding box gizmo
  51143. */
  51144. export class BoundingBoxGizmo extends Gizmo {
  51145. private _lineBoundingBox;
  51146. private _rotateSpheresParent;
  51147. private _scaleBoxesParent;
  51148. private _boundingDimensions;
  51149. private _renderObserver;
  51150. private _pointerObserver;
  51151. private _scaleDragSpeed;
  51152. private _tmpQuaternion;
  51153. private _tmpVector;
  51154. private _tmpRotationMatrix;
  51155. /**
  51156. * 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)
  51157. */
  51158. ignoreChildren: boolean;
  51159. /**
  51160. * 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)
  51161. */
  51162. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51163. /**
  51164. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51165. */
  51166. rotationSphereSize: number;
  51167. /**
  51168. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51169. */
  51170. scaleBoxSize: number;
  51171. /**
  51172. * 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)
  51173. */
  51174. fixedDragMeshScreenSize: boolean;
  51175. /**
  51176. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51177. */
  51178. fixedDragMeshScreenSizeDistanceFactor: number;
  51179. /**
  51180. * Fired when a rotation sphere or scale box is dragged
  51181. */
  51182. onDragStartObservable: Observable<{}>;
  51183. /**
  51184. * Fired when a scale box is dragged
  51185. */
  51186. onScaleBoxDragObservable: Observable<{}>;
  51187. /**
  51188. * Fired when a scale box drag is ended
  51189. */
  51190. onScaleBoxDragEndObservable: Observable<{}>;
  51191. /**
  51192. * Fired when a rotation sphere is dragged
  51193. */
  51194. onRotationSphereDragObservable: Observable<{}>;
  51195. /**
  51196. * Fired when a rotation sphere drag is ended
  51197. */
  51198. onRotationSphereDragEndObservable: Observable<{}>;
  51199. /**
  51200. * 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)
  51201. */
  51202. scalePivot: Nullable<Vector3>;
  51203. /**
  51204. * Mesh used as a pivot to rotate the attached mesh
  51205. */
  51206. private _anchorMesh;
  51207. private _existingMeshScale;
  51208. private _dragMesh;
  51209. private pointerDragBehavior;
  51210. private coloredMaterial;
  51211. private hoverColoredMaterial;
  51212. /**
  51213. * Sets the color of the bounding box gizmo
  51214. * @param color the color to set
  51215. */
  51216. setColor(color: Color3): void;
  51217. /**
  51218. * Creates an BoundingBoxGizmo
  51219. * @param gizmoLayer The utility layer the gizmo will be added to
  51220. * @param color The color of the gizmo
  51221. */
  51222. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51223. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51224. private _selectNode;
  51225. /**
  51226. * Updates the bounding box information for the Gizmo
  51227. */
  51228. updateBoundingBox(): void;
  51229. private _updateRotationSpheres;
  51230. private _updateScaleBoxes;
  51231. /**
  51232. * Enables rotation on the specified axis and disables rotation on the others
  51233. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51234. */
  51235. setEnabledRotationAxis(axis: string): void;
  51236. /**
  51237. * Enables/disables scaling
  51238. * @param enable if scaling should be enabled
  51239. * @param homogeneousScaling defines if scaling should only be homogeneous
  51240. */
  51241. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51242. private _updateDummy;
  51243. /**
  51244. * Enables a pointer drag behavior on the bounding box of the gizmo
  51245. */
  51246. enableDragBehavior(): void;
  51247. /**
  51248. * Disposes of the gizmo
  51249. */
  51250. dispose(): void;
  51251. /**
  51252. * 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)
  51253. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51254. * @returns the bounding box mesh with the passed in mesh as a child
  51255. */
  51256. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51257. /**
  51258. * CustomMeshes are not supported by this gizmo
  51259. * @param mesh The mesh to replace the default mesh of the gizmo
  51260. */
  51261. setCustomMesh(mesh: Mesh): void;
  51262. }
  51263. }
  51264. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51265. import { Observable } from "babylonjs/Misc/observable";
  51266. import { Nullable } from "babylonjs/types";
  51267. import { Vector3 } from "babylonjs/Maths/math.vector";
  51268. import { Color3 } from "babylonjs/Maths/math.color";
  51269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51270. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51271. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51272. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51273. import "babylonjs/Meshes/Builders/linesBuilder";
  51274. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51275. /**
  51276. * Single plane rotation gizmo
  51277. */
  51278. export class PlaneRotationGizmo extends Gizmo {
  51279. /**
  51280. * Drag behavior responsible for the gizmos dragging interactions
  51281. */
  51282. dragBehavior: PointerDragBehavior;
  51283. private _pointerObserver;
  51284. /**
  51285. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51286. */
  51287. snapDistance: number;
  51288. /**
  51289. * Event that fires each time the gizmo snaps to a new location.
  51290. * * snapDistance is the the change in distance
  51291. */
  51292. onSnapObservable: Observable<{
  51293. snapDistance: number;
  51294. }>;
  51295. private _isEnabled;
  51296. private _parent;
  51297. /**
  51298. * Creates a PlaneRotationGizmo
  51299. * @param gizmoLayer The utility layer the gizmo will be added to
  51300. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51301. * @param color The color of the gizmo
  51302. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51303. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51304. */
  51305. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51307. /**
  51308. * If the gizmo is enabled
  51309. */
  51310. set isEnabled(value: boolean);
  51311. get isEnabled(): boolean;
  51312. /**
  51313. * Disposes of the gizmo
  51314. */
  51315. dispose(): void;
  51316. }
  51317. }
  51318. declare module "babylonjs/Gizmos/rotationGizmo" {
  51319. import { Observable } from "babylonjs/Misc/observable";
  51320. import { Nullable } from "babylonjs/types";
  51321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51322. import { Mesh } from "babylonjs/Meshes/mesh";
  51323. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51324. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51325. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51326. /**
  51327. * Gizmo that enables rotating a mesh along 3 axis
  51328. */
  51329. export class RotationGizmo extends Gizmo {
  51330. /**
  51331. * Internal gizmo used for interactions on the x axis
  51332. */
  51333. xGizmo: PlaneRotationGizmo;
  51334. /**
  51335. * Internal gizmo used for interactions on the y axis
  51336. */
  51337. yGizmo: PlaneRotationGizmo;
  51338. /**
  51339. * Internal gizmo used for interactions on the z axis
  51340. */
  51341. zGizmo: PlaneRotationGizmo;
  51342. /** Fires an event when any of it's sub gizmos are dragged */
  51343. onDragStartObservable: Observable<unknown>;
  51344. /** Fires an event when any of it's sub gizmos are released from dragging */
  51345. onDragEndObservable: Observable<unknown>;
  51346. private _meshAttached;
  51347. get attachedMesh(): Nullable<AbstractMesh>;
  51348. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51349. /**
  51350. * Creates a RotationGizmo
  51351. * @param gizmoLayer The utility layer the gizmo will be added to
  51352. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51353. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51354. */
  51355. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51356. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51357. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51358. /**
  51359. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51360. */
  51361. set snapDistance(value: number);
  51362. get snapDistance(): number;
  51363. /**
  51364. * Ratio for the scale of the gizmo (Default: 1)
  51365. */
  51366. set scaleRatio(value: number);
  51367. get scaleRatio(): number;
  51368. /**
  51369. * Disposes of the gizmo
  51370. */
  51371. dispose(): void;
  51372. /**
  51373. * CustomMeshes are not supported by this gizmo
  51374. * @param mesh The mesh to replace the default mesh of the gizmo
  51375. */
  51376. setCustomMesh(mesh: Mesh): void;
  51377. }
  51378. }
  51379. declare module "babylonjs/Gizmos/gizmoManager" {
  51380. import { Observable } from "babylonjs/Misc/observable";
  51381. import { Nullable } from "babylonjs/types";
  51382. import { Scene, IDisposable } from "babylonjs/scene";
  51383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51384. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51385. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51386. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51387. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51388. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51389. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51390. /**
  51391. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51392. */
  51393. export class GizmoManager implements IDisposable {
  51394. private scene;
  51395. /**
  51396. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51397. */
  51398. gizmos: {
  51399. positionGizmo: Nullable<PositionGizmo>;
  51400. rotationGizmo: Nullable<RotationGizmo>;
  51401. scaleGizmo: Nullable<ScaleGizmo>;
  51402. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51403. };
  51404. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51405. clearGizmoOnEmptyPointerEvent: boolean;
  51406. /** Fires an event when the manager is attached to a mesh */
  51407. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51408. private _gizmosEnabled;
  51409. private _pointerObserver;
  51410. private _attachedMesh;
  51411. private _boundingBoxColor;
  51412. private _defaultUtilityLayer;
  51413. private _defaultKeepDepthUtilityLayer;
  51414. /**
  51415. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51416. */
  51417. boundingBoxDragBehavior: SixDofDragBehavior;
  51418. /**
  51419. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51420. */
  51421. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51422. /**
  51423. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51424. */
  51425. usePointerToAttachGizmos: boolean;
  51426. /**
  51427. * Utility layer that the bounding box gizmo belongs to
  51428. */
  51429. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51430. /**
  51431. * Utility layer that all gizmos besides bounding box belong to
  51432. */
  51433. get utilityLayer(): UtilityLayerRenderer;
  51434. /**
  51435. * Instatiates a gizmo manager
  51436. * @param scene the scene to overlay the gizmos on top of
  51437. */
  51438. constructor(scene: Scene);
  51439. /**
  51440. * Attaches a set of gizmos to the specified mesh
  51441. * @param mesh The mesh the gizmo's should be attached to
  51442. */
  51443. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51444. /**
  51445. * If the position gizmo is enabled
  51446. */
  51447. set positionGizmoEnabled(value: boolean);
  51448. get positionGizmoEnabled(): boolean;
  51449. /**
  51450. * If the rotation gizmo is enabled
  51451. */
  51452. set rotationGizmoEnabled(value: boolean);
  51453. get rotationGizmoEnabled(): boolean;
  51454. /**
  51455. * If the scale gizmo is enabled
  51456. */
  51457. set scaleGizmoEnabled(value: boolean);
  51458. get scaleGizmoEnabled(): boolean;
  51459. /**
  51460. * If the boundingBox gizmo is enabled
  51461. */
  51462. set boundingBoxGizmoEnabled(value: boolean);
  51463. get boundingBoxGizmoEnabled(): boolean;
  51464. /**
  51465. * Disposes of the gizmo manager
  51466. */
  51467. dispose(): void;
  51468. }
  51469. }
  51470. declare module "babylonjs/Lights/directionalLight" {
  51471. import { Camera } from "babylonjs/Cameras/camera";
  51472. import { Scene } from "babylonjs/scene";
  51473. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51475. import { Light } from "babylonjs/Lights/light";
  51476. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. /**
  51479. * A directional light is defined by a direction (what a surprise!).
  51480. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51481. * 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.
  51482. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51483. */
  51484. export class DirectionalLight extends ShadowLight {
  51485. private _shadowFrustumSize;
  51486. /**
  51487. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51488. */
  51489. get shadowFrustumSize(): number;
  51490. /**
  51491. * Specifies a fix frustum size for the shadow generation.
  51492. */
  51493. set shadowFrustumSize(value: number);
  51494. private _shadowOrthoScale;
  51495. /**
  51496. * Gets the shadow projection scale against the optimal computed one.
  51497. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51498. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51499. */
  51500. get shadowOrthoScale(): number;
  51501. /**
  51502. * Sets the shadow projection scale against the optimal computed one.
  51503. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51504. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51505. */
  51506. set shadowOrthoScale(value: number);
  51507. /**
  51508. * Automatically compute the projection matrix to best fit (including all the casters)
  51509. * on each frame.
  51510. */
  51511. autoUpdateExtends: boolean;
  51512. /**
  51513. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51514. * on each frame. autoUpdateExtends must be set to true for this to work
  51515. */
  51516. autoCalcShadowZBounds: boolean;
  51517. private _orthoLeft;
  51518. private _orthoRight;
  51519. private _orthoTop;
  51520. private _orthoBottom;
  51521. /**
  51522. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51523. * The directional light is emitted from everywhere in the given direction.
  51524. * It can cast shadows.
  51525. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51526. * @param name The friendly name of the light
  51527. * @param direction The direction of the light
  51528. * @param scene The scene the light belongs to
  51529. */
  51530. constructor(name: string, direction: Vector3, scene: Scene);
  51531. /**
  51532. * Returns the string "DirectionalLight".
  51533. * @return The class name
  51534. */
  51535. getClassName(): string;
  51536. /**
  51537. * Returns the integer 1.
  51538. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51539. */
  51540. getTypeID(): number;
  51541. /**
  51542. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51543. * Returns the DirectionalLight Shadow projection matrix.
  51544. */
  51545. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51546. /**
  51547. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51548. * Returns the DirectionalLight Shadow projection matrix.
  51549. */
  51550. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51551. /**
  51552. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51553. * Returns the DirectionalLight Shadow projection matrix.
  51554. */
  51555. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51556. protected _buildUniformLayout(): void;
  51557. /**
  51558. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51559. * @param effect The effect to update
  51560. * @param lightIndex The index of the light in the effect to update
  51561. * @returns The directional light
  51562. */
  51563. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51564. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51565. /**
  51566. * Gets the minZ used for shadow according to both the scene and the light.
  51567. *
  51568. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51569. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51570. * @param activeCamera The camera we are returning the min for
  51571. * @returns the depth min z
  51572. */
  51573. getDepthMinZ(activeCamera: Camera): number;
  51574. /**
  51575. * Gets the maxZ used for shadow according to both the scene and the light.
  51576. *
  51577. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51578. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51579. * @param activeCamera The camera we are returning the max for
  51580. * @returns the depth max z
  51581. */
  51582. getDepthMaxZ(activeCamera: Camera): number;
  51583. /**
  51584. * Prepares the list of defines specific to the light type.
  51585. * @param defines the list of defines
  51586. * @param lightIndex defines the index of the light for the effect
  51587. */
  51588. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51589. }
  51590. }
  51591. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51592. import { Mesh } from "babylonjs/Meshes/mesh";
  51593. /**
  51594. * Class containing static functions to help procedurally build meshes
  51595. */
  51596. export class HemisphereBuilder {
  51597. /**
  51598. * Creates a hemisphere mesh
  51599. * @param name defines the name of the mesh
  51600. * @param options defines the options used to create the mesh
  51601. * @param scene defines the hosting scene
  51602. * @returns the hemisphere mesh
  51603. */
  51604. static CreateHemisphere(name: string, options: {
  51605. segments?: number;
  51606. diameter?: number;
  51607. sideOrientation?: number;
  51608. }, scene: any): Mesh;
  51609. }
  51610. }
  51611. declare module "babylonjs/Lights/spotLight" {
  51612. import { Nullable } from "babylonjs/types";
  51613. import { Scene } from "babylonjs/scene";
  51614. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51616. import { Effect } from "babylonjs/Materials/effect";
  51617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51618. import { Light } from "babylonjs/Lights/light";
  51619. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51620. /**
  51621. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51622. * These values define a cone of light starting from the position, emitting toward the direction.
  51623. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51624. * and the exponent defines the speed of the decay of the light with distance (reach).
  51625. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51626. */
  51627. export class SpotLight extends ShadowLight {
  51628. private _angle;
  51629. private _innerAngle;
  51630. private _cosHalfAngle;
  51631. private _lightAngleScale;
  51632. private _lightAngleOffset;
  51633. /**
  51634. * Gets the cone angle of the spot light in Radians.
  51635. */
  51636. get angle(): number;
  51637. /**
  51638. * Sets the cone angle of the spot light in Radians.
  51639. */
  51640. set angle(value: number);
  51641. /**
  51642. * Only used in gltf falloff mode, this defines the angle where
  51643. * the directional falloff will start before cutting at angle which could be seen
  51644. * as outer angle.
  51645. */
  51646. get innerAngle(): number;
  51647. /**
  51648. * Only used in gltf falloff mode, this defines the angle where
  51649. * the directional falloff will start before cutting at angle which could be seen
  51650. * as outer angle.
  51651. */
  51652. set innerAngle(value: number);
  51653. private _shadowAngleScale;
  51654. /**
  51655. * Allows scaling the angle of the light for shadow generation only.
  51656. */
  51657. get shadowAngleScale(): number;
  51658. /**
  51659. * Allows scaling the angle of the light for shadow generation only.
  51660. */
  51661. set shadowAngleScale(value: number);
  51662. /**
  51663. * The light decay speed with the distance from the emission spot.
  51664. */
  51665. exponent: number;
  51666. private _projectionTextureMatrix;
  51667. /**
  51668. * Allows reading the projecton texture
  51669. */
  51670. get projectionTextureMatrix(): Matrix;
  51671. protected _projectionTextureLightNear: number;
  51672. /**
  51673. * Gets the near clip of the Spotlight for texture projection.
  51674. */
  51675. get projectionTextureLightNear(): number;
  51676. /**
  51677. * Sets the near clip of the Spotlight for texture projection.
  51678. */
  51679. set projectionTextureLightNear(value: number);
  51680. protected _projectionTextureLightFar: number;
  51681. /**
  51682. * Gets the far clip of the Spotlight for texture projection.
  51683. */
  51684. get projectionTextureLightFar(): number;
  51685. /**
  51686. * Sets the far clip of the Spotlight for texture projection.
  51687. */
  51688. set projectionTextureLightFar(value: number);
  51689. protected _projectionTextureUpDirection: Vector3;
  51690. /**
  51691. * Gets the Up vector of the Spotlight for texture projection.
  51692. */
  51693. get projectionTextureUpDirection(): Vector3;
  51694. /**
  51695. * Sets the Up vector of the Spotlight for texture projection.
  51696. */
  51697. set projectionTextureUpDirection(value: Vector3);
  51698. private _projectionTexture;
  51699. /**
  51700. * Gets the projection texture of the light.
  51701. */
  51702. get projectionTexture(): Nullable<BaseTexture>;
  51703. /**
  51704. * Sets the projection texture of the light.
  51705. */
  51706. set projectionTexture(value: Nullable<BaseTexture>);
  51707. private _projectionTextureViewLightDirty;
  51708. private _projectionTextureProjectionLightDirty;
  51709. private _projectionTextureDirty;
  51710. private _projectionTextureViewTargetVector;
  51711. private _projectionTextureViewLightMatrix;
  51712. private _projectionTextureProjectionLightMatrix;
  51713. private _projectionTextureScalingMatrix;
  51714. /**
  51715. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51716. * It can cast shadows.
  51717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51718. * @param name The light friendly name
  51719. * @param position The position of the spot light in the scene
  51720. * @param direction The direction of the light in the scene
  51721. * @param angle The cone angle of the light in Radians
  51722. * @param exponent The light decay speed with the distance from the emission spot
  51723. * @param scene The scene the lights belongs to
  51724. */
  51725. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51726. /**
  51727. * Returns the string "SpotLight".
  51728. * @returns the class name
  51729. */
  51730. getClassName(): string;
  51731. /**
  51732. * Returns the integer 2.
  51733. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51734. */
  51735. getTypeID(): number;
  51736. /**
  51737. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51738. */
  51739. protected _setDirection(value: Vector3): void;
  51740. /**
  51741. * Overrides the position setter to recompute the projection texture view light Matrix.
  51742. */
  51743. protected _setPosition(value: Vector3): void;
  51744. /**
  51745. * 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.
  51746. * Returns the SpotLight.
  51747. */
  51748. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51749. protected _computeProjectionTextureViewLightMatrix(): void;
  51750. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51751. /**
  51752. * Main function for light texture projection matrix computing.
  51753. */
  51754. protected _computeProjectionTextureMatrix(): void;
  51755. protected _buildUniformLayout(): void;
  51756. private _computeAngleValues;
  51757. /**
  51758. * Sets the passed Effect "effect" with the Light textures.
  51759. * @param effect The effect to update
  51760. * @param lightIndex The index of the light in the effect to update
  51761. * @returns The light
  51762. */
  51763. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51764. /**
  51765. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51766. * @param effect The effect to update
  51767. * @param lightIndex The index of the light in the effect to update
  51768. * @returns The spot light
  51769. */
  51770. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51771. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51772. /**
  51773. * Disposes the light and the associated resources.
  51774. */
  51775. dispose(): void;
  51776. /**
  51777. * Prepares the list of defines specific to the light type.
  51778. * @param defines the list of defines
  51779. * @param lightIndex defines the index of the light for the effect
  51780. */
  51781. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51782. }
  51783. }
  51784. declare module "babylonjs/Gizmos/lightGizmo" {
  51785. import { Nullable } from "babylonjs/types";
  51786. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51787. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51788. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51789. import { Light } from "babylonjs/Lights/light";
  51790. /**
  51791. * Gizmo that enables viewing a light
  51792. */
  51793. export class LightGizmo extends Gizmo {
  51794. private _lightMesh;
  51795. private _material;
  51796. private _cachedPosition;
  51797. private _cachedForward;
  51798. private _attachedMeshParent;
  51799. /**
  51800. * Creates a LightGizmo
  51801. * @param gizmoLayer The utility layer the gizmo will be added to
  51802. */
  51803. constructor(gizmoLayer?: UtilityLayerRenderer);
  51804. private _light;
  51805. /**
  51806. * The light that the gizmo is attached to
  51807. */
  51808. set light(light: Nullable<Light>);
  51809. get light(): Nullable<Light>;
  51810. /**
  51811. * Gets the material used to render the light gizmo
  51812. */
  51813. get material(): StandardMaterial;
  51814. /**
  51815. * @hidden
  51816. * Updates the gizmo to match the attached mesh's position/rotation
  51817. */
  51818. protected _update(): void;
  51819. private static _Scale;
  51820. /**
  51821. * Creates the lines for a light mesh
  51822. */
  51823. private static _CreateLightLines;
  51824. /**
  51825. * Disposes of the light gizmo
  51826. */
  51827. dispose(): void;
  51828. private static _CreateHemisphericLightMesh;
  51829. private static _CreatePointLightMesh;
  51830. private static _CreateSpotLightMesh;
  51831. private static _CreateDirectionalLightMesh;
  51832. }
  51833. }
  51834. declare module "babylonjs/Gizmos/index" {
  51835. export * from "babylonjs/Gizmos/axisDragGizmo";
  51836. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51837. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51838. export * from "babylonjs/Gizmos/gizmo";
  51839. export * from "babylonjs/Gizmos/gizmoManager";
  51840. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51841. export * from "babylonjs/Gizmos/positionGizmo";
  51842. export * from "babylonjs/Gizmos/rotationGizmo";
  51843. export * from "babylonjs/Gizmos/scaleGizmo";
  51844. export * from "babylonjs/Gizmos/lightGizmo";
  51845. export * from "babylonjs/Gizmos/planeDragGizmo";
  51846. }
  51847. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51848. /** @hidden */
  51849. export var backgroundFragmentDeclaration: {
  51850. name: string;
  51851. shader: string;
  51852. };
  51853. }
  51854. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51855. /** @hidden */
  51856. export var backgroundUboDeclaration: {
  51857. name: string;
  51858. shader: string;
  51859. };
  51860. }
  51861. declare module "babylonjs/Shaders/background.fragment" {
  51862. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51863. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51864. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51865. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51866. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51867. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51868. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51869. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51870. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51871. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51872. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51873. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51874. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51875. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51876. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51877. /** @hidden */
  51878. export var backgroundPixelShader: {
  51879. name: string;
  51880. shader: string;
  51881. };
  51882. }
  51883. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51884. /** @hidden */
  51885. export var backgroundVertexDeclaration: {
  51886. name: string;
  51887. shader: string;
  51888. };
  51889. }
  51890. declare module "babylonjs/Shaders/background.vertex" {
  51891. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51892. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51894. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51895. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51896. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51897. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51898. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51899. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51900. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51901. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51902. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51903. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51904. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51905. /** @hidden */
  51906. export var backgroundVertexShader: {
  51907. name: string;
  51908. shader: string;
  51909. };
  51910. }
  51911. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51912. import { Nullable, int, float } from "babylonjs/types";
  51913. import { Scene } from "babylonjs/scene";
  51914. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51915. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51917. import { Mesh } from "babylonjs/Meshes/mesh";
  51918. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51919. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51920. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51922. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51923. import { Color3 } from "babylonjs/Maths/math.color";
  51924. import "babylonjs/Shaders/background.fragment";
  51925. import "babylonjs/Shaders/background.vertex";
  51926. /**
  51927. * Background material used to create an efficient environement around your scene.
  51928. */
  51929. export class BackgroundMaterial extends PushMaterial {
  51930. /**
  51931. * Standard reflectance value at parallel view angle.
  51932. */
  51933. static StandardReflectance0: number;
  51934. /**
  51935. * Standard reflectance value at grazing angle.
  51936. */
  51937. static StandardReflectance90: number;
  51938. protected _primaryColor: Color3;
  51939. /**
  51940. * Key light Color (multiply against the environement texture)
  51941. */
  51942. primaryColor: Color3;
  51943. protected __perceptualColor: Nullable<Color3>;
  51944. /**
  51945. * Experimental Internal Use Only.
  51946. *
  51947. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51948. * This acts as a helper to set the primary color to a more "human friendly" value.
  51949. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51950. * output color as close as possible from the chosen value.
  51951. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51952. * part of lighting setup.)
  51953. */
  51954. get _perceptualColor(): Nullable<Color3>;
  51955. set _perceptualColor(value: Nullable<Color3>);
  51956. protected _primaryColorShadowLevel: float;
  51957. /**
  51958. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51959. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51960. */
  51961. get primaryColorShadowLevel(): float;
  51962. set primaryColorShadowLevel(value: float);
  51963. protected _primaryColorHighlightLevel: float;
  51964. /**
  51965. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51966. * The primary color is used at the level chosen to define what the white area would look.
  51967. */
  51968. get primaryColorHighlightLevel(): float;
  51969. set primaryColorHighlightLevel(value: float);
  51970. protected _reflectionTexture: Nullable<BaseTexture>;
  51971. /**
  51972. * Reflection Texture used in the material.
  51973. * Should be author in a specific way for the best result (refer to the documentation).
  51974. */
  51975. reflectionTexture: Nullable<BaseTexture>;
  51976. protected _reflectionBlur: float;
  51977. /**
  51978. * Reflection Texture level of blur.
  51979. *
  51980. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51981. * texture twice.
  51982. */
  51983. reflectionBlur: float;
  51984. protected _diffuseTexture: Nullable<BaseTexture>;
  51985. /**
  51986. * Diffuse Texture used in the material.
  51987. * Should be author in a specific way for the best result (refer to the documentation).
  51988. */
  51989. diffuseTexture: Nullable<BaseTexture>;
  51990. protected _shadowLights: Nullable<IShadowLight[]>;
  51991. /**
  51992. * Specify the list of lights casting shadow on the material.
  51993. * All scene shadow lights will be included if null.
  51994. */
  51995. shadowLights: Nullable<IShadowLight[]>;
  51996. protected _shadowLevel: float;
  51997. /**
  51998. * Helps adjusting the shadow to a softer level if required.
  51999. * 0 means black shadows and 1 means no shadows.
  52000. */
  52001. shadowLevel: float;
  52002. protected _sceneCenter: Vector3;
  52003. /**
  52004. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52005. * It is usually zero but might be interesting to modify according to your setup.
  52006. */
  52007. sceneCenter: Vector3;
  52008. protected _opacityFresnel: boolean;
  52009. /**
  52010. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52011. * This helps ensuring a nice transition when the camera goes under the ground.
  52012. */
  52013. opacityFresnel: boolean;
  52014. protected _reflectionFresnel: boolean;
  52015. /**
  52016. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52017. * This helps adding a mirror texture on the ground.
  52018. */
  52019. reflectionFresnel: boolean;
  52020. protected _reflectionFalloffDistance: number;
  52021. /**
  52022. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52023. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52024. */
  52025. reflectionFalloffDistance: number;
  52026. protected _reflectionAmount: number;
  52027. /**
  52028. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52029. */
  52030. reflectionAmount: number;
  52031. protected _reflectionReflectance0: number;
  52032. /**
  52033. * This specifies the weight of the reflection at grazing angle.
  52034. */
  52035. reflectionReflectance0: number;
  52036. protected _reflectionReflectance90: number;
  52037. /**
  52038. * This specifies the weight of the reflection at a perpendicular point of view.
  52039. */
  52040. reflectionReflectance90: number;
  52041. /**
  52042. * Sets the reflection reflectance fresnel values according to the default standard
  52043. * empirically know to work well :-)
  52044. */
  52045. set reflectionStandardFresnelWeight(value: number);
  52046. protected _useRGBColor: boolean;
  52047. /**
  52048. * Helps to directly use the maps channels instead of their level.
  52049. */
  52050. useRGBColor: boolean;
  52051. protected _enableNoise: boolean;
  52052. /**
  52053. * This helps reducing the banding effect that could occur on the background.
  52054. */
  52055. enableNoise: boolean;
  52056. /**
  52057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52058. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52059. * Recommended to be keep at 1.0 except for special cases.
  52060. */
  52061. get fovMultiplier(): number;
  52062. set fovMultiplier(value: number);
  52063. private _fovMultiplier;
  52064. /**
  52065. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52066. */
  52067. useEquirectangularFOV: boolean;
  52068. private _maxSimultaneousLights;
  52069. /**
  52070. * Number of Simultaneous lights allowed on the material.
  52071. */
  52072. maxSimultaneousLights: int;
  52073. /**
  52074. * Default configuration related to image processing available in the Background Material.
  52075. */
  52076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52077. /**
  52078. * Keep track of the image processing observer to allow dispose and replace.
  52079. */
  52080. private _imageProcessingObserver;
  52081. /**
  52082. * Attaches a new image processing configuration to the PBR Material.
  52083. * @param configuration (if null the scene configuration will be use)
  52084. */
  52085. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52086. /**
  52087. * Gets the image processing configuration used either in this material.
  52088. */
  52089. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52090. /**
  52091. * Sets the Default image processing configuration used either in the this material.
  52092. *
  52093. * If sets to null, the scene one is in use.
  52094. */
  52095. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52096. /**
  52097. * Gets wether the color curves effect is enabled.
  52098. */
  52099. get cameraColorCurvesEnabled(): boolean;
  52100. /**
  52101. * Sets wether the color curves effect is enabled.
  52102. */
  52103. set cameraColorCurvesEnabled(value: boolean);
  52104. /**
  52105. * Gets wether the color grading effect is enabled.
  52106. */
  52107. get cameraColorGradingEnabled(): boolean;
  52108. /**
  52109. * Gets wether the color grading effect is enabled.
  52110. */
  52111. set cameraColorGradingEnabled(value: boolean);
  52112. /**
  52113. * Gets wether tonemapping is enabled or not.
  52114. */
  52115. get cameraToneMappingEnabled(): boolean;
  52116. /**
  52117. * Sets wether tonemapping is enabled or not
  52118. */
  52119. set cameraToneMappingEnabled(value: boolean);
  52120. /**
  52121. * The camera exposure used on this material.
  52122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52123. * This corresponds to a photographic exposure.
  52124. */
  52125. get cameraExposure(): float;
  52126. /**
  52127. * The camera exposure used on this material.
  52128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52129. * This corresponds to a photographic exposure.
  52130. */
  52131. set cameraExposure(value: float);
  52132. /**
  52133. * Gets The camera contrast used on this material.
  52134. */
  52135. get cameraContrast(): float;
  52136. /**
  52137. * Sets The camera contrast used on this material.
  52138. */
  52139. set cameraContrast(value: float);
  52140. /**
  52141. * Gets the Color Grading 2D Lookup Texture.
  52142. */
  52143. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52144. /**
  52145. * Sets the Color Grading 2D Lookup Texture.
  52146. */
  52147. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52148. /**
  52149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52151. * 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;
  52152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52153. */
  52154. get cameraColorCurves(): Nullable<ColorCurves>;
  52155. /**
  52156. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52157. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52158. * 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;
  52159. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52160. */
  52161. set cameraColorCurves(value: Nullable<ColorCurves>);
  52162. /**
  52163. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52164. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52165. */
  52166. switchToBGR: boolean;
  52167. private _renderTargets;
  52168. private _reflectionControls;
  52169. private _white;
  52170. private _primaryShadowColor;
  52171. private _primaryHighlightColor;
  52172. /**
  52173. * Instantiates a Background Material in the given scene
  52174. * @param name The friendly name of the material
  52175. * @param scene The scene to add the material to
  52176. */
  52177. constructor(name: string, scene: Scene);
  52178. /**
  52179. * Gets a boolean indicating that current material needs to register RTT
  52180. */
  52181. get hasRenderTargetTextures(): boolean;
  52182. /**
  52183. * The entire material has been created in order to prevent overdraw.
  52184. * @returns false
  52185. */
  52186. needAlphaTesting(): boolean;
  52187. /**
  52188. * The entire material has been created in order to prevent overdraw.
  52189. * @returns true if blending is enable
  52190. */
  52191. needAlphaBlending(): boolean;
  52192. /**
  52193. * Checks wether the material is ready to be rendered for a given mesh.
  52194. * @param mesh The mesh to render
  52195. * @param subMesh The submesh to check against
  52196. * @param useInstances Specify wether or not the material is used with instances
  52197. * @returns true if all the dependencies are ready (Textures, Effects...)
  52198. */
  52199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52200. /**
  52201. * Compute the primary color according to the chosen perceptual color.
  52202. */
  52203. private _computePrimaryColorFromPerceptualColor;
  52204. /**
  52205. * Compute the highlights and shadow colors according to their chosen levels.
  52206. */
  52207. private _computePrimaryColors;
  52208. /**
  52209. * Build the uniform buffer used in the material.
  52210. */
  52211. buildUniformLayout(): void;
  52212. /**
  52213. * Unbind the material.
  52214. */
  52215. unbind(): void;
  52216. /**
  52217. * Bind only the world matrix to the material.
  52218. * @param world The world matrix to bind.
  52219. */
  52220. bindOnlyWorldMatrix(world: Matrix): void;
  52221. /**
  52222. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52223. * @param world The world matrix to bind.
  52224. * @param subMesh The submesh to bind for.
  52225. */
  52226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52227. /**
  52228. * Checks to see if a texture is used in the material.
  52229. * @param texture - Base texture to use.
  52230. * @returns - Boolean specifying if a texture is used in the material.
  52231. */
  52232. hasTexture(texture: BaseTexture): boolean;
  52233. /**
  52234. * Dispose the material.
  52235. * @param forceDisposeEffect Force disposal of the associated effect.
  52236. * @param forceDisposeTextures Force disposal of the associated textures.
  52237. */
  52238. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52239. /**
  52240. * Clones the material.
  52241. * @param name The cloned name.
  52242. * @returns The cloned material.
  52243. */
  52244. clone(name: string): BackgroundMaterial;
  52245. /**
  52246. * Serializes the current material to its JSON representation.
  52247. * @returns The JSON representation.
  52248. */
  52249. serialize(): any;
  52250. /**
  52251. * Gets the class name of the material
  52252. * @returns "BackgroundMaterial"
  52253. */
  52254. getClassName(): string;
  52255. /**
  52256. * Parse a JSON input to create back a background material.
  52257. * @param source The JSON data to parse
  52258. * @param scene The scene to create the parsed material in
  52259. * @param rootUrl The root url of the assets the material depends upon
  52260. * @returns the instantiated BackgroundMaterial.
  52261. */
  52262. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52263. }
  52264. }
  52265. declare module "babylonjs/Helpers/environmentHelper" {
  52266. import { Observable } from "babylonjs/Misc/observable";
  52267. import { Nullable } from "babylonjs/types";
  52268. import { Scene } from "babylonjs/scene";
  52269. import { Vector3 } from "babylonjs/Maths/math.vector";
  52270. import { Color3 } from "babylonjs/Maths/math.color";
  52271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52272. import { Mesh } from "babylonjs/Meshes/mesh";
  52273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52274. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52275. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52276. import "babylonjs/Meshes/Builders/planeBuilder";
  52277. import "babylonjs/Meshes/Builders/boxBuilder";
  52278. /**
  52279. * Represents the different options available during the creation of
  52280. * a Environment helper.
  52281. *
  52282. * This can control the default ground, skybox and image processing setup of your scene.
  52283. */
  52284. export interface IEnvironmentHelperOptions {
  52285. /**
  52286. * Specifies whether or not to create a ground.
  52287. * True by default.
  52288. */
  52289. createGround: boolean;
  52290. /**
  52291. * Specifies the ground size.
  52292. * 15 by default.
  52293. */
  52294. groundSize: number;
  52295. /**
  52296. * The texture used on the ground for the main color.
  52297. * Comes from the BabylonJS CDN by default.
  52298. *
  52299. * Remarks: Can be either a texture or a url.
  52300. */
  52301. groundTexture: string | BaseTexture;
  52302. /**
  52303. * The color mixed in the ground texture by default.
  52304. * BabylonJS clearColor by default.
  52305. */
  52306. groundColor: Color3;
  52307. /**
  52308. * Specifies the ground opacity.
  52309. * 1 by default.
  52310. */
  52311. groundOpacity: number;
  52312. /**
  52313. * Enables the ground to receive shadows.
  52314. * True by default.
  52315. */
  52316. enableGroundShadow: boolean;
  52317. /**
  52318. * Helps preventing the shadow to be fully black on the ground.
  52319. * 0.5 by default.
  52320. */
  52321. groundShadowLevel: number;
  52322. /**
  52323. * Creates a mirror texture attach to the ground.
  52324. * false by default.
  52325. */
  52326. enableGroundMirror: boolean;
  52327. /**
  52328. * Specifies the ground mirror size ratio.
  52329. * 0.3 by default as the default kernel is 64.
  52330. */
  52331. groundMirrorSizeRatio: number;
  52332. /**
  52333. * Specifies the ground mirror blur kernel size.
  52334. * 64 by default.
  52335. */
  52336. groundMirrorBlurKernel: number;
  52337. /**
  52338. * Specifies the ground mirror visibility amount.
  52339. * 1 by default
  52340. */
  52341. groundMirrorAmount: number;
  52342. /**
  52343. * Specifies the ground mirror reflectance weight.
  52344. * This uses the standard weight of the background material to setup the fresnel effect
  52345. * of the mirror.
  52346. * 1 by default.
  52347. */
  52348. groundMirrorFresnelWeight: number;
  52349. /**
  52350. * Specifies the ground mirror Falloff distance.
  52351. * This can helps reducing the size of the reflection.
  52352. * 0 by Default.
  52353. */
  52354. groundMirrorFallOffDistance: number;
  52355. /**
  52356. * Specifies the ground mirror texture type.
  52357. * Unsigned Int by Default.
  52358. */
  52359. groundMirrorTextureType: number;
  52360. /**
  52361. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52362. * the shown objects.
  52363. */
  52364. groundYBias: number;
  52365. /**
  52366. * Specifies whether or not to create a skybox.
  52367. * True by default.
  52368. */
  52369. createSkybox: boolean;
  52370. /**
  52371. * Specifies the skybox size.
  52372. * 20 by default.
  52373. */
  52374. skyboxSize: number;
  52375. /**
  52376. * The texture used on the skybox for the main color.
  52377. * Comes from the BabylonJS CDN by default.
  52378. *
  52379. * Remarks: Can be either a texture or a url.
  52380. */
  52381. skyboxTexture: string | BaseTexture;
  52382. /**
  52383. * The color mixed in the skybox texture by default.
  52384. * BabylonJS clearColor by default.
  52385. */
  52386. skyboxColor: Color3;
  52387. /**
  52388. * The background rotation around the Y axis of the scene.
  52389. * This helps aligning the key lights of your scene with the background.
  52390. * 0 by default.
  52391. */
  52392. backgroundYRotation: number;
  52393. /**
  52394. * Compute automatically the size of the elements to best fit with the scene.
  52395. */
  52396. sizeAuto: boolean;
  52397. /**
  52398. * Default position of the rootMesh if autoSize is not true.
  52399. */
  52400. rootPosition: Vector3;
  52401. /**
  52402. * Sets up the image processing in the scene.
  52403. * true by default.
  52404. */
  52405. setupImageProcessing: boolean;
  52406. /**
  52407. * The texture used as your environment texture in the scene.
  52408. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52409. *
  52410. * Remarks: Can be either a texture or a url.
  52411. */
  52412. environmentTexture: string | BaseTexture;
  52413. /**
  52414. * The value of the exposure to apply to the scene.
  52415. * 0.6 by default if setupImageProcessing is true.
  52416. */
  52417. cameraExposure: number;
  52418. /**
  52419. * The value of the contrast to apply to the scene.
  52420. * 1.6 by default if setupImageProcessing is true.
  52421. */
  52422. cameraContrast: number;
  52423. /**
  52424. * Specifies whether or not tonemapping should be enabled in the scene.
  52425. * true by default if setupImageProcessing is true.
  52426. */
  52427. toneMappingEnabled: boolean;
  52428. }
  52429. /**
  52430. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52431. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52432. * It also helps with the default setup of your imageProcessing configuration.
  52433. */
  52434. export class EnvironmentHelper {
  52435. /**
  52436. * Default ground texture URL.
  52437. */
  52438. private static _groundTextureCDNUrl;
  52439. /**
  52440. * Default skybox texture URL.
  52441. */
  52442. private static _skyboxTextureCDNUrl;
  52443. /**
  52444. * Default environment texture URL.
  52445. */
  52446. private static _environmentTextureCDNUrl;
  52447. /**
  52448. * Creates the default options for the helper.
  52449. */
  52450. private static _getDefaultOptions;
  52451. private _rootMesh;
  52452. /**
  52453. * Gets the root mesh created by the helper.
  52454. */
  52455. get rootMesh(): Mesh;
  52456. private _skybox;
  52457. /**
  52458. * Gets the skybox created by the helper.
  52459. */
  52460. get skybox(): Nullable<Mesh>;
  52461. private _skyboxTexture;
  52462. /**
  52463. * Gets the skybox texture created by the helper.
  52464. */
  52465. get skyboxTexture(): Nullable<BaseTexture>;
  52466. private _skyboxMaterial;
  52467. /**
  52468. * Gets the skybox material created by the helper.
  52469. */
  52470. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52471. private _ground;
  52472. /**
  52473. * Gets the ground mesh created by the helper.
  52474. */
  52475. get ground(): Nullable<Mesh>;
  52476. private _groundTexture;
  52477. /**
  52478. * Gets the ground texture created by the helper.
  52479. */
  52480. get groundTexture(): Nullable<BaseTexture>;
  52481. private _groundMirror;
  52482. /**
  52483. * Gets the ground mirror created by the helper.
  52484. */
  52485. get groundMirror(): Nullable<MirrorTexture>;
  52486. /**
  52487. * Gets the ground mirror render list to helps pushing the meshes
  52488. * you wish in the ground reflection.
  52489. */
  52490. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52491. private _groundMaterial;
  52492. /**
  52493. * Gets the ground material created by the helper.
  52494. */
  52495. get groundMaterial(): Nullable<BackgroundMaterial>;
  52496. /**
  52497. * Stores the creation options.
  52498. */
  52499. private readonly _scene;
  52500. private _options;
  52501. /**
  52502. * This observable will be notified with any error during the creation of the environment,
  52503. * mainly texture creation errors.
  52504. */
  52505. onErrorObservable: Observable<{
  52506. message?: string;
  52507. exception?: any;
  52508. }>;
  52509. /**
  52510. * constructor
  52511. * @param options Defines the options we want to customize the helper
  52512. * @param scene The scene to add the material to
  52513. */
  52514. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52515. /**
  52516. * Updates the background according to the new options
  52517. * @param options
  52518. */
  52519. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52520. /**
  52521. * Sets the primary color of all the available elements.
  52522. * @param color the main color to affect to the ground and the background
  52523. */
  52524. setMainColor(color: Color3): void;
  52525. /**
  52526. * Setup the image processing according to the specified options.
  52527. */
  52528. private _setupImageProcessing;
  52529. /**
  52530. * Setup the environment texture according to the specified options.
  52531. */
  52532. private _setupEnvironmentTexture;
  52533. /**
  52534. * Setup the background according to the specified options.
  52535. */
  52536. private _setupBackground;
  52537. /**
  52538. * Get the scene sizes according to the setup.
  52539. */
  52540. private _getSceneSize;
  52541. /**
  52542. * Setup the ground according to the specified options.
  52543. */
  52544. private _setupGround;
  52545. /**
  52546. * Setup the ground material according to the specified options.
  52547. */
  52548. private _setupGroundMaterial;
  52549. /**
  52550. * Setup the ground diffuse texture according to the specified options.
  52551. */
  52552. private _setupGroundDiffuseTexture;
  52553. /**
  52554. * Setup the ground mirror texture according to the specified options.
  52555. */
  52556. private _setupGroundMirrorTexture;
  52557. /**
  52558. * Setup the ground to receive the mirror texture.
  52559. */
  52560. private _setupMirrorInGroundMaterial;
  52561. /**
  52562. * Setup the skybox according to the specified options.
  52563. */
  52564. private _setupSkybox;
  52565. /**
  52566. * Setup the skybox material according to the specified options.
  52567. */
  52568. private _setupSkyboxMaterial;
  52569. /**
  52570. * Setup the skybox reflection texture according to the specified options.
  52571. */
  52572. private _setupSkyboxReflectionTexture;
  52573. private _errorHandler;
  52574. /**
  52575. * Dispose all the elements created by the Helper.
  52576. */
  52577. dispose(): void;
  52578. }
  52579. }
  52580. declare module "babylonjs/Helpers/photoDome" {
  52581. import { Observable } from "babylonjs/Misc/observable";
  52582. import { Nullable } from "babylonjs/types";
  52583. import { Scene } from "babylonjs/scene";
  52584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52585. import { Mesh } from "babylonjs/Meshes/mesh";
  52586. import { Texture } from "babylonjs/Materials/Textures/texture";
  52587. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52588. import "babylonjs/Meshes/Builders/sphereBuilder";
  52589. /**
  52590. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52591. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52592. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52593. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52594. */
  52595. export class PhotoDome extends TransformNode {
  52596. /**
  52597. * Define the image as a Monoscopic panoramic 360 image.
  52598. */
  52599. static readonly MODE_MONOSCOPIC: number;
  52600. /**
  52601. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52602. */
  52603. static readonly MODE_TOPBOTTOM: number;
  52604. /**
  52605. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52606. */
  52607. static readonly MODE_SIDEBYSIDE: number;
  52608. private _useDirectMapping;
  52609. /**
  52610. * The texture being displayed on the sphere
  52611. */
  52612. protected _photoTexture: Texture;
  52613. /**
  52614. * Gets or sets the texture being displayed on the sphere
  52615. */
  52616. get photoTexture(): Texture;
  52617. set photoTexture(value: Texture);
  52618. /**
  52619. * Observable raised when an error occured while loading the 360 image
  52620. */
  52621. onLoadErrorObservable: Observable<string>;
  52622. /**
  52623. * The skybox material
  52624. */
  52625. protected _material: BackgroundMaterial;
  52626. /**
  52627. * The surface used for the skybox
  52628. */
  52629. protected _mesh: Mesh;
  52630. /**
  52631. * Gets the mesh used for the skybox.
  52632. */
  52633. get mesh(): Mesh;
  52634. /**
  52635. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52636. * Also see the options.resolution property.
  52637. */
  52638. get fovMultiplier(): number;
  52639. set fovMultiplier(value: number);
  52640. private _imageMode;
  52641. /**
  52642. * Gets or set the current video mode for the video. It can be:
  52643. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52644. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52645. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52646. */
  52647. get imageMode(): number;
  52648. set imageMode(value: number);
  52649. /**
  52650. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52651. * @param name Element's name, child elements will append suffixes for their own names.
  52652. * @param urlsOfPhoto defines the url of the photo to display
  52653. * @param options defines an object containing optional or exposed sub element properties
  52654. * @param onError defines a callback called when an error occured while loading the texture
  52655. */
  52656. constructor(name: string, urlOfPhoto: string, options: {
  52657. resolution?: number;
  52658. size?: number;
  52659. useDirectMapping?: boolean;
  52660. faceForward?: boolean;
  52661. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52662. private _onBeforeCameraRenderObserver;
  52663. private _changeImageMode;
  52664. /**
  52665. * Releases resources associated with this node.
  52666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52668. */
  52669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52670. }
  52671. }
  52672. declare module "babylonjs/Misc/rgbdTextureTools" {
  52673. import "babylonjs/Shaders/rgbdDecode.fragment";
  52674. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52675. import { Texture } from "babylonjs/Materials/Textures/texture";
  52676. /**
  52677. * Class used to host RGBD texture specific utilities
  52678. */
  52679. export class RGBDTextureTools {
  52680. /**
  52681. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52682. * @param texture the texture to expand.
  52683. */
  52684. static ExpandRGBDTexture(texture: Texture): void;
  52685. }
  52686. }
  52687. declare module "babylonjs/Misc/brdfTextureTools" {
  52688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52689. import { Scene } from "babylonjs/scene";
  52690. /**
  52691. * Class used to host texture specific utilities
  52692. */
  52693. export class BRDFTextureTools {
  52694. /**
  52695. * Prevents texture cache collision
  52696. */
  52697. private static _instanceNumber;
  52698. /**
  52699. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52700. * @param scene defines the hosting scene
  52701. * @returns the environment BRDF texture
  52702. */
  52703. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52704. private static _environmentBRDFBase64Texture;
  52705. }
  52706. }
  52707. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52708. import { Nullable } from "babylonjs/types";
  52709. import { Color3 } from "babylonjs/Maths/math.color";
  52710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52711. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52712. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52713. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52714. import { Engine } from "babylonjs/Engines/engine";
  52715. import { Scene } from "babylonjs/scene";
  52716. /**
  52717. * @hidden
  52718. */
  52719. export interface IMaterialClearCoatDefines {
  52720. CLEARCOAT: boolean;
  52721. CLEARCOAT_DEFAULTIOR: boolean;
  52722. CLEARCOAT_TEXTURE: boolean;
  52723. CLEARCOAT_TEXTUREDIRECTUV: number;
  52724. CLEARCOAT_BUMP: boolean;
  52725. CLEARCOAT_BUMPDIRECTUV: number;
  52726. CLEARCOAT_TINT: boolean;
  52727. CLEARCOAT_TINT_TEXTURE: boolean;
  52728. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52729. /** @hidden */
  52730. _areTexturesDirty: boolean;
  52731. }
  52732. /**
  52733. * Define the code related to the clear coat parameters of the pbr material.
  52734. */
  52735. export class PBRClearCoatConfiguration {
  52736. /**
  52737. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52738. * The default fits with a polyurethane material.
  52739. */
  52740. private static readonly _DefaultIndexOfRefraction;
  52741. private _isEnabled;
  52742. /**
  52743. * Defines if the clear coat is enabled in the material.
  52744. */
  52745. isEnabled: boolean;
  52746. /**
  52747. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52748. */
  52749. intensity: number;
  52750. /**
  52751. * Defines the clear coat layer roughness.
  52752. */
  52753. roughness: number;
  52754. private _indexOfRefraction;
  52755. /**
  52756. * Defines the index of refraction of the clear coat.
  52757. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52758. * The default fits with a polyurethane material.
  52759. * Changing the default value is more performance intensive.
  52760. */
  52761. indexOfRefraction: number;
  52762. private _texture;
  52763. /**
  52764. * Stores the clear coat values in a texture.
  52765. */
  52766. texture: Nullable<BaseTexture>;
  52767. private _bumpTexture;
  52768. /**
  52769. * Define the clear coat specific bump texture.
  52770. */
  52771. bumpTexture: Nullable<BaseTexture>;
  52772. private _isTintEnabled;
  52773. /**
  52774. * Defines if the clear coat tint is enabled in the material.
  52775. */
  52776. isTintEnabled: boolean;
  52777. /**
  52778. * Defines the clear coat tint of the material.
  52779. * This is only use if tint is enabled
  52780. */
  52781. tintColor: Color3;
  52782. /**
  52783. * Defines the distance at which the tint color should be found in the
  52784. * clear coat media.
  52785. * This is only use if tint is enabled
  52786. */
  52787. tintColorAtDistance: number;
  52788. /**
  52789. * Defines the clear coat layer thickness.
  52790. * This is only use if tint is enabled
  52791. */
  52792. tintThickness: number;
  52793. private _tintTexture;
  52794. /**
  52795. * Stores the clear tint values in a texture.
  52796. * rgb is tint
  52797. * a is a thickness factor
  52798. */
  52799. tintTexture: Nullable<BaseTexture>;
  52800. /** @hidden */
  52801. private _internalMarkAllSubMeshesAsTexturesDirty;
  52802. /** @hidden */
  52803. _markAllSubMeshesAsTexturesDirty(): void;
  52804. /**
  52805. * Instantiate a new istance of clear coat configuration.
  52806. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52807. */
  52808. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52809. /**
  52810. * Gets wehter the submesh is ready to be used or not.
  52811. * @param defines the list of "defines" to update.
  52812. * @param scene defines the scene the material belongs to.
  52813. * @param engine defines the engine the material belongs to.
  52814. * @param disableBumpMap defines wether the material disables bump or not.
  52815. * @returns - boolean indicating that the submesh is ready or not.
  52816. */
  52817. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52818. /**
  52819. * Checks to see if a texture is used in the material.
  52820. * @param defines the list of "defines" to update.
  52821. * @param scene defines the scene to the material belongs to.
  52822. */
  52823. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52824. /**
  52825. * Binds the material data.
  52826. * @param uniformBuffer defines the Uniform buffer to fill in.
  52827. * @param scene defines the scene the material belongs to.
  52828. * @param engine defines the engine the material belongs to.
  52829. * @param disableBumpMap defines wether the material disables bump or not.
  52830. * @param isFrozen defines wether the material is frozen or not.
  52831. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52832. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52833. */
  52834. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52835. /**
  52836. * Checks to see if a texture is used in the material.
  52837. * @param texture - Base texture to use.
  52838. * @returns - Boolean specifying if a texture is used in the material.
  52839. */
  52840. hasTexture(texture: BaseTexture): boolean;
  52841. /**
  52842. * Returns an array of the actively used textures.
  52843. * @param activeTextures Array of BaseTextures
  52844. */
  52845. getActiveTextures(activeTextures: BaseTexture[]): void;
  52846. /**
  52847. * Returns the animatable textures.
  52848. * @param animatables Array of animatable textures.
  52849. */
  52850. getAnimatables(animatables: IAnimatable[]): void;
  52851. /**
  52852. * Disposes the resources of the material.
  52853. * @param forceDisposeTextures - Forces the disposal of all textures.
  52854. */
  52855. dispose(forceDisposeTextures?: boolean): void;
  52856. /**
  52857. * Get the current class name of the texture useful for serialization or dynamic coding.
  52858. * @returns "PBRClearCoatConfiguration"
  52859. */
  52860. getClassName(): string;
  52861. /**
  52862. * Add fallbacks to the effect fallbacks list.
  52863. * @param defines defines the Base texture to use.
  52864. * @param fallbacks defines the current fallback list.
  52865. * @param currentRank defines the current fallback rank.
  52866. * @returns the new fallback rank.
  52867. */
  52868. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52869. /**
  52870. * Add the required uniforms to the current list.
  52871. * @param uniforms defines the current uniform list.
  52872. */
  52873. static AddUniforms(uniforms: string[]): void;
  52874. /**
  52875. * Add the required samplers to the current list.
  52876. * @param samplers defines the current sampler list.
  52877. */
  52878. static AddSamplers(samplers: string[]): void;
  52879. /**
  52880. * Add the required uniforms to the current buffer.
  52881. * @param uniformBuffer defines the current uniform buffer.
  52882. */
  52883. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52884. /**
  52885. * Makes a duplicate of the current configuration into another one.
  52886. * @param clearCoatConfiguration define the config where to copy the info
  52887. */
  52888. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52889. /**
  52890. * Serializes this clear coat configuration.
  52891. * @returns - An object with the serialized config.
  52892. */
  52893. serialize(): any;
  52894. /**
  52895. * Parses a anisotropy Configuration from a serialized object.
  52896. * @param source - Serialized object.
  52897. * @param scene Defines the scene we are parsing for
  52898. * @param rootUrl Defines the rootUrl to load from
  52899. */
  52900. parse(source: any, scene: Scene, rootUrl: string): void;
  52901. }
  52902. }
  52903. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52904. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52906. import { Vector2 } from "babylonjs/Maths/math.vector";
  52907. import { Scene } from "babylonjs/scene";
  52908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52909. import { Nullable } from "babylonjs/types";
  52910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52912. /**
  52913. * @hidden
  52914. */
  52915. export interface IMaterialAnisotropicDefines {
  52916. ANISOTROPIC: boolean;
  52917. ANISOTROPIC_TEXTURE: boolean;
  52918. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52919. MAINUV1: boolean;
  52920. _areTexturesDirty: boolean;
  52921. _needUVs: boolean;
  52922. }
  52923. /**
  52924. * Define the code related to the anisotropic parameters of the pbr material.
  52925. */
  52926. export class PBRAnisotropicConfiguration {
  52927. private _isEnabled;
  52928. /**
  52929. * Defines if the anisotropy is enabled in the material.
  52930. */
  52931. isEnabled: boolean;
  52932. /**
  52933. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52934. */
  52935. intensity: number;
  52936. /**
  52937. * Defines if the effect is along the tangents, bitangents or in between.
  52938. * By default, the effect is "strectching" the highlights along the tangents.
  52939. */
  52940. direction: Vector2;
  52941. private _texture;
  52942. /**
  52943. * Stores the anisotropy values in a texture.
  52944. * rg is direction (like normal from -1 to 1)
  52945. * b is a intensity
  52946. */
  52947. texture: Nullable<BaseTexture>;
  52948. /** @hidden */
  52949. private _internalMarkAllSubMeshesAsTexturesDirty;
  52950. /** @hidden */
  52951. _markAllSubMeshesAsTexturesDirty(): void;
  52952. /**
  52953. * Instantiate a new istance of anisotropy configuration.
  52954. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52955. */
  52956. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52957. /**
  52958. * Specifies that the submesh is ready to be used.
  52959. * @param defines the list of "defines" to update.
  52960. * @param scene defines the scene the material belongs to.
  52961. * @returns - boolean indicating that the submesh is ready or not.
  52962. */
  52963. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52964. /**
  52965. * Checks to see if a texture is used in the material.
  52966. * @param defines the list of "defines" to update.
  52967. * @param mesh the mesh we are preparing the defines for.
  52968. * @param scene defines the scene the material belongs to.
  52969. */
  52970. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52971. /**
  52972. * Binds the material data.
  52973. * @param uniformBuffer defines the Uniform buffer to fill in.
  52974. * @param scene defines the scene the material belongs to.
  52975. * @param isFrozen defines wether the material is frozen or not.
  52976. */
  52977. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52978. /**
  52979. * Checks to see if a texture is used in the material.
  52980. * @param texture - Base texture to use.
  52981. * @returns - Boolean specifying if a texture is used in the material.
  52982. */
  52983. hasTexture(texture: BaseTexture): boolean;
  52984. /**
  52985. * Returns an array of the actively used textures.
  52986. * @param activeTextures Array of BaseTextures
  52987. */
  52988. getActiveTextures(activeTextures: BaseTexture[]): void;
  52989. /**
  52990. * Returns the animatable textures.
  52991. * @param animatables Array of animatable textures.
  52992. */
  52993. getAnimatables(animatables: IAnimatable[]): void;
  52994. /**
  52995. * Disposes the resources of the material.
  52996. * @param forceDisposeTextures - Forces the disposal of all textures.
  52997. */
  52998. dispose(forceDisposeTextures?: boolean): void;
  52999. /**
  53000. * Get the current class name of the texture useful for serialization or dynamic coding.
  53001. * @returns "PBRAnisotropicConfiguration"
  53002. */
  53003. getClassName(): string;
  53004. /**
  53005. * Add fallbacks to the effect fallbacks list.
  53006. * @param defines defines the Base texture to use.
  53007. * @param fallbacks defines the current fallback list.
  53008. * @param currentRank defines the current fallback rank.
  53009. * @returns the new fallback rank.
  53010. */
  53011. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53012. /**
  53013. * Add the required uniforms to the current list.
  53014. * @param uniforms defines the current uniform list.
  53015. */
  53016. static AddUniforms(uniforms: string[]): void;
  53017. /**
  53018. * Add the required uniforms to the current buffer.
  53019. * @param uniformBuffer defines the current uniform buffer.
  53020. */
  53021. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53022. /**
  53023. * Add the required samplers to the current list.
  53024. * @param samplers defines the current sampler list.
  53025. */
  53026. static AddSamplers(samplers: string[]): void;
  53027. /**
  53028. * Makes a duplicate of the current configuration into another one.
  53029. * @param anisotropicConfiguration define the config where to copy the info
  53030. */
  53031. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53032. /**
  53033. * Serializes this anisotropy configuration.
  53034. * @returns - An object with the serialized config.
  53035. */
  53036. serialize(): any;
  53037. /**
  53038. * Parses a anisotropy Configuration from a serialized object.
  53039. * @param source - Serialized object.
  53040. * @param scene Defines the scene we are parsing for
  53041. * @param rootUrl Defines the rootUrl to load from
  53042. */
  53043. parse(source: any, scene: Scene, rootUrl: string): void;
  53044. }
  53045. }
  53046. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53047. import { Scene } from "babylonjs/scene";
  53048. /**
  53049. * @hidden
  53050. */
  53051. export interface IMaterialBRDFDefines {
  53052. BRDF_V_HEIGHT_CORRELATED: boolean;
  53053. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53054. SPHERICAL_HARMONICS: boolean;
  53055. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53056. /** @hidden */
  53057. _areMiscDirty: boolean;
  53058. }
  53059. /**
  53060. * Define the code related to the BRDF parameters of the pbr material.
  53061. */
  53062. export class PBRBRDFConfiguration {
  53063. /**
  53064. * Default value used for the energy conservation.
  53065. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53066. */
  53067. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53068. /**
  53069. * Default value used for the Smith Visibility Height Correlated mode.
  53070. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53071. */
  53072. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53073. /**
  53074. * Default value used for the IBL diffuse part.
  53075. * This can help switching back to the polynomials mode globally which is a tiny bit
  53076. * less GPU intensive at the drawback of a lower quality.
  53077. */
  53078. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53079. /**
  53080. * Default value used for activating energy conservation for the specular workflow.
  53081. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53082. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53083. */
  53084. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53085. private _useEnergyConservation;
  53086. /**
  53087. * Defines if the material uses energy conservation.
  53088. */
  53089. useEnergyConservation: boolean;
  53090. private _useSmithVisibilityHeightCorrelated;
  53091. /**
  53092. * LEGACY Mode set to false
  53093. * Defines if the material uses height smith correlated visibility term.
  53094. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53095. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53096. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53097. * Not relying on height correlated will also disable energy conservation.
  53098. */
  53099. useSmithVisibilityHeightCorrelated: boolean;
  53100. private _useSphericalHarmonics;
  53101. /**
  53102. * LEGACY Mode set to false
  53103. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53104. * diffuse part of the IBL.
  53105. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53106. * to the ground truth.
  53107. */
  53108. useSphericalHarmonics: boolean;
  53109. private _useSpecularGlossinessInputEnergyConservation;
  53110. /**
  53111. * Defines if the material uses energy conservation, when the specular workflow is active.
  53112. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53113. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53114. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53115. */
  53116. useSpecularGlossinessInputEnergyConservation: boolean;
  53117. /** @hidden */
  53118. private _internalMarkAllSubMeshesAsMiscDirty;
  53119. /** @hidden */
  53120. _markAllSubMeshesAsMiscDirty(): void;
  53121. /**
  53122. * Instantiate a new istance of clear coat configuration.
  53123. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53124. */
  53125. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53126. /**
  53127. * Checks to see if a texture is used in the material.
  53128. * @param defines the list of "defines" to update.
  53129. */
  53130. prepareDefines(defines: IMaterialBRDFDefines): void;
  53131. /**
  53132. * Get the current class name of the texture useful for serialization or dynamic coding.
  53133. * @returns "PBRClearCoatConfiguration"
  53134. */
  53135. getClassName(): string;
  53136. /**
  53137. * Makes a duplicate of the current configuration into another one.
  53138. * @param brdfConfiguration define the config where to copy the info
  53139. */
  53140. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53141. /**
  53142. * Serializes this BRDF configuration.
  53143. * @returns - An object with the serialized config.
  53144. */
  53145. serialize(): any;
  53146. /**
  53147. * Parses a anisotropy Configuration from a serialized object.
  53148. * @param source - Serialized object.
  53149. * @param scene Defines the scene we are parsing for
  53150. * @param rootUrl Defines the rootUrl to load from
  53151. */
  53152. parse(source: any, scene: Scene, rootUrl: string): void;
  53153. }
  53154. }
  53155. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53156. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53157. import { Color3 } from "babylonjs/Maths/math.color";
  53158. import { Scene } from "babylonjs/scene";
  53159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53160. import { Nullable } from "babylonjs/types";
  53161. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53162. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53163. /**
  53164. * @hidden
  53165. */
  53166. export interface IMaterialSheenDefines {
  53167. SHEEN: boolean;
  53168. SHEEN_TEXTURE: boolean;
  53169. SHEEN_TEXTUREDIRECTUV: number;
  53170. SHEEN_LINKWITHALBEDO: boolean;
  53171. SHEEN_ROUGHNESS: boolean;
  53172. SHEEN_ALBEDOSCALING: boolean;
  53173. /** @hidden */
  53174. _areTexturesDirty: boolean;
  53175. }
  53176. /**
  53177. * Define the code related to the Sheen parameters of the pbr material.
  53178. */
  53179. export class PBRSheenConfiguration {
  53180. private _isEnabled;
  53181. /**
  53182. * Defines if the material uses sheen.
  53183. */
  53184. isEnabled: boolean;
  53185. private _linkSheenWithAlbedo;
  53186. /**
  53187. * Defines if the sheen is linked to the sheen color.
  53188. */
  53189. linkSheenWithAlbedo: boolean;
  53190. /**
  53191. * Defines the sheen intensity.
  53192. */
  53193. intensity: number;
  53194. /**
  53195. * Defines the sheen color.
  53196. */
  53197. color: Color3;
  53198. private _texture;
  53199. /**
  53200. * Stores the sheen tint values in a texture.
  53201. * rgb is tint
  53202. * a is a intensity
  53203. */
  53204. texture: Nullable<BaseTexture>;
  53205. private _roughness;
  53206. /**
  53207. * Defines the sheen roughness.
  53208. * It is not taken into account if linkSheenWithAlbedo is true.
  53209. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53210. */
  53211. roughness: Nullable<number>;
  53212. private _albedoScaling;
  53213. /**
  53214. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53215. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53216. * making it easier to setup and tweak the effect
  53217. */
  53218. albedoScaling: boolean;
  53219. /** @hidden */
  53220. private _internalMarkAllSubMeshesAsTexturesDirty;
  53221. /** @hidden */
  53222. _markAllSubMeshesAsTexturesDirty(): void;
  53223. /**
  53224. * Instantiate a new istance of clear coat configuration.
  53225. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53226. */
  53227. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53228. /**
  53229. * Specifies that the submesh is ready to be used.
  53230. * @param defines the list of "defines" to update.
  53231. * @param scene defines the scene the material belongs to.
  53232. * @returns - boolean indicating that the submesh is ready or not.
  53233. */
  53234. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53235. /**
  53236. * Checks to see if a texture is used in the material.
  53237. * @param defines the list of "defines" to update.
  53238. * @param scene defines the scene the material belongs to.
  53239. */
  53240. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53241. /**
  53242. * Binds the material data.
  53243. * @param uniformBuffer defines the Uniform buffer to fill in.
  53244. * @param scene defines the scene the material belongs to.
  53245. * @param isFrozen defines wether the material is frozen or not.
  53246. */
  53247. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53248. /**
  53249. * Checks to see if a texture is used in the material.
  53250. * @param texture - Base texture to use.
  53251. * @returns - Boolean specifying if a texture is used in the material.
  53252. */
  53253. hasTexture(texture: BaseTexture): boolean;
  53254. /**
  53255. * Returns an array of the actively used textures.
  53256. * @param activeTextures Array of BaseTextures
  53257. */
  53258. getActiveTextures(activeTextures: BaseTexture[]): void;
  53259. /**
  53260. * Returns the animatable textures.
  53261. * @param animatables Array of animatable textures.
  53262. */
  53263. getAnimatables(animatables: IAnimatable[]): void;
  53264. /**
  53265. * Disposes the resources of the material.
  53266. * @param forceDisposeTextures - Forces the disposal of all textures.
  53267. */
  53268. dispose(forceDisposeTextures?: boolean): void;
  53269. /**
  53270. * Get the current class name of the texture useful for serialization or dynamic coding.
  53271. * @returns "PBRSheenConfiguration"
  53272. */
  53273. getClassName(): string;
  53274. /**
  53275. * Add fallbacks to the effect fallbacks list.
  53276. * @param defines defines the Base texture to use.
  53277. * @param fallbacks defines the current fallback list.
  53278. * @param currentRank defines the current fallback rank.
  53279. * @returns the new fallback rank.
  53280. */
  53281. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53282. /**
  53283. * Add the required uniforms to the current list.
  53284. * @param uniforms defines the current uniform list.
  53285. */
  53286. static AddUniforms(uniforms: string[]): void;
  53287. /**
  53288. * Add the required uniforms to the current buffer.
  53289. * @param uniformBuffer defines the current uniform buffer.
  53290. */
  53291. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53292. /**
  53293. * Add the required samplers to the current list.
  53294. * @param samplers defines the current sampler list.
  53295. */
  53296. static AddSamplers(samplers: string[]): void;
  53297. /**
  53298. * Makes a duplicate of the current configuration into another one.
  53299. * @param sheenConfiguration define the config where to copy the info
  53300. */
  53301. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53302. /**
  53303. * Serializes this BRDF configuration.
  53304. * @returns - An object with the serialized config.
  53305. */
  53306. serialize(): any;
  53307. /**
  53308. * Parses a anisotropy Configuration from a serialized object.
  53309. * @param source - Serialized object.
  53310. * @param scene Defines the scene we are parsing for
  53311. * @param rootUrl Defines the rootUrl to load from
  53312. */
  53313. parse(source: any, scene: Scene, rootUrl: string): void;
  53314. }
  53315. }
  53316. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53317. import { Nullable } from "babylonjs/types";
  53318. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53319. import { Color3 } from "babylonjs/Maths/math.color";
  53320. import { SmartArray } from "babylonjs/Misc/smartArray";
  53321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53323. import { Effect } from "babylonjs/Materials/effect";
  53324. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53325. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53326. import { Engine } from "babylonjs/Engines/engine";
  53327. import { Scene } from "babylonjs/scene";
  53328. /**
  53329. * @hidden
  53330. */
  53331. export interface IMaterialSubSurfaceDefines {
  53332. SUBSURFACE: boolean;
  53333. SS_REFRACTION: boolean;
  53334. SS_TRANSLUCENCY: boolean;
  53335. SS_SCATERRING: boolean;
  53336. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53337. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53338. SS_REFRACTIONMAP_3D: boolean;
  53339. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53340. SS_LODINREFRACTIONALPHA: boolean;
  53341. SS_GAMMAREFRACTION: boolean;
  53342. SS_RGBDREFRACTION: boolean;
  53343. SS_LINEARSPECULARREFRACTION: boolean;
  53344. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53345. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53346. /** @hidden */
  53347. _areTexturesDirty: boolean;
  53348. }
  53349. /**
  53350. * Define the code related to the sub surface parameters of the pbr material.
  53351. */
  53352. export class PBRSubSurfaceConfiguration {
  53353. private _isRefractionEnabled;
  53354. /**
  53355. * Defines if the refraction is enabled in the material.
  53356. */
  53357. isRefractionEnabled: boolean;
  53358. private _isTranslucencyEnabled;
  53359. /**
  53360. * Defines if the translucency is enabled in the material.
  53361. */
  53362. isTranslucencyEnabled: boolean;
  53363. private _isScatteringEnabled;
  53364. /**
  53365. * Defines the refraction intensity of the material.
  53366. * The refraction when enabled replaces the Diffuse part of the material.
  53367. * The intensity helps transitionning between diffuse and refraction.
  53368. */
  53369. refractionIntensity: number;
  53370. /**
  53371. * Defines the translucency intensity of the material.
  53372. * When translucency has been enabled, this defines how much of the "translucency"
  53373. * is addded to the diffuse part of the material.
  53374. */
  53375. translucencyIntensity: number;
  53376. /**
  53377. * Defines the scattering intensity of the material.
  53378. * When scattering has been enabled, this defines how much of the "scattered light"
  53379. * is addded to the diffuse part of the material.
  53380. */
  53381. scatteringIntensity: number;
  53382. private _thicknessTexture;
  53383. /**
  53384. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53385. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53386. * 0 would mean minimumThickness
  53387. * 1 would mean maximumThickness
  53388. * The other channels might be use as a mask to vary the different effects intensity.
  53389. */
  53390. thicknessTexture: Nullable<BaseTexture>;
  53391. private _refractionTexture;
  53392. /**
  53393. * Defines the texture to use for refraction.
  53394. */
  53395. refractionTexture: Nullable<BaseTexture>;
  53396. private _indexOfRefraction;
  53397. /**
  53398. * Defines the index of refraction used in the material.
  53399. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53400. */
  53401. indexOfRefraction: number;
  53402. private _invertRefractionY;
  53403. /**
  53404. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53405. */
  53406. invertRefractionY: boolean;
  53407. private _linkRefractionWithTransparency;
  53408. /**
  53409. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53410. * Materials half opaque for instance using refraction could benefit from this control.
  53411. */
  53412. linkRefractionWithTransparency: boolean;
  53413. /**
  53414. * Defines the minimum thickness stored in the thickness map.
  53415. * If no thickness map is defined, this value will be used to simulate thickness.
  53416. */
  53417. minimumThickness: number;
  53418. /**
  53419. * Defines the maximum thickness stored in the thickness map.
  53420. */
  53421. maximumThickness: number;
  53422. /**
  53423. * Defines the volume tint of the material.
  53424. * This is used for both translucency and scattering.
  53425. */
  53426. tintColor: Color3;
  53427. /**
  53428. * Defines the distance at which the tint color should be found in the media.
  53429. * This is used for refraction only.
  53430. */
  53431. tintColorAtDistance: number;
  53432. /**
  53433. * Defines how far each channel transmit through the media.
  53434. * It is defined as a color to simplify it selection.
  53435. */
  53436. diffusionDistance: Color3;
  53437. private _useMaskFromThicknessTexture;
  53438. /**
  53439. * Stores the intensity of the different subsurface effects in the thickness texture.
  53440. * * the green channel is the translucency intensity.
  53441. * * the blue channel is the scattering intensity.
  53442. * * the alpha channel is the refraction intensity.
  53443. */
  53444. useMaskFromThicknessTexture: boolean;
  53445. /** @hidden */
  53446. private _internalMarkAllSubMeshesAsTexturesDirty;
  53447. /** @hidden */
  53448. _markAllSubMeshesAsTexturesDirty(): void;
  53449. /**
  53450. * Instantiate a new istance of sub surface configuration.
  53451. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53452. */
  53453. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53454. /**
  53455. * Gets wehter the submesh is ready to be used or not.
  53456. * @param defines the list of "defines" to update.
  53457. * @param scene defines the scene the material belongs to.
  53458. * @returns - boolean indicating that the submesh is ready or not.
  53459. */
  53460. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53461. /**
  53462. * Checks to see if a texture is used in the material.
  53463. * @param defines the list of "defines" to update.
  53464. * @param scene defines the scene to the material belongs to.
  53465. */
  53466. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53467. /**
  53468. * Binds the material data.
  53469. * @param uniformBuffer defines the Uniform buffer to fill in.
  53470. * @param scene defines the scene the material belongs to.
  53471. * @param engine defines the engine the material belongs to.
  53472. * @param isFrozen defines wether the material is frozen or not.
  53473. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53474. */
  53475. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53476. /**
  53477. * Unbinds the material from the mesh.
  53478. * @param activeEffect defines the effect that should be unbound from.
  53479. * @returns true if unbound, otherwise false
  53480. */
  53481. unbind(activeEffect: Effect): boolean;
  53482. /**
  53483. * Returns the texture used for refraction or null if none is used.
  53484. * @param scene defines the scene the material belongs to.
  53485. * @returns - Refraction texture if present. If no refraction texture and refraction
  53486. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53487. */
  53488. private _getRefractionTexture;
  53489. /**
  53490. * Returns true if alpha blending should be disabled.
  53491. */
  53492. get disableAlphaBlending(): boolean;
  53493. /**
  53494. * Fills the list of render target textures.
  53495. * @param renderTargets the list of render targets to update
  53496. */
  53497. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53498. /**
  53499. * Checks to see if a texture is used in the material.
  53500. * @param texture - Base texture to use.
  53501. * @returns - Boolean specifying if a texture is used in the material.
  53502. */
  53503. hasTexture(texture: BaseTexture): boolean;
  53504. /**
  53505. * Gets a boolean indicating that current material needs to register RTT
  53506. * @returns true if this uses a render target otherwise false.
  53507. */
  53508. hasRenderTargetTextures(): boolean;
  53509. /**
  53510. * Returns an array of the actively used textures.
  53511. * @param activeTextures Array of BaseTextures
  53512. */
  53513. getActiveTextures(activeTextures: BaseTexture[]): void;
  53514. /**
  53515. * Returns the animatable textures.
  53516. * @param animatables Array of animatable textures.
  53517. */
  53518. getAnimatables(animatables: IAnimatable[]): void;
  53519. /**
  53520. * Disposes the resources of the material.
  53521. * @param forceDisposeTextures - Forces the disposal of all textures.
  53522. */
  53523. dispose(forceDisposeTextures?: boolean): void;
  53524. /**
  53525. * Get the current class name of the texture useful for serialization or dynamic coding.
  53526. * @returns "PBRSubSurfaceConfiguration"
  53527. */
  53528. getClassName(): string;
  53529. /**
  53530. * Add fallbacks to the effect fallbacks list.
  53531. * @param defines defines the Base texture to use.
  53532. * @param fallbacks defines the current fallback list.
  53533. * @param currentRank defines the current fallback rank.
  53534. * @returns the new fallback rank.
  53535. */
  53536. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53537. /**
  53538. * Add the required uniforms to the current list.
  53539. * @param uniforms defines the current uniform list.
  53540. */
  53541. static AddUniforms(uniforms: string[]): void;
  53542. /**
  53543. * Add the required samplers to the current list.
  53544. * @param samplers defines the current sampler list.
  53545. */
  53546. static AddSamplers(samplers: string[]): void;
  53547. /**
  53548. * Add the required uniforms to the current buffer.
  53549. * @param uniformBuffer defines the current uniform buffer.
  53550. */
  53551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53552. /**
  53553. * Makes a duplicate of the current configuration into another one.
  53554. * @param configuration define the config where to copy the info
  53555. */
  53556. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53557. /**
  53558. * Serializes this Sub Surface configuration.
  53559. * @returns - An object with the serialized config.
  53560. */
  53561. serialize(): any;
  53562. /**
  53563. * Parses a anisotropy Configuration from a serialized object.
  53564. * @param source - Serialized object.
  53565. * @param scene Defines the scene we are parsing for
  53566. * @param rootUrl Defines the rootUrl to load from
  53567. */
  53568. parse(source: any, scene: Scene, rootUrl: string): void;
  53569. }
  53570. }
  53571. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53572. /** @hidden */
  53573. export var pbrFragmentDeclaration: {
  53574. name: string;
  53575. shader: string;
  53576. };
  53577. }
  53578. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53579. /** @hidden */
  53580. export var pbrUboDeclaration: {
  53581. name: string;
  53582. shader: string;
  53583. };
  53584. }
  53585. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53586. /** @hidden */
  53587. export var pbrFragmentExtraDeclaration: {
  53588. name: string;
  53589. shader: string;
  53590. };
  53591. }
  53592. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53593. /** @hidden */
  53594. export var pbrFragmentSamplersDeclaration: {
  53595. name: string;
  53596. shader: string;
  53597. };
  53598. }
  53599. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53600. /** @hidden */
  53601. export var pbrHelperFunctions: {
  53602. name: string;
  53603. shader: string;
  53604. };
  53605. }
  53606. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53607. /** @hidden */
  53608. export var harmonicsFunctions: {
  53609. name: string;
  53610. shader: string;
  53611. };
  53612. }
  53613. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53614. /** @hidden */
  53615. export var pbrDirectLightingSetupFunctions: {
  53616. name: string;
  53617. shader: string;
  53618. };
  53619. }
  53620. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53621. /** @hidden */
  53622. export var pbrDirectLightingFalloffFunctions: {
  53623. name: string;
  53624. shader: string;
  53625. };
  53626. }
  53627. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53628. /** @hidden */
  53629. export var pbrBRDFFunctions: {
  53630. name: string;
  53631. shader: string;
  53632. };
  53633. }
  53634. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53635. /** @hidden */
  53636. export var pbrDirectLightingFunctions: {
  53637. name: string;
  53638. shader: string;
  53639. };
  53640. }
  53641. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53642. /** @hidden */
  53643. export var pbrIBLFunctions: {
  53644. name: string;
  53645. shader: string;
  53646. };
  53647. }
  53648. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53649. /** @hidden */
  53650. export var pbrBlockAlbedoOpacity: {
  53651. name: string;
  53652. shader: string;
  53653. };
  53654. }
  53655. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53656. /** @hidden */
  53657. export var pbrBlockReflectivity: {
  53658. name: string;
  53659. shader: string;
  53660. };
  53661. }
  53662. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53663. /** @hidden */
  53664. export var pbrBlockAmbientOcclusion: {
  53665. name: string;
  53666. shader: string;
  53667. };
  53668. }
  53669. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53670. /** @hidden */
  53671. export var pbrBlockAlphaFresnel: {
  53672. name: string;
  53673. shader: string;
  53674. };
  53675. }
  53676. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53677. /** @hidden */
  53678. export var pbrBlockAnisotropic: {
  53679. name: string;
  53680. shader: string;
  53681. };
  53682. }
  53683. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53684. /** @hidden */
  53685. export var pbrBlockReflection: {
  53686. name: string;
  53687. shader: string;
  53688. };
  53689. }
  53690. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53691. /** @hidden */
  53692. export var pbrBlockSheen: {
  53693. name: string;
  53694. shader: string;
  53695. };
  53696. }
  53697. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53698. /** @hidden */
  53699. export var pbrBlockClearcoat: {
  53700. name: string;
  53701. shader: string;
  53702. };
  53703. }
  53704. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53705. /** @hidden */
  53706. export var pbrBlockSubSurface: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53712. /** @hidden */
  53713. export var pbrBlockNormalGeometric: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53719. /** @hidden */
  53720. export var pbrBlockNormalFinal: {
  53721. name: string;
  53722. shader: string;
  53723. };
  53724. }
  53725. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53726. /** @hidden */
  53727. export var pbrBlockGeometryInfo: {
  53728. name: string;
  53729. shader: string;
  53730. };
  53731. }
  53732. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53733. /** @hidden */
  53734. export var pbrBlockReflectance0: {
  53735. name: string;
  53736. shader: string;
  53737. };
  53738. }
  53739. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53740. /** @hidden */
  53741. export var pbrBlockReflectance: {
  53742. name: string;
  53743. shader: string;
  53744. };
  53745. }
  53746. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53747. /** @hidden */
  53748. export var pbrBlockDirectLighting: {
  53749. name: string;
  53750. shader: string;
  53751. };
  53752. }
  53753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53754. /** @hidden */
  53755. export var pbrBlockFinalLitComponents: {
  53756. name: string;
  53757. shader: string;
  53758. };
  53759. }
  53760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53761. /** @hidden */
  53762. export var pbrBlockFinalUnlitComponents: {
  53763. name: string;
  53764. shader: string;
  53765. };
  53766. }
  53767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53768. /** @hidden */
  53769. export var pbrBlockFinalColorComposition: {
  53770. name: string;
  53771. shader: string;
  53772. };
  53773. }
  53774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53775. /** @hidden */
  53776. export var pbrBlockImageProcessing: {
  53777. name: string;
  53778. shader: string;
  53779. };
  53780. }
  53781. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53782. /** @hidden */
  53783. export var pbrDebug: {
  53784. name: string;
  53785. shader: string;
  53786. };
  53787. }
  53788. declare module "babylonjs/Shaders/pbr.fragment" {
  53789. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53790. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53791. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53792. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53793. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53794. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53796. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53797. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53798. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53799. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53800. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53801. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53802. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53803. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53804. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53805. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53806. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53807. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53808. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53809. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53810. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53811. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53812. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53813. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53814. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53815. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53816. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53817. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53818. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53819. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53820. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53821. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53822. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53823. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53824. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53825. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53826. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53827. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53828. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53829. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53830. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53831. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53832. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53833. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53834. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53835. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53836. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53837. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53838. /** @hidden */
  53839. export var pbrPixelShader: {
  53840. name: string;
  53841. shader: string;
  53842. };
  53843. }
  53844. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53845. /** @hidden */
  53846. export var pbrVertexDeclaration: {
  53847. name: string;
  53848. shader: string;
  53849. };
  53850. }
  53851. declare module "babylonjs/Shaders/pbr.vertex" {
  53852. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53853. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53856. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53857. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53858. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53859. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53860. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53861. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53862. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53865. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53867. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53868. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53869. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53870. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53871. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53872. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53873. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53874. /** @hidden */
  53875. export var pbrVertexShader: {
  53876. name: string;
  53877. shader: string;
  53878. };
  53879. }
  53880. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53881. import { Nullable } from "babylonjs/types";
  53882. import { Scene } from "babylonjs/scene";
  53883. import { Matrix } from "babylonjs/Maths/math.vector";
  53884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53886. import { Mesh } from "babylonjs/Meshes/mesh";
  53887. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53888. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53889. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53890. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53891. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53892. import { Color3 } from "babylonjs/Maths/math.color";
  53893. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53894. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53895. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53896. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53899. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53900. import "babylonjs/Shaders/pbr.fragment";
  53901. import "babylonjs/Shaders/pbr.vertex";
  53902. /**
  53903. * Manages the defines for the PBR Material.
  53904. * @hidden
  53905. */
  53906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53907. PBR: boolean;
  53908. MAINUV1: boolean;
  53909. MAINUV2: boolean;
  53910. UV1: boolean;
  53911. UV2: boolean;
  53912. ALBEDO: boolean;
  53913. GAMMAALBEDO: boolean;
  53914. ALBEDODIRECTUV: number;
  53915. VERTEXCOLOR: boolean;
  53916. AMBIENT: boolean;
  53917. AMBIENTDIRECTUV: number;
  53918. AMBIENTINGRAYSCALE: boolean;
  53919. OPACITY: boolean;
  53920. VERTEXALPHA: boolean;
  53921. OPACITYDIRECTUV: number;
  53922. OPACITYRGB: boolean;
  53923. ALPHATEST: boolean;
  53924. DEPTHPREPASS: boolean;
  53925. ALPHABLEND: boolean;
  53926. ALPHAFROMALBEDO: boolean;
  53927. ALPHATESTVALUE: string;
  53928. SPECULAROVERALPHA: boolean;
  53929. RADIANCEOVERALPHA: boolean;
  53930. ALPHAFRESNEL: boolean;
  53931. LINEARALPHAFRESNEL: boolean;
  53932. PREMULTIPLYALPHA: boolean;
  53933. EMISSIVE: boolean;
  53934. EMISSIVEDIRECTUV: number;
  53935. REFLECTIVITY: boolean;
  53936. REFLECTIVITYDIRECTUV: number;
  53937. SPECULARTERM: boolean;
  53938. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53939. MICROSURFACEAUTOMATIC: boolean;
  53940. LODBASEDMICROSFURACE: boolean;
  53941. MICROSURFACEMAP: boolean;
  53942. MICROSURFACEMAPDIRECTUV: number;
  53943. METALLICWORKFLOW: boolean;
  53944. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53945. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53946. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53947. AOSTOREINMETALMAPRED: boolean;
  53948. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53949. ENVIRONMENTBRDF: boolean;
  53950. ENVIRONMENTBRDF_RGBD: boolean;
  53951. NORMAL: boolean;
  53952. TANGENT: boolean;
  53953. BUMP: boolean;
  53954. BUMPDIRECTUV: number;
  53955. OBJECTSPACE_NORMALMAP: boolean;
  53956. PARALLAX: boolean;
  53957. PARALLAXOCCLUSION: boolean;
  53958. NORMALXYSCALE: boolean;
  53959. LIGHTMAP: boolean;
  53960. LIGHTMAPDIRECTUV: number;
  53961. USELIGHTMAPASSHADOWMAP: boolean;
  53962. GAMMALIGHTMAP: boolean;
  53963. RGBDLIGHTMAP: boolean;
  53964. REFLECTION: boolean;
  53965. REFLECTIONMAP_3D: boolean;
  53966. REFLECTIONMAP_SPHERICAL: boolean;
  53967. REFLECTIONMAP_PLANAR: boolean;
  53968. REFLECTIONMAP_CUBIC: boolean;
  53969. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53970. REFLECTIONMAP_PROJECTION: boolean;
  53971. REFLECTIONMAP_SKYBOX: boolean;
  53972. REFLECTIONMAP_EXPLICIT: boolean;
  53973. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53974. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53975. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53976. INVERTCUBICMAP: boolean;
  53977. USESPHERICALFROMREFLECTIONMAP: boolean;
  53978. USEIRRADIANCEMAP: boolean;
  53979. SPHERICAL_HARMONICS: boolean;
  53980. USESPHERICALINVERTEX: boolean;
  53981. REFLECTIONMAP_OPPOSITEZ: boolean;
  53982. LODINREFLECTIONALPHA: boolean;
  53983. GAMMAREFLECTION: boolean;
  53984. RGBDREFLECTION: boolean;
  53985. LINEARSPECULARREFLECTION: boolean;
  53986. RADIANCEOCCLUSION: boolean;
  53987. HORIZONOCCLUSION: boolean;
  53988. INSTANCES: boolean;
  53989. NUM_BONE_INFLUENCERS: number;
  53990. BonesPerMesh: number;
  53991. BONETEXTURE: boolean;
  53992. NONUNIFORMSCALING: boolean;
  53993. MORPHTARGETS: boolean;
  53994. MORPHTARGETS_NORMAL: boolean;
  53995. MORPHTARGETS_TANGENT: boolean;
  53996. MORPHTARGETS_UV: boolean;
  53997. NUM_MORPH_INFLUENCERS: number;
  53998. IMAGEPROCESSING: boolean;
  53999. VIGNETTE: boolean;
  54000. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54001. VIGNETTEBLENDMODEOPAQUE: boolean;
  54002. TONEMAPPING: boolean;
  54003. TONEMAPPING_ACES: boolean;
  54004. CONTRAST: boolean;
  54005. COLORCURVES: boolean;
  54006. COLORGRADING: boolean;
  54007. COLORGRADING3D: boolean;
  54008. SAMPLER3DGREENDEPTH: boolean;
  54009. SAMPLER3DBGRMAP: boolean;
  54010. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54011. EXPOSURE: boolean;
  54012. MULTIVIEW: boolean;
  54013. USEPHYSICALLIGHTFALLOFF: boolean;
  54014. USEGLTFLIGHTFALLOFF: boolean;
  54015. TWOSIDEDLIGHTING: boolean;
  54016. SHADOWFLOAT: boolean;
  54017. CLIPPLANE: boolean;
  54018. CLIPPLANE2: boolean;
  54019. CLIPPLANE3: boolean;
  54020. CLIPPLANE4: boolean;
  54021. CLIPPLANE5: boolean;
  54022. CLIPPLANE6: boolean;
  54023. POINTSIZE: boolean;
  54024. FOG: boolean;
  54025. LOGARITHMICDEPTH: boolean;
  54026. FORCENORMALFORWARD: boolean;
  54027. SPECULARAA: boolean;
  54028. CLEARCOAT: boolean;
  54029. CLEARCOAT_DEFAULTIOR: boolean;
  54030. CLEARCOAT_TEXTURE: boolean;
  54031. CLEARCOAT_TEXTUREDIRECTUV: number;
  54032. CLEARCOAT_BUMP: boolean;
  54033. CLEARCOAT_BUMPDIRECTUV: number;
  54034. CLEARCOAT_TINT: boolean;
  54035. CLEARCOAT_TINT_TEXTURE: boolean;
  54036. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54037. ANISOTROPIC: boolean;
  54038. ANISOTROPIC_TEXTURE: boolean;
  54039. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54040. BRDF_V_HEIGHT_CORRELATED: boolean;
  54041. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54042. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54043. SHEEN: boolean;
  54044. SHEEN_TEXTURE: boolean;
  54045. SHEEN_TEXTUREDIRECTUV: number;
  54046. SHEEN_LINKWITHALBEDO: boolean;
  54047. SHEEN_ROUGHNESS: boolean;
  54048. SHEEN_ALBEDOSCALING: boolean;
  54049. SUBSURFACE: boolean;
  54050. SS_REFRACTION: boolean;
  54051. SS_TRANSLUCENCY: boolean;
  54052. SS_SCATERRING: boolean;
  54053. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54054. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54055. SS_REFRACTIONMAP_3D: boolean;
  54056. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54057. SS_LODINREFRACTIONALPHA: boolean;
  54058. SS_GAMMAREFRACTION: boolean;
  54059. SS_RGBDREFRACTION: boolean;
  54060. SS_LINEARSPECULARREFRACTION: boolean;
  54061. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54062. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54063. UNLIT: boolean;
  54064. DEBUGMODE: number;
  54065. /**
  54066. * Initializes the PBR Material defines.
  54067. */
  54068. constructor();
  54069. /**
  54070. * Resets the PBR Material defines.
  54071. */
  54072. reset(): void;
  54073. }
  54074. /**
  54075. * The Physically based material base class of BJS.
  54076. *
  54077. * This offers the main features of a standard PBR material.
  54078. * For more information, please refer to the documentation :
  54079. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54080. */
  54081. export abstract class PBRBaseMaterial extends PushMaterial {
  54082. /**
  54083. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54084. */
  54085. static readonly PBRMATERIAL_OPAQUE: number;
  54086. /**
  54087. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54088. */
  54089. static readonly PBRMATERIAL_ALPHATEST: number;
  54090. /**
  54091. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54092. */
  54093. static readonly PBRMATERIAL_ALPHABLEND: number;
  54094. /**
  54095. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54096. * They are also discarded below the alpha cutoff threshold to improve performances.
  54097. */
  54098. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54099. /**
  54100. * Defines the default value of how much AO map is occluding the analytical lights
  54101. * (point spot...).
  54102. */
  54103. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54104. /**
  54105. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54106. */
  54107. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54108. /**
  54109. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54110. * to enhance interoperability with other engines.
  54111. */
  54112. static readonly LIGHTFALLOFF_GLTF: number;
  54113. /**
  54114. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54115. * to enhance interoperability with other materials.
  54116. */
  54117. static readonly LIGHTFALLOFF_STANDARD: number;
  54118. /**
  54119. * Intensity of the direct lights e.g. the four lights available in your scene.
  54120. * This impacts both the direct diffuse and specular highlights.
  54121. */
  54122. protected _directIntensity: number;
  54123. /**
  54124. * Intensity of the emissive part of the material.
  54125. * This helps controlling the emissive effect without modifying the emissive color.
  54126. */
  54127. protected _emissiveIntensity: number;
  54128. /**
  54129. * Intensity of the environment e.g. how much the environment will light the object
  54130. * either through harmonics for rough material or through the refelction for shiny ones.
  54131. */
  54132. protected _environmentIntensity: number;
  54133. /**
  54134. * This is a special control allowing the reduction of the specular highlights coming from the
  54135. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54136. */
  54137. protected _specularIntensity: number;
  54138. /**
  54139. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54140. */
  54141. private _lightingInfos;
  54142. /**
  54143. * Debug Control allowing disabling the bump map on this material.
  54144. */
  54145. protected _disableBumpMap: boolean;
  54146. /**
  54147. * AKA Diffuse Texture in standard nomenclature.
  54148. */
  54149. protected _albedoTexture: Nullable<BaseTexture>;
  54150. /**
  54151. * AKA Occlusion Texture in other nomenclature.
  54152. */
  54153. protected _ambientTexture: Nullable<BaseTexture>;
  54154. /**
  54155. * AKA Occlusion Texture Intensity in other nomenclature.
  54156. */
  54157. protected _ambientTextureStrength: number;
  54158. /**
  54159. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54160. * 1 means it completely occludes it
  54161. * 0 mean it has no impact
  54162. */
  54163. protected _ambientTextureImpactOnAnalyticalLights: number;
  54164. /**
  54165. * Stores the alpha values in a texture.
  54166. */
  54167. protected _opacityTexture: Nullable<BaseTexture>;
  54168. /**
  54169. * Stores the reflection values in a texture.
  54170. */
  54171. protected _reflectionTexture: Nullable<BaseTexture>;
  54172. /**
  54173. * Stores the emissive values in a texture.
  54174. */
  54175. protected _emissiveTexture: Nullable<BaseTexture>;
  54176. /**
  54177. * AKA Specular texture in other nomenclature.
  54178. */
  54179. protected _reflectivityTexture: Nullable<BaseTexture>;
  54180. /**
  54181. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54182. */
  54183. protected _metallicTexture: Nullable<BaseTexture>;
  54184. /**
  54185. * Specifies the metallic scalar of the metallic/roughness workflow.
  54186. * Can also be used to scale the metalness values of the metallic texture.
  54187. */
  54188. protected _metallic: Nullable<number>;
  54189. /**
  54190. * Specifies the roughness scalar of the metallic/roughness workflow.
  54191. * Can also be used to scale the roughness values of the metallic texture.
  54192. */
  54193. protected _roughness: Nullable<number>;
  54194. /**
  54195. * Specifies the an F0 factor to help configuring the material F0.
  54196. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54197. * to 0.5 the previously hard coded value stays the same.
  54198. * Can also be used to scale the F0 values of the metallic texture.
  54199. */
  54200. protected _metallicF0Factor: number;
  54201. /**
  54202. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54203. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54204. * your expectation as it multiplies with the texture data.
  54205. */
  54206. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54207. /**
  54208. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54209. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54210. */
  54211. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54212. /**
  54213. * Stores surface normal data used to displace a mesh in a texture.
  54214. */
  54215. protected _bumpTexture: Nullable<BaseTexture>;
  54216. /**
  54217. * Stores the pre-calculated light information of a mesh in a texture.
  54218. */
  54219. protected _lightmapTexture: Nullable<BaseTexture>;
  54220. /**
  54221. * The color of a material in ambient lighting.
  54222. */
  54223. protected _ambientColor: Color3;
  54224. /**
  54225. * AKA Diffuse Color in other nomenclature.
  54226. */
  54227. protected _albedoColor: Color3;
  54228. /**
  54229. * AKA Specular Color in other nomenclature.
  54230. */
  54231. protected _reflectivityColor: Color3;
  54232. /**
  54233. * The color applied when light is reflected from a material.
  54234. */
  54235. protected _reflectionColor: Color3;
  54236. /**
  54237. * The color applied when light is emitted from a material.
  54238. */
  54239. protected _emissiveColor: Color3;
  54240. /**
  54241. * AKA Glossiness in other nomenclature.
  54242. */
  54243. protected _microSurface: number;
  54244. /**
  54245. * Specifies that the material will use the light map as a show map.
  54246. */
  54247. protected _useLightmapAsShadowmap: boolean;
  54248. /**
  54249. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54250. * makes the reflect vector face the model (under horizon).
  54251. */
  54252. protected _useHorizonOcclusion: boolean;
  54253. /**
  54254. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54255. * too much the area relying on ambient texture to define their ambient occlusion.
  54256. */
  54257. protected _useRadianceOcclusion: boolean;
  54258. /**
  54259. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54260. */
  54261. protected _useAlphaFromAlbedoTexture: boolean;
  54262. /**
  54263. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54264. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54265. */
  54266. protected _useSpecularOverAlpha: boolean;
  54267. /**
  54268. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54269. */
  54270. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54271. /**
  54272. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54273. */
  54274. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54275. /**
  54276. * Specifies if the metallic texture contains the roughness information in its green channel.
  54277. */
  54278. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54279. /**
  54280. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54281. */
  54282. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54283. /**
  54284. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54285. */
  54286. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54287. /**
  54288. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54289. */
  54290. protected _useAmbientInGrayScale: boolean;
  54291. /**
  54292. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54293. * The material will try to infer what glossiness each pixel should be.
  54294. */
  54295. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54296. /**
  54297. * Defines the falloff type used in this material.
  54298. * It by default is Physical.
  54299. */
  54300. protected _lightFalloff: number;
  54301. /**
  54302. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54303. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54304. */
  54305. protected _useRadianceOverAlpha: boolean;
  54306. /**
  54307. * Allows using an object space normal map (instead of tangent space).
  54308. */
  54309. protected _useObjectSpaceNormalMap: boolean;
  54310. /**
  54311. * Allows using the bump map in parallax mode.
  54312. */
  54313. protected _useParallax: boolean;
  54314. /**
  54315. * Allows using the bump map in parallax occlusion mode.
  54316. */
  54317. protected _useParallaxOcclusion: boolean;
  54318. /**
  54319. * Controls the scale bias of the parallax mode.
  54320. */
  54321. protected _parallaxScaleBias: number;
  54322. /**
  54323. * If sets to true, disables all the lights affecting the material.
  54324. */
  54325. protected _disableLighting: boolean;
  54326. /**
  54327. * Number of Simultaneous lights allowed on the material.
  54328. */
  54329. protected _maxSimultaneousLights: number;
  54330. /**
  54331. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54332. */
  54333. protected _invertNormalMapX: boolean;
  54334. /**
  54335. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54336. */
  54337. protected _invertNormalMapY: boolean;
  54338. /**
  54339. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54340. */
  54341. protected _twoSidedLighting: boolean;
  54342. /**
  54343. * Defines the alpha limits in alpha test mode.
  54344. */
  54345. protected _alphaCutOff: number;
  54346. /**
  54347. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54348. */
  54349. protected _forceAlphaTest: boolean;
  54350. /**
  54351. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54352. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54353. */
  54354. protected _useAlphaFresnel: boolean;
  54355. /**
  54356. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54357. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54358. */
  54359. protected _useLinearAlphaFresnel: boolean;
  54360. /**
  54361. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54362. * from cos thetav and roughness:
  54363. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54364. */
  54365. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54366. /**
  54367. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54368. */
  54369. protected _forceIrradianceInFragment: boolean;
  54370. /**
  54371. * Force normal to face away from face.
  54372. */
  54373. protected _forceNormalForward: boolean;
  54374. /**
  54375. * Enables specular anti aliasing in the PBR shader.
  54376. * It will both interacts on the Geometry for analytical and IBL lighting.
  54377. * It also prefilter the roughness map based on the bump values.
  54378. */
  54379. protected _enableSpecularAntiAliasing: boolean;
  54380. /**
  54381. * Default configuration related to image processing available in the PBR Material.
  54382. */
  54383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54384. /**
  54385. * Keep track of the image processing observer to allow dispose and replace.
  54386. */
  54387. private _imageProcessingObserver;
  54388. /**
  54389. * Attaches a new image processing configuration to the PBR Material.
  54390. * @param configuration
  54391. */
  54392. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54393. /**
  54394. * Stores the available render targets.
  54395. */
  54396. private _renderTargets;
  54397. /**
  54398. * Sets the global ambient color for the material used in lighting calculations.
  54399. */
  54400. private _globalAmbientColor;
  54401. /**
  54402. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54403. */
  54404. private _useLogarithmicDepth;
  54405. /**
  54406. * If set to true, no lighting calculations will be applied.
  54407. */
  54408. private _unlit;
  54409. private _debugMode;
  54410. /**
  54411. * @hidden
  54412. * This is reserved for the inspector.
  54413. * Defines the material debug mode.
  54414. * It helps seeing only some components of the material while troubleshooting.
  54415. */
  54416. debugMode: number;
  54417. /**
  54418. * @hidden
  54419. * This is reserved for the inspector.
  54420. * Specify from where on screen the debug mode should start.
  54421. * The value goes from -1 (full screen) to 1 (not visible)
  54422. * It helps with side by side comparison against the final render
  54423. * This defaults to -1
  54424. */
  54425. private debugLimit;
  54426. /**
  54427. * @hidden
  54428. * This is reserved for the inspector.
  54429. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54430. * You can use the factor to better multiply the final value.
  54431. */
  54432. private debugFactor;
  54433. /**
  54434. * Defines the clear coat layer parameters for the material.
  54435. */
  54436. readonly clearCoat: PBRClearCoatConfiguration;
  54437. /**
  54438. * Defines the anisotropic parameters for the material.
  54439. */
  54440. readonly anisotropy: PBRAnisotropicConfiguration;
  54441. /**
  54442. * Defines the BRDF parameters for the material.
  54443. */
  54444. readonly brdf: PBRBRDFConfiguration;
  54445. /**
  54446. * Defines the Sheen parameters for the material.
  54447. */
  54448. readonly sheen: PBRSheenConfiguration;
  54449. /**
  54450. * Defines the SubSurface parameters for the material.
  54451. */
  54452. readonly subSurface: PBRSubSurfaceConfiguration;
  54453. protected _rebuildInParallel: boolean;
  54454. /**
  54455. * Instantiates a new PBRMaterial instance.
  54456. *
  54457. * @param name The material name
  54458. * @param scene The scene the material will be use in.
  54459. */
  54460. constructor(name: string, scene: Scene);
  54461. /**
  54462. * Gets a boolean indicating that current material needs to register RTT
  54463. */
  54464. get hasRenderTargetTextures(): boolean;
  54465. /**
  54466. * Gets the name of the material class.
  54467. */
  54468. getClassName(): string;
  54469. /**
  54470. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54471. */
  54472. get useLogarithmicDepth(): boolean;
  54473. /**
  54474. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54475. */
  54476. set useLogarithmicDepth(value: boolean);
  54477. /**
  54478. * Returns true if alpha blending should be disabled.
  54479. */
  54480. protected get _disableAlphaBlending(): boolean;
  54481. /**
  54482. * Specifies whether or not this material should be rendered in alpha blend mode.
  54483. */
  54484. needAlphaBlending(): boolean;
  54485. /**
  54486. * Specifies whether or not this material should be rendered in alpha test mode.
  54487. */
  54488. needAlphaTesting(): boolean;
  54489. /**
  54490. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54491. */
  54492. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54493. /**
  54494. * Gets the texture used for the alpha test.
  54495. */
  54496. getAlphaTestTexture(): Nullable<BaseTexture>;
  54497. /**
  54498. * Specifies that the submesh is ready to be used.
  54499. * @param mesh - BJS mesh.
  54500. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54501. * @param useInstances - Specifies that instances should be used.
  54502. * @returns - boolean indicating that the submesh is ready or not.
  54503. */
  54504. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54505. /**
  54506. * Specifies if the material uses metallic roughness workflow.
  54507. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54508. */
  54509. isMetallicWorkflow(): boolean;
  54510. private _prepareEffect;
  54511. private _prepareDefines;
  54512. /**
  54513. * Force shader compilation
  54514. */
  54515. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54516. /**
  54517. * Initializes the uniform buffer layout for the shader.
  54518. */
  54519. buildUniformLayout(): void;
  54520. /**
  54521. * Unbinds the material from the mesh
  54522. */
  54523. unbind(): void;
  54524. /**
  54525. * Binds the submesh data.
  54526. * @param world - The world matrix.
  54527. * @param mesh - The BJS mesh.
  54528. * @param subMesh - A submesh of the BJS mesh.
  54529. */
  54530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54531. /**
  54532. * Returns the animatable textures.
  54533. * @returns - Array of animatable textures.
  54534. */
  54535. getAnimatables(): IAnimatable[];
  54536. /**
  54537. * Returns the texture used for reflections.
  54538. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54539. */
  54540. private _getReflectionTexture;
  54541. /**
  54542. * Returns an array of the actively used textures.
  54543. * @returns - Array of BaseTextures
  54544. */
  54545. getActiveTextures(): BaseTexture[];
  54546. /**
  54547. * Checks to see if a texture is used in the material.
  54548. * @param texture - Base texture to use.
  54549. * @returns - Boolean specifying if a texture is used in the material.
  54550. */
  54551. hasTexture(texture: BaseTexture): boolean;
  54552. /**
  54553. * Disposes the resources of the material.
  54554. * @param forceDisposeEffect - Forces the disposal of effects.
  54555. * @param forceDisposeTextures - Forces the disposal of all textures.
  54556. */
  54557. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54558. }
  54559. }
  54560. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54561. import { Nullable } from "babylonjs/types";
  54562. import { Scene } from "babylonjs/scene";
  54563. import { Color3 } from "babylonjs/Maths/math.color";
  54564. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54565. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54567. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54568. /**
  54569. * The Physically based material of BJS.
  54570. *
  54571. * This offers the main features of a standard PBR material.
  54572. * For more information, please refer to the documentation :
  54573. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54574. */
  54575. export class PBRMaterial extends PBRBaseMaterial {
  54576. /**
  54577. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54578. */
  54579. static readonly PBRMATERIAL_OPAQUE: number;
  54580. /**
  54581. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54582. */
  54583. static readonly PBRMATERIAL_ALPHATEST: number;
  54584. /**
  54585. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54586. */
  54587. static readonly PBRMATERIAL_ALPHABLEND: number;
  54588. /**
  54589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54590. * They are also discarded below the alpha cutoff threshold to improve performances.
  54591. */
  54592. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54593. /**
  54594. * Defines the default value of how much AO map is occluding the analytical lights
  54595. * (point spot...).
  54596. */
  54597. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54598. /**
  54599. * Intensity of the direct lights e.g. the four lights available in your scene.
  54600. * This impacts both the direct diffuse and specular highlights.
  54601. */
  54602. directIntensity: number;
  54603. /**
  54604. * Intensity of the emissive part of the material.
  54605. * This helps controlling the emissive effect without modifying the emissive color.
  54606. */
  54607. emissiveIntensity: number;
  54608. /**
  54609. * Intensity of the environment e.g. how much the environment will light the object
  54610. * either through harmonics for rough material or through the refelction for shiny ones.
  54611. */
  54612. environmentIntensity: number;
  54613. /**
  54614. * This is a special control allowing the reduction of the specular highlights coming from the
  54615. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54616. */
  54617. specularIntensity: number;
  54618. /**
  54619. * Debug Control allowing disabling the bump map on this material.
  54620. */
  54621. disableBumpMap: boolean;
  54622. /**
  54623. * AKA Diffuse Texture in standard nomenclature.
  54624. */
  54625. albedoTexture: BaseTexture;
  54626. /**
  54627. * AKA Occlusion Texture in other nomenclature.
  54628. */
  54629. ambientTexture: BaseTexture;
  54630. /**
  54631. * AKA Occlusion Texture Intensity in other nomenclature.
  54632. */
  54633. ambientTextureStrength: number;
  54634. /**
  54635. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54636. * 1 means it completely occludes it
  54637. * 0 mean it has no impact
  54638. */
  54639. ambientTextureImpactOnAnalyticalLights: number;
  54640. /**
  54641. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54642. */
  54643. opacityTexture: BaseTexture;
  54644. /**
  54645. * Stores the reflection values in a texture.
  54646. */
  54647. reflectionTexture: Nullable<BaseTexture>;
  54648. /**
  54649. * Stores the emissive values in a texture.
  54650. */
  54651. emissiveTexture: BaseTexture;
  54652. /**
  54653. * AKA Specular texture in other nomenclature.
  54654. */
  54655. reflectivityTexture: BaseTexture;
  54656. /**
  54657. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54658. */
  54659. metallicTexture: BaseTexture;
  54660. /**
  54661. * Specifies the metallic scalar of the metallic/roughness workflow.
  54662. * Can also be used to scale the metalness values of the metallic texture.
  54663. */
  54664. metallic: Nullable<number>;
  54665. /**
  54666. * Specifies the roughness scalar of the metallic/roughness workflow.
  54667. * Can also be used to scale the roughness values of the metallic texture.
  54668. */
  54669. roughness: Nullable<number>;
  54670. /**
  54671. * Specifies the an F0 factor to help configuring the material F0.
  54672. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54673. * to 0.5 the previously hard coded value stays the same.
  54674. * Can also be used to scale the F0 values of the metallic texture.
  54675. */
  54676. metallicF0Factor: number;
  54677. /**
  54678. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54679. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54680. * your expectation as it multiplies with the texture data.
  54681. */
  54682. useMetallicF0FactorFromMetallicTexture: boolean;
  54683. /**
  54684. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54685. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54686. */
  54687. microSurfaceTexture: BaseTexture;
  54688. /**
  54689. * Stores surface normal data used to displace a mesh in a texture.
  54690. */
  54691. bumpTexture: BaseTexture;
  54692. /**
  54693. * Stores the pre-calculated light information of a mesh in a texture.
  54694. */
  54695. lightmapTexture: BaseTexture;
  54696. /**
  54697. * Stores the refracted light information in a texture.
  54698. */
  54699. get refractionTexture(): Nullable<BaseTexture>;
  54700. set refractionTexture(value: Nullable<BaseTexture>);
  54701. /**
  54702. * The color of a material in ambient lighting.
  54703. */
  54704. ambientColor: Color3;
  54705. /**
  54706. * AKA Diffuse Color in other nomenclature.
  54707. */
  54708. albedoColor: Color3;
  54709. /**
  54710. * AKA Specular Color in other nomenclature.
  54711. */
  54712. reflectivityColor: Color3;
  54713. /**
  54714. * The color reflected from the material.
  54715. */
  54716. reflectionColor: Color3;
  54717. /**
  54718. * The color emitted from the material.
  54719. */
  54720. emissiveColor: Color3;
  54721. /**
  54722. * AKA Glossiness in other nomenclature.
  54723. */
  54724. microSurface: number;
  54725. /**
  54726. * source material index of refraction (IOR)' / 'destination material IOR.
  54727. */
  54728. get indexOfRefraction(): number;
  54729. set indexOfRefraction(value: number);
  54730. /**
  54731. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54732. */
  54733. get invertRefractionY(): boolean;
  54734. set invertRefractionY(value: boolean);
  54735. /**
  54736. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54737. * Materials half opaque for instance using refraction could benefit from this control.
  54738. */
  54739. get linkRefractionWithTransparency(): boolean;
  54740. set linkRefractionWithTransparency(value: boolean);
  54741. /**
  54742. * If true, the light map contains occlusion information instead of lighting info.
  54743. */
  54744. useLightmapAsShadowmap: boolean;
  54745. /**
  54746. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54747. */
  54748. useAlphaFromAlbedoTexture: boolean;
  54749. /**
  54750. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54751. */
  54752. forceAlphaTest: boolean;
  54753. /**
  54754. * Defines the alpha limits in alpha test mode.
  54755. */
  54756. alphaCutOff: number;
  54757. /**
  54758. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54760. */
  54761. useSpecularOverAlpha: boolean;
  54762. /**
  54763. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54764. */
  54765. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54766. /**
  54767. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54768. */
  54769. useRoughnessFromMetallicTextureAlpha: boolean;
  54770. /**
  54771. * Specifies if the metallic texture contains the roughness information in its green channel.
  54772. */
  54773. useRoughnessFromMetallicTextureGreen: boolean;
  54774. /**
  54775. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54776. */
  54777. useMetallnessFromMetallicTextureBlue: boolean;
  54778. /**
  54779. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54780. */
  54781. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54782. /**
  54783. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54784. */
  54785. useAmbientInGrayScale: boolean;
  54786. /**
  54787. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54788. * The material will try to infer what glossiness each pixel should be.
  54789. */
  54790. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54791. /**
  54792. * BJS is using an harcoded light falloff based on a manually sets up range.
  54793. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54794. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54795. */
  54796. get usePhysicalLightFalloff(): boolean;
  54797. /**
  54798. * BJS is using an harcoded light falloff based on a manually sets up range.
  54799. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54800. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54801. */
  54802. set usePhysicalLightFalloff(value: boolean);
  54803. /**
  54804. * In order to support the falloff compatibility with gltf, a special mode has been added
  54805. * to reproduce the gltf light falloff.
  54806. */
  54807. get useGLTFLightFalloff(): boolean;
  54808. /**
  54809. * In order to support the falloff compatibility with gltf, a special mode has been added
  54810. * to reproduce the gltf light falloff.
  54811. */
  54812. set useGLTFLightFalloff(value: boolean);
  54813. /**
  54814. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54815. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54816. */
  54817. useRadianceOverAlpha: boolean;
  54818. /**
  54819. * Allows using an object space normal map (instead of tangent space).
  54820. */
  54821. useObjectSpaceNormalMap: boolean;
  54822. /**
  54823. * Allows using the bump map in parallax mode.
  54824. */
  54825. useParallax: boolean;
  54826. /**
  54827. * Allows using the bump map in parallax occlusion mode.
  54828. */
  54829. useParallaxOcclusion: boolean;
  54830. /**
  54831. * Controls the scale bias of the parallax mode.
  54832. */
  54833. parallaxScaleBias: number;
  54834. /**
  54835. * If sets to true, disables all the lights affecting the material.
  54836. */
  54837. disableLighting: boolean;
  54838. /**
  54839. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54840. */
  54841. forceIrradianceInFragment: boolean;
  54842. /**
  54843. * Number of Simultaneous lights allowed on the material.
  54844. */
  54845. maxSimultaneousLights: number;
  54846. /**
  54847. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54848. */
  54849. invertNormalMapX: boolean;
  54850. /**
  54851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54852. */
  54853. invertNormalMapY: boolean;
  54854. /**
  54855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54856. */
  54857. twoSidedLighting: boolean;
  54858. /**
  54859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54860. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54861. */
  54862. useAlphaFresnel: boolean;
  54863. /**
  54864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54865. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54866. */
  54867. useLinearAlphaFresnel: boolean;
  54868. /**
  54869. * Let user defines the brdf lookup texture used for IBL.
  54870. * A default 8bit version is embedded but you could point at :
  54871. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54872. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54873. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54874. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54875. */
  54876. environmentBRDFTexture: Nullable<BaseTexture>;
  54877. /**
  54878. * Force normal to face away from face.
  54879. */
  54880. forceNormalForward: boolean;
  54881. /**
  54882. * Enables specular anti aliasing in the PBR shader.
  54883. * It will both interacts on the Geometry for analytical and IBL lighting.
  54884. * It also prefilter the roughness map based on the bump values.
  54885. */
  54886. enableSpecularAntiAliasing: boolean;
  54887. /**
  54888. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54889. * makes the reflect vector face the model (under horizon).
  54890. */
  54891. useHorizonOcclusion: boolean;
  54892. /**
  54893. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54894. * too much the area relying on ambient texture to define their ambient occlusion.
  54895. */
  54896. useRadianceOcclusion: boolean;
  54897. /**
  54898. * If set to true, no lighting calculations will be applied.
  54899. */
  54900. unlit: boolean;
  54901. /**
  54902. * Gets the image processing configuration used either in this material.
  54903. */
  54904. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54905. /**
  54906. * Sets the Default image processing configuration used either in the this material.
  54907. *
  54908. * If sets to null, the scene one is in use.
  54909. */
  54910. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54911. /**
  54912. * Gets wether the color curves effect is enabled.
  54913. */
  54914. get cameraColorCurvesEnabled(): boolean;
  54915. /**
  54916. * Sets wether the color curves effect is enabled.
  54917. */
  54918. set cameraColorCurvesEnabled(value: boolean);
  54919. /**
  54920. * Gets wether the color grading effect is enabled.
  54921. */
  54922. get cameraColorGradingEnabled(): boolean;
  54923. /**
  54924. * Gets wether the color grading effect is enabled.
  54925. */
  54926. set cameraColorGradingEnabled(value: boolean);
  54927. /**
  54928. * Gets wether tonemapping is enabled or not.
  54929. */
  54930. get cameraToneMappingEnabled(): boolean;
  54931. /**
  54932. * Sets wether tonemapping is enabled or not
  54933. */
  54934. set cameraToneMappingEnabled(value: boolean);
  54935. /**
  54936. * The camera exposure used on this material.
  54937. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54938. * This corresponds to a photographic exposure.
  54939. */
  54940. get cameraExposure(): number;
  54941. /**
  54942. * The camera exposure used on this material.
  54943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54944. * This corresponds to a photographic exposure.
  54945. */
  54946. set cameraExposure(value: number);
  54947. /**
  54948. * Gets The camera contrast used on this material.
  54949. */
  54950. get cameraContrast(): number;
  54951. /**
  54952. * Sets The camera contrast used on this material.
  54953. */
  54954. set cameraContrast(value: number);
  54955. /**
  54956. * Gets the Color Grading 2D Lookup Texture.
  54957. */
  54958. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54959. /**
  54960. * Sets the Color Grading 2D Lookup Texture.
  54961. */
  54962. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54963. /**
  54964. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54965. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54966. * 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;
  54967. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54968. */
  54969. get cameraColorCurves(): Nullable<ColorCurves>;
  54970. /**
  54971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54973. * 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;
  54974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54975. */
  54976. set cameraColorCurves(value: Nullable<ColorCurves>);
  54977. /**
  54978. * Instantiates a new PBRMaterial instance.
  54979. *
  54980. * @param name The material name
  54981. * @param scene The scene the material will be use in.
  54982. */
  54983. constructor(name: string, scene: Scene);
  54984. /**
  54985. * Returns the name of this material class.
  54986. */
  54987. getClassName(): string;
  54988. /**
  54989. * Makes a duplicate of the current material.
  54990. * @param name - name to use for the new material.
  54991. */
  54992. clone(name: string): PBRMaterial;
  54993. /**
  54994. * Serializes this PBR Material.
  54995. * @returns - An object with the serialized material.
  54996. */
  54997. serialize(): any;
  54998. /**
  54999. * Parses a PBR Material from a serialized object.
  55000. * @param source - Serialized object.
  55001. * @param scene - BJS scene instance.
  55002. * @param rootUrl - url for the scene object
  55003. * @returns - PBRMaterial
  55004. */
  55005. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55006. }
  55007. }
  55008. declare module "babylonjs/Misc/dds" {
  55009. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55011. import { Nullable } from "babylonjs/types";
  55012. import { Scene } from "babylonjs/scene";
  55013. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55014. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55015. /**
  55016. * Direct draw surface info
  55017. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55018. */
  55019. export interface DDSInfo {
  55020. /**
  55021. * Width of the texture
  55022. */
  55023. width: number;
  55024. /**
  55025. * Width of the texture
  55026. */
  55027. height: number;
  55028. /**
  55029. * Number of Mipmaps for the texture
  55030. * @see https://en.wikipedia.org/wiki/Mipmap
  55031. */
  55032. mipmapCount: number;
  55033. /**
  55034. * If the textures format is a known fourCC format
  55035. * @see https://www.fourcc.org/
  55036. */
  55037. isFourCC: boolean;
  55038. /**
  55039. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55040. */
  55041. isRGB: boolean;
  55042. /**
  55043. * If the texture is a lumincance format
  55044. */
  55045. isLuminance: boolean;
  55046. /**
  55047. * If this is a cube texture
  55048. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55049. */
  55050. isCube: boolean;
  55051. /**
  55052. * If the texture is a compressed format eg. FOURCC_DXT1
  55053. */
  55054. isCompressed: boolean;
  55055. /**
  55056. * The dxgiFormat of the texture
  55057. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55058. */
  55059. dxgiFormat: number;
  55060. /**
  55061. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55062. */
  55063. textureType: number;
  55064. /**
  55065. * Sphericle polynomial created for the dds texture
  55066. */
  55067. sphericalPolynomial?: SphericalPolynomial;
  55068. }
  55069. /**
  55070. * Class used to provide DDS decompression tools
  55071. */
  55072. export class DDSTools {
  55073. /**
  55074. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55075. */
  55076. static StoreLODInAlphaChannel: boolean;
  55077. /**
  55078. * Gets DDS information from an array buffer
  55079. * @param data defines the array buffer view to read data from
  55080. * @returns the DDS information
  55081. */
  55082. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55083. private static _FloatView;
  55084. private static _Int32View;
  55085. private static _ToHalfFloat;
  55086. private static _FromHalfFloat;
  55087. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55088. private static _GetHalfFloatRGBAArrayBuffer;
  55089. private static _GetFloatRGBAArrayBuffer;
  55090. private static _GetFloatAsUIntRGBAArrayBuffer;
  55091. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55092. private static _GetRGBAArrayBuffer;
  55093. private static _ExtractLongWordOrder;
  55094. private static _GetRGBArrayBuffer;
  55095. private static _GetLuminanceArrayBuffer;
  55096. /**
  55097. * Uploads DDS Levels to a Babylon Texture
  55098. * @hidden
  55099. */
  55100. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55101. }
  55102. module "babylonjs/Engines/thinEngine" {
  55103. interface ThinEngine {
  55104. /**
  55105. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55106. * @param rootUrl defines the url where the file to load is located
  55107. * @param scene defines the current scene
  55108. * @param lodScale defines scale to apply to the mip map selection
  55109. * @param lodOffset defines offset to apply to the mip map selection
  55110. * @param onLoad defines an optional callback raised when the texture is loaded
  55111. * @param onError defines an optional callback raised if there is an issue to load the texture
  55112. * @param format defines the format of the data
  55113. * @param forcedExtension defines the extension to use to pick the right loader
  55114. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55115. * @returns the cube texture as an InternalTexture
  55116. */
  55117. 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;
  55118. }
  55119. }
  55120. }
  55121. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55122. import { Nullable } from "babylonjs/types";
  55123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55124. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55125. /**
  55126. * Implementation of the DDS Texture Loader.
  55127. * @hidden
  55128. */
  55129. export class _DDSTextureLoader implements IInternalTextureLoader {
  55130. /**
  55131. * Defines wether the loader supports cascade loading the different faces.
  55132. */
  55133. readonly supportCascades: boolean;
  55134. /**
  55135. * This returns if the loader support the current file information.
  55136. * @param extension defines the file extension of the file being loaded
  55137. * @returns true if the loader can load the specified file
  55138. */
  55139. canLoad(extension: string): boolean;
  55140. /**
  55141. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55142. * @param data contains the texture data
  55143. * @param texture defines the BabylonJS internal texture
  55144. * @param createPolynomials will be true if polynomials have been requested
  55145. * @param onLoad defines the callback to trigger once the texture is ready
  55146. * @param onError defines the callback to trigger in case of error
  55147. */
  55148. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55149. /**
  55150. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55151. * @param data contains the texture data
  55152. * @param texture defines the BabylonJS internal texture
  55153. * @param callback defines the method to call once ready to upload
  55154. */
  55155. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55156. }
  55157. }
  55158. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55159. import { Nullable } from "babylonjs/types";
  55160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55161. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55162. /**
  55163. * Implementation of the ENV Texture Loader.
  55164. * @hidden
  55165. */
  55166. export class _ENVTextureLoader implements IInternalTextureLoader {
  55167. /**
  55168. * Defines wether the loader supports cascade loading the different faces.
  55169. */
  55170. readonly supportCascades: boolean;
  55171. /**
  55172. * This returns if the loader support the current file information.
  55173. * @param extension defines the file extension of the file being loaded
  55174. * @returns true if the loader can load the specified file
  55175. */
  55176. canLoad(extension: string): boolean;
  55177. /**
  55178. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55179. * @param data contains the texture data
  55180. * @param texture defines the BabylonJS internal texture
  55181. * @param createPolynomials will be true if polynomials have been requested
  55182. * @param onLoad defines the callback to trigger once the texture is ready
  55183. * @param onError defines the callback to trigger in case of error
  55184. */
  55185. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55186. /**
  55187. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55188. * @param data contains the texture data
  55189. * @param texture defines the BabylonJS internal texture
  55190. * @param callback defines the method to call once ready to upload
  55191. */
  55192. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55193. }
  55194. }
  55195. declare module "babylonjs/Misc/khronosTextureContainer" {
  55196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55197. /**
  55198. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55199. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55200. */
  55201. export class KhronosTextureContainer {
  55202. /** contents of the KTX container file */
  55203. data: ArrayBufferView;
  55204. private static HEADER_LEN;
  55205. private static COMPRESSED_2D;
  55206. private static COMPRESSED_3D;
  55207. private static TEX_2D;
  55208. private static TEX_3D;
  55209. /**
  55210. * Gets the openGL type
  55211. */
  55212. glType: number;
  55213. /**
  55214. * Gets the openGL type size
  55215. */
  55216. glTypeSize: number;
  55217. /**
  55218. * Gets the openGL format
  55219. */
  55220. glFormat: number;
  55221. /**
  55222. * Gets the openGL internal format
  55223. */
  55224. glInternalFormat: number;
  55225. /**
  55226. * Gets the base internal format
  55227. */
  55228. glBaseInternalFormat: number;
  55229. /**
  55230. * Gets image width in pixel
  55231. */
  55232. pixelWidth: number;
  55233. /**
  55234. * Gets image height in pixel
  55235. */
  55236. pixelHeight: number;
  55237. /**
  55238. * Gets image depth in pixels
  55239. */
  55240. pixelDepth: number;
  55241. /**
  55242. * Gets the number of array elements
  55243. */
  55244. numberOfArrayElements: number;
  55245. /**
  55246. * Gets the number of faces
  55247. */
  55248. numberOfFaces: number;
  55249. /**
  55250. * Gets the number of mipmap levels
  55251. */
  55252. numberOfMipmapLevels: number;
  55253. /**
  55254. * Gets the bytes of key value data
  55255. */
  55256. bytesOfKeyValueData: number;
  55257. /**
  55258. * Gets the load type
  55259. */
  55260. loadType: number;
  55261. /**
  55262. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55263. */
  55264. isInvalid: boolean;
  55265. /**
  55266. * Creates a new KhronosTextureContainer
  55267. * @param data contents of the KTX container file
  55268. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55269. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55270. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55271. */
  55272. constructor(
  55273. /** contents of the KTX container file */
  55274. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55275. /**
  55276. * Uploads KTX content to a Babylon Texture.
  55277. * It is assumed that the texture has already been created & is currently bound
  55278. * @hidden
  55279. */
  55280. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55281. private _upload2DCompressedLevels;
  55282. /**
  55283. * Checks if the given data starts with a KTX file identifier.
  55284. * @param data the data to check
  55285. * @returns true if the data is a KTX file or false otherwise
  55286. */
  55287. static IsValid(data: ArrayBufferView): boolean;
  55288. }
  55289. }
  55290. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55291. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55292. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55293. /**
  55294. * Class for loading KTX2 files
  55295. * !!! Experimental Extension Subject to Changes !!!
  55296. * @hidden
  55297. */
  55298. export class KhronosTextureContainer2 {
  55299. private static _ModulePromise;
  55300. private static _TranscodeFormat;
  55301. constructor(engine: ThinEngine);
  55302. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55303. private _determineTranscodeFormat;
  55304. /**
  55305. * Checks if the given data starts with a KTX2 file identifier.
  55306. * @param data the data to check
  55307. * @returns true if the data is a KTX2 file or false otherwise
  55308. */
  55309. static IsValid(data: ArrayBufferView): boolean;
  55310. }
  55311. }
  55312. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55313. import { Nullable } from "babylonjs/types";
  55314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55315. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55316. /**
  55317. * Implementation of the KTX Texture Loader.
  55318. * @hidden
  55319. */
  55320. export class _KTXTextureLoader implements IInternalTextureLoader {
  55321. /**
  55322. * Defines wether the loader supports cascade loading the different faces.
  55323. */
  55324. readonly supportCascades: boolean;
  55325. /**
  55326. * This returns if the loader support the current file information.
  55327. * @param extension defines the file extension of the file being loaded
  55328. * @returns true if the loader can load the specified file
  55329. */
  55330. canLoad(extension: string): boolean;
  55331. /**
  55332. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55333. * @param data contains the texture data
  55334. * @param texture defines the BabylonJS internal texture
  55335. * @param createPolynomials will be true if polynomials have been requested
  55336. * @param onLoad defines the callback to trigger once the texture is ready
  55337. * @param onError defines the callback to trigger in case of error
  55338. */
  55339. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55340. /**
  55341. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55342. * @param data contains the texture data
  55343. * @param texture defines the BabylonJS internal texture
  55344. * @param callback defines the method to call once ready to upload
  55345. */
  55346. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55347. }
  55348. }
  55349. declare module "babylonjs/Helpers/sceneHelpers" {
  55350. import { Nullable } from "babylonjs/types";
  55351. import { Mesh } from "babylonjs/Meshes/mesh";
  55352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55353. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55354. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55355. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55356. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55357. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55358. import "babylonjs/Meshes/Builders/boxBuilder";
  55359. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55360. /** @hidden */
  55361. export var _forceSceneHelpersToBundle: boolean;
  55362. module "babylonjs/scene" {
  55363. interface Scene {
  55364. /**
  55365. * Creates a default light for the scene.
  55366. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55367. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55368. */
  55369. createDefaultLight(replace?: boolean): void;
  55370. /**
  55371. * Creates a default camera for the scene.
  55372. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55373. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55374. * @param replace has default false, when true replaces the active camera in the scene
  55375. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55376. */
  55377. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55378. /**
  55379. * Creates a default camera and a default light.
  55380. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55381. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55382. * @param replace has the default false, when true replaces the active camera/light in the scene
  55383. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55384. */
  55385. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55386. /**
  55387. * Creates a new sky box
  55388. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55389. * @param environmentTexture defines the texture to use as environment texture
  55390. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55391. * @param scale defines the overall scale of the skybox
  55392. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55393. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55394. * @returns a new mesh holding the sky box
  55395. */
  55396. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55397. /**
  55398. * Creates a new environment
  55399. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55400. * @param options defines the options you can use to configure the environment
  55401. * @returns the new EnvironmentHelper
  55402. */
  55403. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55404. /**
  55405. * Creates a new VREXperienceHelper
  55406. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55407. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55408. * @returns a new VREXperienceHelper
  55409. */
  55410. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55411. /**
  55412. * Creates a new WebXRDefaultExperience
  55413. * @see http://doc.babylonjs.com/how_to/webxr
  55414. * @param options experience options
  55415. * @returns a promise for a new WebXRDefaultExperience
  55416. */
  55417. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55418. }
  55419. }
  55420. }
  55421. declare module "babylonjs/Helpers/videoDome" {
  55422. import { Scene } from "babylonjs/scene";
  55423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55424. import { Mesh } from "babylonjs/Meshes/mesh";
  55425. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55426. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55427. import "babylonjs/Meshes/Builders/sphereBuilder";
  55428. /**
  55429. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55430. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55431. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55432. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55433. */
  55434. export class VideoDome extends TransformNode {
  55435. /**
  55436. * Define the video source as a Monoscopic panoramic 360 video.
  55437. */
  55438. static readonly MODE_MONOSCOPIC: number;
  55439. /**
  55440. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55441. */
  55442. static readonly MODE_TOPBOTTOM: number;
  55443. /**
  55444. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55445. */
  55446. static readonly MODE_SIDEBYSIDE: number;
  55447. private _halfDome;
  55448. private _useDirectMapping;
  55449. /**
  55450. * The video texture being displayed on the sphere
  55451. */
  55452. protected _videoTexture: VideoTexture;
  55453. /**
  55454. * Gets the video texture being displayed on the sphere
  55455. */
  55456. get videoTexture(): VideoTexture;
  55457. /**
  55458. * The skybox material
  55459. */
  55460. protected _material: BackgroundMaterial;
  55461. /**
  55462. * The surface used for the skybox
  55463. */
  55464. protected _mesh: Mesh;
  55465. /**
  55466. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55467. */
  55468. private _halfDomeMask;
  55469. /**
  55470. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55471. * Also see the options.resolution property.
  55472. */
  55473. get fovMultiplier(): number;
  55474. set fovMultiplier(value: number);
  55475. private _videoMode;
  55476. /**
  55477. * Gets or set the current video mode for the video. It can be:
  55478. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55479. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55480. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55481. */
  55482. get videoMode(): number;
  55483. set videoMode(value: number);
  55484. /**
  55485. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55486. *
  55487. */
  55488. get halfDome(): boolean;
  55489. /**
  55490. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55491. */
  55492. set halfDome(enabled: boolean);
  55493. /**
  55494. * Oberserver used in Stereoscopic VR Mode.
  55495. */
  55496. private _onBeforeCameraRenderObserver;
  55497. /**
  55498. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55499. * @param name Element's name, child elements will append suffixes for their own names.
  55500. * @param urlsOrVideo defines the url(s) or the video element to use
  55501. * @param options An object containing optional or exposed sub element properties
  55502. */
  55503. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55504. resolution?: number;
  55505. clickToPlay?: boolean;
  55506. autoPlay?: boolean;
  55507. loop?: boolean;
  55508. size?: number;
  55509. poster?: string;
  55510. faceForward?: boolean;
  55511. useDirectMapping?: boolean;
  55512. halfDomeMode?: boolean;
  55513. }, scene: Scene);
  55514. private _changeVideoMode;
  55515. /**
  55516. * Releases resources associated with this node.
  55517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55519. */
  55520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55521. }
  55522. }
  55523. declare module "babylonjs/Helpers/index" {
  55524. export * from "babylonjs/Helpers/environmentHelper";
  55525. export * from "babylonjs/Helpers/photoDome";
  55526. export * from "babylonjs/Helpers/sceneHelpers";
  55527. export * from "babylonjs/Helpers/videoDome";
  55528. }
  55529. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55530. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55531. import { IDisposable } from "babylonjs/scene";
  55532. import { Engine } from "babylonjs/Engines/engine";
  55533. /**
  55534. * This class can be used to get instrumentation data from a Babylon engine
  55535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55536. */
  55537. export class EngineInstrumentation implements IDisposable {
  55538. /**
  55539. * Define the instrumented engine.
  55540. */
  55541. engine: Engine;
  55542. private _captureGPUFrameTime;
  55543. private _gpuFrameTimeToken;
  55544. private _gpuFrameTime;
  55545. private _captureShaderCompilationTime;
  55546. private _shaderCompilationTime;
  55547. private _onBeginFrameObserver;
  55548. private _onEndFrameObserver;
  55549. private _onBeforeShaderCompilationObserver;
  55550. private _onAfterShaderCompilationObserver;
  55551. /**
  55552. * Gets the perf counter used for GPU frame time
  55553. */
  55554. get gpuFrameTimeCounter(): PerfCounter;
  55555. /**
  55556. * Gets the GPU frame time capture status
  55557. */
  55558. get captureGPUFrameTime(): boolean;
  55559. /**
  55560. * Enable or disable the GPU frame time capture
  55561. */
  55562. set captureGPUFrameTime(value: boolean);
  55563. /**
  55564. * Gets the perf counter used for shader compilation time
  55565. */
  55566. get shaderCompilationTimeCounter(): PerfCounter;
  55567. /**
  55568. * Gets the shader compilation time capture status
  55569. */
  55570. get captureShaderCompilationTime(): boolean;
  55571. /**
  55572. * Enable or disable the shader compilation time capture
  55573. */
  55574. set captureShaderCompilationTime(value: boolean);
  55575. /**
  55576. * Instantiates a new engine instrumentation.
  55577. * This class can be used to get instrumentation data from a Babylon engine
  55578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55579. * @param engine Defines the engine to instrument
  55580. */
  55581. constructor(
  55582. /**
  55583. * Define the instrumented engine.
  55584. */
  55585. engine: Engine);
  55586. /**
  55587. * Dispose and release associated resources.
  55588. */
  55589. dispose(): void;
  55590. }
  55591. }
  55592. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55593. import { Scene, IDisposable } from "babylonjs/scene";
  55594. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55595. /**
  55596. * This class can be used to get instrumentation data from a Babylon engine
  55597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55598. */
  55599. export class SceneInstrumentation implements IDisposable {
  55600. /**
  55601. * Defines the scene to instrument
  55602. */
  55603. scene: Scene;
  55604. private _captureActiveMeshesEvaluationTime;
  55605. private _activeMeshesEvaluationTime;
  55606. private _captureRenderTargetsRenderTime;
  55607. private _renderTargetsRenderTime;
  55608. private _captureFrameTime;
  55609. private _frameTime;
  55610. private _captureRenderTime;
  55611. private _renderTime;
  55612. private _captureInterFrameTime;
  55613. private _interFrameTime;
  55614. private _captureParticlesRenderTime;
  55615. private _particlesRenderTime;
  55616. private _captureSpritesRenderTime;
  55617. private _spritesRenderTime;
  55618. private _capturePhysicsTime;
  55619. private _physicsTime;
  55620. private _captureAnimationsTime;
  55621. private _animationsTime;
  55622. private _captureCameraRenderTime;
  55623. private _cameraRenderTime;
  55624. private _onBeforeActiveMeshesEvaluationObserver;
  55625. private _onAfterActiveMeshesEvaluationObserver;
  55626. private _onBeforeRenderTargetsRenderObserver;
  55627. private _onAfterRenderTargetsRenderObserver;
  55628. private _onAfterRenderObserver;
  55629. private _onBeforeDrawPhaseObserver;
  55630. private _onAfterDrawPhaseObserver;
  55631. private _onBeforeAnimationsObserver;
  55632. private _onBeforeParticlesRenderingObserver;
  55633. private _onAfterParticlesRenderingObserver;
  55634. private _onBeforeSpritesRenderingObserver;
  55635. private _onAfterSpritesRenderingObserver;
  55636. private _onBeforePhysicsObserver;
  55637. private _onAfterPhysicsObserver;
  55638. private _onAfterAnimationsObserver;
  55639. private _onBeforeCameraRenderObserver;
  55640. private _onAfterCameraRenderObserver;
  55641. /**
  55642. * Gets the perf counter used for active meshes evaluation time
  55643. */
  55644. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55645. /**
  55646. * Gets the active meshes evaluation time capture status
  55647. */
  55648. get captureActiveMeshesEvaluationTime(): boolean;
  55649. /**
  55650. * Enable or disable the active meshes evaluation time capture
  55651. */
  55652. set captureActiveMeshesEvaluationTime(value: boolean);
  55653. /**
  55654. * Gets the perf counter used for render targets render time
  55655. */
  55656. get renderTargetsRenderTimeCounter(): PerfCounter;
  55657. /**
  55658. * Gets the render targets render time capture status
  55659. */
  55660. get captureRenderTargetsRenderTime(): boolean;
  55661. /**
  55662. * Enable or disable the render targets render time capture
  55663. */
  55664. set captureRenderTargetsRenderTime(value: boolean);
  55665. /**
  55666. * Gets the perf counter used for particles render time
  55667. */
  55668. get particlesRenderTimeCounter(): PerfCounter;
  55669. /**
  55670. * Gets the particles render time capture status
  55671. */
  55672. get captureParticlesRenderTime(): boolean;
  55673. /**
  55674. * Enable or disable the particles render time capture
  55675. */
  55676. set captureParticlesRenderTime(value: boolean);
  55677. /**
  55678. * Gets the perf counter used for sprites render time
  55679. */
  55680. get spritesRenderTimeCounter(): PerfCounter;
  55681. /**
  55682. * Gets the sprites render time capture status
  55683. */
  55684. get captureSpritesRenderTime(): boolean;
  55685. /**
  55686. * Enable or disable the sprites render time capture
  55687. */
  55688. set captureSpritesRenderTime(value: boolean);
  55689. /**
  55690. * Gets the perf counter used for physics time
  55691. */
  55692. get physicsTimeCounter(): PerfCounter;
  55693. /**
  55694. * Gets the physics time capture status
  55695. */
  55696. get capturePhysicsTime(): boolean;
  55697. /**
  55698. * Enable or disable the physics time capture
  55699. */
  55700. set capturePhysicsTime(value: boolean);
  55701. /**
  55702. * Gets the perf counter used for animations time
  55703. */
  55704. get animationsTimeCounter(): PerfCounter;
  55705. /**
  55706. * Gets the animations time capture status
  55707. */
  55708. get captureAnimationsTime(): boolean;
  55709. /**
  55710. * Enable or disable the animations time capture
  55711. */
  55712. set captureAnimationsTime(value: boolean);
  55713. /**
  55714. * Gets the perf counter used for frame time capture
  55715. */
  55716. get frameTimeCounter(): PerfCounter;
  55717. /**
  55718. * Gets the frame time capture status
  55719. */
  55720. get captureFrameTime(): boolean;
  55721. /**
  55722. * Enable or disable the frame time capture
  55723. */
  55724. set captureFrameTime(value: boolean);
  55725. /**
  55726. * Gets the perf counter used for inter-frames time capture
  55727. */
  55728. get interFrameTimeCounter(): PerfCounter;
  55729. /**
  55730. * Gets the inter-frames time capture status
  55731. */
  55732. get captureInterFrameTime(): boolean;
  55733. /**
  55734. * Enable or disable the inter-frames time capture
  55735. */
  55736. set captureInterFrameTime(value: boolean);
  55737. /**
  55738. * Gets the perf counter used for render time capture
  55739. */
  55740. get renderTimeCounter(): PerfCounter;
  55741. /**
  55742. * Gets the render time capture status
  55743. */
  55744. get captureRenderTime(): boolean;
  55745. /**
  55746. * Enable or disable the render time capture
  55747. */
  55748. set captureRenderTime(value: boolean);
  55749. /**
  55750. * Gets the perf counter used for camera render time capture
  55751. */
  55752. get cameraRenderTimeCounter(): PerfCounter;
  55753. /**
  55754. * Gets the camera render time capture status
  55755. */
  55756. get captureCameraRenderTime(): boolean;
  55757. /**
  55758. * Enable or disable the camera render time capture
  55759. */
  55760. set captureCameraRenderTime(value: boolean);
  55761. /**
  55762. * Gets the perf counter used for draw calls
  55763. */
  55764. get drawCallsCounter(): PerfCounter;
  55765. /**
  55766. * Instantiates a new scene instrumentation.
  55767. * This class can be used to get instrumentation data from a Babylon engine
  55768. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55769. * @param scene Defines the scene to instrument
  55770. */
  55771. constructor(
  55772. /**
  55773. * Defines the scene to instrument
  55774. */
  55775. scene: Scene);
  55776. /**
  55777. * Dispose and release associated resources.
  55778. */
  55779. dispose(): void;
  55780. }
  55781. }
  55782. declare module "babylonjs/Instrumentation/index" {
  55783. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55784. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55785. export * from "babylonjs/Instrumentation/timeToken";
  55786. }
  55787. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55788. /** @hidden */
  55789. export var glowMapGenerationPixelShader: {
  55790. name: string;
  55791. shader: string;
  55792. };
  55793. }
  55794. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55795. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55796. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55797. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55798. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55799. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55800. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55801. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55802. /** @hidden */
  55803. export var glowMapGenerationVertexShader: {
  55804. name: string;
  55805. shader: string;
  55806. };
  55807. }
  55808. declare module "babylonjs/Layers/effectLayer" {
  55809. import { Observable } from "babylonjs/Misc/observable";
  55810. import { Nullable } from "babylonjs/types";
  55811. import { Camera } from "babylonjs/Cameras/camera";
  55812. import { Scene } from "babylonjs/scene";
  55813. import { ISize } from "babylonjs/Maths/math.size";
  55814. import { Color4 } from "babylonjs/Maths/math.color";
  55815. import { Engine } from "babylonjs/Engines/engine";
  55816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55818. import { Mesh } from "babylonjs/Meshes/mesh";
  55819. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55822. import { Effect } from "babylonjs/Materials/effect";
  55823. import { Material } from "babylonjs/Materials/material";
  55824. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55825. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55826. /**
  55827. * Effect layer options. This helps customizing the behaviour
  55828. * of the effect layer.
  55829. */
  55830. export interface IEffectLayerOptions {
  55831. /**
  55832. * Multiplication factor apply to the canvas size to compute the render target size
  55833. * used to generated the objects (the smaller the faster).
  55834. */
  55835. mainTextureRatio: number;
  55836. /**
  55837. * Enforces a fixed size texture to ensure effect stability across devices.
  55838. */
  55839. mainTextureFixedSize?: number;
  55840. /**
  55841. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55842. */
  55843. alphaBlendingMode: number;
  55844. /**
  55845. * The camera attached to the layer.
  55846. */
  55847. camera: Nullable<Camera>;
  55848. /**
  55849. * The rendering group to draw the layer in.
  55850. */
  55851. renderingGroupId: number;
  55852. }
  55853. /**
  55854. * The effect layer Helps adding post process effect blended with the main pass.
  55855. *
  55856. * This can be for instance use to generate glow or higlight effects on the scene.
  55857. *
  55858. * The effect layer class can not be used directly and is intented to inherited from to be
  55859. * customized per effects.
  55860. */
  55861. export abstract class EffectLayer {
  55862. private _vertexBuffers;
  55863. private _indexBuffer;
  55864. private _cachedDefines;
  55865. private _effectLayerMapGenerationEffect;
  55866. private _effectLayerOptions;
  55867. private _mergeEffect;
  55868. protected _scene: Scene;
  55869. protected _engine: Engine;
  55870. protected _maxSize: number;
  55871. protected _mainTextureDesiredSize: ISize;
  55872. protected _mainTexture: RenderTargetTexture;
  55873. protected _shouldRender: boolean;
  55874. protected _postProcesses: PostProcess[];
  55875. protected _textures: BaseTexture[];
  55876. protected _emissiveTextureAndColor: {
  55877. texture: Nullable<BaseTexture>;
  55878. color: Color4;
  55879. };
  55880. /**
  55881. * The name of the layer
  55882. */
  55883. name: string;
  55884. /**
  55885. * The clear color of the texture used to generate the glow map.
  55886. */
  55887. neutralColor: Color4;
  55888. /**
  55889. * Specifies whether the highlight layer is enabled or not.
  55890. */
  55891. isEnabled: boolean;
  55892. /**
  55893. * Gets the camera attached to the layer.
  55894. */
  55895. get camera(): Nullable<Camera>;
  55896. /**
  55897. * Gets the rendering group id the layer should render in.
  55898. */
  55899. get renderingGroupId(): number;
  55900. set renderingGroupId(renderingGroupId: number);
  55901. /**
  55902. * An event triggered when the effect layer has been disposed.
  55903. */
  55904. onDisposeObservable: Observable<EffectLayer>;
  55905. /**
  55906. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55907. */
  55908. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55909. /**
  55910. * An event triggered when the generated texture is being merged in the scene.
  55911. */
  55912. onBeforeComposeObservable: Observable<EffectLayer>;
  55913. /**
  55914. * An event triggered when the mesh is rendered into the effect render target.
  55915. */
  55916. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55917. /**
  55918. * An event triggered after the mesh has been rendered into the effect render target.
  55919. */
  55920. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55921. /**
  55922. * An event triggered when the generated texture has been merged in the scene.
  55923. */
  55924. onAfterComposeObservable: Observable<EffectLayer>;
  55925. /**
  55926. * An event triggered when the efffect layer changes its size.
  55927. */
  55928. onSizeChangedObservable: Observable<EffectLayer>;
  55929. /** @hidden */
  55930. static _SceneComponentInitialization: (scene: Scene) => void;
  55931. /**
  55932. * Instantiates a new effect Layer and references it in the scene.
  55933. * @param name The name of the layer
  55934. * @param scene The scene to use the layer in
  55935. */
  55936. constructor(
  55937. /** The Friendly of the effect in the scene */
  55938. name: string, scene: Scene);
  55939. /**
  55940. * Get the effect name of the layer.
  55941. * @return The effect name
  55942. */
  55943. abstract getEffectName(): string;
  55944. /**
  55945. * Checks for the readiness of the element composing the layer.
  55946. * @param subMesh the mesh to check for
  55947. * @param useInstances specify whether or not to use instances to render the mesh
  55948. * @return true if ready otherwise, false
  55949. */
  55950. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55951. /**
  55952. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55953. * @returns true if the effect requires stencil during the main canvas render pass.
  55954. */
  55955. abstract needStencil(): boolean;
  55956. /**
  55957. * Create the merge effect. This is the shader use to blit the information back
  55958. * to the main canvas at the end of the scene rendering.
  55959. * @returns The effect containing the shader used to merge the effect on the main canvas
  55960. */
  55961. protected abstract _createMergeEffect(): Effect;
  55962. /**
  55963. * Creates the render target textures and post processes used in the effect layer.
  55964. */
  55965. protected abstract _createTextureAndPostProcesses(): void;
  55966. /**
  55967. * Implementation specific of rendering the generating effect on the main canvas.
  55968. * @param effect The effect used to render through
  55969. */
  55970. protected abstract _internalRender(effect: Effect): void;
  55971. /**
  55972. * Sets the required values for both the emissive texture and and the main color.
  55973. */
  55974. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55975. /**
  55976. * Free any resources and references associated to a mesh.
  55977. * Internal use
  55978. * @param mesh The mesh to free.
  55979. */
  55980. abstract _disposeMesh(mesh: Mesh): void;
  55981. /**
  55982. * Serializes this layer (Glow or Highlight for example)
  55983. * @returns a serialized layer object
  55984. */
  55985. abstract serialize?(): any;
  55986. /**
  55987. * Initializes the effect layer with the required options.
  55988. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55989. */
  55990. protected _init(options: Partial<IEffectLayerOptions>): void;
  55991. /**
  55992. * Generates the index buffer of the full screen quad blending to the main canvas.
  55993. */
  55994. private _generateIndexBuffer;
  55995. /**
  55996. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55997. */
  55998. private _generateVertexBuffer;
  55999. /**
  56000. * Sets the main texture desired size which is the closest power of two
  56001. * of the engine canvas size.
  56002. */
  56003. private _setMainTextureSize;
  56004. /**
  56005. * Creates the main texture for the effect layer.
  56006. */
  56007. protected _createMainTexture(): void;
  56008. /**
  56009. * Adds specific effects defines.
  56010. * @param defines The defines to add specifics to.
  56011. */
  56012. protected _addCustomEffectDefines(defines: string[]): void;
  56013. /**
  56014. * Checks for the readiness of the element composing the layer.
  56015. * @param subMesh the mesh to check for
  56016. * @param useInstances specify whether or not to use instances to render the mesh
  56017. * @param emissiveTexture the associated emissive texture used to generate the glow
  56018. * @return true if ready otherwise, false
  56019. */
  56020. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56021. /**
  56022. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56023. */
  56024. render(): void;
  56025. /**
  56026. * Determine if a given mesh will be used in the current effect.
  56027. * @param mesh mesh to test
  56028. * @returns true if the mesh will be used
  56029. */
  56030. hasMesh(mesh: AbstractMesh): boolean;
  56031. /**
  56032. * Returns true if the layer contains information to display, otherwise false.
  56033. * @returns true if the glow layer should be rendered
  56034. */
  56035. shouldRender(): boolean;
  56036. /**
  56037. * Returns true if the mesh should render, otherwise false.
  56038. * @param mesh The mesh to render
  56039. * @returns true if it should render otherwise false
  56040. */
  56041. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56042. /**
  56043. * Returns true if the mesh can be rendered, otherwise false.
  56044. * @param mesh The mesh to render
  56045. * @param material The material used on the mesh
  56046. * @returns true if it can be rendered otherwise false
  56047. */
  56048. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56049. /**
  56050. * Returns true if the mesh should render, otherwise false.
  56051. * @param mesh The mesh to render
  56052. * @returns true if it should render otherwise false
  56053. */
  56054. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56055. /**
  56056. * Renders the submesh passed in parameter to the generation map.
  56057. */
  56058. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56059. /**
  56060. * Defines whether the current material of the mesh should be use to render the effect.
  56061. * @param mesh defines the current mesh to render
  56062. */
  56063. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56064. /**
  56065. * Rebuild the required buffers.
  56066. * @hidden Internal use only.
  56067. */
  56068. _rebuild(): void;
  56069. /**
  56070. * Dispose only the render target textures and post process.
  56071. */
  56072. private _disposeTextureAndPostProcesses;
  56073. /**
  56074. * Dispose the highlight layer and free resources.
  56075. */
  56076. dispose(): void;
  56077. /**
  56078. * Gets the class name of the effect layer
  56079. * @returns the string with the class name of the effect layer
  56080. */
  56081. getClassName(): string;
  56082. /**
  56083. * Creates an effect layer from parsed effect layer data
  56084. * @param parsedEffectLayer defines effect layer data
  56085. * @param scene defines the current scene
  56086. * @param rootUrl defines the root URL containing the effect layer information
  56087. * @returns a parsed effect Layer
  56088. */
  56089. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56090. }
  56091. }
  56092. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56093. import { Scene } from "babylonjs/scene";
  56094. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56095. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56096. import { AbstractScene } from "babylonjs/abstractScene";
  56097. module "babylonjs/abstractScene" {
  56098. interface AbstractScene {
  56099. /**
  56100. * The list of effect layers (highlights/glow) added to the scene
  56101. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56102. * @see http://doc.babylonjs.com/how_to/glow_layer
  56103. */
  56104. effectLayers: Array<EffectLayer>;
  56105. /**
  56106. * Removes the given effect layer from this scene.
  56107. * @param toRemove defines the effect layer to remove
  56108. * @returns the index of the removed effect layer
  56109. */
  56110. removeEffectLayer(toRemove: EffectLayer): number;
  56111. /**
  56112. * Adds the given effect layer to this scene
  56113. * @param newEffectLayer defines the effect layer to add
  56114. */
  56115. addEffectLayer(newEffectLayer: EffectLayer): void;
  56116. }
  56117. }
  56118. /**
  56119. * Defines the layer scene component responsible to manage any effect layers
  56120. * in a given scene.
  56121. */
  56122. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56123. /**
  56124. * The component name helpfull to identify the component in the list of scene components.
  56125. */
  56126. readonly name: string;
  56127. /**
  56128. * The scene the component belongs to.
  56129. */
  56130. scene: Scene;
  56131. private _engine;
  56132. private _renderEffects;
  56133. private _needStencil;
  56134. private _previousStencilState;
  56135. /**
  56136. * Creates a new instance of the component for the given scene
  56137. * @param scene Defines the scene to register the component in
  56138. */
  56139. constructor(scene: Scene);
  56140. /**
  56141. * Registers the component in a given scene
  56142. */
  56143. register(): void;
  56144. /**
  56145. * Rebuilds the elements related to this component in case of
  56146. * context lost for instance.
  56147. */
  56148. rebuild(): void;
  56149. /**
  56150. * Serializes the component data to the specified json object
  56151. * @param serializationObject The object to serialize to
  56152. */
  56153. serialize(serializationObject: any): void;
  56154. /**
  56155. * Adds all the elements from the container to the scene
  56156. * @param container the container holding the elements
  56157. */
  56158. addFromContainer(container: AbstractScene): void;
  56159. /**
  56160. * Removes all the elements in the container from the scene
  56161. * @param container contains the elements to remove
  56162. * @param dispose if the removed element should be disposed (default: false)
  56163. */
  56164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56165. /**
  56166. * Disposes the component and the associated ressources.
  56167. */
  56168. dispose(): void;
  56169. private _isReadyForMesh;
  56170. private _renderMainTexture;
  56171. private _setStencil;
  56172. private _setStencilBack;
  56173. private _draw;
  56174. private _drawCamera;
  56175. private _drawRenderingGroup;
  56176. }
  56177. }
  56178. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56179. /** @hidden */
  56180. export var glowMapMergePixelShader: {
  56181. name: string;
  56182. shader: string;
  56183. };
  56184. }
  56185. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56186. /** @hidden */
  56187. export var glowMapMergeVertexShader: {
  56188. name: string;
  56189. shader: string;
  56190. };
  56191. }
  56192. declare module "babylonjs/Layers/glowLayer" {
  56193. import { Nullable } from "babylonjs/types";
  56194. import { Camera } from "babylonjs/Cameras/camera";
  56195. import { Scene } from "babylonjs/scene";
  56196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56198. import { Mesh } from "babylonjs/Meshes/mesh";
  56199. import { Texture } from "babylonjs/Materials/Textures/texture";
  56200. import { Effect } from "babylonjs/Materials/effect";
  56201. import { Material } from "babylonjs/Materials/material";
  56202. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56203. import { Color4 } from "babylonjs/Maths/math.color";
  56204. import "babylonjs/Shaders/glowMapMerge.fragment";
  56205. import "babylonjs/Shaders/glowMapMerge.vertex";
  56206. import "babylonjs/Layers/effectLayerSceneComponent";
  56207. module "babylonjs/abstractScene" {
  56208. interface AbstractScene {
  56209. /**
  56210. * Return a the first highlight layer of the scene with a given name.
  56211. * @param name The name of the highlight layer to look for.
  56212. * @return The highlight layer if found otherwise null.
  56213. */
  56214. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56215. }
  56216. }
  56217. /**
  56218. * Glow layer options. This helps customizing the behaviour
  56219. * of the glow layer.
  56220. */
  56221. export interface IGlowLayerOptions {
  56222. /**
  56223. * Multiplication factor apply to the canvas size to compute the render target size
  56224. * used to generated the glowing objects (the smaller the faster).
  56225. */
  56226. mainTextureRatio: number;
  56227. /**
  56228. * Enforces a fixed size texture to ensure resize independant blur.
  56229. */
  56230. mainTextureFixedSize?: number;
  56231. /**
  56232. * How big is the kernel of the blur texture.
  56233. */
  56234. blurKernelSize: number;
  56235. /**
  56236. * The camera attached to the layer.
  56237. */
  56238. camera: Nullable<Camera>;
  56239. /**
  56240. * Enable MSAA by chosing the number of samples.
  56241. */
  56242. mainTextureSamples?: number;
  56243. /**
  56244. * The rendering group to draw the layer in.
  56245. */
  56246. renderingGroupId: number;
  56247. }
  56248. /**
  56249. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56250. *
  56251. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56252. *
  56253. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56254. */
  56255. export class GlowLayer extends EffectLayer {
  56256. /**
  56257. * Effect Name of the layer.
  56258. */
  56259. static readonly EffectName: string;
  56260. /**
  56261. * The default blur kernel size used for the glow.
  56262. */
  56263. static DefaultBlurKernelSize: number;
  56264. /**
  56265. * The default texture size ratio used for the glow.
  56266. */
  56267. static DefaultTextureRatio: number;
  56268. /**
  56269. * Sets the kernel size of the blur.
  56270. */
  56271. set blurKernelSize(value: number);
  56272. /**
  56273. * Gets the kernel size of the blur.
  56274. */
  56275. get blurKernelSize(): number;
  56276. /**
  56277. * Sets the glow intensity.
  56278. */
  56279. set intensity(value: number);
  56280. /**
  56281. * Gets the glow intensity.
  56282. */
  56283. get intensity(): number;
  56284. private _options;
  56285. private _intensity;
  56286. private _horizontalBlurPostprocess1;
  56287. private _verticalBlurPostprocess1;
  56288. private _horizontalBlurPostprocess2;
  56289. private _verticalBlurPostprocess2;
  56290. private _blurTexture1;
  56291. private _blurTexture2;
  56292. private _postProcesses1;
  56293. private _postProcesses2;
  56294. private _includedOnlyMeshes;
  56295. private _excludedMeshes;
  56296. private _meshesUsingTheirOwnMaterials;
  56297. /**
  56298. * Callback used to let the user override the color selection on a per mesh basis
  56299. */
  56300. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56301. /**
  56302. * Callback used to let the user override the texture selection on a per mesh basis
  56303. */
  56304. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56305. /**
  56306. * Instantiates a new glow Layer and references it to the scene.
  56307. * @param name The name of the layer
  56308. * @param scene The scene to use the layer in
  56309. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56310. */
  56311. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56312. /**
  56313. * Get the effect name of the layer.
  56314. * @return The effect name
  56315. */
  56316. getEffectName(): string;
  56317. /**
  56318. * Create the merge effect. This is the shader use to blit the information back
  56319. * to the main canvas at the end of the scene rendering.
  56320. */
  56321. protected _createMergeEffect(): Effect;
  56322. /**
  56323. * Creates the render target textures and post processes used in the glow layer.
  56324. */
  56325. protected _createTextureAndPostProcesses(): void;
  56326. /**
  56327. * Checks for the readiness of the element composing the layer.
  56328. * @param subMesh the mesh to check for
  56329. * @param useInstances specify wether or not to use instances to render the mesh
  56330. * @param emissiveTexture the associated emissive texture used to generate the glow
  56331. * @return true if ready otherwise, false
  56332. */
  56333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56334. /**
  56335. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56336. */
  56337. needStencil(): boolean;
  56338. /**
  56339. * Returns true if the mesh can be rendered, otherwise false.
  56340. * @param mesh The mesh to render
  56341. * @param material The material used on the mesh
  56342. * @returns true if it can be rendered otherwise false
  56343. */
  56344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56345. /**
  56346. * Implementation specific of rendering the generating effect on the main canvas.
  56347. * @param effect The effect used to render through
  56348. */
  56349. protected _internalRender(effect: Effect): void;
  56350. /**
  56351. * Sets the required values for both the emissive texture and and the main color.
  56352. */
  56353. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56354. /**
  56355. * Returns true if the mesh should render, otherwise false.
  56356. * @param mesh The mesh to render
  56357. * @returns true if it should render otherwise false
  56358. */
  56359. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56360. /**
  56361. * Adds specific effects defines.
  56362. * @param defines The defines to add specifics to.
  56363. */
  56364. protected _addCustomEffectDefines(defines: string[]): void;
  56365. /**
  56366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56367. * @param mesh The mesh to exclude from the glow layer
  56368. */
  56369. addExcludedMesh(mesh: Mesh): void;
  56370. /**
  56371. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56372. * @param mesh The mesh to remove
  56373. */
  56374. removeExcludedMesh(mesh: Mesh): void;
  56375. /**
  56376. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56377. * @param mesh The mesh to include in the glow layer
  56378. */
  56379. addIncludedOnlyMesh(mesh: Mesh): void;
  56380. /**
  56381. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56382. * @param mesh The mesh to remove
  56383. */
  56384. removeIncludedOnlyMesh(mesh: Mesh): void;
  56385. /**
  56386. * Determine if a given mesh will be used in the glow layer
  56387. * @param mesh The mesh to test
  56388. * @returns true if the mesh will be highlighted by the current glow layer
  56389. */
  56390. hasMesh(mesh: AbstractMesh): boolean;
  56391. /**
  56392. * Defines whether the current material of the mesh should be use to render the effect.
  56393. * @param mesh defines the current mesh to render
  56394. */
  56395. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56396. /**
  56397. * Add a mesh to be rendered through its own material and not with emissive only.
  56398. * @param mesh The mesh for which we need to use its material
  56399. */
  56400. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56401. /**
  56402. * Remove a mesh from being rendered through its own material and not with emissive only.
  56403. * @param mesh The mesh for which we need to not use its material
  56404. */
  56405. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56406. /**
  56407. * Free any resources and references associated to a mesh.
  56408. * Internal use
  56409. * @param mesh The mesh to free.
  56410. * @hidden
  56411. */
  56412. _disposeMesh(mesh: Mesh): void;
  56413. /**
  56414. * Gets the class name of the effect layer
  56415. * @returns the string with the class name of the effect layer
  56416. */
  56417. getClassName(): string;
  56418. /**
  56419. * Serializes this glow layer
  56420. * @returns a serialized glow layer object
  56421. */
  56422. serialize(): any;
  56423. /**
  56424. * Creates a Glow Layer from parsed glow layer data
  56425. * @param parsedGlowLayer defines glow layer data
  56426. * @param scene defines the current scene
  56427. * @param rootUrl defines the root URL containing the glow layer information
  56428. * @returns a parsed Glow Layer
  56429. */
  56430. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56431. }
  56432. }
  56433. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56434. /** @hidden */
  56435. export var glowBlurPostProcessPixelShader: {
  56436. name: string;
  56437. shader: string;
  56438. };
  56439. }
  56440. declare module "babylonjs/Layers/highlightLayer" {
  56441. import { Observable } from "babylonjs/Misc/observable";
  56442. import { Nullable } from "babylonjs/types";
  56443. import { Camera } from "babylonjs/Cameras/camera";
  56444. import { Scene } from "babylonjs/scene";
  56445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56447. import { Mesh } from "babylonjs/Meshes/mesh";
  56448. import { Effect } from "babylonjs/Materials/effect";
  56449. import { Material } from "babylonjs/Materials/material";
  56450. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56451. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56452. import "babylonjs/Shaders/glowMapMerge.fragment";
  56453. import "babylonjs/Shaders/glowMapMerge.vertex";
  56454. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56455. module "babylonjs/abstractScene" {
  56456. interface AbstractScene {
  56457. /**
  56458. * Return a the first highlight layer of the scene with a given name.
  56459. * @param name The name of the highlight layer to look for.
  56460. * @return The highlight layer if found otherwise null.
  56461. */
  56462. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56463. }
  56464. }
  56465. /**
  56466. * Highlight layer options. This helps customizing the behaviour
  56467. * of the highlight layer.
  56468. */
  56469. export interface IHighlightLayerOptions {
  56470. /**
  56471. * Multiplication factor apply to the canvas size to compute the render target size
  56472. * used to generated the glowing objects (the smaller the faster).
  56473. */
  56474. mainTextureRatio: number;
  56475. /**
  56476. * Enforces a fixed size texture to ensure resize independant blur.
  56477. */
  56478. mainTextureFixedSize?: number;
  56479. /**
  56480. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56481. * of the picture to blur (the smaller the faster).
  56482. */
  56483. blurTextureSizeRatio: number;
  56484. /**
  56485. * How big in texel of the blur texture is the vertical blur.
  56486. */
  56487. blurVerticalSize: number;
  56488. /**
  56489. * How big in texel of the blur texture is the horizontal blur.
  56490. */
  56491. blurHorizontalSize: number;
  56492. /**
  56493. * Alpha blending mode used to apply the blur. Default is combine.
  56494. */
  56495. alphaBlendingMode: number;
  56496. /**
  56497. * The camera attached to the layer.
  56498. */
  56499. camera: Nullable<Camera>;
  56500. /**
  56501. * Should we display highlight as a solid stroke?
  56502. */
  56503. isStroke?: boolean;
  56504. /**
  56505. * The rendering group to draw the layer in.
  56506. */
  56507. renderingGroupId: number;
  56508. }
  56509. /**
  56510. * The highlight layer Helps adding a glow effect around a mesh.
  56511. *
  56512. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56513. * glowy meshes to your scene.
  56514. *
  56515. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56516. */
  56517. export class HighlightLayer extends EffectLayer {
  56518. name: string;
  56519. /**
  56520. * Effect Name of the highlight layer.
  56521. */
  56522. static readonly EffectName: string;
  56523. /**
  56524. * The neutral color used during the preparation of the glow effect.
  56525. * This is black by default as the blend operation is a blend operation.
  56526. */
  56527. static NeutralColor: Color4;
  56528. /**
  56529. * Stencil value used for glowing meshes.
  56530. */
  56531. static GlowingMeshStencilReference: number;
  56532. /**
  56533. * Stencil value used for the other meshes in the scene.
  56534. */
  56535. static NormalMeshStencilReference: number;
  56536. /**
  56537. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56538. */
  56539. innerGlow: boolean;
  56540. /**
  56541. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56542. */
  56543. outerGlow: boolean;
  56544. /**
  56545. * Specifies the horizontal size of the blur.
  56546. */
  56547. set blurHorizontalSize(value: number);
  56548. /**
  56549. * Specifies the vertical size of the blur.
  56550. */
  56551. set blurVerticalSize(value: number);
  56552. /**
  56553. * Gets the horizontal size of the blur.
  56554. */
  56555. get blurHorizontalSize(): number;
  56556. /**
  56557. * Gets the vertical size of the blur.
  56558. */
  56559. get blurVerticalSize(): number;
  56560. /**
  56561. * An event triggered when the highlight layer is being blurred.
  56562. */
  56563. onBeforeBlurObservable: Observable<HighlightLayer>;
  56564. /**
  56565. * An event triggered when the highlight layer has been blurred.
  56566. */
  56567. onAfterBlurObservable: Observable<HighlightLayer>;
  56568. private _instanceGlowingMeshStencilReference;
  56569. private _options;
  56570. private _downSamplePostprocess;
  56571. private _horizontalBlurPostprocess;
  56572. private _verticalBlurPostprocess;
  56573. private _blurTexture;
  56574. private _meshes;
  56575. private _excludedMeshes;
  56576. /**
  56577. * Instantiates a new highlight Layer and references it to the scene..
  56578. * @param name The name of the layer
  56579. * @param scene The scene to use the layer in
  56580. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56581. */
  56582. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56583. /**
  56584. * Get the effect name of the layer.
  56585. * @return The effect name
  56586. */
  56587. getEffectName(): string;
  56588. /**
  56589. * Create the merge effect. This is the shader use to blit the information back
  56590. * to the main canvas at the end of the scene rendering.
  56591. */
  56592. protected _createMergeEffect(): Effect;
  56593. /**
  56594. * Creates the render target textures and post processes used in the highlight layer.
  56595. */
  56596. protected _createTextureAndPostProcesses(): void;
  56597. /**
  56598. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56599. */
  56600. needStencil(): boolean;
  56601. /**
  56602. * Checks for the readiness of the element composing the layer.
  56603. * @param subMesh the mesh to check for
  56604. * @param useInstances specify wether or not to use instances to render the mesh
  56605. * @param emissiveTexture the associated emissive texture used to generate the glow
  56606. * @return true if ready otherwise, false
  56607. */
  56608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56609. /**
  56610. * Implementation specific of rendering the generating effect on the main canvas.
  56611. * @param effect The effect used to render through
  56612. */
  56613. protected _internalRender(effect: Effect): void;
  56614. /**
  56615. * Returns true if the layer contains information to display, otherwise false.
  56616. */
  56617. shouldRender(): boolean;
  56618. /**
  56619. * Returns true if the mesh should render, otherwise false.
  56620. * @param mesh The mesh to render
  56621. * @returns true if it should render otherwise false
  56622. */
  56623. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56624. /**
  56625. * Adds specific effects defines.
  56626. * @param defines The defines to add specifics to.
  56627. */
  56628. protected _addCustomEffectDefines(defines: string[]): void;
  56629. /**
  56630. * Sets the required values for both the emissive texture and and the main color.
  56631. */
  56632. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56633. /**
  56634. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56635. * @param mesh The mesh to exclude from the highlight layer
  56636. */
  56637. addExcludedMesh(mesh: Mesh): void;
  56638. /**
  56639. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56640. * @param mesh The mesh to highlight
  56641. */
  56642. removeExcludedMesh(mesh: Mesh): void;
  56643. /**
  56644. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56645. * @param mesh mesh to test
  56646. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56647. */
  56648. hasMesh(mesh: AbstractMesh): boolean;
  56649. /**
  56650. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56651. * @param mesh The mesh to highlight
  56652. * @param color The color of the highlight
  56653. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56654. */
  56655. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56656. /**
  56657. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56658. * @param mesh The mesh to highlight
  56659. */
  56660. removeMesh(mesh: Mesh): void;
  56661. /**
  56662. * Remove all the meshes currently referenced in the highlight layer
  56663. */
  56664. removeAllMeshes(): void;
  56665. /**
  56666. * Force the stencil to the normal expected value for none glowing parts
  56667. */
  56668. private _defaultStencilReference;
  56669. /**
  56670. * Free any resources and references associated to a mesh.
  56671. * Internal use
  56672. * @param mesh The mesh to free.
  56673. * @hidden
  56674. */
  56675. _disposeMesh(mesh: Mesh): void;
  56676. /**
  56677. * Dispose the highlight layer and free resources.
  56678. */
  56679. dispose(): void;
  56680. /**
  56681. * Gets the class name of the effect layer
  56682. * @returns the string with the class name of the effect layer
  56683. */
  56684. getClassName(): string;
  56685. /**
  56686. * Serializes this Highlight layer
  56687. * @returns a serialized Highlight layer object
  56688. */
  56689. serialize(): any;
  56690. /**
  56691. * Creates a Highlight layer from parsed Highlight layer data
  56692. * @param parsedHightlightLayer defines the Highlight layer data
  56693. * @param scene defines the current scene
  56694. * @param rootUrl defines the root URL containing the Highlight layer information
  56695. * @returns a parsed Highlight layer
  56696. */
  56697. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56698. }
  56699. }
  56700. declare module "babylonjs/Layers/layerSceneComponent" {
  56701. import { Scene } from "babylonjs/scene";
  56702. import { ISceneComponent } from "babylonjs/sceneComponent";
  56703. import { Layer } from "babylonjs/Layers/layer";
  56704. import { AbstractScene } from "babylonjs/abstractScene";
  56705. module "babylonjs/abstractScene" {
  56706. interface AbstractScene {
  56707. /**
  56708. * The list of layers (background and foreground) of the scene
  56709. */
  56710. layers: Array<Layer>;
  56711. }
  56712. }
  56713. /**
  56714. * Defines the layer scene component responsible to manage any layers
  56715. * in a given scene.
  56716. */
  56717. export class LayerSceneComponent implements ISceneComponent {
  56718. /**
  56719. * The component name helpfull to identify the component in the list of scene components.
  56720. */
  56721. readonly name: string;
  56722. /**
  56723. * The scene the component belongs to.
  56724. */
  56725. scene: Scene;
  56726. private _engine;
  56727. /**
  56728. * Creates a new instance of the component for the given scene
  56729. * @param scene Defines the scene to register the component in
  56730. */
  56731. constructor(scene: Scene);
  56732. /**
  56733. * Registers the component in a given scene
  56734. */
  56735. register(): void;
  56736. /**
  56737. * Rebuilds the elements related to this component in case of
  56738. * context lost for instance.
  56739. */
  56740. rebuild(): void;
  56741. /**
  56742. * Disposes the component and the associated ressources.
  56743. */
  56744. dispose(): void;
  56745. private _draw;
  56746. private _drawCameraPredicate;
  56747. private _drawCameraBackground;
  56748. private _drawCameraForeground;
  56749. private _drawRenderTargetPredicate;
  56750. private _drawRenderTargetBackground;
  56751. private _drawRenderTargetForeground;
  56752. /**
  56753. * Adds all the elements from the container to the scene
  56754. * @param container the container holding the elements
  56755. */
  56756. addFromContainer(container: AbstractScene): void;
  56757. /**
  56758. * Removes all the elements in the container from the scene
  56759. * @param container contains the elements to remove
  56760. * @param dispose if the removed element should be disposed (default: false)
  56761. */
  56762. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56763. }
  56764. }
  56765. declare module "babylonjs/Shaders/layer.fragment" {
  56766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56767. /** @hidden */
  56768. export var layerPixelShader: {
  56769. name: string;
  56770. shader: string;
  56771. };
  56772. }
  56773. declare module "babylonjs/Shaders/layer.vertex" {
  56774. /** @hidden */
  56775. export var layerVertexShader: {
  56776. name: string;
  56777. shader: string;
  56778. };
  56779. }
  56780. declare module "babylonjs/Layers/layer" {
  56781. import { Observable } from "babylonjs/Misc/observable";
  56782. import { Nullable } from "babylonjs/types";
  56783. import { Scene } from "babylonjs/scene";
  56784. import { Vector2 } from "babylonjs/Maths/math.vector";
  56785. import { Color4 } from "babylonjs/Maths/math.color";
  56786. import { Texture } from "babylonjs/Materials/Textures/texture";
  56787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56788. import "babylonjs/Shaders/layer.fragment";
  56789. import "babylonjs/Shaders/layer.vertex";
  56790. /**
  56791. * This represents a full screen 2d layer.
  56792. * This can be useful to display a picture in the background of your scene for instance.
  56793. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56794. */
  56795. export class Layer {
  56796. /**
  56797. * Define the name of the layer.
  56798. */
  56799. name: string;
  56800. /**
  56801. * Define the texture the layer should display.
  56802. */
  56803. texture: Nullable<Texture>;
  56804. /**
  56805. * Is the layer in background or foreground.
  56806. */
  56807. isBackground: boolean;
  56808. /**
  56809. * Define the color of the layer (instead of texture).
  56810. */
  56811. color: Color4;
  56812. /**
  56813. * Define the scale of the layer in order to zoom in out of the texture.
  56814. */
  56815. scale: Vector2;
  56816. /**
  56817. * Define an offset for the layer in order to shift the texture.
  56818. */
  56819. offset: Vector2;
  56820. /**
  56821. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56822. */
  56823. alphaBlendingMode: number;
  56824. /**
  56825. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56826. * Alpha test will not mix with the background color in case of transparency.
  56827. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56828. */
  56829. alphaTest: boolean;
  56830. /**
  56831. * Define a mask to restrict the layer to only some of the scene cameras.
  56832. */
  56833. layerMask: number;
  56834. /**
  56835. * Define the list of render target the layer is visible into.
  56836. */
  56837. renderTargetTextures: RenderTargetTexture[];
  56838. /**
  56839. * Define if the layer is only used in renderTarget or if it also
  56840. * renders in the main frame buffer of the canvas.
  56841. */
  56842. renderOnlyInRenderTargetTextures: boolean;
  56843. private _scene;
  56844. private _vertexBuffers;
  56845. private _indexBuffer;
  56846. private _effect;
  56847. private _previousDefines;
  56848. /**
  56849. * An event triggered when the layer is disposed.
  56850. */
  56851. onDisposeObservable: Observable<Layer>;
  56852. private _onDisposeObserver;
  56853. /**
  56854. * Back compatibility with callback before the onDisposeObservable existed.
  56855. * The set callback will be triggered when the layer has been disposed.
  56856. */
  56857. set onDispose(callback: () => void);
  56858. /**
  56859. * An event triggered before rendering the scene
  56860. */
  56861. onBeforeRenderObservable: Observable<Layer>;
  56862. private _onBeforeRenderObserver;
  56863. /**
  56864. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56865. * The set callback will be triggered just before rendering the layer.
  56866. */
  56867. set onBeforeRender(callback: () => void);
  56868. /**
  56869. * An event triggered after rendering the scene
  56870. */
  56871. onAfterRenderObservable: Observable<Layer>;
  56872. private _onAfterRenderObserver;
  56873. /**
  56874. * Back compatibility with callback before the onAfterRenderObservable existed.
  56875. * The set callback will be triggered just after rendering the layer.
  56876. */
  56877. set onAfterRender(callback: () => void);
  56878. /**
  56879. * Instantiates a new layer.
  56880. * This represents a full screen 2d layer.
  56881. * This can be useful to display a picture in the background of your scene for instance.
  56882. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56883. * @param name Define the name of the layer in the scene
  56884. * @param imgUrl Define the url of the texture to display in the layer
  56885. * @param scene Define the scene the layer belongs to
  56886. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56887. * @param color Defines a color for the layer
  56888. */
  56889. constructor(
  56890. /**
  56891. * Define the name of the layer.
  56892. */
  56893. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56894. private _createIndexBuffer;
  56895. /** @hidden */
  56896. _rebuild(): void;
  56897. /**
  56898. * Renders the layer in the scene.
  56899. */
  56900. render(): void;
  56901. /**
  56902. * Disposes and releases the associated ressources.
  56903. */
  56904. dispose(): void;
  56905. }
  56906. }
  56907. declare module "babylonjs/Layers/index" {
  56908. export * from "babylonjs/Layers/effectLayer";
  56909. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56910. export * from "babylonjs/Layers/glowLayer";
  56911. export * from "babylonjs/Layers/highlightLayer";
  56912. export * from "babylonjs/Layers/layer";
  56913. export * from "babylonjs/Layers/layerSceneComponent";
  56914. }
  56915. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56916. /** @hidden */
  56917. export var lensFlarePixelShader: {
  56918. name: string;
  56919. shader: string;
  56920. };
  56921. }
  56922. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56923. /** @hidden */
  56924. export var lensFlareVertexShader: {
  56925. name: string;
  56926. shader: string;
  56927. };
  56928. }
  56929. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56930. import { Scene } from "babylonjs/scene";
  56931. import { Vector3 } from "babylonjs/Maths/math.vector";
  56932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56933. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56934. import "babylonjs/Shaders/lensFlare.fragment";
  56935. import "babylonjs/Shaders/lensFlare.vertex";
  56936. import { Viewport } from "babylonjs/Maths/math.viewport";
  56937. /**
  56938. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56939. * It is usually composed of several `lensFlare`.
  56940. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56941. */
  56942. export class LensFlareSystem {
  56943. /**
  56944. * Define the name of the lens flare system
  56945. */
  56946. name: string;
  56947. /**
  56948. * List of lens flares used in this system.
  56949. */
  56950. lensFlares: LensFlare[];
  56951. /**
  56952. * Define a limit from the border the lens flare can be visible.
  56953. */
  56954. borderLimit: number;
  56955. /**
  56956. * Define a viewport border we do not want to see the lens flare in.
  56957. */
  56958. viewportBorder: number;
  56959. /**
  56960. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56961. */
  56962. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56963. /**
  56964. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56965. */
  56966. layerMask: number;
  56967. /**
  56968. * Define the id of the lens flare system in the scene.
  56969. * (equal to name by default)
  56970. */
  56971. id: string;
  56972. private _scene;
  56973. private _emitter;
  56974. private _vertexBuffers;
  56975. private _indexBuffer;
  56976. private _effect;
  56977. private _positionX;
  56978. private _positionY;
  56979. private _isEnabled;
  56980. /** @hidden */
  56981. static _SceneComponentInitialization: (scene: Scene) => void;
  56982. /**
  56983. * Instantiates a lens flare system.
  56984. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56985. * It is usually composed of several `lensFlare`.
  56986. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56987. * @param name Define the name of the lens flare system in the scene
  56988. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56989. * @param scene Define the scene the lens flare system belongs to
  56990. */
  56991. constructor(
  56992. /**
  56993. * Define the name of the lens flare system
  56994. */
  56995. name: string, emitter: any, scene: Scene);
  56996. /**
  56997. * Define if the lens flare system is enabled.
  56998. */
  56999. get isEnabled(): boolean;
  57000. set isEnabled(value: boolean);
  57001. /**
  57002. * Get the scene the effects belongs to.
  57003. * @returns the scene holding the lens flare system
  57004. */
  57005. getScene(): Scene;
  57006. /**
  57007. * Get the emitter of the lens flare system.
  57008. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57009. * @returns the emitter of the lens flare system
  57010. */
  57011. getEmitter(): any;
  57012. /**
  57013. * Set the emitter of the lens flare system.
  57014. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57015. * @param newEmitter Define the new emitter of the system
  57016. */
  57017. setEmitter(newEmitter: any): void;
  57018. /**
  57019. * Get the lens flare system emitter position.
  57020. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57021. * @returns the position
  57022. */
  57023. getEmitterPosition(): Vector3;
  57024. /**
  57025. * @hidden
  57026. */
  57027. computeEffectivePosition(globalViewport: Viewport): boolean;
  57028. /** @hidden */
  57029. _isVisible(): boolean;
  57030. /**
  57031. * @hidden
  57032. */
  57033. render(): boolean;
  57034. /**
  57035. * Dispose and release the lens flare with its associated resources.
  57036. */
  57037. dispose(): void;
  57038. /**
  57039. * Parse a lens flare system from a JSON repressentation
  57040. * @param parsedLensFlareSystem Define the JSON to parse
  57041. * @param scene Define the scene the parsed system should be instantiated in
  57042. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57043. * @returns the parsed system
  57044. */
  57045. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57046. /**
  57047. * Serialize the current Lens Flare System into a JSON representation.
  57048. * @returns the serialized JSON
  57049. */
  57050. serialize(): any;
  57051. }
  57052. }
  57053. declare module "babylonjs/LensFlares/lensFlare" {
  57054. import { Nullable } from "babylonjs/types";
  57055. import { Color3 } from "babylonjs/Maths/math.color";
  57056. import { Texture } from "babylonjs/Materials/Textures/texture";
  57057. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57058. /**
  57059. * This represents one of the lens effect in a `lensFlareSystem`.
  57060. * It controls one of the indiviual texture used in the effect.
  57061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57062. */
  57063. export class LensFlare {
  57064. /**
  57065. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57066. */
  57067. size: number;
  57068. /**
  57069. * 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.
  57070. */
  57071. position: number;
  57072. /**
  57073. * Define the lens color.
  57074. */
  57075. color: Color3;
  57076. /**
  57077. * Define the lens texture.
  57078. */
  57079. texture: Nullable<Texture>;
  57080. /**
  57081. * Define the alpha mode to render this particular lens.
  57082. */
  57083. alphaMode: number;
  57084. private _system;
  57085. /**
  57086. * Creates a new Lens Flare.
  57087. * This represents one of the lens effect in a `lensFlareSystem`.
  57088. * It controls one of the indiviual texture used in the effect.
  57089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57090. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57091. * @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.
  57092. * @param color Define the lens color
  57093. * @param imgUrl Define the lens texture url
  57094. * @param system Define the `lensFlareSystem` this flare is part of
  57095. * @returns The newly created Lens Flare
  57096. */
  57097. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57098. /**
  57099. * Instantiates a new Lens Flare.
  57100. * This represents one of the lens effect in a `lensFlareSystem`.
  57101. * It controls one of the indiviual texture used in the effect.
  57102. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57103. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57104. * @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.
  57105. * @param color Define the lens color
  57106. * @param imgUrl Define the lens texture url
  57107. * @param system Define the `lensFlareSystem` this flare is part of
  57108. */
  57109. constructor(
  57110. /**
  57111. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57112. */
  57113. size: number,
  57114. /**
  57115. * 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.
  57116. */
  57117. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57118. /**
  57119. * Dispose and release the lens flare with its associated resources.
  57120. */
  57121. dispose(): void;
  57122. }
  57123. }
  57124. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57125. import { Nullable } from "babylonjs/types";
  57126. import { Scene } from "babylonjs/scene";
  57127. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57128. import { AbstractScene } from "babylonjs/abstractScene";
  57129. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57130. module "babylonjs/abstractScene" {
  57131. interface AbstractScene {
  57132. /**
  57133. * The list of lens flare system added to the scene
  57134. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57135. */
  57136. lensFlareSystems: Array<LensFlareSystem>;
  57137. /**
  57138. * Removes the given lens flare system from this scene.
  57139. * @param toRemove The lens flare system to remove
  57140. * @returns The index of the removed lens flare system
  57141. */
  57142. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57143. /**
  57144. * Adds the given lens flare system to this scene
  57145. * @param newLensFlareSystem The lens flare system to add
  57146. */
  57147. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57148. /**
  57149. * Gets a lens flare system using its name
  57150. * @param name defines the name to look for
  57151. * @returns the lens flare system or null if not found
  57152. */
  57153. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57154. /**
  57155. * Gets a lens flare system using its id
  57156. * @param id defines the id to look for
  57157. * @returns the lens flare system or null if not found
  57158. */
  57159. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57160. }
  57161. }
  57162. /**
  57163. * Defines the lens flare scene component responsible to manage any lens flares
  57164. * in a given scene.
  57165. */
  57166. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57167. /**
  57168. * The component name helpfull to identify the component in the list of scene components.
  57169. */
  57170. readonly name: string;
  57171. /**
  57172. * The scene the component belongs to.
  57173. */
  57174. scene: Scene;
  57175. /**
  57176. * Creates a new instance of the component for the given scene
  57177. * @param scene Defines the scene to register the component in
  57178. */
  57179. constructor(scene: Scene);
  57180. /**
  57181. * Registers the component in a given scene
  57182. */
  57183. register(): void;
  57184. /**
  57185. * Rebuilds the elements related to this component in case of
  57186. * context lost for instance.
  57187. */
  57188. rebuild(): void;
  57189. /**
  57190. * Adds all the elements from the container to the scene
  57191. * @param container the container holding the elements
  57192. */
  57193. addFromContainer(container: AbstractScene): void;
  57194. /**
  57195. * Removes all the elements in the container from the scene
  57196. * @param container contains the elements to remove
  57197. * @param dispose if the removed element should be disposed (default: false)
  57198. */
  57199. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57200. /**
  57201. * Serializes the component data to the specified json object
  57202. * @param serializationObject The object to serialize to
  57203. */
  57204. serialize(serializationObject: any): void;
  57205. /**
  57206. * Disposes the component and the associated ressources.
  57207. */
  57208. dispose(): void;
  57209. private _draw;
  57210. }
  57211. }
  57212. declare module "babylonjs/LensFlares/index" {
  57213. export * from "babylonjs/LensFlares/lensFlare";
  57214. export * from "babylonjs/LensFlares/lensFlareSystem";
  57215. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57216. }
  57217. declare module "babylonjs/Shaders/depth.fragment" {
  57218. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57219. /** @hidden */
  57220. export var depthPixelShader: {
  57221. name: string;
  57222. shader: string;
  57223. };
  57224. }
  57225. declare module "babylonjs/Shaders/depth.vertex" {
  57226. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57229. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57230. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57231. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57232. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57233. /** @hidden */
  57234. export var depthVertexShader: {
  57235. name: string;
  57236. shader: string;
  57237. };
  57238. }
  57239. declare module "babylonjs/Rendering/depthRenderer" {
  57240. import { Nullable } from "babylonjs/types";
  57241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57242. import { Scene } from "babylonjs/scene";
  57243. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57244. import { Camera } from "babylonjs/Cameras/camera";
  57245. import "babylonjs/Shaders/depth.fragment";
  57246. import "babylonjs/Shaders/depth.vertex";
  57247. /**
  57248. * This represents a depth renderer in Babylon.
  57249. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57250. */
  57251. export class DepthRenderer {
  57252. private _scene;
  57253. private _depthMap;
  57254. private _effect;
  57255. private readonly _storeNonLinearDepth;
  57256. private readonly _clearColor;
  57257. /** Get if the depth renderer is using packed depth or not */
  57258. readonly isPacked: boolean;
  57259. private _cachedDefines;
  57260. private _camera;
  57261. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57262. enabled: boolean;
  57263. /**
  57264. * Specifiess that the depth renderer will only be used within
  57265. * the camera it is created for.
  57266. * This can help forcing its rendering during the camera processing.
  57267. */
  57268. useOnlyInActiveCamera: boolean;
  57269. /** @hidden */
  57270. static _SceneComponentInitialization: (scene: Scene) => void;
  57271. /**
  57272. * Instantiates a depth renderer
  57273. * @param scene The scene the renderer belongs to
  57274. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57275. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57276. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57277. */
  57278. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57279. /**
  57280. * Creates the depth rendering effect and checks if the effect is ready.
  57281. * @param subMesh The submesh to be used to render the depth map of
  57282. * @param useInstances If multiple world instances should be used
  57283. * @returns if the depth renderer is ready to render the depth map
  57284. */
  57285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57286. /**
  57287. * Gets the texture which the depth map will be written to.
  57288. * @returns The depth map texture
  57289. */
  57290. getDepthMap(): RenderTargetTexture;
  57291. /**
  57292. * Disposes of the depth renderer.
  57293. */
  57294. dispose(): void;
  57295. }
  57296. }
  57297. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57298. /** @hidden */
  57299. export var minmaxReduxPixelShader: {
  57300. name: string;
  57301. shader: string;
  57302. };
  57303. }
  57304. declare module "babylonjs/Misc/minMaxReducer" {
  57305. import { Nullable } from "babylonjs/types";
  57306. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57307. import { Camera } from "babylonjs/Cameras/camera";
  57308. import { Observer } from "babylonjs/Misc/observable";
  57309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57310. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57311. import { Observable } from "babylonjs/Misc/observable";
  57312. import "babylonjs/Shaders/minmaxRedux.fragment";
  57313. /**
  57314. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57315. * and maximum values from all values of the texture.
  57316. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57317. * The source values are read from the red channel of the texture.
  57318. */
  57319. export class MinMaxReducer {
  57320. /**
  57321. * Observable triggered when the computation has been performed
  57322. */
  57323. onAfterReductionPerformed: Observable<{
  57324. min: number;
  57325. max: number;
  57326. }>;
  57327. protected _camera: Camera;
  57328. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57329. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57330. protected _postProcessManager: PostProcessManager;
  57331. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57332. protected _forceFullscreenViewport: boolean;
  57333. /**
  57334. * Creates a min/max reducer
  57335. * @param camera The camera to use for the post processes
  57336. */
  57337. constructor(camera: Camera);
  57338. /**
  57339. * Gets the texture used to read the values from.
  57340. */
  57341. get sourceTexture(): Nullable<RenderTargetTexture>;
  57342. /**
  57343. * Sets the source texture to read the values from.
  57344. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57345. * because in such textures '1' value must not be taken into account to compute the maximum
  57346. * as this value is used to clear the texture.
  57347. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57348. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57349. * @param depthRedux Indicates if the texture is a depth texture or not
  57350. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57351. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57352. */
  57353. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57354. /**
  57355. * Defines the refresh rate of the computation.
  57356. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57357. */
  57358. get refreshRate(): number;
  57359. set refreshRate(value: number);
  57360. protected _activated: boolean;
  57361. /**
  57362. * Gets the activation status of the reducer
  57363. */
  57364. get activated(): boolean;
  57365. /**
  57366. * Activates the reduction computation.
  57367. * When activated, the observers registered in onAfterReductionPerformed are
  57368. * called after the compuation is performed
  57369. */
  57370. activate(): void;
  57371. /**
  57372. * Deactivates the reduction computation.
  57373. */
  57374. deactivate(): void;
  57375. /**
  57376. * Disposes the min/max reducer
  57377. * @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.
  57378. */
  57379. dispose(disposeAll?: boolean): void;
  57380. }
  57381. }
  57382. declare module "babylonjs/Misc/depthReducer" {
  57383. import { Nullable } from "babylonjs/types";
  57384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57385. import { Camera } from "babylonjs/Cameras/camera";
  57386. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57387. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57388. /**
  57389. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57390. */
  57391. export class DepthReducer extends MinMaxReducer {
  57392. private _depthRenderer;
  57393. private _depthRendererId;
  57394. /**
  57395. * Gets the depth renderer used for the computation.
  57396. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57397. */
  57398. get depthRenderer(): Nullable<DepthRenderer>;
  57399. /**
  57400. * Creates a depth reducer
  57401. * @param camera The camera used to render the depth texture
  57402. */
  57403. constructor(camera: Camera);
  57404. /**
  57405. * Sets the depth renderer to use to generate the depth map
  57406. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57407. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57408. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57409. */
  57410. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57411. /** @hidden */
  57412. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57413. /**
  57414. * Activates the reduction computation.
  57415. * When activated, the observers registered in onAfterReductionPerformed are
  57416. * called after the compuation is performed
  57417. */
  57418. activate(): void;
  57419. /**
  57420. * Deactivates the reduction computation.
  57421. */
  57422. deactivate(): void;
  57423. /**
  57424. * Disposes the depth reducer
  57425. * @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.
  57426. */
  57427. dispose(disposeAll?: boolean): void;
  57428. }
  57429. }
  57430. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57431. import { Nullable } from "babylonjs/types";
  57432. import { Scene } from "babylonjs/scene";
  57433. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57436. import { Effect } from "babylonjs/Materials/effect";
  57437. import "babylonjs/Shaders/shadowMap.fragment";
  57438. import "babylonjs/Shaders/shadowMap.vertex";
  57439. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57440. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57441. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57442. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57443. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57444. /**
  57445. * A CSM implementation allowing casting shadows on large scenes.
  57446. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57447. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57448. */
  57449. export class CascadedShadowGenerator extends ShadowGenerator {
  57450. private static readonly frustumCornersNDCSpace;
  57451. /**
  57452. * Name of the CSM class
  57453. */
  57454. static CLASSNAME: string;
  57455. /**
  57456. * Defines the default number of cascades used by the CSM.
  57457. */
  57458. static readonly DEFAULT_CASCADES_COUNT: number;
  57459. /**
  57460. * Defines the minimum number of cascades used by the CSM.
  57461. */
  57462. static readonly MIN_CASCADES_COUNT: number;
  57463. /**
  57464. * Defines the maximum number of cascades used by the CSM.
  57465. */
  57466. static readonly MAX_CASCADES_COUNT: number;
  57467. protected _validateFilter(filter: number): number;
  57468. /**
  57469. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57470. */
  57471. penumbraDarkness: number;
  57472. private _numCascades;
  57473. /**
  57474. * Gets or set the number of cascades used by the CSM.
  57475. */
  57476. get numCascades(): number;
  57477. set numCascades(value: number);
  57478. /**
  57479. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57480. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57481. */
  57482. stabilizeCascades: boolean;
  57483. private _freezeShadowCastersBoundingInfo;
  57484. private _freezeShadowCastersBoundingInfoObservable;
  57485. /**
  57486. * Enables or disables the shadow casters bounding info computation.
  57487. * If your shadow casters don't move, you can disable this feature.
  57488. * If it is enabled, the bounding box computation is done every frame.
  57489. */
  57490. get freezeShadowCastersBoundingInfo(): boolean;
  57491. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57492. private _scbiMin;
  57493. private _scbiMax;
  57494. protected _computeShadowCastersBoundingInfo(): void;
  57495. protected _shadowCastersBoundingInfo: BoundingInfo;
  57496. /**
  57497. * Gets or sets the shadow casters bounding info.
  57498. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57499. * so that the system won't overwrite the bounds you provide
  57500. */
  57501. get shadowCastersBoundingInfo(): BoundingInfo;
  57502. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57503. protected _breaksAreDirty: boolean;
  57504. protected _minDistance: number;
  57505. protected _maxDistance: number;
  57506. /**
  57507. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57508. *
  57509. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57510. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57511. * @param min minimal distance for the breaks (default to 0.)
  57512. * @param max maximal distance for the breaks (default to 1.)
  57513. */
  57514. setMinMaxDistance(min: number, max: number): void;
  57515. /** Gets the minimal distance used in the cascade break computation */
  57516. get minDistance(): number;
  57517. /** Gets the maximal distance used in the cascade break computation */
  57518. get maxDistance(): number;
  57519. /**
  57520. * Gets the class name of that object
  57521. * @returns "CascadedShadowGenerator"
  57522. */
  57523. getClassName(): string;
  57524. private _cascadeMinExtents;
  57525. private _cascadeMaxExtents;
  57526. /**
  57527. * Gets a cascade minimum extents
  57528. * @param cascadeIndex index of the cascade
  57529. * @returns the minimum cascade extents
  57530. */
  57531. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57532. /**
  57533. * Gets a cascade maximum extents
  57534. * @param cascadeIndex index of the cascade
  57535. * @returns the maximum cascade extents
  57536. */
  57537. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57538. private _cascades;
  57539. private _currentLayer;
  57540. private _viewSpaceFrustumsZ;
  57541. private _viewMatrices;
  57542. private _projectionMatrices;
  57543. private _transformMatrices;
  57544. private _transformMatricesAsArray;
  57545. private _frustumLengths;
  57546. private _lightSizeUVCorrection;
  57547. private _depthCorrection;
  57548. private _frustumCornersWorldSpace;
  57549. private _frustumCenter;
  57550. private _shadowCameraPos;
  57551. private _shadowMaxZ;
  57552. /**
  57553. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57554. * It defaults to camera.maxZ
  57555. */
  57556. get shadowMaxZ(): number;
  57557. /**
  57558. * Sets the shadow max z distance.
  57559. */
  57560. set shadowMaxZ(value: number);
  57561. protected _debug: boolean;
  57562. /**
  57563. * Gets or sets the debug flag.
  57564. * When enabled, the cascades are materialized by different colors on the screen.
  57565. */
  57566. get debug(): boolean;
  57567. set debug(dbg: boolean);
  57568. private _depthClamp;
  57569. /**
  57570. * Gets or sets the depth clamping value.
  57571. *
  57572. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57573. * to account for the shadow casters far away.
  57574. *
  57575. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57576. */
  57577. get depthClamp(): boolean;
  57578. set depthClamp(value: boolean);
  57579. private _cascadeBlendPercentage;
  57580. /**
  57581. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57582. * It defaults to 0.1 (10% blending).
  57583. */
  57584. get cascadeBlendPercentage(): number;
  57585. set cascadeBlendPercentage(value: number);
  57586. private _lambda;
  57587. /**
  57588. * Gets or set the lambda parameter.
  57589. * This parameter is used to split the camera frustum and create the cascades.
  57590. * 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.
  57591. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57592. */
  57593. get lambda(): number;
  57594. set lambda(value: number);
  57595. /**
  57596. * Gets the view matrix corresponding to a given cascade
  57597. * @param cascadeNum cascade to retrieve the view matrix from
  57598. * @returns the cascade view matrix
  57599. */
  57600. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57601. /**
  57602. * Gets the projection matrix corresponding to a given cascade
  57603. * @param cascadeNum cascade to retrieve the projection matrix from
  57604. * @returns the cascade projection matrix
  57605. */
  57606. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57607. /**
  57608. * Gets the transformation matrix corresponding to a given cascade
  57609. * @param cascadeNum cascade to retrieve the transformation matrix from
  57610. * @returns the cascade transformation matrix
  57611. */
  57612. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57613. private _depthRenderer;
  57614. /**
  57615. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57616. *
  57617. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57618. *
  57619. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57620. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57621. * @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
  57622. */
  57623. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57624. private _depthReducer;
  57625. private _autoCalcDepthBounds;
  57626. /**
  57627. * Gets or sets the autoCalcDepthBounds property.
  57628. *
  57629. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57630. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57631. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57632. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57633. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57634. */
  57635. get autoCalcDepthBounds(): boolean;
  57636. set autoCalcDepthBounds(value: boolean);
  57637. /**
  57638. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57639. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57640. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57641. * for setting the refresh rate on the renderer yourself!
  57642. */
  57643. get autoCalcDepthBoundsRefreshRate(): number;
  57644. set autoCalcDepthBoundsRefreshRate(value: number);
  57645. /**
  57646. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57647. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57648. * you change the camera near/far planes!
  57649. */
  57650. splitFrustum(): void;
  57651. private _splitFrustum;
  57652. private _computeMatrices;
  57653. private _computeFrustumInWorldSpace;
  57654. private _computeCascadeFrustum;
  57655. /**
  57656. * Support test.
  57657. */
  57658. static get IsSupported(): boolean;
  57659. /** @hidden */
  57660. static _SceneComponentInitialization: (scene: Scene) => void;
  57661. /**
  57662. * Creates a Cascaded Shadow Generator object.
  57663. * A ShadowGenerator is the required tool to use the shadows.
  57664. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57665. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57666. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57667. * @param light The directional light object generating the shadows.
  57668. * @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.
  57669. */
  57670. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57671. protected _initializeGenerator(): void;
  57672. protected _createTargetRenderTexture(): void;
  57673. protected _initializeShadowMap(): void;
  57674. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57675. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57676. /**
  57677. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57678. * @param defines Defines of the material we want to update
  57679. * @param lightIndex Index of the light in the enabled light list of the material
  57680. */
  57681. prepareDefines(defines: any, lightIndex: number): void;
  57682. /**
  57683. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57684. * defined in the generator but impacting the effect).
  57685. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57686. * @param effect The effect we are binfing the information for
  57687. */
  57688. bindShadowLight(lightIndex: string, effect: Effect): void;
  57689. /**
  57690. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57691. * (eq to view projection * shadow projection matrices)
  57692. * @returns The transform matrix used to create the shadow map
  57693. */
  57694. getTransformMatrix(): Matrix;
  57695. /**
  57696. * Disposes the ShadowGenerator.
  57697. * Returns nothing.
  57698. */
  57699. dispose(): void;
  57700. /**
  57701. * Serializes the shadow generator setup to a json object.
  57702. * @returns The serialized JSON object
  57703. */
  57704. serialize(): any;
  57705. /**
  57706. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57707. * @param parsedShadowGenerator The JSON object to parse
  57708. * @param scene The scene to create the shadow map for
  57709. * @returns The parsed shadow generator
  57710. */
  57711. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57712. }
  57713. }
  57714. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57715. import { Scene } from "babylonjs/scene";
  57716. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57717. import { AbstractScene } from "babylonjs/abstractScene";
  57718. /**
  57719. * Defines the shadow generator component responsible to manage any shadow generators
  57720. * in a given scene.
  57721. */
  57722. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57723. /**
  57724. * The component name helpfull to identify the component in the list of scene components.
  57725. */
  57726. readonly name: string;
  57727. /**
  57728. * The scene the component belongs to.
  57729. */
  57730. scene: Scene;
  57731. /**
  57732. * Creates a new instance of the component for the given scene
  57733. * @param scene Defines the scene to register the component in
  57734. */
  57735. constructor(scene: Scene);
  57736. /**
  57737. * Registers the component in a given scene
  57738. */
  57739. register(): void;
  57740. /**
  57741. * Rebuilds the elements related to this component in case of
  57742. * context lost for instance.
  57743. */
  57744. rebuild(): void;
  57745. /**
  57746. * Serializes the component data to the specified json object
  57747. * @param serializationObject The object to serialize to
  57748. */
  57749. serialize(serializationObject: any): void;
  57750. /**
  57751. * Adds all the elements from the container to the scene
  57752. * @param container the container holding the elements
  57753. */
  57754. addFromContainer(container: AbstractScene): void;
  57755. /**
  57756. * Removes all the elements in the container from the scene
  57757. * @param container contains the elements to remove
  57758. * @param dispose if the removed element should be disposed (default: false)
  57759. */
  57760. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57761. /**
  57762. * Rebuilds the elements related to this component in case of
  57763. * context lost for instance.
  57764. */
  57765. dispose(): void;
  57766. private _gatherRenderTargets;
  57767. }
  57768. }
  57769. declare module "babylonjs/Lights/Shadows/index" {
  57770. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57771. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57772. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57773. }
  57774. declare module "babylonjs/Lights/pointLight" {
  57775. import { Scene } from "babylonjs/scene";
  57776. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57778. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57779. import { Effect } from "babylonjs/Materials/effect";
  57780. /**
  57781. * A point light is a light defined by an unique point in world space.
  57782. * The light is emitted in every direction from this point.
  57783. * A good example of a point light is a standard light bulb.
  57784. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57785. */
  57786. export class PointLight extends ShadowLight {
  57787. private _shadowAngle;
  57788. /**
  57789. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57790. * This specifies what angle the shadow will use to be created.
  57791. *
  57792. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57793. */
  57794. get shadowAngle(): number;
  57795. /**
  57796. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57797. * This specifies what angle the shadow will use to be created.
  57798. *
  57799. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57800. */
  57801. set shadowAngle(value: number);
  57802. /**
  57803. * Gets the direction if it has been set.
  57804. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57805. */
  57806. get direction(): Vector3;
  57807. /**
  57808. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57809. */
  57810. set direction(value: Vector3);
  57811. /**
  57812. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57813. * A PointLight emits the light in every direction.
  57814. * It can cast shadows.
  57815. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57816. * ```javascript
  57817. * var pointLight = new PointLight("pl", camera.position, scene);
  57818. * ```
  57819. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57820. * @param name The light friendly name
  57821. * @param position The position of the point light in the scene
  57822. * @param scene The scene the lights belongs to
  57823. */
  57824. constructor(name: string, position: Vector3, scene: Scene);
  57825. /**
  57826. * Returns the string "PointLight"
  57827. * @returns the class name
  57828. */
  57829. getClassName(): string;
  57830. /**
  57831. * Returns the integer 0.
  57832. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57833. */
  57834. getTypeID(): number;
  57835. /**
  57836. * Specifies wether or not the shadowmap should be a cube texture.
  57837. * @returns true if the shadowmap needs to be a cube texture.
  57838. */
  57839. needCube(): boolean;
  57840. /**
  57841. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57842. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57843. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57844. */
  57845. getShadowDirection(faceIndex?: number): Vector3;
  57846. /**
  57847. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57848. * - fov = PI / 2
  57849. * - aspect ratio : 1.0
  57850. * - z-near and far equal to the active camera minZ and maxZ.
  57851. * Returns the PointLight.
  57852. */
  57853. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57854. protected _buildUniformLayout(): void;
  57855. /**
  57856. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57857. * @param effect The effect to update
  57858. * @param lightIndex The index of the light in the effect to update
  57859. * @returns The point light
  57860. */
  57861. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57862. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57863. /**
  57864. * Prepares the list of defines specific to the light type.
  57865. * @param defines the list of defines
  57866. * @param lightIndex defines the index of the light for the effect
  57867. */
  57868. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57869. }
  57870. }
  57871. declare module "babylonjs/Lights/index" {
  57872. export * from "babylonjs/Lights/light";
  57873. export * from "babylonjs/Lights/shadowLight";
  57874. export * from "babylonjs/Lights/Shadows/index";
  57875. export * from "babylonjs/Lights/directionalLight";
  57876. export * from "babylonjs/Lights/hemisphericLight";
  57877. export * from "babylonjs/Lights/pointLight";
  57878. export * from "babylonjs/Lights/spotLight";
  57879. }
  57880. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57881. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57882. /**
  57883. * Header information of HDR texture files.
  57884. */
  57885. export interface HDRInfo {
  57886. /**
  57887. * The height of the texture in pixels.
  57888. */
  57889. height: number;
  57890. /**
  57891. * The width of the texture in pixels.
  57892. */
  57893. width: number;
  57894. /**
  57895. * The index of the beginning of the data in the binary file.
  57896. */
  57897. dataPosition: number;
  57898. }
  57899. /**
  57900. * This groups tools to convert HDR texture to native colors array.
  57901. */
  57902. export class HDRTools {
  57903. private static Ldexp;
  57904. private static Rgbe2float;
  57905. private static readStringLine;
  57906. /**
  57907. * Reads header information from an RGBE texture stored in a native array.
  57908. * More information on this format are available here:
  57909. * https://en.wikipedia.org/wiki/RGBE_image_format
  57910. *
  57911. * @param uint8array The binary file stored in native array.
  57912. * @return The header information.
  57913. */
  57914. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57915. /**
  57916. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57917. * This RGBE texture needs to store the information as a panorama.
  57918. *
  57919. * More information on this format are available here:
  57920. * https://en.wikipedia.org/wiki/RGBE_image_format
  57921. *
  57922. * @param buffer The binary file stored in an array buffer.
  57923. * @param size The expected size of the extracted cubemap.
  57924. * @return The Cube Map information.
  57925. */
  57926. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57927. /**
  57928. * Returns the pixels data extracted from an RGBE texture.
  57929. * This pixels will be stored left to right up to down in the R G B order in one array.
  57930. *
  57931. * More information on this format are available here:
  57932. * https://en.wikipedia.org/wiki/RGBE_image_format
  57933. *
  57934. * @param uint8array The binary file stored in an array buffer.
  57935. * @param hdrInfo The header information of the file.
  57936. * @return The pixels data in RGB right to left up to down order.
  57937. */
  57938. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57939. private static RGBE_ReadPixels_RLE;
  57940. }
  57941. }
  57942. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57943. import { Nullable } from "babylonjs/types";
  57944. import { Scene } from "babylonjs/scene";
  57945. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57947. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57948. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57949. /**
  57950. * This represents a texture coming from an HDR input.
  57951. *
  57952. * The only supported format is currently panorama picture stored in RGBE format.
  57953. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57954. */
  57955. export class HDRCubeTexture extends BaseTexture {
  57956. private static _facesMapping;
  57957. private _generateHarmonics;
  57958. private _noMipmap;
  57959. private _textureMatrix;
  57960. private _size;
  57961. private _onLoad;
  57962. private _onError;
  57963. /**
  57964. * The texture URL.
  57965. */
  57966. url: string;
  57967. /**
  57968. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57969. */
  57970. coordinatesMode: number;
  57971. protected _isBlocking: boolean;
  57972. /**
  57973. * Sets wether or not the texture is blocking during loading.
  57974. */
  57975. set isBlocking(value: boolean);
  57976. /**
  57977. * Gets wether or not the texture is blocking during loading.
  57978. */
  57979. get isBlocking(): boolean;
  57980. protected _rotationY: number;
  57981. /**
  57982. * Sets texture matrix rotation angle around Y axis in radians.
  57983. */
  57984. set rotationY(value: number);
  57985. /**
  57986. * Gets texture matrix rotation angle around Y axis radians.
  57987. */
  57988. get rotationY(): number;
  57989. /**
  57990. * Gets or sets the center of the bounding box associated with the cube texture
  57991. * It must define where the camera used to render the texture was set
  57992. */
  57993. boundingBoxPosition: Vector3;
  57994. private _boundingBoxSize;
  57995. /**
  57996. * Gets or sets the size of the bounding box associated with the cube texture
  57997. * When defined, the cubemap will switch to local mode
  57998. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57999. * @example https://www.babylonjs-playground.com/#RNASML
  58000. */
  58001. set boundingBoxSize(value: Vector3);
  58002. get boundingBoxSize(): Vector3;
  58003. /**
  58004. * Instantiates an HDRTexture from the following parameters.
  58005. *
  58006. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58007. * @param scene The scene the texture will be used in
  58008. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58009. * @param noMipmap Forces to not generate the mipmap if true
  58010. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58011. * @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)
  58012. * @param reserved Reserved flag for internal use.
  58013. */
  58014. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58015. /**
  58016. * Get the current class name of the texture useful for serialization or dynamic coding.
  58017. * @returns "HDRCubeTexture"
  58018. */
  58019. getClassName(): string;
  58020. /**
  58021. * Occurs when the file is raw .hdr file.
  58022. */
  58023. private loadTexture;
  58024. clone(): HDRCubeTexture;
  58025. delayLoad(): void;
  58026. /**
  58027. * Get the texture reflection matrix used to rotate/transform the reflection.
  58028. * @returns the reflection matrix
  58029. */
  58030. getReflectionTextureMatrix(): Matrix;
  58031. /**
  58032. * Set the texture reflection matrix used to rotate/transform the reflection.
  58033. * @param value Define the reflection matrix to set
  58034. */
  58035. setReflectionTextureMatrix(value: Matrix): void;
  58036. /**
  58037. * Parses a JSON representation of an HDR Texture in order to create the texture
  58038. * @param parsedTexture Define the JSON representation
  58039. * @param scene Define the scene the texture should be created in
  58040. * @param rootUrl Define the root url in case we need to load relative dependencies
  58041. * @returns the newly created texture after parsing
  58042. */
  58043. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58044. serialize(): any;
  58045. }
  58046. }
  58047. declare module "babylonjs/Physics/physicsEngine" {
  58048. import { Nullable } from "babylonjs/types";
  58049. import { Vector3 } from "babylonjs/Maths/math.vector";
  58050. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58051. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58052. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58053. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58054. /**
  58055. * Class used to control physics engine
  58056. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58057. */
  58058. export class PhysicsEngine implements IPhysicsEngine {
  58059. private _physicsPlugin;
  58060. /**
  58061. * Global value used to control the smallest number supported by the simulation
  58062. */
  58063. static Epsilon: number;
  58064. private _impostors;
  58065. private _joints;
  58066. private _subTimeStep;
  58067. /**
  58068. * Gets the gravity vector used by the simulation
  58069. */
  58070. gravity: Vector3;
  58071. /**
  58072. * Factory used to create the default physics plugin.
  58073. * @returns The default physics plugin
  58074. */
  58075. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58076. /**
  58077. * Creates a new Physics Engine
  58078. * @param gravity defines the gravity vector used by the simulation
  58079. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58080. */
  58081. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58082. /**
  58083. * Sets the gravity vector used by the simulation
  58084. * @param gravity defines the gravity vector to use
  58085. */
  58086. setGravity(gravity: Vector3): void;
  58087. /**
  58088. * Set the time step of the physics engine.
  58089. * Default is 1/60.
  58090. * To slow it down, enter 1/600 for example.
  58091. * To speed it up, 1/30
  58092. * @param newTimeStep defines the new timestep to apply to this world.
  58093. */
  58094. setTimeStep(newTimeStep?: number): void;
  58095. /**
  58096. * Get the time step of the physics engine.
  58097. * @returns the current time step
  58098. */
  58099. getTimeStep(): number;
  58100. /**
  58101. * Set the sub time step of the physics engine.
  58102. * Default is 0 meaning there is no sub steps
  58103. * To increase physics resolution precision, set a small value (like 1 ms)
  58104. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58105. */
  58106. setSubTimeStep(subTimeStep?: number): void;
  58107. /**
  58108. * Get the sub time step of the physics engine.
  58109. * @returns the current sub time step
  58110. */
  58111. getSubTimeStep(): number;
  58112. /**
  58113. * Release all resources
  58114. */
  58115. dispose(): void;
  58116. /**
  58117. * Gets the name of the current physics plugin
  58118. * @returns the name of the plugin
  58119. */
  58120. getPhysicsPluginName(): string;
  58121. /**
  58122. * Adding a new impostor for the impostor tracking.
  58123. * This will be done by the impostor itself.
  58124. * @param impostor the impostor to add
  58125. */
  58126. addImpostor(impostor: PhysicsImpostor): void;
  58127. /**
  58128. * Remove an impostor from the engine.
  58129. * This impostor and its mesh will not longer be updated by the physics engine.
  58130. * @param impostor the impostor to remove
  58131. */
  58132. removeImpostor(impostor: PhysicsImpostor): void;
  58133. /**
  58134. * Add a joint to the physics engine
  58135. * @param mainImpostor defines the main impostor to which the joint is added.
  58136. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58137. * @param joint defines the joint that will connect both impostors.
  58138. */
  58139. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58140. /**
  58141. * Removes a joint from the simulation
  58142. * @param mainImpostor defines the impostor used with the joint
  58143. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58144. * @param joint defines the joint to remove
  58145. */
  58146. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58147. /**
  58148. * Called by the scene. No need to call it.
  58149. * @param delta defines the timespam between frames
  58150. */
  58151. _step(delta: number): void;
  58152. /**
  58153. * Gets the current plugin used to run the simulation
  58154. * @returns current plugin
  58155. */
  58156. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58157. /**
  58158. * Gets the list of physic impostors
  58159. * @returns an array of PhysicsImpostor
  58160. */
  58161. getImpostors(): Array<PhysicsImpostor>;
  58162. /**
  58163. * Gets the impostor for a physics enabled object
  58164. * @param object defines the object impersonated by the impostor
  58165. * @returns the PhysicsImpostor or null if not found
  58166. */
  58167. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58168. /**
  58169. * Gets the impostor for a physics body object
  58170. * @param body defines physics body used by the impostor
  58171. * @returns the PhysicsImpostor or null if not found
  58172. */
  58173. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58174. /**
  58175. * Does a raycast in the physics world
  58176. * @param from when should the ray start?
  58177. * @param to when should the ray end?
  58178. * @returns PhysicsRaycastResult
  58179. */
  58180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58181. }
  58182. }
  58183. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58184. import { Nullable } from "babylonjs/types";
  58185. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58187. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58188. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58189. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58190. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58191. /** @hidden */
  58192. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58193. private _useDeltaForWorldStep;
  58194. world: any;
  58195. name: string;
  58196. private _physicsMaterials;
  58197. private _fixedTimeStep;
  58198. private _cannonRaycastResult;
  58199. private _raycastResult;
  58200. private _physicsBodysToRemoveAfterStep;
  58201. BJSCANNON: any;
  58202. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58203. setGravity(gravity: Vector3): void;
  58204. setTimeStep(timeStep: number): void;
  58205. getTimeStep(): number;
  58206. executeStep(delta: number): void;
  58207. private _removeMarkedPhysicsBodiesFromWorld;
  58208. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58209. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58210. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58211. private _processChildMeshes;
  58212. removePhysicsBody(impostor: PhysicsImpostor): void;
  58213. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58214. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58215. private _addMaterial;
  58216. private _checkWithEpsilon;
  58217. private _createShape;
  58218. private _createHeightmap;
  58219. private _minus90X;
  58220. private _plus90X;
  58221. private _tmpPosition;
  58222. private _tmpDeltaPosition;
  58223. private _tmpUnityRotation;
  58224. private _updatePhysicsBodyTransformation;
  58225. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58226. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58227. isSupported(): boolean;
  58228. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58229. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58230. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58231. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58232. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58233. getBodyMass(impostor: PhysicsImpostor): number;
  58234. getBodyFriction(impostor: PhysicsImpostor): number;
  58235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58236. getBodyRestitution(impostor: PhysicsImpostor): number;
  58237. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58238. sleepBody(impostor: PhysicsImpostor): void;
  58239. wakeUpBody(impostor: PhysicsImpostor): void;
  58240. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58241. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58242. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58243. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58244. getRadius(impostor: PhysicsImpostor): number;
  58245. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58246. dispose(): void;
  58247. private _extendNamespace;
  58248. /**
  58249. * Does a raycast in the physics world
  58250. * @param from when should the ray start?
  58251. * @param to when should the ray end?
  58252. * @returns PhysicsRaycastResult
  58253. */
  58254. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58255. }
  58256. }
  58257. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58258. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58259. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58260. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58262. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58263. import { Nullable } from "babylonjs/types";
  58264. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58265. /** @hidden */
  58266. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58267. private _useDeltaForWorldStep;
  58268. world: any;
  58269. name: string;
  58270. BJSOIMO: any;
  58271. private _raycastResult;
  58272. private _fixedTimeStep;
  58273. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58274. setGravity(gravity: Vector3): void;
  58275. setTimeStep(timeStep: number): void;
  58276. getTimeStep(): number;
  58277. private _tmpImpostorsArray;
  58278. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58279. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58280. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58281. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58282. private _tmpPositionVector;
  58283. removePhysicsBody(impostor: PhysicsImpostor): void;
  58284. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58285. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58286. isSupported(): boolean;
  58287. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58288. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58289. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58290. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58291. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58292. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58293. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58294. getBodyMass(impostor: PhysicsImpostor): number;
  58295. getBodyFriction(impostor: PhysicsImpostor): number;
  58296. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58297. getBodyRestitution(impostor: PhysicsImpostor): number;
  58298. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58299. sleepBody(impostor: PhysicsImpostor): void;
  58300. wakeUpBody(impostor: PhysicsImpostor): void;
  58301. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58302. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58303. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58304. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58305. getRadius(impostor: PhysicsImpostor): number;
  58306. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58307. dispose(): void;
  58308. /**
  58309. * Does a raycast in the physics world
  58310. * @param from when should the ray start?
  58311. * @param to when should the ray end?
  58312. * @returns PhysicsRaycastResult
  58313. */
  58314. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58315. }
  58316. }
  58317. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58318. import { Nullable } from "babylonjs/types";
  58319. import { Scene } from "babylonjs/scene";
  58320. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58321. import { Color4 } from "babylonjs/Maths/math.color";
  58322. import { Mesh } from "babylonjs/Meshes/mesh";
  58323. /**
  58324. * Class containing static functions to help procedurally build meshes
  58325. */
  58326. export class RibbonBuilder {
  58327. /**
  58328. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58329. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58330. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58331. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58332. * * 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
  58333. * * 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
  58334. * * 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
  58335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58337. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58338. * * 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
  58339. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58340. * * 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
  58341. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58343. * @param name defines the name of the mesh
  58344. * @param options defines the options used to create the mesh
  58345. * @param scene defines the hosting scene
  58346. * @returns the ribbon mesh
  58347. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58349. */
  58350. static CreateRibbon(name: string, options: {
  58351. pathArray: Vector3[][];
  58352. closeArray?: boolean;
  58353. closePath?: boolean;
  58354. offset?: number;
  58355. updatable?: boolean;
  58356. sideOrientation?: number;
  58357. frontUVs?: Vector4;
  58358. backUVs?: Vector4;
  58359. instance?: Mesh;
  58360. invertUV?: boolean;
  58361. uvs?: Vector2[];
  58362. colors?: Color4[];
  58363. }, scene?: Nullable<Scene>): Mesh;
  58364. }
  58365. }
  58366. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58367. import { Nullable } from "babylonjs/types";
  58368. import { Scene } from "babylonjs/scene";
  58369. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58370. import { Mesh } from "babylonjs/Meshes/mesh";
  58371. /**
  58372. * Class containing static functions to help procedurally build meshes
  58373. */
  58374. export class ShapeBuilder {
  58375. /**
  58376. * 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.
  58377. * * 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.
  58378. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58379. * * 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.
  58380. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58381. * * 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
  58382. * * 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
  58383. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58386. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58388. * @param name defines the name of the mesh
  58389. * @param options defines the options used to create the mesh
  58390. * @param scene defines the hosting scene
  58391. * @returns the extruded shape mesh
  58392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58394. */
  58395. static ExtrudeShape(name: string, options: {
  58396. shape: Vector3[];
  58397. path: Vector3[];
  58398. scale?: number;
  58399. rotation?: number;
  58400. cap?: number;
  58401. updatable?: boolean;
  58402. sideOrientation?: number;
  58403. frontUVs?: Vector4;
  58404. backUVs?: Vector4;
  58405. instance?: Mesh;
  58406. invertUV?: boolean;
  58407. }, scene?: Nullable<Scene>): Mesh;
  58408. /**
  58409. * Creates an custom extruded shape mesh.
  58410. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58411. * * 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.
  58412. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58413. * * 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
  58414. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58415. * * 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
  58416. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58417. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58418. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58419. * * 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
  58420. * * 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
  58421. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58426. * @param name defines the name of the mesh
  58427. * @param options defines the options used to create the mesh
  58428. * @param scene defines the hosting scene
  58429. * @returns the custom extruded shape mesh
  58430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58433. */
  58434. static ExtrudeShapeCustom(name: string, options: {
  58435. shape: Vector3[];
  58436. path: Vector3[];
  58437. scaleFunction?: any;
  58438. rotationFunction?: any;
  58439. ribbonCloseArray?: boolean;
  58440. ribbonClosePath?: boolean;
  58441. cap?: number;
  58442. updatable?: boolean;
  58443. sideOrientation?: number;
  58444. frontUVs?: Vector4;
  58445. backUVs?: Vector4;
  58446. instance?: Mesh;
  58447. invertUV?: boolean;
  58448. }, scene?: Nullable<Scene>): Mesh;
  58449. private static _ExtrudeShapeGeneric;
  58450. }
  58451. }
  58452. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58453. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58454. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58456. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58457. import { Nullable } from "babylonjs/types";
  58458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58459. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58460. /**
  58461. * AmmoJS Physics plugin
  58462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58463. * @see https://github.com/kripken/ammo.js/
  58464. */
  58465. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58466. private _useDeltaForWorldStep;
  58467. /**
  58468. * Reference to the Ammo library
  58469. */
  58470. bjsAMMO: any;
  58471. /**
  58472. * Created ammoJS world which physics bodies are added to
  58473. */
  58474. world: any;
  58475. /**
  58476. * Name of the plugin
  58477. */
  58478. name: string;
  58479. private _timeStep;
  58480. private _fixedTimeStep;
  58481. private _maxSteps;
  58482. private _tmpQuaternion;
  58483. private _tmpAmmoTransform;
  58484. private _tmpAmmoQuaternion;
  58485. private _tmpAmmoConcreteContactResultCallback;
  58486. private _collisionConfiguration;
  58487. private _dispatcher;
  58488. private _overlappingPairCache;
  58489. private _solver;
  58490. private _softBodySolver;
  58491. private _tmpAmmoVectorA;
  58492. private _tmpAmmoVectorB;
  58493. private _tmpAmmoVectorC;
  58494. private _tmpAmmoVectorD;
  58495. private _tmpContactCallbackResult;
  58496. private _tmpAmmoVectorRCA;
  58497. private _tmpAmmoVectorRCB;
  58498. private _raycastResult;
  58499. private static readonly DISABLE_COLLISION_FLAG;
  58500. private static readonly KINEMATIC_FLAG;
  58501. private static readonly DISABLE_DEACTIVATION_FLAG;
  58502. /**
  58503. * Initializes the ammoJS plugin
  58504. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58505. * @param ammoInjection can be used to inject your own ammo reference
  58506. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58507. */
  58508. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58509. /**
  58510. * Sets the gravity of the physics world (m/(s^2))
  58511. * @param gravity Gravity to set
  58512. */
  58513. setGravity(gravity: Vector3): void;
  58514. /**
  58515. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58516. * @param timeStep timestep to use in seconds
  58517. */
  58518. setTimeStep(timeStep: number): void;
  58519. /**
  58520. * 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)
  58521. * @param fixedTimeStep fixedTimeStep to use in seconds
  58522. */
  58523. setFixedTimeStep(fixedTimeStep: number): void;
  58524. /**
  58525. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58526. * @param maxSteps the maximum number of steps by the physics engine per frame
  58527. */
  58528. setMaxSteps(maxSteps: number): void;
  58529. /**
  58530. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58531. * @returns the current timestep in seconds
  58532. */
  58533. getTimeStep(): number;
  58534. /**
  58535. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58536. */
  58537. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58538. private _isImpostorInContact;
  58539. private _isImpostorPairInContact;
  58540. private _stepSimulation;
  58541. /**
  58542. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58543. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58544. * After the step the babylon meshes are set to the position of the physics imposters
  58545. * @param delta amount of time to step forward
  58546. * @param impostors array of imposters to update before/after the step
  58547. */
  58548. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58549. /**
  58550. * Update babylon mesh to match physics world object
  58551. * @param impostor imposter to match
  58552. */
  58553. private _afterSoftStep;
  58554. /**
  58555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58556. * @param impostor imposter to match
  58557. */
  58558. private _ropeStep;
  58559. /**
  58560. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58561. * @param impostor imposter to match
  58562. */
  58563. private _softbodyOrClothStep;
  58564. private _tmpMatrix;
  58565. /**
  58566. * Applies an impulse on the imposter
  58567. * @param impostor imposter to apply impulse to
  58568. * @param force amount of force to be applied to the imposter
  58569. * @param contactPoint the location to apply the impulse on the imposter
  58570. */
  58571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58572. /**
  58573. * Applies a force on the imposter
  58574. * @param impostor imposter to apply force
  58575. * @param force amount of force to be applied to the imposter
  58576. * @param contactPoint the location to apply the force on the imposter
  58577. */
  58578. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58579. /**
  58580. * Creates a physics body using the plugin
  58581. * @param impostor the imposter to create the physics body on
  58582. */
  58583. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58584. /**
  58585. * Removes the physics body from the imposter and disposes of the body's memory
  58586. * @param impostor imposter to remove the physics body from
  58587. */
  58588. removePhysicsBody(impostor: PhysicsImpostor): void;
  58589. /**
  58590. * Generates a joint
  58591. * @param impostorJoint the imposter joint to create the joint with
  58592. */
  58593. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58594. /**
  58595. * Removes a joint
  58596. * @param impostorJoint the imposter joint to remove the joint from
  58597. */
  58598. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58599. private _addMeshVerts;
  58600. /**
  58601. * Initialise the soft body vertices to match its object's (mesh) vertices
  58602. * Softbody vertices (nodes) are in world space and to match this
  58603. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58604. * @param impostor to create the softbody for
  58605. */
  58606. private _softVertexData;
  58607. /**
  58608. * Create an impostor's soft body
  58609. * @param impostor to create the softbody for
  58610. */
  58611. private _createSoftbody;
  58612. /**
  58613. * Create cloth for an impostor
  58614. * @param impostor to create the softbody for
  58615. */
  58616. private _createCloth;
  58617. /**
  58618. * Create rope for an impostor
  58619. * @param impostor to create the softbody for
  58620. */
  58621. private _createRope;
  58622. /**
  58623. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58624. * @param impostor to create the custom physics shape for
  58625. */
  58626. private _createCustom;
  58627. private _addHullVerts;
  58628. private _createShape;
  58629. /**
  58630. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58631. * @param impostor imposter containing the physics body and babylon object
  58632. */
  58633. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58634. /**
  58635. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58636. * @param impostor imposter containing the physics body and babylon object
  58637. * @param newPosition new position
  58638. * @param newRotation new rotation
  58639. */
  58640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58641. /**
  58642. * If this plugin is supported
  58643. * @returns true if its supported
  58644. */
  58645. isSupported(): boolean;
  58646. /**
  58647. * Sets the linear velocity of the physics body
  58648. * @param impostor imposter to set the velocity on
  58649. * @param velocity velocity to set
  58650. */
  58651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58652. /**
  58653. * Sets the angular velocity of the physics body
  58654. * @param impostor imposter to set the velocity on
  58655. * @param velocity velocity to set
  58656. */
  58657. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58658. /**
  58659. * gets the linear velocity
  58660. * @param impostor imposter to get linear velocity from
  58661. * @returns linear velocity
  58662. */
  58663. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58664. /**
  58665. * gets the angular velocity
  58666. * @param impostor imposter to get angular velocity from
  58667. * @returns angular velocity
  58668. */
  58669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58670. /**
  58671. * Sets the mass of physics body
  58672. * @param impostor imposter to set the mass on
  58673. * @param mass mass to set
  58674. */
  58675. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58676. /**
  58677. * Gets the mass of the physics body
  58678. * @param impostor imposter to get the mass from
  58679. * @returns mass
  58680. */
  58681. getBodyMass(impostor: PhysicsImpostor): number;
  58682. /**
  58683. * Gets friction of the impostor
  58684. * @param impostor impostor to get friction from
  58685. * @returns friction value
  58686. */
  58687. getBodyFriction(impostor: PhysicsImpostor): number;
  58688. /**
  58689. * Sets friction of the impostor
  58690. * @param impostor impostor to set friction on
  58691. * @param friction friction value
  58692. */
  58693. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58694. /**
  58695. * Gets restitution of the impostor
  58696. * @param impostor impostor to get restitution from
  58697. * @returns restitution value
  58698. */
  58699. getBodyRestitution(impostor: PhysicsImpostor): number;
  58700. /**
  58701. * Sets resitution of the impostor
  58702. * @param impostor impostor to set resitution on
  58703. * @param restitution resitution value
  58704. */
  58705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58706. /**
  58707. * Gets pressure inside the impostor
  58708. * @param impostor impostor to get pressure from
  58709. * @returns pressure value
  58710. */
  58711. getBodyPressure(impostor: PhysicsImpostor): number;
  58712. /**
  58713. * Sets pressure inside a soft body impostor
  58714. * Cloth and rope must remain 0 pressure
  58715. * @param impostor impostor to set pressure on
  58716. * @param pressure pressure value
  58717. */
  58718. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58719. /**
  58720. * Gets stiffness of the impostor
  58721. * @param impostor impostor to get stiffness from
  58722. * @returns pressure value
  58723. */
  58724. getBodyStiffness(impostor: PhysicsImpostor): number;
  58725. /**
  58726. * Sets stiffness of the impostor
  58727. * @param impostor impostor to set stiffness on
  58728. * @param stiffness stiffness value from 0 to 1
  58729. */
  58730. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58731. /**
  58732. * Gets velocityIterations of the impostor
  58733. * @param impostor impostor to get velocity iterations from
  58734. * @returns velocityIterations value
  58735. */
  58736. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58737. /**
  58738. * Sets velocityIterations of the impostor
  58739. * @param impostor impostor to set velocity iterations on
  58740. * @param velocityIterations velocityIterations value
  58741. */
  58742. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58743. /**
  58744. * Gets positionIterations of the impostor
  58745. * @param impostor impostor to get position iterations from
  58746. * @returns positionIterations value
  58747. */
  58748. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58749. /**
  58750. * Sets positionIterations of the impostor
  58751. * @param impostor impostor to set position on
  58752. * @param positionIterations positionIterations value
  58753. */
  58754. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58755. /**
  58756. * Append an anchor to a cloth object
  58757. * @param impostor is the cloth impostor to add anchor to
  58758. * @param otherImpostor is the rigid impostor to anchor to
  58759. * @param width ratio across width from 0 to 1
  58760. * @param height ratio up height from 0 to 1
  58761. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58763. */
  58764. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58765. /**
  58766. * Append an hook to a rope object
  58767. * @param impostor is the rope impostor to add hook to
  58768. * @param otherImpostor is the rigid impostor to hook to
  58769. * @param length ratio along the rope from 0 to 1
  58770. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58771. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58772. */
  58773. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58774. /**
  58775. * Sleeps the physics body and stops it from being active
  58776. * @param impostor impostor to sleep
  58777. */
  58778. sleepBody(impostor: PhysicsImpostor): void;
  58779. /**
  58780. * Activates the physics body
  58781. * @param impostor impostor to activate
  58782. */
  58783. wakeUpBody(impostor: PhysicsImpostor): void;
  58784. /**
  58785. * Updates the distance parameters of the joint
  58786. * @param joint joint to update
  58787. * @param maxDistance maximum distance of the joint
  58788. * @param minDistance minimum distance of the joint
  58789. */
  58790. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58791. /**
  58792. * Sets a motor on the joint
  58793. * @param joint joint to set motor on
  58794. * @param speed speed of the motor
  58795. * @param maxForce maximum force of the motor
  58796. * @param motorIndex index of the motor
  58797. */
  58798. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58799. /**
  58800. * Sets the motors limit
  58801. * @param joint joint to set limit on
  58802. * @param upperLimit upper limit
  58803. * @param lowerLimit lower limit
  58804. */
  58805. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58806. /**
  58807. * Syncs the position and rotation of a mesh with the impostor
  58808. * @param mesh mesh to sync
  58809. * @param impostor impostor to update the mesh with
  58810. */
  58811. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58812. /**
  58813. * Gets the radius of the impostor
  58814. * @param impostor impostor to get radius from
  58815. * @returns the radius
  58816. */
  58817. getRadius(impostor: PhysicsImpostor): number;
  58818. /**
  58819. * Gets the box size of the impostor
  58820. * @param impostor impostor to get box size from
  58821. * @param result the resulting box size
  58822. */
  58823. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58824. /**
  58825. * Disposes of the impostor
  58826. */
  58827. dispose(): void;
  58828. /**
  58829. * Does a raycast in the physics world
  58830. * @param from when should the ray start?
  58831. * @param to when should the ray end?
  58832. * @returns PhysicsRaycastResult
  58833. */
  58834. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58835. }
  58836. }
  58837. declare module "babylonjs/Probes/reflectionProbe" {
  58838. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58839. import { Vector3 } from "babylonjs/Maths/math.vector";
  58840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58841. import { Nullable } from "babylonjs/types";
  58842. import { Scene } from "babylonjs/scene";
  58843. module "babylonjs/abstractScene" {
  58844. interface AbstractScene {
  58845. /**
  58846. * The list of reflection probes added to the scene
  58847. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58848. */
  58849. reflectionProbes: Array<ReflectionProbe>;
  58850. /**
  58851. * Removes the given reflection probe from this scene.
  58852. * @param toRemove The reflection probe to remove
  58853. * @returns The index of the removed reflection probe
  58854. */
  58855. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58856. /**
  58857. * Adds the given reflection probe to this scene.
  58858. * @param newReflectionProbe The reflection probe to add
  58859. */
  58860. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58861. }
  58862. }
  58863. /**
  58864. * Class used to generate realtime reflection / refraction cube textures
  58865. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58866. */
  58867. export class ReflectionProbe {
  58868. /** defines the name of the probe */
  58869. name: string;
  58870. private _scene;
  58871. private _renderTargetTexture;
  58872. private _projectionMatrix;
  58873. private _viewMatrix;
  58874. private _target;
  58875. private _add;
  58876. private _attachedMesh;
  58877. private _invertYAxis;
  58878. /** Gets or sets probe position (center of the cube map) */
  58879. position: Vector3;
  58880. /**
  58881. * Creates a new reflection probe
  58882. * @param name defines the name of the probe
  58883. * @param size defines the texture resolution (for each face)
  58884. * @param scene defines the hosting scene
  58885. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58886. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58887. */
  58888. constructor(
  58889. /** defines the name of the probe */
  58890. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58891. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58892. get samples(): number;
  58893. set samples(value: number);
  58894. /** Gets or sets the refresh rate to use (on every frame by default) */
  58895. get refreshRate(): number;
  58896. set refreshRate(value: number);
  58897. /**
  58898. * Gets the hosting scene
  58899. * @returns a Scene
  58900. */
  58901. getScene(): Scene;
  58902. /** Gets the internal CubeTexture used to render to */
  58903. get cubeTexture(): RenderTargetTexture;
  58904. /** Gets the list of meshes to render */
  58905. get renderList(): Nullable<AbstractMesh[]>;
  58906. /**
  58907. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58908. * @param mesh defines the mesh to attach to
  58909. */
  58910. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58911. /**
  58912. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58913. * @param renderingGroupId The rendering group id corresponding to its index
  58914. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58915. */
  58916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58917. /**
  58918. * Clean all associated resources
  58919. */
  58920. dispose(): void;
  58921. /**
  58922. * Converts the reflection probe information to a readable string for debug purpose.
  58923. * @param fullDetails Supports for multiple levels of logging within scene loading
  58924. * @returns the human readable reflection probe info
  58925. */
  58926. toString(fullDetails?: boolean): string;
  58927. /**
  58928. * Get the class name of the relfection probe.
  58929. * @returns "ReflectionProbe"
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58934. * @returns The JSON representation of the texture
  58935. */
  58936. serialize(): any;
  58937. /**
  58938. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58939. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58940. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58941. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58942. * @returns The parsed reflection probe if successful
  58943. */
  58944. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58945. }
  58946. }
  58947. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58948. /** @hidden */
  58949. export var _BabylonLoaderRegistered: boolean;
  58950. /**
  58951. * Helps setting up some configuration for the babylon file loader.
  58952. */
  58953. export class BabylonFileLoaderConfiguration {
  58954. /**
  58955. * The loader does not allow injecting custom physix engine into the plugins.
  58956. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58957. * So you could set this variable to your engine import to make it work.
  58958. */
  58959. static LoaderInjectedPhysicsEngine: any;
  58960. }
  58961. }
  58962. declare module "babylonjs/Loading/Plugins/index" {
  58963. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58964. }
  58965. declare module "babylonjs/Loading/index" {
  58966. export * from "babylonjs/Loading/loadingScreen";
  58967. export * from "babylonjs/Loading/Plugins/index";
  58968. export * from "babylonjs/Loading/sceneLoader";
  58969. export * from "babylonjs/Loading/sceneLoaderFlags";
  58970. }
  58971. declare module "babylonjs/Materials/Background/index" {
  58972. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58973. }
  58974. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58975. import { Scene } from "babylonjs/scene";
  58976. import { Color3 } from "babylonjs/Maths/math.color";
  58977. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58979. /**
  58980. * The Physically based simple base material of BJS.
  58981. *
  58982. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58983. * It is used as the base class for both the specGloss and metalRough conventions.
  58984. */
  58985. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58986. /**
  58987. * Number of Simultaneous lights allowed on the material.
  58988. */
  58989. maxSimultaneousLights: number;
  58990. /**
  58991. * If sets to true, disables all the lights affecting the material.
  58992. */
  58993. disableLighting: boolean;
  58994. /**
  58995. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58996. */
  58997. environmentTexture: BaseTexture;
  58998. /**
  58999. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59000. */
  59001. invertNormalMapX: boolean;
  59002. /**
  59003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59004. */
  59005. invertNormalMapY: boolean;
  59006. /**
  59007. * Normal map used in the model.
  59008. */
  59009. normalTexture: BaseTexture;
  59010. /**
  59011. * Emissivie color used to self-illuminate the model.
  59012. */
  59013. emissiveColor: Color3;
  59014. /**
  59015. * Emissivie texture used to self-illuminate the model.
  59016. */
  59017. emissiveTexture: BaseTexture;
  59018. /**
  59019. * Occlusion Channel Strenght.
  59020. */
  59021. occlusionStrength: number;
  59022. /**
  59023. * Occlusion Texture of the material (adding extra occlusion effects).
  59024. */
  59025. occlusionTexture: BaseTexture;
  59026. /**
  59027. * Defines the alpha limits in alpha test mode.
  59028. */
  59029. alphaCutOff: number;
  59030. /**
  59031. * Gets the current double sided mode.
  59032. */
  59033. get doubleSided(): boolean;
  59034. /**
  59035. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59036. */
  59037. set doubleSided(value: boolean);
  59038. /**
  59039. * Stores the pre-calculated light information of a mesh in a texture.
  59040. */
  59041. lightmapTexture: BaseTexture;
  59042. /**
  59043. * If true, the light map contains occlusion information instead of lighting info.
  59044. */
  59045. useLightmapAsShadowmap: boolean;
  59046. /**
  59047. * Instantiates a new PBRMaterial instance.
  59048. *
  59049. * @param name The material name
  59050. * @param scene The scene the material will be use in.
  59051. */
  59052. constructor(name: string, scene: Scene);
  59053. getClassName(): string;
  59054. }
  59055. }
  59056. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59057. import { Scene } from "babylonjs/scene";
  59058. import { Color3 } from "babylonjs/Maths/math.color";
  59059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59060. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59061. /**
  59062. * The PBR material of BJS following the metal roughness convention.
  59063. *
  59064. * This fits to the PBR convention in the GLTF definition:
  59065. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59066. */
  59067. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59068. /**
  59069. * The base color has two different interpretations depending on the value of metalness.
  59070. * When the material is a metal, the base color is the specific measured reflectance value
  59071. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59072. * of the material.
  59073. */
  59074. baseColor: Color3;
  59075. /**
  59076. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59077. * well as opacity information in the alpha channel.
  59078. */
  59079. baseTexture: BaseTexture;
  59080. /**
  59081. * Specifies the metallic scalar value of the material.
  59082. * Can also be used to scale the metalness values of the metallic texture.
  59083. */
  59084. metallic: number;
  59085. /**
  59086. * Specifies the roughness scalar value of the material.
  59087. * Can also be used to scale the roughness values of the metallic texture.
  59088. */
  59089. roughness: number;
  59090. /**
  59091. * Texture containing both the metallic value in the B channel and the
  59092. * roughness value in the G channel to keep better precision.
  59093. */
  59094. metallicRoughnessTexture: BaseTexture;
  59095. /**
  59096. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59097. *
  59098. * @param name The material name
  59099. * @param scene The scene the material will be use in.
  59100. */
  59101. constructor(name: string, scene: Scene);
  59102. /**
  59103. * Return the currrent class name of the material.
  59104. */
  59105. getClassName(): string;
  59106. /**
  59107. * Makes a duplicate of the current material.
  59108. * @param name - name to use for the new material.
  59109. */
  59110. clone(name: string): PBRMetallicRoughnessMaterial;
  59111. /**
  59112. * Serialize the material to a parsable JSON object.
  59113. */
  59114. serialize(): any;
  59115. /**
  59116. * Parses a JSON object correponding to the serialize function.
  59117. */
  59118. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59119. }
  59120. }
  59121. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59122. import { Scene } from "babylonjs/scene";
  59123. import { Color3 } from "babylonjs/Maths/math.color";
  59124. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59125. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59126. /**
  59127. * The PBR material of BJS following the specular glossiness convention.
  59128. *
  59129. * This fits to the PBR convention in the GLTF definition:
  59130. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59131. */
  59132. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59133. /**
  59134. * Specifies the diffuse color of the material.
  59135. */
  59136. diffuseColor: Color3;
  59137. /**
  59138. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59139. * channel.
  59140. */
  59141. diffuseTexture: BaseTexture;
  59142. /**
  59143. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59144. */
  59145. specularColor: Color3;
  59146. /**
  59147. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59148. */
  59149. glossiness: number;
  59150. /**
  59151. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59152. */
  59153. specularGlossinessTexture: BaseTexture;
  59154. /**
  59155. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59156. *
  59157. * @param name The material name
  59158. * @param scene The scene the material will be use in.
  59159. */
  59160. constructor(name: string, scene: Scene);
  59161. /**
  59162. * Return the currrent class name of the material.
  59163. */
  59164. getClassName(): string;
  59165. /**
  59166. * Makes a duplicate of the current material.
  59167. * @param name - name to use for the new material.
  59168. */
  59169. clone(name: string): PBRSpecularGlossinessMaterial;
  59170. /**
  59171. * Serialize the material to a parsable JSON object.
  59172. */
  59173. serialize(): any;
  59174. /**
  59175. * Parses a JSON object correponding to the serialize function.
  59176. */
  59177. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59178. }
  59179. }
  59180. declare module "babylonjs/Materials/PBR/index" {
  59181. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59182. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59183. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59184. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59185. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59186. }
  59187. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59188. import { Nullable } from "babylonjs/types";
  59189. import { Scene } from "babylonjs/scene";
  59190. import { Matrix } from "babylonjs/Maths/math.vector";
  59191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59192. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59193. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59194. /**
  59195. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59196. * It can help converting any input color in a desired output one. This can then be used to create effects
  59197. * from sepia, black and white to sixties or futuristic rendering...
  59198. *
  59199. * The only supported format is currently 3dl.
  59200. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59201. */
  59202. export class ColorGradingTexture extends BaseTexture {
  59203. /**
  59204. * The texture URL.
  59205. */
  59206. url: string;
  59207. /**
  59208. * Empty line regex stored for GC.
  59209. */
  59210. private static _noneEmptyLineRegex;
  59211. private _textureMatrix;
  59212. private _engine;
  59213. private _onLoad;
  59214. /**
  59215. * Instantiates a ColorGradingTexture from the following parameters.
  59216. *
  59217. * @param url The location of the color gradind data (currently only supporting 3dl)
  59218. * @param sceneOrEngine The scene or engine the texture will be used in
  59219. * @param onLoad defines a callback triggered when the texture has been loaded
  59220. */
  59221. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59222. /**
  59223. * Fires the onload event from the constructor if requested.
  59224. */
  59225. private _triggerOnLoad;
  59226. /**
  59227. * Returns the texture matrix used in most of the material.
  59228. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59229. */
  59230. getTextureMatrix(): Matrix;
  59231. /**
  59232. * Occurs when the file being loaded is a .3dl LUT file.
  59233. */
  59234. private load3dlTexture;
  59235. /**
  59236. * Starts the loading process of the texture.
  59237. */
  59238. private loadTexture;
  59239. /**
  59240. * Clones the color gradind texture.
  59241. */
  59242. clone(): ColorGradingTexture;
  59243. /**
  59244. * Called during delayed load for textures.
  59245. */
  59246. delayLoad(): void;
  59247. /**
  59248. * Parses a color grading texture serialized by Babylon.
  59249. * @param parsedTexture The texture information being parsedTexture
  59250. * @param scene The scene to load the texture in
  59251. * @param rootUrl The root url of the data assets to load
  59252. * @return A color gradind texture
  59253. */
  59254. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59255. /**
  59256. * Serializes the LUT texture to json format.
  59257. */
  59258. serialize(): any;
  59259. /**
  59260. * Returns true if the passed parameter is a scene object (can be use for typings)
  59261. * @param sceneOrEngine The object to test.
  59262. */
  59263. private static _isScene;
  59264. }
  59265. }
  59266. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59268. import { Scene } from "babylonjs/scene";
  59269. import { Nullable } from "babylonjs/types";
  59270. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59271. /**
  59272. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59273. */
  59274. export class EquiRectangularCubeTexture extends BaseTexture {
  59275. /** The six faces of the cube. */
  59276. private static _FacesMapping;
  59277. private _noMipmap;
  59278. private _onLoad;
  59279. private _onError;
  59280. /** The size of the cubemap. */
  59281. private _size;
  59282. /** The buffer of the image. */
  59283. private _buffer;
  59284. /** The width of the input image. */
  59285. private _width;
  59286. /** The height of the input image. */
  59287. private _height;
  59288. /** The URL to the image. */
  59289. url: string;
  59290. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59291. coordinatesMode: number;
  59292. /**
  59293. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59294. * @param url The location of the image
  59295. * @param scene The scene the texture will be used in
  59296. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59297. * @param noMipmap Forces to not generate the mipmap if true
  59298. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59299. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59300. * @param onLoad — defines a callback called when texture is loaded
  59301. * @param onError — defines a callback called if there is an error
  59302. */
  59303. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59304. /**
  59305. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59306. */
  59307. private loadImage;
  59308. /**
  59309. * Convert the image buffer into a cubemap and create a CubeTexture.
  59310. */
  59311. private loadTexture;
  59312. /**
  59313. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59314. * @param buffer The ArrayBuffer that should be converted.
  59315. * @returns The buffer as Float32Array.
  59316. */
  59317. private getFloat32ArrayFromArrayBuffer;
  59318. /**
  59319. * Get the current class name of the texture useful for serialization or dynamic coding.
  59320. * @returns "EquiRectangularCubeTexture"
  59321. */
  59322. getClassName(): string;
  59323. /**
  59324. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59325. * @returns A clone of the current EquiRectangularCubeTexture.
  59326. */
  59327. clone(): EquiRectangularCubeTexture;
  59328. }
  59329. }
  59330. declare module "babylonjs/Misc/tga" {
  59331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59332. /**
  59333. * Based on jsTGALoader - Javascript loader for TGA file
  59334. * By Vincent Thibault
  59335. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59336. */
  59337. export class TGATools {
  59338. private static _TYPE_INDEXED;
  59339. private static _TYPE_RGB;
  59340. private static _TYPE_GREY;
  59341. private static _TYPE_RLE_INDEXED;
  59342. private static _TYPE_RLE_RGB;
  59343. private static _TYPE_RLE_GREY;
  59344. private static _ORIGIN_MASK;
  59345. private static _ORIGIN_SHIFT;
  59346. private static _ORIGIN_BL;
  59347. private static _ORIGIN_BR;
  59348. private static _ORIGIN_UL;
  59349. private static _ORIGIN_UR;
  59350. /**
  59351. * Gets the header of a TGA file
  59352. * @param data defines the TGA data
  59353. * @returns the header
  59354. */
  59355. static GetTGAHeader(data: Uint8Array): any;
  59356. /**
  59357. * Uploads TGA content to a Babylon Texture
  59358. * @hidden
  59359. */
  59360. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59361. /** @hidden */
  59362. 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;
  59363. /** @hidden */
  59364. 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;
  59365. /** @hidden */
  59366. 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;
  59367. /** @hidden */
  59368. 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;
  59369. /** @hidden */
  59370. 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;
  59371. /** @hidden */
  59372. 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;
  59373. }
  59374. }
  59375. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59376. import { Nullable } from "babylonjs/types";
  59377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59378. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59379. /**
  59380. * Implementation of the TGA Texture Loader.
  59381. * @hidden
  59382. */
  59383. export class _TGATextureLoader implements IInternalTextureLoader {
  59384. /**
  59385. * Defines wether the loader supports cascade loading the different faces.
  59386. */
  59387. readonly supportCascades: boolean;
  59388. /**
  59389. * This returns if the loader support the current file information.
  59390. * @param extension defines the file extension of the file being loaded
  59391. * @returns true if the loader can load the specified file
  59392. */
  59393. canLoad(extension: string): boolean;
  59394. /**
  59395. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59396. * @param data contains the texture data
  59397. * @param texture defines the BabylonJS internal texture
  59398. * @param createPolynomials will be true if polynomials have been requested
  59399. * @param onLoad defines the callback to trigger once the texture is ready
  59400. * @param onError defines the callback to trigger in case of error
  59401. */
  59402. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59403. /**
  59404. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59405. * @param data contains the texture data
  59406. * @param texture defines the BabylonJS internal texture
  59407. * @param callback defines the method to call once ready to upload
  59408. */
  59409. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59410. }
  59411. }
  59412. declare module "babylonjs/Misc/basis" {
  59413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59414. /**
  59415. * Info about the .basis files
  59416. */
  59417. class BasisFileInfo {
  59418. /**
  59419. * If the file has alpha
  59420. */
  59421. hasAlpha: boolean;
  59422. /**
  59423. * Info about each image of the basis file
  59424. */
  59425. images: Array<{
  59426. levels: Array<{
  59427. width: number;
  59428. height: number;
  59429. transcodedPixels: ArrayBufferView;
  59430. }>;
  59431. }>;
  59432. }
  59433. /**
  59434. * Result of transcoding a basis file
  59435. */
  59436. class TranscodeResult {
  59437. /**
  59438. * Info about the .basis file
  59439. */
  59440. fileInfo: BasisFileInfo;
  59441. /**
  59442. * Format to use when loading the file
  59443. */
  59444. format: number;
  59445. }
  59446. /**
  59447. * Configuration options for the Basis transcoder
  59448. */
  59449. export class BasisTranscodeConfiguration {
  59450. /**
  59451. * Supported compression formats used to determine the supported output format of the transcoder
  59452. */
  59453. supportedCompressionFormats?: {
  59454. /**
  59455. * etc1 compression format
  59456. */
  59457. etc1?: boolean;
  59458. /**
  59459. * s3tc compression format
  59460. */
  59461. s3tc?: boolean;
  59462. /**
  59463. * pvrtc compression format
  59464. */
  59465. pvrtc?: boolean;
  59466. /**
  59467. * etc2 compression format
  59468. */
  59469. etc2?: boolean;
  59470. };
  59471. /**
  59472. * If mipmap levels should be loaded for transcoded images (Default: true)
  59473. */
  59474. loadMipmapLevels?: boolean;
  59475. /**
  59476. * Index of a single image to load (Default: all images)
  59477. */
  59478. loadSingleImage?: number;
  59479. }
  59480. /**
  59481. * Used to load .Basis files
  59482. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59483. */
  59484. export class BasisTools {
  59485. private static _IgnoreSupportedFormats;
  59486. /**
  59487. * URL to use when loading the basis transcoder
  59488. */
  59489. static JSModuleURL: string;
  59490. /**
  59491. * URL to use when loading the wasm module for the transcoder
  59492. */
  59493. static WasmModuleURL: string;
  59494. /**
  59495. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59496. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59497. * @returns internal format corresponding to the Basis format
  59498. */
  59499. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59500. private static _WorkerPromise;
  59501. private static _Worker;
  59502. private static _actionId;
  59503. private static _CreateWorkerAsync;
  59504. /**
  59505. * Transcodes a loaded image file to compressed pixel data
  59506. * @param data image data to transcode
  59507. * @param config configuration options for the transcoding
  59508. * @returns a promise resulting in the transcoded image
  59509. */
  59510. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59511. /**
  59512. * Loads a texture from the transcode result
  59513. * @param texture texture load to
  59514. * @param transcodeResult the result of transcoding the basis file to load from
  59515. */
  59516. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59517. }
  59518. }
  59519. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59520. import { Nullable } from "babylonjs/types";
  59521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59522. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59523. /**
  59524. * Loader for .basis file format
  59525. */
  59526. export class _BasisTextureLoader implements IInternalTextureLoader {
  59527. /**
  59528. * Defines whether the loader supports cascade loading the different faces.
  59529. */
  59530. readonly supportCascades: boolean;
  59531. /**
  59532. * This returns if the loader support the current file information.
  59533. * @param extension defines the file extension of the file being loaded
  59534. * @returns true if the loader can load the specified file
  59535. */
  59536. canLoad(extension: string): boolean;
  59537. /**
  59538. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59539. * @param data contains the texture data
  59540. * @param texture defines the BabylonJS internal texture
  59541. * @param createPolynomials will be true if polynomials have been requested
  59542. * @param onLoad defines the callback to trigger once the texture is ready
  59543. * @param onError defines the callback to trigger in case of error
  59544. */
  59545. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59546. /**
  59547. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59548. * @param data contains the texture data
  59549. * @param texture defines the BabylonJS internal texture
  59550. * @param callback defines the method to call once ready to upload
  59551. */
  59552. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59553. }
  59554. }
  59555. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59556. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59557. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59558. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59559. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59560. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59561. }
  59562. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59563. import { Scene } from "babylonjs/scene";
  59564. import { Texture } from "babylonjs/Materials/Textures/texture";
  59565. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59566. /**
  59567. * 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.
  59568. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59569. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59570. */
  59571. export class CustomProceduralTexture extends ProceduralTexture {
  59572. private _animate;
  59573. private _time;
  59574. private _config;
  59575. private _texturePath;
  59576. /**
  59577. * Instantiates a new Custom Procedural Texture.
  59578. * 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.
  59579. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59580. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59581. * @param name Define the name of the texture
  59582. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59583. * @param size Define the size of the texture to create
  59584. * @param scene Define the scene the texture belongs to
  59585. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59586. * @param generateMipMaps Define if the texture should creates mip maps or not
  59587. */
  59588. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59589. private _loadJson;
  59590. /**
  59591. * Is the texture ready to be used ? (rendered at least once)
  59592. * @returns true if ready, otherwise, false.
  59593. */
  59594. isReady(): boolean;
  59595. /**
  59596. * Render the texture to its associated render target.
  59597. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59598. */
  59599. render(useCameraPostProcess?: boolean): void;
  59600. /**
  59601. * Update the list of dependant textures samplers in the shader.
  59602. */
  59603. updateTextures(): void;
  59604. /**
  59605. * Update the uniform values of the procedural texture in the shader.
  59606. */
  59607. updateShaderUniforms(): void;
  59608. /**
  59609. * Define if the texture animates or not.
  59610. */
  59611. get animate(): boolean;
  59612. set animate(value: boolean);
  59613. }
  59614. }
  59615. declare module "babylonjs/Shaders/noise.fragment" {
  59616. /** @hidden */
  59617. export var noisePixelShader: {
  59618. name: string;
  59619. shader: string;
  59620. };
  59621. }
  59622. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59623. import { Nullable } from "babylonjs/types";
  59624. import { Scene } from "babylonjs/scene";
  59625. import { Texture } from "babylonjs/Materials/Textures/texture";
  59626. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59627. import "babylonjs/Shaders/noise.fragment";
  59628. /**
  59629. * Class used to generate noise procedural textures
  59630. */
  59631. export class NoiseProceduralTexture extends ProceduralTexture {
  59632. private _time;
  59633. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59634. brightness: number;
  59635. /** Defines the number of octaves to process */
  59636. octaves: number;
  59637. /** Defines the level of persistence (0.8 by default) */
  59638. persistence: number;
  59639. /** Gets or sets animation speed factor (default is 1) */
  59640. animationSpeedFactor: number;
  59641. /**
  59642. * Creates a new NoiseProceduralTexture
  59643. * @param name defines the name fo the texture
  59644. * @param size defines the size of the texture (default is 256)
  59645. * @param scene defines the hosting scene
  59646. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59647. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59648. */
  59649. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59650. private _updateShaderUniforms;
  59651. protected _getDefines(): string;
  59652. /** Generate the current state of the procedural texture */
  59653. render(useCameraPostProcess?: boolean): void;
  59654. /**
  59655. * Serializes this noise procedural texture
  59656. * @returns a serialized noise procedural texture object
  59657. */
  59658. serialize(): any;
  59659. /**
  59660. * Clone the texture.
  59661. * @returns the cloned texture
  59662. */
  59663. clone(): NoiseProceduralTexture;
  59664. /**
  59665. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59666. * @param parsedTexture defines parsed texture data
  59667. * @param scene defines the current scene
  59668. * @param rootUrl defines the root URL containing noise procedural texture information
  59669. * @returns a parsed NoiseProceduralTexture
  59670. */
  59671. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59672. }
  59673. }
  59674. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59675. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59676. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59677. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59678. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59679. }
  59680. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59681. import { Nullable } from "babylonjs/types";
  59682. import { Scene } from "babylonjs/scene";
  59683. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59685. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59686. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59687. /**
  59688. * Raw cube texture where the raw buffers are passed in
  59689. */
  59690. export class RawCubeTexture extends CubeTexture {
  59691. /**
  59692. * Creates a cube texture where the raw buffers are passed in.
  59693. * @param scene defines the scene the texture is attached to
  59694. * @param data defines the array of data to use to create each face
  59695. * @param size defines the size of the textures
  59696. * @param format defines the format of the data
  59697. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59698. * @param generateMipMaps defines if the engine should generate the mip levels
  59699. * @param invertY defines if data must be stored with Y axis inverted
  59700. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59701. * @param compression defines the compression used (null by default)
  59702. */
  59703. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59704. /**
  59705. * Updates the raw cube texture.
  59706. * @param data defines the data to store
  59707. * @param format defines the data format
  59708. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59709. * @param invertY defines if data must be stored with Y axis inverted
  59710. * @param compression defines the compression used (null by default)
  59711. * @param level defines which level of the texture to update
  59712. */
  59713. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59714. /**
  59715. * Updates a raw cube texture with RGBD encoded data.
  59716. * @param data defines the array of data [mipmap][face] to use to create each face
  59717. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59718. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59719. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59720. * @returns a promsie that resolves when the operation is complete
  59721. */
  59722. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59723. /**
  59724. * Clones the raw cube texture.
  59725. * @return a new cube texture
  59726. */
  59727. clone(): CubeTexture;
  59728. /** @hidden */
  59729. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59730. }
  59731. }
  59732. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59733. import { Scene } from "babylonjs/scene";
  59734. import { Texture } from "babylonjs/Materials/Textures/texture";
  59735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59736. /**
  59737. * Class used to store 3D textures containing user data
  59738. */
  59739. export class RawTexture3D extends Texture {
  59740. /** Gets or sets the texture format to use */
  59741. format: number;
  59742. private _engine;
  59743. /**
  59744. * Create a new RawTexture3D
  59745. * @param data defines the data of the texture
  59746. * @param width defines the width of the texture
  59747. * @param height defines the height of the texture
  59748. * @param depth defines the depth of the texture
  59749. * @param format defines the texture format to use
  59750. * @param scene defines the hosting scene
  59751. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59752. * @param invertY defines if texture must be stored with Y axis inverted
  59753. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59754. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59755. */
  59756. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59757. /** Gets or sets the texture format to use */
  59758. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59759. /**
  59760. * Update the texture with new data
  59761. * @param data defines the data to store in the texture
  59762. */
  59763. update(data: ArrayBufferView): void;
  59764. }
  59765. }
  59766. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59767. import { Scene } from "babylonjs/scene";
  59768. import { Texture } from "babylonjs/Materials/Textures/texture";
  59769. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59770. /**
  59771. * Class used to store 2D array textures containing user data
  59772. */
  59773. export class RawTexture2DArray extends Texture {
  59774. /** Gets or sets the texture format to use */
  59775. format: number;
  59776. private _engine;
  59777. /**
  59778. * Create a new RawTexture2DArray
  59779. * @param data defines the data of the texture
  59780. * @param width defines the width of the texture
  59781. * @param height defines the height of the texture
  59782. * @param depth defines the number of layers of the texture
  59783. * @param format defines the texture format to use
  59784. * @param scene defines the hosting scene
  59785. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59786. * @param invertY defines if texture must be stored with Y axis inverted
  59787. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59789. */
  59790. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59791. /** Gets or sets the texture format to use */
  59792. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59793. /**
  59794. * Update the texture with new data
  59795. * @param data defines the data to store in the texture
  59796. */
  59797. update(data: ArrayBufferView): void;
  59798. }
  59799. }
  59800. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59801. import { Scene } from "babylonjs/scene";
  59802. import { Plane } from "babylonjs/Maths/math.plane";
  59803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59804. /**
  59805. * Creates a refraction texture used by refraction channel of the standard material.
  59806. * It is like a mirror but to see through a material.
  59807. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59808. */
  59809. export class RefractionTexture extends RenderTargetTexture {
  59810. /**
  59811. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59812. * 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.
  59813. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59814. */
  59815. refractionPlane: Plane;
  59816. /**
  59817. * Define how deep under the surface we should see.
  59818. */
  59819. depth: number;
  59820. /**
  59821. * Creates a refraction texture used by refraction channel of the standard material.
  59822. * It is like a mirror but to see through a material.
  59823. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59824. * @param name Define the texture name
  59825. * @param size Define the size of the underlying texture
  59826. * @param scene Define the scene the refraction belongs to
  59827. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59828. */
  59829. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59830. /**
  59831. * Clone the refraction texture.
  59832. * @returns the cloned texture
  59833. */
  59834. clone(): RefractionTexture;
  59835. /**
  59836. * Serialize the texture to a JSON representation you could use in Parse later on
  59837. * @returns the serialized JSON representation
  59838. */
  59839. serialize(): any;
  59840. }
  59841. }
  59842. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59843. import { Nullable } from "babylonjs/types";
  59844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59845. import { Matrix } from "babylonjs/Maths/math.vector";
  59846. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59847. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59848. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59849. import { Scene } from "babylonjs/scene";
  59850. /**
  59851. * Defines the options related to the creation of an HtmlElementTexture
  59852. */
  59853. export interface IHtmlElementTextureOptions {
  59854. /**
  59855. * Defines wether mip maps should be created or not.
  59856. */
  59857. generateMipMaps?: boolean;
  59858. /**
  59859. * Defines the sampling mode of the texture.
  59860. */
  59861. samplingMode?: number;
  59862. /**
  59863. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59864. */
  59865. engine: Nullable<ThinEngine>;
  59866. /**
  59867. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59868. */
  59869. scene: Nullable<Scene>;
  59870. }
  59871. /**
  59872. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59873. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59874. * is automatically managed.
  59875. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59876. * in your application.
  59877. *
  59878. * As the update is not automatic, you need to call them manually.
  59879. */
  59880. export class HtmlElementTexture extends BaseTexture {
  59881. /**
  59882. * The texture URL.
  59883. */
  59884. element: HTMLVideoElement | HTMLCanvasElement;
  59885. private static readonly DefaultOptions;
  59886. private _textureMatrix;
  59887. private _engine;
  59888. private _isVideo;
  59889. private _generateMipMaps;
  59890. private _samplingMode;
  59891. /**
  59892. * Instantiates a HtmlElementTexture from the following parameters.
  59893. *
  59894. * @param name Defines the name of the texture
  59895. * @param element Defines the video or canvas the texture is filled with
  59896. * @param options Defines the other none mandatory texture creation options
  59897. */
  59898. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59899. private _createInternalTexture;
  59900. /**
  59901. * Returns the texture matrix used in most of the material.
  59902. */
  59903. getTextureMatrix(): Matrix;
  59904. /**
  59905. * Updates the content of the texture.
  59906. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59907. */
  59908. update(invertY?: Nullable<boolean>): void;
  59909. }
  59910. }
  59911. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59912. import { Vector2 } from "babylonjs/Maths/math.vector";
  59913. /**
  59914. * Defines the basic options interface of a TexturePacker Frame
  59915. */
  59916. export interface ITexturePackerFrame {
  59917. /**
  59918. * The frame ID
  59919. */
  59920. id: number;
  59921. /**
  59922. * The frames Scale
  59923. */
  59924. scale: Vector2;
  59925. /**
  59926. * The Frames offset
  59927. */
  59928. offset: Vector2;
  59929. }
  59930. /**
  59931. * This is a support class for frame Data on texture packer sets.
  59932. */
  59933. export class TexturePackerFrame implements ITexturePackerFrame {
  59934. /**
  59935. * The frame ID
  59936. */
  59937. id: number;
  59938. /**
  59939. * The frames Scale
  59940. */
  59941. scale: Vector2;
  59942. /**
  59943. * The Frames offset
  59944. */
  59945. offset: Vector2;
  59946. /**
  59947. * Initializes a texture package frame.
  59948. * @param id The numerical frame identifier
  59949. * @param scale Scalar Vector2 for UV frame
  59950. * @param offset Vector2 for the frame position in UV units.
  59951. * @returns TexturePackerFrame
  59952. */
  59953. constructor(id: number, scale: Vector2, offset: Vector2);
  59954. }
  59955. }
  59956. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59958. import { Scene } from "babylonjs/scene";
  59959. import { Nullable } from "babylonjs/types";
  59960. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59961. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59962. /**
  59963. * Defines the basic options interface of a TexturePacker
  59964. */
  59965. export interface ITexturePackerOptions {
  59966. /**
  59967. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59968. */
  59969. map?: string[];
  59970. /**
  59971. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59972. */
  59973. uvsIn?: string;
  59974. /**
  59975. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59976. */
  59977. uvsOut?: string;
  59978. /**
  59979. * number representing the layout style. Defaults to LAYOUT_STRIP
  59980. */
  59981. layout?: number;
  59982. /**
  59983. * number of columns if using custom column count layout(2). This defaults to 4.
  59984. */
  59985. colnum?: number;
  59986. /**
  59987. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59988. */
  59989. updateInputMeshes?: boolean;
  59990. /**
  59991. * boolean flag to dispose all the source textures. Defaults to true.
  59992. */
  59993. disposeSources?: boolean;
  59994. /**
  59995. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59996. */
  59997. fillBlanks?: boolean;
  59998. /**
  59999. * string value representing the context fill style color. Defaults to 'black'.
  60000. */
  60001. customFillColor?: string;
  60002. /**
  60003. * Width and Height Value of each Frame in the TexturePacker Sets
  60004. */
  60005. frameSize?: number;
  60006. /**
  60007. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60008. */
  60009. paddingRatio?: number;
  60010. /**
  60011. * Number that declares the fill method for the padding gutter.
  60012. */
  60013. paddingMode?: number;
  60014. /**
  60015. * If in SUBUV_COLOR padding mode what color to use.
  60016. */
  60017. paddingColor?: Color3 | Color4;
  60018. }
  60019. /**
  60020. * Defines the basic interface of a TexturePacker JSON File
  60021. */
  60022. export interface ITexturePackerJSON {
  60023. /**
  60024. * The frame ID
  60025. */
  60026. name: string;
  60027. /**
  60028. * The base64 channel data
  60029. */
  60030. sets: any;
  60031. /**
  60032. * The options of the Packer
  60033. */
  60034. options: ITexturePackerOptions;
  60035. /**
  60036. * The frame data of the Packer
  60037. */
  60038. frames: Array<number>;
  60039. }
  60040. /**
  60041. * This is a support class that generates a series of packed texture sets.
  60042. * @see https://doc.babylonjs.com/babylon101/materials
  60043. */
  60044. export class TexturePacker {
  60045. /** Packer Layout Constant 0 */
  60046. static readonly LAYOUT_STRIP: number;
  60047. /** Packer Layout Constant 1 */
  60048. static readonly LAYOUT_POWER2: number;
  60049. /** Packer Layout Constant 2 */
  60050. static readonly LAYOUT_COLNUM: number;
  60051. /** Packer Layout Constant 0 */
  60052. static readonly SUBUV_WRAP: number;
  60053. /** Packer Layout Constant 1 */
  60054. static readonly SUBUV_EXTEND: number;
  60055. /** Packer Layout Constant 2 */
  60056. static readonly SUBUV_COLOR: number;
  60057. /** The Name of the Texture Package */
  60058. name: string;
  60059. /** The scene scope of the TexturePacker */
  60060. scene: Scene;
  60061. /** The Meshes to target */
  60062. meshes: AbstractMesh[];
  60063. /** Arguments passed with the Constructor */
  60064. options: ITexturePackerOptions;
  60065. /** The promise that is started upon initialization */
  60066. promise: Nullable<Promise<TexturePacker | string>>;
  60067. /** The Container object for the channel sets that are generated */
  60068. sets: object;
  60069. /** The Container array for the frames that are generated */
  60070. frames: TexturePackerFrame[];
  60071. /** The expected number of textures the system is parsing. */
  60072. private _expecting;
  60073. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60074. private _paddingValue;
  60075. /**
  60076. * Initializes a texture package series from an array of meshes or a single mesh.
  60077. * @param name The name of the package
  60078. * @param meshes The target meshes to compose the package from
  60079. * @param options The arguments that texture packer should follow while building.
  60080. * @param scene The scene which the textures are scoped to.
  60081. * @returns TexturePacker
  60082. */
  60083. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60084. /**
  60085. * Starts the package process
  60086. * @param resolve The promises resolution function
  60087. * @returns TexturePacker
  60088. */
  60089. private _createFrames;
  60090. /**
  60091. * Calculates the Size of the Channel Sets
  60092. * @returns Vector2
  60093. */
  60094. private _calculateSize;
  60095. /**
  60096. * Calculates the UV data for the frames.
  60097. * @param baseSize the base frameSize
  60098. * @param padding the base frame padding
  60099. * @param dtSize size of the Dynamic Texture for that channel
  60100. * @param dtUnits is 1/dtSize
  60101. * @param update flag to update the input meshes
  60102. */
  60103. private _calculateMeshUVFrames;
  60104. /**
  60105. * Calculates the frames Offset.
  60106. * @param index of the frame
  60107. * @returns Vector2
  60108. */
  60109. private _getFrameOffset;
  60110. /**
  60111. * Updates a Mesh to the frame data
  60112. * @param mesh that is the target
  60113. * @param frameID or the frame index
  60114. */
  60115. private _updateMeshUV;
  60116. /**
  60117. * Updates a Meshes materials to use the texture packer channels
  60118. * @param m is the mesh to target
  60119. * @param force all channels on the packer to be set.
  60120. */
  60121. private _updateTextureReferences;
  60122. /**
  60123. * Public method to set a Mesh to a frame
  60124. * @param m that is the target
  60125. * @param frameID or the frame index
  60126. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60127. */
  60128. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60129. /**
  60130. * Starts the async promise to compile the texture packer.
  60131. * @returns Promise<void>
  60132. */
  60133. processAsync(): Promise<void>;
  60134. /**
  60135. * Disposes all textures associated with this packer
  60136. */
  60137. dispose(): void;
  60138. /**
  60139. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60140. * @param imageType is the image type to use.
  60141. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60142. */
  60143. download(imageType?: string, quality?: number): void;
  60144. /**
  60145. * Public method to load a texturePacker JSON file.
  60146. * @param data of the JSON file in string format.
  60147. */
  60148. updateFromJSON(data: string): void;
  60149. }
  60150. }
  60151. declare module "babylonjs/Materials/Textures/Packer/index" {
  60152. export * from "babylonjs/Materials/Textures/Packer/packer";
  60153. export * from "babylonjs/Materials/Textures/Packer/frame";
  60154. }
  60155. declare module "babylonjs/Materials/Textures/index" {
  60156. export * from "babylonjs/Materials/Textures/baseTexture";
  60157. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60158. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60159. export * from "babylonjs/Materials/Textures/cubeTexture";
  60160. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60161. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60162. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60163. export * from "babylonjs/Materials/Textures/internalTexture";
  60164. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60165. export * from "babylonjs/Materials/Textures/Loaders/index";
  60166. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60167. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60168. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60169. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60170. export * from "babylonjs/Materials/Textures/rawTexture";
  60171. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60172. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60173. export * from "babylonjs/Materials/Textures/refractionTexture";
  60174. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60175. export * from "babylonjs/Materials/Textures/texture";
  60176. export * from "babylonjs/Materials/Textures/videoTexture";
  60177. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60178. export * from "babylonjs/Materials/Textures/Packer/index";
  60179. }
  60180. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60181. /**
  60182. * Enum used to define the target of a block
  60183. */
  60184. export enum NodeMaterialBlockTargets {
  60185. /** Vertex shader */
  60186. Vertex = 1,
  60187. /** Fragment shader */
  60188. Fragment = 2,
  60189. /** Neutral */
  60190. Neutral = 4,
  60191. /** Vertex and Fragment */
  60192. VertexAndFragment = 3
  60193. }
  60194. }
  60195. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60196. /**
  60197. * Defines the kind of connection point for node based material
  60198. */
  60199. export enum NodeMaterialBlockConnectionPointTypes {
  60200. /** Float */
  60201. Float = 1,
  60202. /** Int */
  60203. Int = 2,
  60204. /** Vector2 */
  60205. Vector2 = 4,
  60206. /** Vector3 */
  60207. Vector3 = 8,
  60208. /** Vector4 */
  60209. Vector4 = 16,
  60210. /** Color3 */
  60211. Color3 = 32,
  60212. /** Color4 */
  60213. Color4 = 64,
  60214. /** Matrix */
  60215. Matrix = 128,
  60216. /** Custom object */
  60217. Object = 256,
  60218. /** Detect type based on connection */
  60219. AutoDetect = 1024,
  60220. /** Output type that will be defined by input type */
  60221. BasedOnInput = 2048
  60222. }
  60223. }
  60224. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60225. /**
  60226. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60227. */
  60228. export enum NodeMaterialBlockConnectionPointMode {
  60229. /** Value is an uniform */
  60230. Uniform = 0,
  60231. /** Value is a mesh attribute */
  60232. Attribute = 1,
  60233. /** Value is a varying between vertex and fragment shaders */
  60234. Varying = 2,
  60235. /** Mode is undefined */
  60236. Undefined = 3
  60237. }
  60238. }
  60239. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60240. /**
  60241. * Enum used to define system values e.g. values automatically provided by the system
  60242. */
  60243. export enum NodeMaterialSystemValues {
  60244. /** World */
  60245. World = 1,
  60246. /** View */
  60247. View = 2,
  60248. /** Projection */
  60249. Projection = 3,
  60250. /** ViewProjection */
  60251. ViewProjection = 4,
  60252. /** WorldView */
  60253. WorldView = 5,
  60254. /** WorldViewProjection */
  60255. WorldViewProjection = 6,
  60256. /** CameraPosition */
  60257. CameraPosition = 7,
  60258. /** Fog Color */
  60259. FogColor = 8,
  60260. /** Delta time */
  60261. DeltaTime = 9
  60262. }
  60263. }
  60264. declare module "babylonjs/Materials/Node/Enums/index" {
  60265. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60266. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60267. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60268. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60269. }
  60270. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60272. /**
  60273. * Root class for all node material optimizers
  60274. */
  60275. export class NodeMaterialOptimizer {
  60276. /**
  60277. * Function used to optimize a NodeMaterial graph
  60278. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60279. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60280. */
  60281. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60282. }
  60283. }
  60284. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60288. import { Scene } from "babylonjs/scene";
  60289. /**
  60290. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60291. */
  60292. export class TransformBlock extends NodeMaterialBlock {
  60293. /**
  60294. * Defines the value to use to complement W value to transform it to a Vector4
  60295. */
  60296. complementW: number;
  60297. /**
  60298. * Defines the value to use to complement z value to transform it to a Vector4
  60299. */
  60300. complementZ: number;
  60301. /**
  60302. * Creates a new TransformBlock
  60303. * @param name defines the block name
  60304. */
  60305. constructor(name: string);
  60306. /**
  60307. * Gets the current class name
  60308. * @returns the class name
  60309. */
  60310. getClassName(): string;
  60311. /**
  60312. * Gets the vector input
  60313. */
  60314. get vector(): NodeMaterialConnectionPoint;
  60315. /**
  60316. * Gets the output component
  60317. */
  60318. get output(): NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the xyz output component
  60321. */
  60322. get xyz(): NodeMaterialConnectionPoint;
  60323. /**
  60324. * Gets the matrix transform input
  60325. */
  60326. get transform(): NodeMaterialConnectionPoint;
  60327. protected _buildBlock(state: NodeMaterialBuildState): this;
  60328. serialize(): any;
  60329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60330. protected _dumpPropertiesCode(): string;
  60331. }
  60332. }
  60333. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60337. /**
  60338. * Block used to output the vertex position
  60339. */
  60340. export class VertexOutputBlock extends NodeMaterialBlock {
  60341. /**
  60342. * Creates a new VertexOutputBlock
  60343. * @param name defines the block name
  60344. */
  60345. constructor(name: string);
  60346. /**
  60347. * Gets the current class name
  60348. * @returns the class name
  60349. */
  60350. getClassName(): string;
  60351. /**
  60352. * Gets the vector input component
  60353. */
  60354. get vector(): NodeMaterialConnectionPoint;
  60355. protected _buildBlock(state: NodeMaterialBuildState): this;
  60356. }
  60357. }
  60358. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60362. /**
  60363. * Block used to output the final color
  60364. */
  60365. export class FragmentOutputBlock extends NodeMaterialBlock {
  60366. /**
  60367. * Create a new FragmentOutputBlock
  60368. * @param name defines the block name
  60369. */
  60370. constructor(name: string);
  60371. /**
  60372. * Gets the current class name
  60373. * @returns the class name
  60374. */
  60375. getClassName(): string;
  60376. /**
  60377. * Gets the rgba input component
  60378. */
  60379. get rgba(): NodeMaterialConnectionPoint;
  60380. /**
  60381. * Gets the rgb input component
  60382. */
  60383. get rgb(): NodeMaterialConnectionPoint;
  60384. /**
  60385. * Gets the a input component
  60386. */
  60387. get a(): NodeMaterialConnectionPoint;
  60388. protected _buildBlock(state: NodeMaterialBuildState): this;
  60389. }
  60390. }
  60391. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60397. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60398. import { Effect } from "babylonjs/Materials/effect";
  60399. import { Mesh } from "babylonjs/Meshes/mesh";
  60400. import { Nullable } from "babylonjs/types";
  60401. import { Scene } from "babylonjs/scene";
  60402. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60403. /**
  60404. * Base block used to read a reflection texture from a sampler
  60405. */
  60406. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60407. /** @hidden */
  60408. _define3DName: string;
  60409. /** @hidden */
  60410. _defineCubicName: string;
  60411. /** @hidden */
  60412. _defineExplicitName: string;
  60413. /** @hidden */
  60414. _defineProjectionName: string;
  60415. /** @hidden */
  60416. _defineLocalCubicName: string;
  60417. /** @hidden */
  60418. _defineSphericalName: string;
  60419. /** @hidden */
  60420. _definePlanarName: string;
  60421. /** @hidden */
  60422. _defineEquirectangularName: string;
  60423. /** @hidden */
  60424. _defineMirroredEquirectangularFixedName: string;
  60425. /** @hidden */
  60426. _defineEquirectangularFixedName: string;
  60427. /** @hidden */
  60428. _defineSkyboxName: string;
  60429. /** @hidden */
  60430. _defineOppositeZ: string;
  60431. /** @hidden */
  60432. _cubeSamplerName: string;
  60433. /** @hidden */
  60434. _2DSamplerName: string;
  60435. protected _positionUVWName: string;
  60436. protected _directionWName: string;
  60437. protected _reflectionVectorName: string;
  60438. /** @hidden */
  60439. _reflectionCoordsName: string;
  60440. /** @hidden */
  60441. _reflectionMatrixName: string;
  60442. protected _reflectionColorName: string;
  60443. /**
  60444. * Gets or sets the texture associated with the node
  60445. */
  60446. texture: Nullable<BaseTexture>;
  60447. /**
  60448. * Create a new ReflectionTextureBaseBlock
  60449. * @param name defines the block name
  60450. */
  60451. constructor(name: string);
  60452. /**
  60453. * Gets the current class name
  60454. * @returns the class name
  60455. */
  60456. getClassName(): string;
  60457. /**
  60458. * Gets the world position input component
  60459. */
  60460. abstract get position(): NodeMaterialConnectionPoint;
  60461. /**
  60462. * Gets the world position input component
  60463. */
  60464. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60465. /**
  60466. * Gets the world normal input component
  60467. */
  60468. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the world input component
  60471. */
  60472. abstract get world(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the camera (or eye) position component
  60475. */
  60476. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60477. /**
  60478. * Gets the view input component
  60479. */
  60480. abstract get view(): NodeMaterialConnectionPoint;
  60481. protected _getTexture(): Nullable<BaseTexture>;
  60482. autoConfigure(material: NodeMaterial): void;
  60483. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60484. isReady(): boolean;
  60485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60486. /**
  60487. * Gets the code to inject in the vertex shader
  60488. * @param state current state of the node material building
  60489. * @returns the shader code
  60490. */
  60491. handleVertexSide(state: NodeMaterialBuildState): string;
  60492. /**
  60493. * Handles the inits for the fragment code path
  60494. * @param state node material build state
  60495. */
  60496. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60497. /**
  60498. * Generates the reflection coords code for the fragment code path
  60499. * @param worldNormalVarName name of the world normal variable
  60500. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60501. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60502. * @returns the shader code
  60503. */
  60504. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60505. /**
  60506. * Generates the reflection color code for the fragment code path
  60507. * @param lodVarName name of the lod variable
  60508. * @param swizzleLookupTexture swizzle to use for the final color variable
  60509. * @returns the shader code
  60510. */
  60511. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60512. /**
  60513. * Generates the code corresponding to the connected output points
  60514. * @param state node material build state
  60515. * @param varName name of the variable to output
  60516. * @returns the shader code
  60517. */
  60518. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60519. protected _buildBlock(state: NodeMaterialBuildState): this;
  60520. protected _dumpPropertiesCode(): string;
  60521. serialize(): any;
  60522. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60523. }
  60524. }
  60525. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60527. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60528. import { Nullable } from "babylonjs/types";
  60529. /**
  60530. * Defines a connection point to be used for points with a custom object type
  60531. */
  60532. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60533. private _blockType;
  60534. private _blockName;
  60535. private _nameForCheking?;
  60536. /**
  60537. * Creates a new connection point
  60538. * @param name defines the connection point name
  60539. * @param ownerBlock defines the block hosting this connection point
  60540. * @param direction defines the direction of the connection point
  60541. */
  60542. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60543. /**
  60544. * Gets a number indicating if the current point can be connected to another point
  60545. * @param connectionPoint defines the other connection point
  60546. * @returns a number defining the compatibility state
  60547. */
  60548. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60549. /**
  60550. * Creates a block suitable to be used as an input for this input point.
  60551. * If null is returned, a block based on the point type will be created.
  60552. * @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
  60553. */
  60554. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60555. }
  60556. }
  60557. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60558. /**
  60559. * Enum defining the type of properties that can be edited in the property pages in the NME
  60560. */
  60561. export enum PropertyTypeForEdition {
  60562. /** property is a boolean */
  60563. Boolean = 0,
  60564. /** property is a float */
  60565. Float = 1,
  60566. /** property is a Vector2 */
  60567. Vector2 = 2,
  60568. /** property is a list of values */
  60569. List = 3
  60570. }
  60571. /**
  60572. * Interface that defines an option in a variable of type list
  60573. */
  60574. export interface IEditablePropertyListOption {
  60575. /** label of the option */
  60576. "label": string;
  60577. /** value of the option */
  60578. "value": number;
  60579. }
  60580. /**
  60581. * Interface that defines the options available for an editable property
  60582. */
  60583. export interface IEditablePropertyOption {
  60584. /** min value */
  60585. "min"?: number;
  60586. /** max value */
  60587. "max"?: number;
  60588. /** notifiers: indicates which actions to take when the property is changed */
  60589. "notifiers"?: {
  60590. /** the material should be rebuilt */
  60591. "rebuild"?: boolean;
  60592. /** the preview should be updated */
  60593. "update"?: boolean;
  60594. };
  60595. /** list of the options for a variable of type list */
  60596. "options"?: IEditablePropertyListOption[];
  60597. }
  60598. /**
  60599. * Interface that describes an editable property
  60600. */
  60601. export interface IPropertyDescriptionForEdition {
  60602. /** name of the property */
  60603. "propertyName": string;
  60604. /** display name of the property */
  60605. "displayName": string;
  60606. /** type of the property */
  60607. "type": PropertyTypeForEdition;
  60608. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60609. "groupName": string;
  60610. /** options for the property */
  60611. "options": IEditablePropertyOption;
  60612. }
  60613. /**
  60614. * Decorator that flags a property in a node material block as being editable
  60615. */
  60616. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60617. }
  60618. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60621. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60623. import { Nullable } from "babylonjs/types";
  60624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60625. import { Mesh } from "babylonjs/Meshes/mesh";
  60626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60627. import { Effect } from "babylonjs/Materials/effect";
  60628. import { Scene } from "babylonjs/scene";
  60629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60630. /**
  60631. * Block used to implement the refraction part of the sub surface module of the PBR material
  60632. */
  60633. export class RefractionBlock extends NodeMaterialBlock {
  60634. /** @hidden */
  60635. _define3DName: string;
  60636. /** @hidden */
  60637. _refractionMatrixName: string;
  60638. /** @hidden */
  60639. _defineLODRefractionAlpha: string;
  60640. /** @hidden */
  60641. _defineLinearSpecularRefraction: string;
  60642. /** @hidden */
  60643. _defineOppositeZ: string;
  60644. /** @hidden */
  60645. _cubeSamplerName: string;
  60646. /** @hidden */
  60647. _2DSamplerName: string;
  60648. /** @hidden */
  60649. _vRefractionMicrosurfaceInfosName: string;
  60650. /** @hidden */
  60651. _vRefractionInfosName: string;
  60652. private _scene;
  60653. /**
  60654. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60655. * Materials half opaque for instance using refraction could benefit from this control.
  60656. */
  60657. linkRefractionWithTransparency: boolean;
  60658. /**
  60659. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60660. */
  60661. invertRefractionY: boolean;
  60662. /**
  60663. * Gets or sets the texture associated with the node
  60664. */
  60665. texture: Nullable<BaseTexture>;
  60666. /**
  60667. * Create a new RefractionBlock
  60668. * @param name defines the block name
  60669. */
  60670. constructor(name: string);
  60671. /**
  60672. * Gets the current class name
  60673. * @returns the class name
  60674. */
  60675. getClassName(): string;
  60676. /**
  60677. * Gets the intensity input component
  60678. */
  60679. get intensity(): NodeMaterialConnectionPoint;
  60680. /**
  60681. * Gets the index of refraction input component
  60682. */
  60683. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60684. /**
  60685. * Gets the tint at distance input component
  60686. */
  60687. get tintAtDistance(): NodeMaterialConnectionPoint;
  60688. /**
  60689. * Gets the view input component
  60690. */
  60691. get view(): NodeMaterialConnectionPoint;
  60692. /**
  60693. * Gets the refraction object output component
  60694. */
  60695. get refraction(): NodeMaterialConnectionPoint;
  60696. /**
  60697. * Returns true if the block has a texture
  60698. */
  60699. get hasTexture(): boolean;
  60700. protected _getTexture(): Nullable<BaseTexture>;
  60701. autoConfigure(material: NodeMaterial): void;
  60702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60703. isReady(): boolean;
  60704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60705. /**
  60706. * Gets the main code of the block (fragment side)
  60707. * @param state current state of the node material building
  60708. * @returns the shader code
  60709. */
  60710. getCode(state: NodeMaterialBuildState): string;
  60711. protected _buildBlock(state: NodeMaterialBuildState): this;
  60712. protected _dumpPropertiesCode(): string;
  60713. serialize(): any;
  60714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60715. }
  60716. }
  60717. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60719. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60720. import { Scene } from "babylonjs/scene";
  60721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60722. import { Matrix } from "babylonjs/Maths/math.vector";
  60723. import { Mesh } from "babylonjs/Meshes/mesh";
  60724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60725. import { Observable } from "babylonjs/Misc/observable";
  60726. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60727. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60728. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60729. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60730. import { Nullable } from "babylonjs/types";
  60731. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60732. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60733. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  60734. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  60735. /**
  60736. * Interface used to configure the node material editor
  60737. */
  60738. export interface INodeMaterialEditorOptions {
  60739. /** Define the URl to load node editor script */
  60740. editorURL?: string;
  60741. }
  60742. /** @hidden */
  60743. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60744. NORMAL: boolean;
  60745. TANGENT: boolean;
  60746. UV1: boolean;
  60747. /** BONES */
  60748. NUM_BONE_INFLUENCERS: number;
  60749. BonesPerMesh: number;
  60750. BONETEXTURE: boolean;
  60751. /** MORPH TARGETS */
  60752. MORPHTARGETS: boolean;
  60753. MORPHTARGETS_NORMAL: boolean;
  60754. MORPHTARGETS_TANGENT: boolean;
  60755. MORPHTARGETS_UV: boolean;
  60756. NUM_MORPH_INFLUENCERS: number;
  60757. /** IMAGE PROCESSING */
  60758. IMAGEPROCESSING: boolean;
  60759. VIGNETTE: boolean;
  60760. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60761. VIGNETTEBLENDMODEOPAQUE: boolean;
  60762. TONEMAPPING: boolean;
  60763. TONEMAPPING_ACES: boolean;
  60764. CONTRAST: boolean;
  60765. EXPOSURE: boolean;
  60766. COLORCURVES: boolean;
  60767. COLORGRADING: boolean;
  60768. COLORGRADING3D: boolean;
  60769. SAMPLER3DGREENDEPTH: boolean;
  60770. SAMPLER3DBGRMAP: boolean;
  60771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60772. /** MISC. */
  60773. BUMPDIRECTUV: number;
  60774. constructor();
  60775. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  60776. }
  60777. /**
  60778. * Class used to configure NodeMaterial
  60779. */
  60780. export interface INodeMaterialOptions {
  60781. /**
  60782. * Defines if blocks should emit comments
  60783. */
  60784. emitComments: boolean;
  60785. }
  60786. /**
  60787. * Class used to create a node based material built by assembling shader blocks
  60788. */
  60789. export class NodeMaterial extends PushMaterial {
  60790. private static _BuildIdGenerator;
  60791. private _options;
  60792. private _vertexCompilationState;
  60793. private _fragmentCompilationState;
  60794. private _sharedData;
  60795. private _buildId;
  60796. private _buildWasSuccessful;
  60797. private _cachedWorldViewMatrix;
  60798. private _cachedWorldViewProjectionMatrix;
  60799. private _optimizers;
  60800. private _animationFrame;
  60801. /** Define the Url to load node editor script */
  60802. static EditorURL: string;
  60803. /** Define the Url to load snippets */
  60804. static SnippetUrl: string;
  60805. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60806. static IgnoreTexturesAtLoadTime: boolean;
  60807. private BJSNODEMATERIALEDITOR;
  60808. /** Get the inspector from bundle or global */
  60809. private _getGlobalNodeMaterialEditor;
  60810. /**
  60811. * Snippet ID if the material was created from the snippet server
  60812. */
  60813. snippetId: string;
  60814. /**
  60815. * Gets or sets data used by visual editor
  60816. * @see https://nme.babylonjs.com
  60817. */
  60818. editorData: any;
  60819. /**
  60820. * 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)
  60821. */
  60822. ignoreAlpha: boolean;
  60823. /**
  60824. * Defines the maximum number of lights that can be used in the material
  60825. */
  60826. maxSimultaneousLights: number;
  60827. /**
  60828. * Observable raised when the material is built
  60829. */
  60830. onBuildObservable: Observable<NodeMaterial>;
  60831. /**
  60832. * Gets or sets the root nodes of the material vertex shader
  60833. */
  60834. _vertexOutputNodes: NodeMaterialBlock[];
  60835. /**
  60836. * Gets or sets the root nodes of the material fragment (pixel) shader
  60837. */
  60838. _fragmentOutputNodes: NodeMaterialBlock[];
  60839. /** Gets or sets options to control the node material overall behavior */
  60840. get options(): INodeMaterialOptions;
  60841. set options(options: INodeMaterialOptions);
  60842. /**
  60843. * Default configuration related to image processing available in the standard Material.
  60844. */
  60845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60846. /**
  60847. * Gets the image processing configuration used either in this material.
  60848. */
  60849. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60850. /**
  60851. * Sets the Default image processing configuration used either in the this material.
  60852. *
  60853. * If sets to null, the scene one is in use.
  60854. */
  60855. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60856. /**
  60857. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60858. */
  60859. attachedBlocks: NodeMaterialBlock[];
  60860. /**
  60861. * Create a new node based material
  60862. * @param name defines the material name
  60863. * @param scene defines the hosting scene
  60864. * @param options defines creation option
  60865. */
  60866. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60867. /**
  60868. * Gets the current class name of the material e.g. "NodeMaterial"
  60869. * @returns the class name
  60870. */
  60871. getClassName(): string;
  60872. /**
  60873. * Keep track of the image processing observer to allow dispose and replace.
  60874. */
  60875. private _imageProcessingObserver;
  60876. /**
  60877. * Attaches a new image processing configuration to the Standard Material.
  60878. * @param configuration
  60879. */
  60880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60881. /**
  60882. * Get a block by its name
  60883. * @param name defines the name of the block to retrieve
  60884. * @returns the required block or null if not found
  60885. */
  60886. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60887. /**
  60888. * Get a block by its name
  60889. * @param predicate defines the predicate used to find the good candidate
  60890. * @returns the required block or null if not found
  60891. */
  60892. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60893. /**
  60894. * Get an input block by its name
  60895. * @param predicate defines the predicate used to find the good candidate
  60896. * @returns the required input block or null if not found
  60897. */
  60898. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60899. /**
  60900. * Gets the list of input blocks attached to this material
  60901. * @returns an array of InputBlocks
  60902. */
  60903. getInputBlocks(): InputBlock[];
  60904. /**
  60905. * Adds a new optimizer to the list of optimizers
  60906. * @param optimizer defines the optimizers to add
  60907. * @returns the current material
  60908. */
  60909. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60910. /**
  60911. * Remove an optimizer from the list of optimizers
  60912. * @param optimizer defines the optimizers to remove
  60913. * @returns the current material
  60914. */
  60915. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60916. /**
  60917. * Add a new block to the list of output nodes
  60918. * @param node defines the node to add
  60919. * @returns the current material
  60920. */
  60921. addOutputNode(node: NodeMaterialBlock): this;
  60922. /**
  60923. * Remove a block from the list of root nodes
  60924. * @param node defines the node to remove
  60925. * @returns the current material
  60926. */
  60927. removeOutputNode(node: NodeMaterialBlock): this;
  60928. private _addVertexOutputNode;
  60929. private _removeVertexOutputNode;
  60930. private _addFragmentOutputNode;
  60931. private _removeFragmentOutputNode;
  60932. /**
  60933. * Specifies if the material will require alpha blending
  60934. * @returns a boolean specifying if alpha blending is needed
  60935. */
  60936. needAlphaBlending(): boolean;
  60937. /**
  60938. * Specifies if this material should be rendered in alpha test mode
  60939. * @returns a boolean specifying if an alpha test is needed.
  60940. */
  60941. needAlphaTesting(): boolean;
  60942. private _initializeBlock;
  60943. private _resetDualBlocks;
  60944. /**
  60945. * Remove a block from the current node material
  60946. * @param block defines the block to remove
  60947. */
  60948. removeBlock(block: NodeMaterialBlock): void;
  60949. /**
  60950. * Build the material and generates the inner effect
  60951. * @param verbose defines if the build should log activity
  60952. */
  60953. build(verbose?: boolean): void;
  60954. /**
  60955. * Runs an otpimization phase to try to improve the shader code
  60956. */
  60957. optimize(): void;
  60958. private _prepareDefinesForAttributes;
  60959. /**
  60960. * Get if the submesh is ready to be used and all its information available.
  60961. * Child classes can use it to update shaders
  60962. * @param mesh defines the mesh to check
  60963. * @param subMesh defines which submesh to check
  60964. * @param useInstances specifies that instances should be used
  60965. * @returns a boolean indicating that the submesh is ready or not
  60966. */
  60967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60968. /**
  60969. * Get a string representing the shaders built by the current node graph
  60970. */
  60971. get compiledShaders(): string;
  60972. /**
  60973. * Binds the world matrix to the material
  60974. * @param world defines the world transformation matrix
  60975. */
  60976. bindOnlyWorldMatrix(world: Matrix): void;
  60977. /**
  60978. * Binds the submesh to this material by preparing the effect and shader to draw
  60979. * @param world defines the world transformation matrix
  60980. * @param mesh defines the mesh containing the submesh
  60981. * @param subMesh defines the submesh to bind the material to
  60982. */
  60983. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60984. /**
  60985. * Gets the active textures from the material
  60986. * @returns an array of textures
  60987. */
  60988. getActiveTextures(): BaseTexture[];
  60989. /**
  60990. * Gets the list of texture blocks
  60991. * @returns an array of texture blocks
  60992. */
  60993. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  60994. /**
  60995. * Specifies if the material uses a texture
  60996. * @param texture defines the texture to check against the material
  60997. * @returns a boolean specifying if the material uses the texture
  60998. */
  60999. hasTexture(texture: BaseTexture): boolean;
  61000. /**
  61001. * Disposes the material
  61002. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61003. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  61004. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61005. */
  61006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61007. /** Creates the node editor window. */
  61008. private _createNodeEditor;
  61009. /**
  61010. * Launch the node material editor
  61011. * @param config Define the configuration of the editor
  61012. * @return a promise fulfilled when the node editor is visible
  61013. */
  61014. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61015. /**
  61016. * Clear the current material
  61017. */
  61018. clear(): void;
  61019. /**
  61020. * Clear the current material and set it to a default state
  61021. */
  61022. setToDefault(): void;
  61023. /**
  61024. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61025. * @param url defines the url to load from
  61026. * @returns a promise that will fullfil when the material is fully loaded
  61027. */
  61028. loadAsync(url: string): Promise<void>;
  61029. private _gatherBlocks;
  61030. /**
  61031. * Generate a string containing the code declaration required to create an equivalent of this material
  61032. * @returns a string
  61033. */
  61034. generateCode(): string;
  61035. /**
  61036. * Serializes this material in a JSON representation
  61037. * @returns the serialized material object
  61038. */
  61039. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61040. private _restoreConnections;
  61041. /**
  61042. * Clear the current graph and load a new one from a serialization object
  61043. * @param source defines the JSON representation of the material
  61044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61045. */
  61046. loadFromSerialization(source: any, rootUrl?: string): void;
  61047. /**
  61048. * Makes a duplicate of the current material.
  61049. * @param name - name to use for the new material.
  61050. */
  61051. clone(name: string): NodeMaterial;
  61052. /**
  61053. * Creates a node material from parsed material data
  61054. * @param source defines the JSON representation of the material
  61055. * @param scene defines the hosting scene
  61056. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61057. * @returns a new node material
  61058. */
  61059. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61060. /**
  61061. * Creates a node material from a snippet saved in a remote file
  61062. * @param name defines the name of the material to create
  61063. * @param url defines the url to load from
  61064. * @param scene defines the hosting scene
  61065. * @returns a promise that will resolve to the new node material
  61066. */
  61067. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61068. /**
  61069. * Creates a node material from a snippet saved by the node material editor
  61070. * @param snippetId defines the snippet to load
  61071. * @param scene defines the hosting scene
  61072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61073. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61074. * @returns a promise that will resolve to the new node material
  61075. */
  61076. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61077. /**
  61078. * Creates a new node material set to default basic configuration
  61079. * @param name defines the name of the material
  61080. * @param scene defines the hosting scene
  61081. * @returns a new NodeMaterial
  61082. */
  61083. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61084. }
  61085. }
  61086. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61089. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61092. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61093. import { Effect } from "babylonjs/Materials/effect";
  61094. import { Mesh } from "babylonjs/Meshes/mesh";
  61095. import { Nullable } from "babylonjs/types";
  61096. import { Texture } from "babylonjs/Materials/Textures/texture";
  61097. import { Scene } from "babylonjs/scene";
  61098. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61099. /**
  61100. * Block used to read a texture from a sampler
  61101. */
  61102. export class TextureBlock extends NodeMaterialBlock {
  61103. private _defineName;
  61104. private _linearDefineName;
  61105. private _gammaDefineName;
  61106. private _tempTextureRead;
  61107. private _samplerName;
  61108. private _transformedUVName;
  61109. private _textureTransformName;
  61110. private _textureInfoName;
  61111. private _mainUVName;
  61112. private _mainUVDefineName;
  61113. /**
  61114. * Gets or sets the texture associated with the node
  61115. */
  61116. texture: Nullable<Texture>;
  61117. /**
  61118. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61119. */
  61120. convertToGammaSpace: boolean;
  61121. /**
  61122. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61123. */
  61124. convertToLinearSpace: boolean;
  61125. /**
  61126. * Create a new TextureBlock
  61127. * @param name defines the block name
  61128. */
  61129. constructor(name: string);
  61130. /**
  61131. * Gets the current class name
  61132. * @returns the class name
  61133. */
  61134. getClassName(): string;
  61135. /**
  61136. * Gets the uv input component
  61137. */
  61138. get uv(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the rgba output component
  61141. */
  61142. get rgba(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the rgb output component
  61145. */
  61146. get rgb(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the r output component
  61149. */
  61150. get r(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the g output component
  61153. */
  61154. get g(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Gets the b output component
  61157. */
  61158. get b(): NodeMaterialConnectionPoint;
  61159. /**
  61160. * Gets the a output component
  61161. */
  61162. get a(): NodeMaterialConnectionPoint;
  61163. get target(): NodeMaterialBlockTargets;
  61164. autoConfigure(material: NodeMaterial): void;
  61165. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61167. isReady(): boolean;
  61168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61169. private get _isMixed();
  61170. private _injectVertexCode;
  61171. private _writeTextureRead;
  61172. private _writeOutput;
  61173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61174. protected _dumpPropertiesCode(): string;
  61175. serialize(): any;
  61176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61177. }
  61178. }
  61179. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61182. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61183. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61184. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61185. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61186. import { Scene } from "babylonjs/scene";
  61187. /**
  61188. * Class used to store shared data between 2 NodeMaterialBuildState
  61189. */
  61190. export class NodeMaterialBuildStateSharedData {
  61191. /**
  61192. * Gets the list of emitted varyings
  61193. */
  61194. temps: string[];
  61195. /**
  61196. * Gets the list of emitted varyings
  61197. */
  61198. varyings: string[];
  61199. /**
  61200. * Gets the varying declaration string
  61201. */
  61202. varyingDeclaration: string;
  61203. /**
  61204. * Input blocks
  61205. */
  61206. inputBlocks: InputBlock[];
  61207. /**
  61208. * Input blocks
  61209. */
  61210. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  61211. /**
  61212. * Bindable blocks (Blocks that need to set data to the effect)
  61213. */
  61214. bindableBlocks: NodeMaterialBlock[];
  61215. /**
  61216. * List of blocks that can provide a compilation fallback
  61217. */
  61218. blocksWithFallbacks: NodeMaterialBlock[];
  61219. /**
  61220. * List of blocks that can provide a define update
  61221. */
  61222. blocksWithDefines: NodeMaterialBlock[];
  61223. /**
  61224. * List of blocks that can provide a repeatable content
  61225. */
  61226. repeatableContentBlocks: NodeMaterialBlock[];
  61227. /**
  61228. * List of blocks that can provide a dynamic list of uniforms
  61229. */
  61230. dynamicUniformBlocks: NodeMaterialBlock[];
  61231. /**
  61232. * List of blocks that can block the isReady function for the material
  61233. */
  61234. blockingBlocks: NodeMaterialBlock[];
  61235. /**
  61236. * Gets the list of animated inputs
  61237. */
  61238. animatedInputs: InputBlock[];
  61239. /**
  61240. * Build Id used to avoid multiple recompilations
  61241. */
  61242. buildId: number;
  61243. /** List of emitted variables */
  61244. variableNames: {
  61245. [key: string]: number;
  61246. };
  61247. /** List of emitted defines */
  61248. defineNames: {
  61249. [key: string]: number;
  61250. };
  61251. /** Should emit comments? */
  61252. emitComments: boolean;
  61253. /** Emit build activity */
  61254. verbose: boolean;
  61255. /** Gets or sets the hosting scene */
  61256. scene: Scene;
  61257. /**
  61258. * Gets the compilation hints emitted at compilation time
  61259. */
  61260. hints: {
  61261. needWorldViewMatrix: boolean;
  61262. needWorldViewProjectionMatrix: boolean;
  61263. needAlphaBlending: boolean;
  61264. needAlphaTesting: boolean;
  61265. };
  61266. /**
  61267. * List of compilation checks
  61268. */
  61269. checks: {
  61270. emitVertex: boolean;
  61271. emitFragment: boolean;
  61272. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61273. };
  61274. /** Creates a new shared data */
  61275. constructor();
  61276. /**
  61277. * Emits console errors and exceptions if there is a failing check
  61278. */
  61279. emitErrors(): void;
  61280. }
  61281. }
  61282. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61283. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61284. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61285. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61286. /**
  61287. * Class used to store node based material build state
  61288. */
  61289. export class NodeMaterialBuildState {
  61290. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61291. supportUniformBuffers: boolean;
  61292. /**
  61293. * Gets the list of emitted attributes
  61294. */
  61295. attributes: string[];
  61296. /**
  61297. * Gets the list of emitted uniforms
  61298. */
  61299. uniforms: string[];
  61300. /**
  61301. * Gets the list of emitted constants
  61302. */
  61303. constants: string[];
  61304. /**
  61305. * Gets the list of emitted samplers
  61306. */
  61307. samplers: string[];
  61308. /**
  61309. * Gets the list of emitted functions
  61310. */
  61311. functions: {
  61312. [key: string]: string;
  61313. };
  61314. /**
  61315. * Gets the list of emitted extensions
  61316. */
  61317. extensions: {
  61318. [key: string]: string;
  61319. };
  61320. /**
  61321. * Gets the target of the compilation state
  61322. */
  61323. target: NodeMaterialBlockTargets;
  61324. /**
  61325. * Gets the list of emitted counters
  61326. */
  61327. counters: {
  61328. [key: string]: number;
  61329. };
  61330. /**
  61331. * Shared data between multiple NodeMaterialBuildState instances
  61332. */
  61333. sharedData: NodeMaterialBuildStateSharedData;
  61334. /** @hidden */
  61335. _vertexState: NodeMaterialBuildState;
  61336. /** @hidden */
  61337. _attributeDeclaration: string;
  61338. /** @hidden */
  61339. _uniformDeclaration: string;
  61340. /** @hidden */
  61341. _constantDeclaration: string;
  61342. /** @hidden */
  61343. _samplerDeclaration: string;
  61344. /** @hidden */
  61345. _varyingTransfer: string;
  61346. /** @hidden */
  61347. _injectAtEnd: string;
  61348. private _repeatableContentAnchorIndex;
  61349. /** @hidden */
  61350. _builtCompilationString: string;
  61351. /**
  61352. * Gets the emitted compilation strings
  61353. */
  61354. compilationString: string;
  61355. /**
  61356. * Finalize the compilation strings
  61357. * @param state defines the current compilation state
  61358. */
  61359. finalize(state: NodeMaterialBuildState): void;
  61360. /** @hidden */
  61361. get _repeatableContentAnchor(): string;
  61362. /** @hidden */
  61363. _getFreeVariableName(prefix: string): string;
  61364. /** @hidden */
  61365. _getFreeDefineName(prefix: string): string;
  61366. /** @hidden */
  61367. _excludeVariableName(name: string): void;
  61368. /** @hidden */
  61369. _emit2DSampler(name: string): void;
  61370. /** @hidden */
  61371. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61372. /** @hidden */
  61373. _emitExtension(name: string, extension: string, define?: string): void;
  61374. /** @hidden */
  61375. _emitFunction(name: string, code: string, comments: string): void;
  61376. /** @hidden */
  61377. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61378. replaceStrings?: {
  61379. search: RegExp;
  61380. replace: string;
  61381. }[];
  61382. repeatKey?: string;
  61383. }): string;
  61384. /** @hidden */
  61385. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61386. repeatKey?: string;
  61387. removeAttributes?: boolean;
  61388. removeUniforms?: boolean;
  61389. removeVaryings?: boolean;
  61390. removeIfDef?: boolean;
  61391. replaceStrings?: {
  61392. search: RegExp;
  61393. replace: string;
  61394. }[];
  61395. }, storeKey?: string): void;
  61396. /** @hidden */
  61397. _registerTempVariable(name: string): boolean;
  61398. /** @hidden */
  61399. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61400. /** @hidden */
  61401. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61402. /** @hidden */
  61403. _emitFloat(value: number): string;
  61404. }
  61405. }
  61406. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61407. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61409. import { Nullable } from "babylonjs/types";
  61410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61411. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61412. import { Effect } from "babylonjs/Materials/effect";
  61413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61414. import { Mesh } from "babylonjs/Meshes/mesh";
  61415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61416. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61417. import { Scene } from "babylonjs/scene";
  61418. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61419. /**
  61420. * Defines a block that can be used inside a node based material
  61421. */
  61422. export class NodeMaterialBlock {
  61423. private _buildId;
  61424. private _buildTarget;
  61425. private _target;
  61426. private _isFinalMerger;
  61427. private _isInput;
  61428. protected _isUnique: boolean;
  61429. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61430. inputsAreExclusive: boolean;
  61431. /** @hidden */
  61432. _codeVariableName: string;
  61433. /** @hidden */
  61434. _inputs: NodeMaterialConnectionPoint[];
  61435. /** @hidden */
  61436. _outputs: NodeMaterialConnectionPoint[];
  61437. /** @hidden */
  61438. _preparationId: number;
  61439. /**
  61440. * Gets or sets the name of the block
  61441. */
  61442. name: string;
  61443. /**
  61444. * Gets or sets the unique id of the node
  61445. */
  61446. uniqueId: number;
  61447. /**
  61448. * Gets or sets the comments associated with this block
  61449. */
  61450. comments: string;
  61451. /**
  61452. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61453. */
  61454. get isUnique(): boolean;
  61455. /**
  61456. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61457. */
  61458. get isFinalMerger(): boolean;
  61459. /**
  61460. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61461. */
  61462. get isInput(): boolean;
  61463. /**
  61464. * Gets or sets the build Id
  61465. */
  61466. get buildId(): number;
  61467. set buildId(value: number);
  61468. /**
  61469. * Gets or sets the target of the block
  61470. */
  61471. get target(): NodeMaterialBlockTargets;
  61472. set target(value: NodeMaterialBlockTargets);
  61473. /**
  61474. * Gets the list of input points
  61475. */
  61476. get inputs(): NodeMaterialConnectionPoint[];
  61477. /** Gets the list of output points */
  61478. get outputs(): NodeMaterialConnectionPoint[];
  61479. /**
  61480. * Find an input by its name
  61481. * @param name defines the name of the input to look for
  61482. * @returns the input or null if not found
  61483. */
  61484. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61485. /**
  61486. * Find an output by its name
  61487. * @param name defines the name of the outputto look for
  61488. * @returns the output or null if not found
  61489. */
  61490. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61491. /**
  61492. * Creates a new NodeMaterialBlock
  61493. * @param name defines the block name
  61494. * @param target defines the target of that block (Vertex by default)
  61495. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61496. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61497. */
  61498. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61499. /**
  61500. * Initialize the block and prepare the context for build
  61501. * @param state defines the state that will be used for the build
  61502. */
  61503. initialize(state: NodeMaterialBuildState): void;
  61504. /**
  61505. * Bind data to effect. Will only be called for blocks with isBindable === true
  61506. * @param effect defines the effect to bind data to
  61507. * @param nodeMaterial defines the hosting NodeMaterial
  61508. * @param mesh defines the mesh that will be rendered
  61509. * @param subMesh defines the submesh that will be rendered
  61510. */
  61511. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61512. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61513. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61514. protected _writeFloat(value: number): string;
  61515. /**
  61516. * Gets the current class name e.g. "NodeMaterialBlock"
  61517. * @returns the class name
  61518. */
  61519. getClassName(): string;
  61520. /**
  61521. * Register a new input. Must be called inside a block constructor
  61522. * @param name defines the connection point name
  61523. * @param type defines the connection point type
  61524. * @param isOptional defines a boolean indicating that this input can be omitted
  61525. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61526. * @param point an already created connection point. If not provided, create a new one
  61527. * @returns the current block
  61528. */
  61529. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61530. /**
  61531. * Register a new output. Must be called inside a block constructor
  61532. * @param name defines the connection point name
  61533. * @param type defines the connection point type
  61534. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61535. * @param point an already created connection point. If not provided, create a new one
  61536. * @returns the current block
  61537. */
  61538. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61539. /**
  61540. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61541. * @param forOutput defines an optional connection point to check compatibility with
  61542. * @returns the first available input or null
  61543. */
  61544. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61545. /**
  61546. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61547. * @param forBlock defines an optional block to check compatibility with
  61548. * @returns the first available input or null
  61549. */
  61550. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61551. /**
  61552. * Gets the sibling of the given output
  61553. * @param current defines the current output
  61554. * @returns the next output in the list or null
  61555. */
  61556. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61557. /**
  61558. * Connect current block with another block
  61559. * @param other defines the block to connect with
  61560. * @param options define the various options to help pick the right connections
  61561. * @returns the current block
  61562. */
  61563. connectTo(other: NodeMaterialBlock, options?: {
  61564. input?: string;
  61565. output?: string;
  61566. outputSwizzle?: string;
  61567. }): this | undefined;
  61568. protected _buildBlock(state: NodeMaterialBuildState): void;
  61569. /**
  61570. * Add uniforms, samplers and uniform buffers at compilation time
  61571. * @param state defines the state to update
  61572. * @param nodeMaterial defines the node material requesting the update
  61573. * @param defines defines the material defines to update
  61574. * @param uniformBuffers defines the list of uniform buffer names
  61575. */
  61576. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61577. /**
  61578. * Add potential fallbacks if shader compilation fails
  61579. * @param mesh defines the mesh to be rendered
  61580. * @param fallbacks defines the current prioritized list of fallbacks
  61581. */
  61582. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61583. /**
  61584. * Initialize defines for shader compilation
  61585. * @param mesh defines the mesh to be rendered
  61586. * @param nodeMaterial defines the node material requesting the update
  61587. * @param defines defines the material defines to update
  61588. * @param useInstances specifies that instances should be used
  61589. */
  61590. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61591. /**
  61592. * Update defines for shader compilation
  61593. * @param mesh defines the mesh to be rendered
  61594. * @param nodeMaterial defines the node material requesting the update
  61595. * @param defines defines the material defines to update
  61596. * @param useInstances specifies that instances should be used
  61597. */
  61598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61599. /**
  61600. * Lets the block try to connect some inputs automatically
  61601. * @param material defines the hosting NodeMaterial
  61602. */
  61603. autoConfigure(material: NodeMaterial): void;
  61604. /**
  61605. * Function called when a block is declared as repeatable content generator
  61606. * @param vertexShaderState defines the current compilation state for the vertex shader
  61607. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61608. * @param mesh defines the mesh to be rendered
  61609. * @param defines defines the material defines to update
  61610. */
  61611. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61612. /**
  61613. * Checks if the block is ready
  61614. * @param mesh defines the mesh to be rendered
  61615. * @param nodeMaterial defines the node material requesting the update
  61616. * @param defines defines the material defines to update
  61617. * @param useInstances specifies that instances should be used
  61618. * @returns true if the block is ready
  61619. */
  61620. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61621. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61622. private _processBuild;
  61623. /**
  61624. * Compile the current node and generate the shader code
  61625. * @param state defines the current compilation state (uniforms, samplers, current string)
  61626. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61627. * @returns true if already built
  61628. */
  61629. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61630. protected _inputRename(name: string): string;
  61631. protected _outputRename(name: string): string;
  61632. protected _dumpPropertiesCode(): string;
  61633. /** @hidden */
  61634. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61635. /** @hidden */
  61636. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61637. /**
  61638. * Clone the current block to a new identical block
  61639. * @param scene defines the hosting scene
  61640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61641. * @returns a copy of the current block
  61642. */
  61643. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61644. /**
  61645. * Serializes this block in a JSON representation
  61646. * @returns the serialized block object
  61647. */
  61648. serialize(): any;
  61649. /** @hidden */
  61650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61651. private _deserializePortDisplayNames;
  61652. /**
  61653. * Release resources
  61654. */
  61655. dispose(): void;
  61656. }
  61657. }
  61658. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61659. /**
  61660. * Enum defining the type of animations supported by InputBlock
  61661. */
  61662. export enum AnimatedInputBlockTypes {
  61663. /** No animation */
  61664. None = 0,
  61665. /** Time based animation. Will only work for floats */
  61666. Time = 1
  61667. }
  61668. }
  61669. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61671. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61672. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61673. import { Nullable } from "babylonjs/types";
  61674. import { Effect } from "babylonjs/Materials/effect";
  61675. import { Matrix } from "babylonjs/Maths/math.vector";
  61676. import { Scene } from "babylonjs/scene";
  61677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61679. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61680. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61681. import { Observable } from "babylonjs/Misc/observable";
  61682. /**
  61683. * Block used to expose an input value
  61684. */
  61685. export class InputBlock extends NodeMaterialBlock {
  61686. private _mode;
  61687. private _associatedVariableName;
  61688. private _storedValue;
  61689. private _valueCallback;
  61690. private _type;
  61691. private _animationType;
  61692. /** Gets or set a value used to limit the range of float values */
  61693. min: number;
  61694. /** Gets or set a value used to limit the range of float values */
  61695. max: number;
  61696. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61697. isBoolean: boolean;
  61698. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61699. matrixMode: number;
  61700. /** @hidden */
  61701. _systemValue: Nullable<NodeMaterialSystemValues>;
  61702. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61703. visibleInInspector: boolean;
  61704. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61705. isConstant: boolean;
  61706. /** Gets or sets the group to use to display this block in the Inspector */
  61707. groupInInspector: string;
  61708. /** Gets an observable raised when the value is changed */
  61709. onValueChangedObservable: Observable<InputBlock>;
  61710. /**
  61711. * Gets or sets the connection point type (default is float)
  61712. */
  61713. get type(): NodeMaterialBlockConnectionPointTypes;
  61714. /**
  61715. * Creates a new InputBlock
  61716. * @param name defines the block name
  61717. * @param target defines the target of that block (Vertex by default)
  61718. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61719. */
  61720. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61721. /**
  61722. * Gets the output component
  61723. */
  61724. get output(): NodeMaterialConnectionPoint;
  61725. /**
  61726. * Set the source of this connection point to a vertex attribute
  61727. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61728. * @returns the current connection point
  61729. */
  61730. setAsAttribute(attributeName?: string): InputBlock;
  61731. /**
  61732. * Set the source of this connection point to a system value
  61733. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61734. * @returns the current connection point
  61735. */
  61736. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61737. /**
  61738. * Gets or sets the value of that point.
  61739. * Please note that this value will be ignored if valueCallback is defined
  61740. */
  61741. get value(): any;
  61742. set value(value: any);
  61743. /**
  61744. * Gets or sets a callback used to get the value of that point.
  61745. * Please note that setting this value will force the connection point to ignore the value property
  61746. */
  61747. get valueCallback(): () => any;
  61748. set valueCallback(value: () => any);
  61749. /**
  61750. * Gets or sets the associated variable name in the shader
  61751. */
  61752. get associatedVariableName(): string;
  61753. set associatedVariableName(value: string);
  61754. /** Gets or sets the type of animation applied to the input */
  61755. get animationType(): AnimatedInputBlockTypes;
  61756. set animationType(value: AnimatedInputBlockTypes);
  61757. /**
  61758. * Gets a boolean indicating that this connection point not defined yet
  61759. */
  61760. get isUndefined(): boolean;
  61761. /**
  61762. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61763. * In this case the connection point name must be the name of the uniform to use.
  61764. * Can only be set on inputs
  61765. */
  61766. get isUniform(): boolean;
  61767. set isUniform(value: boolean);
  61768. /**
  61769. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61770. * In this case the connection point name must be the name of the attribute to use
  61771. * Can only be set on inputs
  61772. */
  61773. get isAttribute(): boolean;
  61774. set isAttribute(value: boolean);
  61775. /**
  61776. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61777. * Can only be set on exit points
  61778. */
  61779. get isVarying(): boolean;
  61780. set isVarying(value: boolean);
  61781. /**
  61782. * Gets a boolean indicating that the current connection point is a system value
  61783. */
  61784. get isSystemValue(): boolean;
  61785. /**
  61786. * Gets or sets the current well known value or null if not defined as a system value
  61787. */
  61788. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61789. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61790. /**
  61791. * Gets the current class name
  61792. * @returns the class name
  61793. */
  61794. getClassName(): string;
  61795. /**
  61796. * Animate the input if animationType !== None
  61797. * @param scene defines the rendering scene
  61798. */
  61799. animate(scene: Scene): void;
  61800. private _emitDefine;
  61801. initialize(state: NodeMaterialBuildState): void;
  61802. /**
  61803. * Set the input block to its default value (based on its type)
  61804. */
  61805. setDefaultValue(): void;
  61806. private _emitConstant;
  61807. private _emit;
  61808. /** @hidden */
  61809. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61810. /** @hidden */
  61811. _transmit(effect: Effect, scene: Scene): void;
  61812. protected _buildBlock(state: NodeMaterialBuildState): void;
  61813. protected _dumpPropertiesCode(): string;
  61814. dispose(): void;
  61815. serialize(): any;
  61816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61817. }
  61818. }
  61819. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61820. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61821. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61822. import { Nullable } from "babylonjs/types";
  61823. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61824. import { Observable } from "babylonjs/Misc/observable";
  61825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61826. /**
  61827. * Enum used to define the compatibility state between two connection points
  61828. */
  61829. export enum NodeMaterialConnectionPointCompatibilityStates {
  61830. /** Points are compatibles */
  61831. Compatible = 0,
  61832. /** Points are incompatible because of their types */
  61833. TypeIncompatible = 1,
  61834. /** Points are incompatible because of their targets (vertex vs fragment) */
  61835. TargetIncompatible = 2
  61836. }
  61837. /**
  61838. * Defines the direction of a connection point
  61839. */
  61840. export enum NodeMaterialConnectionPointDirection {
  61841. /** Input */
  61842. Input = 0,
  61843. /** Output */
  61844. Output = 1
  61845. }
  61846. /**
  61847. * Defines a connection point for a block
  61848. */
  61849. export class NodeMaterialConnectionPoint {
  61850. /** @hidden */
  61851. _ownerBlock: NodeMaterialBlock;
  61852. /** @hidden */
  61853. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61854. private _endpoints;
  61855. private _associatedVariableName;
  61856. private _direction;
  61857. /** @hidden */
  61858. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61859. /** @hidden */
  61860. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61861. private _type;
  61862. /** @hidden */
  61863. _enforceAssociatedVariableName: boolean;
  61864. /** Gets the direction of the point */
  61865. get direction(): NodeMaterialConnectionPointDirection;
  61866. /** Indicates that this connection point needs dual validation before being connected to another point */
  61867. needDualDirectionValidation: boolean;
  61868. /**
  61869. * Gets or sets the additional types supported by this connection point
  61870. */
  61871. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61872. /**
  61873. * Gets or sets the additional types excluded by this connection point
  61874. */
  61875. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61876. /**
  61877. * Observable triggered when this point is connected
  61878. */
  61879. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61880. /**
  61881. * Gets or sets the associated variable name in the shader
  61882. */
  61883. get associatedVariableName(): string;
  61884. set associatedVariableName(value: string);
  61885. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61886. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61887. /**
  61888. * Gets or sets the connection point type (default is float)
  61889. */
  61890. get type(): NodeMaterialBlockConnectionPointTypes;
  61891. set type(value: NodeMaterialBlockConnectionPointTypes);
  61892. /**
  61893. * Gets or sets the connection point name
  61894. */
  61895. name: string;
  61896. /**
  61897. * Gets or sets the connection point name
  61898. */
  61899. displayName: string;
  61900. /**
  61901. * Gets or sets a boolean indicating that this connection point can be omitted
  61902. */
  61903. isOptional: boolean;
  61904. /**
  61905. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61906. */
  61907. define: string;
  61908. /** @hidden */
  61909. _prioritizeVertex: boolean;
  61910. private _target;
  61911. /** Gets or sets the target of that connection point */
  61912. get target(): NodeMaterialBlockTargets;
  61913. set target(value: NodeMaterialBlockTargets);
  61914. /**
  61915. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  61916. */
  61917. get isConnected(): boolean;
  61918. /**
  61919. * Gets a boolean indicating that the current point is connected to an input block
  61920. */
  61921. get isConnectedToInputBlock(): boolean;
  61922. /**
  61923. * Gets a the connected input block (if any)
  61924. */
  61925. get connectInputBlock(): Nullable<InputBlock>;
  61926. /** Get the other side of the connection (if any) */
  61927. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61928. /** Get the block that owns this connection point */
  61929. get ownerBlock(): NodeMaterialBlock;
  61930. /** Get the block connected on the other side of this connection (if any) */
  61931. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61932. /** Get the block connected on the endpoints of this connection (if any) */
  61933. get connectedBlocks(): Array<NodeMaterialBlock>;
  61934. /** Gets the list of connected endpoints */
  61935. get endpoints(): NodeMaterialConnectionPoint[];
  61936. /** Gets a boolean indicating if that output point is connected to at least one input */
  61937. get hasEndpoints(): boolean;
  61938. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61939. get isConnectedInVertexShader(): boolean;
  61940. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61941. get isConnectedInFragmentShader(): boolean;
  61942. /**
  61943. * Creates a block suitable to be used as an input for this input point.
  61944. * If null is returned, a block based on the point type will be created.
  61945. * @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
  61946. */
  61947. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  61948. /**
  61949. * Creates a new connection point
  61950. * @param name defines the connection point name
  61951. * @param ownerBlock defines the block hosting this connection point
  61952. * @param direction defines the direction of the connection point
  61953. */
  61954. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61955. /**
  61956. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61957. * @returns the class name
  61958. */
  61959. getClassName(): string;
  61960. /**
  61961. * Gets a boolean indicating if the current point can be connected to another point
  61962. * @param connectionPoint defines the other connection point
  61963. * @returns a boolean
  61964. */
  61965. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61966. /**
  61967. * Gets a number indicating if the current point can be connected to another point
  61968. * @param connectionPoint defines the other connection point
  61969. * @returns a number defining the compatibility state
  61970. */
  61971. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61972. /**
  61973. * Connect this point to another connection point
  61974. * @param connectionPoint defines the other connection point
  61975. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61976. * @returns the current connection point
  61977. */
  61978. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Disconnect this point from one of his endpoint
  61981. * @param endpoint defines the other connection point
  61982. * @returns the current connection point
  61983. */
  61984. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Serializes this point in a JSON representation
  61987. * @param isInput defines if the connection point is an input (default is true)
  61988. * @returns the serialized point object
  61989. */
  61990. serialize(isInput?: boolean): any;
  61991. /**
  61992. * Release resources
  61993. */
  61994. dispose(): void;
  61995. }
  61996. }
  61997. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62001. import { Mesh } from "babylonjs/Meshes/mesh";
  62002. import { Effect } from "babylonjs/Materials/effect";
  62003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62005. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62007. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62008. /**
  62009. * Block used to add support for vertex skinning (bones)
  62010. */
  62011. export class BonesBlock extends NodeMaterialBlock {
  62012. /**
  62013. * Creates a new BonesBlock
  62014. * @param name defines the block name
  62015. */
  62016. constructor(name: string);
  62017. /**
  62018. * Initialize the block and prepare the context for build
  62019. * @param state defines the state that will be used for the build
  62020. */
  62021. initialize(state: NodeMaterialBuildState): void;
  62022. /**
  62023. * Gets the current class name
  62024. * @returns the class name
  62025. */
  62026. getClassName(): string;
  62027. /**
  62028. * Gets the matrix indices input component
  62029. */
  62030. get matricesIndices(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the matrix weights input component
  62033. */
  62034. get matricesWeights(): NodeMaterialConnectionPoint;
  62035. /**
  62036. * Gets the extra matrix indices input component
  62037. */
  62038. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the extra matrix weights input component
  62041. */
  62042. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the world input component
  62045. */
  62046. get world(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the output component
  62049. */
  62050. get output(): NodeMaterialConnectionPoint;
  62051. autoConfigure(material: NodeMaterial): void;
  62052. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62054. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62055. protected _buildBlock(state: NodeMaterialBuildState): this;
  62056. }
  62057. }
  62058. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62063. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62064. /**
  62065. * Block used to add support for instances
  62066. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62067. */
  62068. export class InstancesBlock extends NodeMaterialBlock {
  62069. /**
  62070. * Creates a new InstancesBlock
  62071. * @param name defines the block name
  62072. */
  62073. constructor(name: string);
  62074. /**
  62075. * Gets the current class name
  62076. * @returns the class name
  62077. */
  62078. getClassName(): string;
  62079. /**
  62080. * Gets the first world row input component
  62081. */
  62082. get world0(): NodeMaterialConnectionPoint;
  62083. /**
  62084. * Gets the second world row input component
  62085. */
  62086. get world1(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the third world row input component
  62089. */
  62090. get world2(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the forth world row input component
  62093. */
  62094. get world3(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the world input component
  62097. */
  62098. get world(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the output component
  62101. */
  62102. get output(): NodeMaterialConnectionPoint;
  62103. /**
  62104. * Gets the isntanceID component
  62105. */
  62106. get instanceID(): NodeMaterialConnectionPoint;
  62107. autoConfigure(material: NodeMaterial): void;
  62108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62109. protected _buildBlock(state: NodeMaterialBuildState): this;
  62110. }
  62111. }
  62112. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62117. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62118. import { Effect } from "babylonjs/Materials/effect";
  62119. import { Mesh } from "babylonjs/Meshes/mesh";
  62120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62122. /**
  62123. * Block used to add morph targets support to vertex shader
  62124. */
  62125. export class MorphTargetsBlock extends NodeMaterialBlock {
  62126. private _repeatableContentAnchor;
  62127. /**
  62128. * Create a new MorphTargetsBlock
  62129. * @param name defines the block name
  62130. */
  62131. constructor(name: string);
  62132. /**
  62133. * Gets the current class name
  62134. * @returns the class name
  62135. */
  62136. getClassName(): string;
  62137. /**
  62138. * Gets the position input component
  62139. */
  62140. get position(): NodeMaterialConnectionPoint;
  62141. /**
  62142. * Gets the normal input component
  62143. */
  62144. get normal(): NodeMaterialConnectionPoint;
  62145. /**
  62146. * Gets the tangent input component
  62147. */
  62148. get tangent(): NodeMaterialConnectionPoint;
  62149. /**
  62150. * Gets the tangent input component
  62151. */
  62152. get uv(): NodeMaterialConnectionPoint;
  62153. /**
  62154. * Gets the position output component
  62155. */
  62156. get positionOutput(): NodeMaterialConnectionPoint;
  62157. /**
  62158. * Gets the normal output component
  62159. */
  62160. get normalOutput(): NodeMaterialConnectionPoint;
  62161. /**
  62162. * Gets the tangent output component
  62163. */
  62164. get tangentOutput(): NodeMaterialConnectionPoint;
  62165. /**
  62166. * Gets the tangent output component
  62167. */
  62168. get uvOutput(): NodeMaterialConnectionPoint;
  62169. initialize(state: NodeMaterialBuildState): void;
  62170. autoConfigure(material: NodeMaterial): void;
  62171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62173. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62174. protected _buildBlock(state: NodeMaterialBuildState): this;
  62175. }
  62176. }
  62177. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62181. import { Nullable } from "babylonjs/types";
  62182. import { Scene } from "babylonjs/scene";
  62183. import { Effect } from "babylonjs/Materials/effect";
  62184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62185. import { Mesh } from "babylonjs/Meshes/mesh";
  62186. import { Light } from "babylonjs/Lights/light";
  62187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62188. /**
  62189. * Block used to get data information from a light
  62190. */
  62191. export class LightInformationBlock extends NodeMaterialBlock {
  62192. private _lightDataUniformName;
  62193. private _lightColorUniformName;
  62194. private _lightTypeDefineName;
  62195. /**
  62196. * Gets or sets the light associated with this block
  62197. */
  62198. light: Nullable<Light>;
  62199. /**
  62200. * Creates a new LightInformationBlock
  62201. * @param name defines the block name
  62202. */
  62203. constructor(name: string);
  62204. /**
  62205. * Gets the current class name
  62206. * @returns the class name
  62207. */
  62208. getClassName(): string;
  62209. /**
  62210. * Gets the world position input component
  62211. */
  62212. get worldPosition(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the direction output component
  62215. */
  62216. get direction(): NodeMaterialConnectionPoint;
  62217. /**
  62218. * Gets the direction output component
  62219. */
  62220. get color(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the direction output component
  62223. */
  62224. get intensity(): NodeMaterialConnectionPoint;
  62225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62227. protected _buildBlock(state: NodeMaterialBuildState): this;
  62228. serialize(): any;
  62229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62230. }
  62231. }
  62232. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62233. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62234. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62235. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62236. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62237. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62238. }
  62239. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62245. import { Effect } from "babylonjs/Materials/effect";
  62246. import { Mesh } from "babylonjs/Meshes/mesh";
  62247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62250. /**
  62251. * Block used to add image processing support to fragment shader
  62252. */
  62253. export class ImageProcessingBlock extends NodeMaterialBlock {
  62254. /**
  62255. * Create a new ImageProcessingBlock
  62256. * @param name defines the block name
  62257. */
  62258. constructor(name: string);
  62259. /**
  62260. * Gets the current class name
  62261. * @returns the class name
  62262. */
  62263. getClassName(): string;
  62264. /**
  62265. * Gets the color input component
  62266. */
  62267. get color(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the output component
  62270. */
  62271. get output(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Initialize the block and prepare the context for build
  62274. * @param state defines the state that will be used for the build
  62275. */
  62276. initialize(state: NodeMaterialBuildState): void;
  62277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62280. protected _buildBlock(state: NodeMaterialBuildState): this;
  62281. }
  62282. }
  62283. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62289. import { Effect } from "babylonjs/Materials/effect";
  62290. import { Mesh } from "babylonjs/Meshes/mesh";
  62291. import { Scene } from "babylonjs/scene";
  62292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62293. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62294. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62295. /**
  62296. * Block used to pertub normals based on a normal map
  62297. */
  62298. export class PerturbNormalBlock extends NodeMaterialBlock {
  62299. private _tangentSpaceParameterName;
  62300. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62301. invertX: boolean;
  62302. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62303. invertY: boolean;
  62304. /**
  62305. * Create a new PerturbNormalBlock
  62306. * @param name defines the block name
  62307. */
  62308. constructor(name: string);
  62309. /**
  62310. * Gets the current class name
  62311. * @returns the class name
  62312. */
  62313. getClassName(): string;
  62314. /**
  62315. * Gets the world position input component
  62316. */
  62317. get worldPosition(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the world normal input component
  62320. */
  62321. get worldNormal(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the world tangent input component
  62324. */
  62325. get worldTangent(): NodeMaterialConnectionPoint;
  62326. /**
  62327. * Gets the uv input component
  62328. */
  62329. get uv(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the normal map color input component
  62332. */
  62333. get normalMapColor(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the strength input component
  62336. */
  62337. get strength(): NodeMaterialConnectionPoint;
  62338. /**
  62339. * Gets the output component
  62340. */
  62341. get output(): NodeMaterialConnectionPoint;
  62342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62344. autoConfigure(material: NodeMaterial): void;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this;
  62346. protected _dumpPropertiesCode(): string;
  62347. serialize(): any;
  62348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62349. }
  62350. }
  62351. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62355. /**
  62356. * Block used to discard a pixel if a value is smaller than a cutoff
  62357. */
  62358. export class DiscardBlock extends NodeMaterialBlock {
  62359. /**
  62360. * Create a new DiscardBlock
  62361. * @param name defines the block name
  62362. */
  62363. constructor(name: string);
  62364. /**
  62365. * Gets the current class name
  62366. * @returns the class name
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Gets the color input component
  62371. */
  62372. get value(): NodeMaterialConnectionPoint;
  62373. /**
  62374. * Gets the cutoff input component
  62375. */
  62376. get cutoff(): NodeMaterialConnectionPoint;
  62377. protected _buildBlock(state: NodeMaterialBuildState): this;
  62378. }
  62379. }
  62380. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62384. /**
  62385. * Block used to test if the fragment shader is front facing
  62386. */
  62387. export class FrontFacingBlock extends NodeMaterialBlock {
  62388. /**
  62389. * Creates a new FrontFacingBlock
  62390. * @param name defines the block name
  62391. */
  62392. constructor(name: string);
  62393. /**
  62394. * Gets the current class name
  62395. * @returns the class name
  62396. */
  62397. getClassName(): string;
  62398. /**
  62399. * Gets the output component
  62400. */
  62401. get output(): NodeMaterialConnectionPoint;
  62402. protected _buildBlock(state: NodeMaterialBuildState): this;
  62403. }
  62404. }
  62405. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62409. /**
  62410. * Block used to get the derivative value on x and y of a given input
  62411. */
  62412. export class DerivativeBlock extends NodeMaterialBlock {
  62413. /**
  62414. * Create a new DerivativeBlock
  62415. * @param name defines the block name
  62416. */
  62417. constructor(name: string);
  62418. /**
  62419. * Gets the current class name
  62420. * @returns the class name
  62421. */
  62422. getClassName(): string;
  62423. /**
  62424. * Gets the input component
  62425. */
  62426. get input(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the derivative output on x
  62429. */
  62430. get dx(): NodeMaterialConnectionPoint;
  62431. /**
  62432. * Gets the derivative output on y
  62433. */
  62434. get dy(): NodeMaterialConnectionPoint;
  62435. protected _buildBlock(state: NodeMaterialBuildState): this;
  62436. }
  62437. }
  62438. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62439. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62440. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62441. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62442. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62443. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62444. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62445. }
  62446. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62449. import { Mesh } from "babylonjs/Meshes/mesh";
  62450. import { Effect } from "babylonjs/Materials/effect";
  62451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62453. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62454. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62455. /**
  62456. * Block used to add support for scene fog
  62457. */
  62458. export class FogBlock extends NodeMaterialBlock {
  62459. private _fogDistanceName;
  62460. private _fogParameters;
  62461. /**
  62462. * Create a new FogBlock
  62463. * @param name defines the block name
  62464. */
  62465. constructor(name: string);
  62466. /**
  62467. * Gets the current class name
  62468. * @returns the class name
  62469. */
  62470. getClassName(): string;
  62471. /**
  62472. * Gets the world position input component
  62473. */
  62474. get worldPosition(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the view input component
  62477. */
  62478. get view(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the color input component
  62481. */
  62482. get input(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the fog color input component
  62485. */
  62486. get fogColor(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the output component
  62489. */
  62490. get output(): NodeMaterialConnectionPoint;
  62491. autoConfigure(material: NodeMaterial): void;
  62492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62494. protected _buildBlock(state: NodeMaterialBuildState): this;
  62495. }
  62496. }
  62497. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62502. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62503. import { Effect } from "babylonjs/Materials/effect";
  62504. import { Mesh } from "babylonjs/Meshes/mesh";
  62505. import { Light } from "babylonjs/Lights/light";
  62506. import { Nullable } from "babylonjs/types";
  62507. import { Scene } from "babylonjs/scene";
  62508. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62509. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62510. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62512. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62513. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62514. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62515. /**
  62516. * Block used to add light in the fragment shader
  62517. */
  62518. export class LightBlock extends NodeMaterialBlock {
  62519. private _lightId;
  62520. /**
  62521. * Gets or sets the light associated with this block
  62522. */
  62523. light: Nullable<Light>;
  62524. /**
  62525. * Create a new LightBlock
  62526. * @param name defines the block name
  62527. */
  62528. constructor(name: string);
  62529. /**
  62530. * Gets the current class name
  62531. * @returns the class name
  62532. */
  62533. getClassName(): string;
  62534. /**
  62535. * Gets the world position input component
  62536. */
  62537. get worldPosition(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the world normal input component
  62540. */
  62541. get worldNormal(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the camera (or eye) position component
  62544. */
  62545. get cameraPosition(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the glossiness component
  62548. */
  62549. get glossiness(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the glossinness power component
  62552. */
  62553. get glossPower(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the diffuse color component
  62556. */
  62557. get diffuseColor(): NodeMaterialConnectionPoint;
  62558. /**
  62559. * Gets the specular color component
  62560. */
  62561. get specularColor(): NodeMaterialConnectionPoint;
  62562. /**
  62563. * Gets the diffuse output component
  62564. */
  62565. get diffuseOutput(): NodeMaterialConnectionPoint;
  62566. /**
  62567. * Gets the specular output component
  62568. */
  62569. get specularOutput(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the shadow output component
  62572. */
  62573. get shadow(): NodeMaterialConnectionPoint;
  62574. autoConfigure(material: NodeMaterial): void;
  62575. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62576. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62578. private _injectVertexCode;
  62579. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62580. serialize(): any;
  62581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62582. }
  62583. }
  62584. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62587. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62588. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62589. /**
  62590. * Block used to read a reflection texture from a sampler
  62591. */
  62592. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62593. /**
  62594. * Create a new ReflectionTextureBlock
  62595. * @param name defines the block name
  62596. */
  62597. constructor(name: string);
  62598. /**
  62599. * Gets the current class name
  62600. * @returns the class name
  62601. */
  62602. getClassName(): string;
  62603. /**
  62604. * Gets the world position input component
  62605. */
  62606. get position(): NodeMaterialConnectionPoint;
  62607. /**
  62608. * Gets the world position input component
  62609. */
  62610. get worldPosition(): NodeMaterialConnectionPoint;
  62611. /**
  62612. * Gets the world normal input component
  62613. */
  62614. get worldNormal(): NodeMaterialConnectionPoint;
  62615. /**
  62616. * Gets the world input component
  62617. */
  62618. get world(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the camera (or eye) position component
  62621. */
  62622. get cameraPosition(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the view input component
  62625. */
  62626. get view(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the rgb output component
  62629. */
  62630. get rgb(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the r output component
  62633. */
  62634. get r(): NodeMaterialConnectionPoint;
  62635. /**
  62636. * Gets the g output component
  62637. */
  62638. get g(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the b output component
  62641. */
  62642. get b(): NodeMaterialConnectionPoint;
  62643. autoConfigure(material: NodeMaterial): void;
  62644. protected _buildBlock(state: NodeMaterialBuildState): this;
  62645. }
  62646. }
  62647. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62648. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62649. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62650. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62651. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62652. }
  62653. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62654. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62655. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62656. }
  62657. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62661. /**
  62662. * Block used to multiply 2 values
  62663. */
  62664. export class MultiplyBlock extends NodeMaterialBlock {
  62665. /**
  62666. * Creates a new MultiplyBlock
  62667. * @param name defines the block name
  62668. */
  62669. constructor(name: string);
  62670. /**
  62671. * Gets the current class name
  62672. * @returns the class name
  62673. */
  62674. getClassName(): string;
  62675. /**
  62676. * Gets the left operand input component
  62677. */
  62678. get left(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the right operand input component
  62681. */
  62682. get right(): NodeMaterialConnectionPoint;
  62683. /**
  62684. * Gets the output component
  62685. */
  62686. get output(): NodeMaterialConnectionPoint;
  62687. protected _buildBlock(state: NodeMaterialBuildState): this;
  62688. }
  62689. }
  62690. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62694. /**
  62695. * Block used to add 2 vectors
  62696. */
  62697. export class AddBlock extends NodeMaterialBlock {
  62698. /**
  62699. * Creates a new AddBlock
  62700. * @param name defines the block name
  62701. */
  62702. constructor(name: string);
  62703. /**
  62704. * Gets the current class name
  62705. * @returns the class name
  62706. */
  62707. getClassName(): string;
  62708. /**
  62709. * Gets the left operand input component
  62710. */
  62711. get left(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the right operand input component
  62714. */
  62715. get right(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the output component
  62718. */
  62719. get output(): NodeMaterialConnectionPoint;
  62720. protected _buildBlock(state: NodeMaterialBuildState): this;
  62721. }
  62722. }
  62723. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62727. /**
  62728. * Block used to scale a vector by a float
  62729. */
  62730. export class ScaleBlock extends NodeMaterialBlock {
  62731. /**
  62732. * Creates a new ScaleBlock
  62733. * @param name defines the block name
  62734. */
  62735. constructor(name: string);
  62736. /**
  62737. * Gets the current class name
  62738. * @returns the class name
  62739. */
  62740. getClassName(): string;
  62741. /**
  62742. * Gets the input component
  62743. */
  62744. get input(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the factor input component
  62747. */
  62748. get factor(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the output component
  62751. */
  62752. get output(): NodeMaterialConnectionPoint;
  62753. protected _buildBlock(state: NodeMaterialBuildState): this;
  62754. }
  62755. }
  62756. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62760. import { Scene } from "babylonjs/scene";
  62761. /**
  62762. * Block used to clamp a float
  62763. */
  62764. export class ClampBlock extends NodeMaterialBlock {
  62765. /** Gets or sets the minimum range */
  62766. minimum: number;
  62767. /** Gets or sets the maximum range */
  62768. maximum: number;
  62769. /**
  62770. * Creates a new ClampBlock
  62771. * @param name defines the block name
  62772. */
  62773. constructor(name: string);
  62774. /**
  62775. * Gets the current class name
  62776. * @returns the class name
  62777. */
  62778. getClassName(): string;
  62779. /**
  62780. * Gets the value input component
  62781. */
  62782. get value(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. protected _dumpPropertiesCode(): string;
  62789. serialize(): any;
  62790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62791. }
  62792. }
  62793. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62797. /**
  62798. * Block used to apply a cross product between 2 vectors
  62799. */
  62800. export class CrossBlock extends NodeMaterialBlock {
  62801. /**
  62802. * Creates a new CrossBlock
  62803. * @param name defines the block name
  62804. */
  62805. constructor(name: string);
  62806. /**
  62807. * Gets the current class name
  62808. * @returns the class name
  62809. */
  62810. getClassName(): string;
  62811. /**
  62812. * Gets the left operand input component
  62813. */
  62814. get left(): NodeMaterialConnectionPoint;
  62815. /**
  62816. * Gets the right operand input component
  62817. */
  62818. get right(): NodeMaterialConnectionPoint;
  62819. /**
  62820. * Gets the output component
  62821. */
  62822. get output(): NodeMaterialConnectionPoint;
  62823. protected _buildBlock(state: NodeMaterialBuildState): this;
  62824. }
  62825. }
  62826. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62830. /**
  62831. * Block used to apply a dot product between 2 vectors
  62832. */
  62833. export class DotBlock extends NodeMaterialBlock {
  62834. /**
  62835. * Creates a new DotBlock
  62836. * @param name defines the block name
  62837. */
  62838. constructor(name: string);
  62839. /**
  62840. * Gets the current class name
  62841. * @returns the class name
  62842. */
  62843. getClassName(): string;
  62844. /**
  62845. * Gets the left operand input component
  62846. */
  62847. get left(): NodeMaterialConnectionPoint;
  62848. /**
  62849. * Gets the right operand input component
  62850. */
  62851. get right(): NodeMaterialConnectionPoint;
  62852. /**
  62853. * Gets the output component
  62854. */
  62855. get output(): NodeMaterialConnectionPoint;
  62856. protected _buildBlock(state: NodeMaterialBuildState): this;
  62857. }
  62858. }
  62859. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62863. import { Vector2 } from "babylonjs/Maths/math.vector";
  62864. import { Scene } from "babylonjs/scene";
  62865. /**
  62866. * Block used to remap a float from a range to a new one
  62867. */
  62868. export class RemapBlock extends NodeMaterialBlock {
  62869. /**
  62870. * Gets or sets the source range
  62871. */
  62872. sourceRange: Vector2;
  62873. /**
  62874. * Gets or sets the target range
  62875. */
  62876. targetRange: Vector2;
  62877. /**
  62878. * Creates a new RemapBlock
  62879. * @param name defines the block name
  62880. */
  62881. constructor(name: string);
  62882. /**
  62883. * Gets the current class name
  62884. * @returns the class name
  62885. */
  62886. getClassName(): string;
  62887. /**
  62888. * Gets the input component
  62889. */
  62890. get input(): NodeMaterialConnectionPoint;
  62891. /**
  62892. * Gets the source min input component
  62893. */
  62894. get sourceMin(): NodeMaterialConnectionPoint;
  62895. /**
  62896. * Gets the source max input component
  62897. */
  62898. get sourceMax(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the target min input component
  62901. */
  62902. get targetMin(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the target max input component
  62905. */
  62906. get targetMax(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the output component
  62909. */
  62910. get output(): NodeMaterialConnectionPoint;
  62911. protected _buildBlock(state: NodeMaterialBuildState): this;
  62912. protected _dumpPropertiesCode(): string;
  62913. serialize(): any;
  62914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62915. }
  62916. }
  62917. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62921. /**
  62922. * Block used to normalize a vector
  62923. */
  62924. export class NormalizeBlock extends NodeMaterialBlock {
  62925. /**
  62926. * Creates a new NormalizeBlock
  62927. * @param name defines the block name
  62928. */
  62929. constructor(name: string);
  62930. /**
  62931. * Gets the current class name
  62932. * @returns the class name
  62933. */
  62934. getClassName(): string;
  62935. /**
  62936. * Gets the input component
  62937. */
  62938. get input(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the output component
  62941. */
  62942. get output(): NodeMaterialConnectionPoint;
  62943. protected _buildBlock(state: NodeMaterialBuildState): this;
  62944. }
  62945. }
  62946. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62950. import { Scene } from "babylonjs/scene";
  62951. /**
  62952. * Operations supported by the Trigonometry block
  62953. */
  62954. export enum TrigonometryBlockOperations {
  62955. /** Cos */
  62956. Cos = 0,
  62957. /** Sin */
  62958. Sin = 1,
  62959. /** Abs */
  62960. Abs = 2,
  62961. /** Exp */
  62962. Exp = 3,
  62963. /** Exp2 */
  62964. Exp2 = 4,
  62965. /** Round */
  62966. Round = 5,
  62967. /** Floor */
  62968. Floor = 6,
  62969. /** Ceiling */
  62970. Ceiling = 7,
  62971. /** Square root */
  62972. Sqrt = 8,
  62973. /** Log */
  62974. Log = 9,
  62975. /** Tangent */
  62976. Tan = 10,
  62977. /** Arc tangent */
  62978. ArcTan = 11,
  62979. /** Arc cosinus */
  62980. ArcCos = 12,
  62981. /** Arc sinus */
  62982. ArcSin = 13,
  62983. /** Fraction */
  62984. Fract = 14,
  62985. /** Sign */
  62986. Sign = 15,
  62987. /** To radians (from degrees) */
  62988. Radians = 16,
  62989. /** To degrees (from radians) */
  62990. Degrees = 17
  62991. }
  62992. /**
  62993. * Block used to apply trigonometry operation to floats
  62994. */
  62995. export class TrigonometryBlock extends NodeMaterialBlock {
  62996. /**
  62997. * Gets or sets the operation applied by the block
  62998. */
  62999. operation: TrigonometryBlockOperations;
  63000. /**
  63001. * Creates a new TrigonometryBlock
  63002. * @param name defines the block name
  63003. */
  63004. constructor(name: string);
  63005. /**
  63006. * Gets the current class name
  63007. * @returns the class name
  63008. */
  63009. getClassName(): string;
  63010. /**
  63011. * Gets the input component
  63012. */
  63013. get input(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the output component
  63016. */
  63017. get output(): NodeMaterialConnectionPoint;
  63018. protected _buildBlock(state: NodeMaterialBuildState): this;
  63019. serialize(): any;
  63020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63021. protected _dumpPropertiesCode(): string;
  63022. }
  63023. }
  63024. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63028. /**
  63029. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63030. */
  63031. export class ColorMergerBlock extends NodeMaterialBlock {
  63032. /**
  63033. * Create a new ColorMergerBlock
  63034. * @param name defines the block name
  63035. */
  63036. constructor(name: string);
  63037. /**
  63038. * Gets the current class name
  63039. * @returns the class name
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Gets the rgb component (input)
  63044. */
  63045. get rgbIn(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the r component (input)
  63048. */
  63049. get r(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the g component (input)
  63052. */
  63053. get g(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the b component (input)
  63056. */
  63057. get b(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the a component (input)
  63060. */
  63061. get a(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the rgba component (output)
  63064. */
  63065. get rgba(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the rgb component (output)
  63068. */
  63069. get rgbOut(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the rgb component (output)
  63072. * @deprecated Please use rgbOut instead.
  63073. */
  63074. get rgb(): NodeMaterialConnectionPoint;
  63075. protected _buildBlock(state: NodeMaterialBuildState): this;
  63076. }
  63077. }
  63078. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  63079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63082. /**
  63083. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  63084. */
  63085. export class VectorMergerBlock extends NodeMaterialBlock {
  63086. /**
  63087. * Create a new VectorMergerBlock
  63088. * @param name defines the block name
  63089. */
  63090. constructor(name: string);
  63091. /**
  63092. * Gets the current class name
  63093. * @returns the class name
  63094. */
  63095. getClassName(): string;
  63096. /**
  63097. * Gets the xyz component (input)
  63098. */
  63099. get xyzIn(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the xy component (input)
  63102. */
  63103. get xyIn(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the x component (input)
  63106. */
  63107. get x(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the y component (input)
  63110. */
  63111. get y(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the z component (input)
  63114. */
  63115. get z(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the w component (input)
  63118. */
  63119. get w(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the xyzw component (output)
  63122. */
  63123. get xyzw(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the xyz component (output)
  63126. */
  63127. get xyzOut(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the xy component (output)
  63130. */
  63131. get xyOut(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the xy component (output)
  63134. * @deprecated Please use xyOut instead.
  63135. */
  63136. get xy(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the xyz component (output)
  63139. * @deprecated Please use xyzOut instead.
  63140. */
  63141. get xyz(): NodeMaterialConnectionPoint;
  63142. protected _buildBlock(state: NodeMaterialBuildState): this;
  63143. }
  63144. }
  63145. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63149. /**
  63150. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63151. */
  63152. export class ColorSplitterBlock extends NodeMaterialBlock {
  63153. /**
  63154. * Create a new ColorSplitterBlock
  63155. * @param name defines the block name
  63156. */
  63157. constructor(name: string);
  63158. /**
  63159. * Gets the current class name
  63160. * @returns the class name
  63161. */
  63162. getClassName(): string;
  63163. /**
  63164. * Gets the rgba component (input)
  63165. */
  63166. get rgba(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the rgb component (input)
  63169. */
  63170. get rgbIn(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the rgb component (output)
  63173. */
  63174. get rgbOut(): NodeMaterialConnectionPoint;
  63175. /**
  63176. * Gets the r component (output)
  63177. */
  63178. get r(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the g component (output)
  63181. */
  63182. get g(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the b component (output)
  63185. */
  63186. get b(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the a component (output)
  63189. */
  63190. get a(): NodeMaterialConnectionPoint;
  63191. protected _inputRename(name: string): string;
  63192. protected _outputRename(name: string): string;
  63193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63194. }
  63195. }
  63196. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63200. /**
  63201. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63202. */
  63203. export class VectorSplitterBlock extends NodeMaterialBlock {
  63204. /**
  63205. * Create a new VectorSplitterBlock
  63206. * @param name defines the block name
  63207. */
  63208. constructor(name: string);
  63209. /**
  63210. * Gets the current class name
  63211. * @returns the class name
  63212. */
  63213. getClassName(): string;
  63214. /**
  63215. * Gets the xyzw component (input)
  63216. */
  63217. get xyzw(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the xyz component (input)
  63220. */
  63221. get xyzIn(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the xy component (input)
  63224. */
  63225. get xyIn(): NodeMaterialConnectionPoint;
  63226. /**
  63227. * Gets the xyz component (output)
  63228. */
  63229. get xyzOut(): NodeMaterialConnectionPoint;
  63230. /**
  63231. * Gets the xy component (output)
  63232. */
  63233. get xyOut(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the x component (output)
  63236. */
  63237. get x(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the y component (output)
  63240. */
  63241. get y(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Gets the z component (output)
  63244. */
  63245. get z(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the w component (output)
  63248. */
  63249. get w(): NodeMaterialConnectionPoint;
  63250. protected _inputRename(name: string): string;
  63251. protected _outputRename(name: string): string;
  63252. protected _buildBlock(state: NodeMaterialBuildState): this;
  63253. }
  63254. }
  63255. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63259. /**
  63260. * Block used to lerp between 2 values
  63261. */
  63262. export class LerpBlock extends NodeMaterialBlock {
  63263. /**
  63264. * Creates a new LerpBlock
  63265. * @param name defines the block name
  63266. */
  63267. constructor(name: string);
  63268. /**
  63269. * Gets the current class name
  63270. * @returns the class name
  63271. */
  63272. getClassName(): string;
  63273. /**
  63274. * Gets the left operand input component
  63275. */
  63276. get left(): NodeMaterialConnectionPoint;
  63277. /**
  63278. * Gets the right operand input component
  63279. */
  63280. get right(): NodeMaterialConnectionPoint;
  63281. /**
  63282. * Gets the gradient operand input component
  63283. */
  63284. get gradient(): NodeMaterialConnectionPoint;
  63285. /**
  63286. * Gets the output component
  63287. */
  63288. get output(): NodeMaterialConnectionPoint;
  63289. protected _buildBlock(state: NodeMaterialBuildState): this;
  63290. }
  63291. }
  63292. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63296. /**
  63297. * Block used to divide 2 vectors
  63298. */
  63299. export class DivideBlock extends NodeMaterialBlock {
  63300. /**
  63301. * Creates a new DivideBlock
  63302. * @param name defines the block name
  63303. */
  63304. constructor(name: string);
  63305. /**
  63306. * Gets the current class name
  63307. * @returns the class name
  63308. */
  63309. getClassName(): string;
  63310. /**
  63311. * Gets the left operand input component
  63312. */
  63313. get left(): NodeMaterialConnectionPoint;
  63314. /**
  63315. * Gets the right operand input component
  63316. */
  63317. get right(): NodeMaterialConnectionPoint;
  63318. /**
  63319. * Gets the output component
  63320. */
  63321. get output(): NodeMaterialConnectionPoint;
  63322. protected _buildBlock(state: NodeMaterialBuildState): this;
  63323. }
  63324. }
  63325. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63329. /**
  63330. * Block used to subtract 2 vectors
  63331. */
  63332. export class SubtractBlock extends NodeMaterialBlock {
  63333. /**
  63334. * Creates a new SubtractBlock
  63335. * @param name defines the block name
  63336. */
  63337. constructor(name: string);
  63338. /**
  63339. * Gets the current class name
  63340. * @returns the class name
  63341. */
  63342. getClassName(): string;
  63343. /**
  63344. * Gets the left operand input component
  63345. */
  63346. get left(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the right operand input component
  63349. */
  63350. get right(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the output component
  63353. */
  63354. get output(): NodeMaterialConnectionPoint;
  63355. protected _buildBlock(state: NodeMaterialBuildState): this;
  63356. }
  63357. }
  63358. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63362. /**
  63363. * Block used to step a value
  63364. */
  63365. export class StepBlock extends NodeMaterialBlock {
  63366. /**
  63367. * Creates a new StepBlock
  63368. * @param name defines the block name
  63369. */
  63370. constructor(name: string);
  63371. /**
  63372. * Gets the current class name
  63373. * @returns the class name
  63374. */
  63375. getClassName(): string;
  63376. /**
  63377. * Gets the value operand input component
  63378. */
  63379. get value(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the edge operand input component
  63382. */
  63383. get edge(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the output component
  63386. */
  63387. get output(): NodeMaterialConnectionPoint;
  63388. protected _buildBlock(state: NodeMaterialBuildState): this;
  63389. }
  63390. }
  63391. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63395. /**
  63396. * Block used to get the opposite (1 - x) of a value
  63397. */
  63398. export class OneMinusBlock extends NodeMaterialBlock {
  63399. /**
  63400. * Creates a new OneMinusBlock
  63401. * @param name defines the block name
  63402. */
  63403. constructor(name: string);
  63404. /**
  63405. * Gets the current class name
  63406. * @returns the class name
  63407. */
  63408. getClassName(): string;
  63409. /**
  63410. * Gets the input component
  63411. */
  63412. get input(): NodeMaterialConnectionPoint;
  63413. /**
  63414. * Gets the output component
  63415. */
  63416. get output(): NodeMaterialConnectionPoint;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. }
  63419. }
  63420. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63424. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63425. /**
  63426. * Block used to get the view direction
  63427. */
  63428. export class ViewDirectionBlock extends NodeMaterialBlock {
  63429. /**
  63430. * Creates a new ViewDirectionBlock
  63431. * @param name defines the block name
  63432. */
  63433. constructor(name: string);
  63434. /**
  63435. * Gets the current class name
  63436. * @returns the class name
  63437. */
  63438. getClassName(): string;
  63439. /**
  63440. * Gets the world position component
  63441. */
  63442. get worldPosition(): NodeMaterialConnectionPoint;
  63443. /**
  63444. * Gets the camera position component
  63445. */
  63446. get cameraPosition(): NodeMaterialConnectionPoint;
  63447. /**
  63448. * Gets the output component
  63449. */
  63450. get output(): NodeMaterialConnectionPoint;
  63451. autoConfigure(material: NodeMaterial): void;
  63452. protected _buildBlock(state: NodeMaterialBuildState): this;
  63453. }
  63454. }
  63455. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63459. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63460. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63461. /**
  63462. * Block used to compute fresnel value
  63463. */
  63464. export class FresnelBlock extends NodeMaterialBlock {
  63465. /**
  63466. * Create a new FresnelBlock
  63467. * @param name defines the block name
  63468. */
  63469. constructor(name: string);
  63470. /**
  63471. * Gets the current class name
  63472. * @returns the class name
  63473. */
  63474. getClassName(): string;
  63475. /**
  63476. * Gets the world normal input component
  63477. */
  63478. get worldNormal(): NodeMaterialConnectionPoint;
  63479. /**
  63480. * Gets the view direction input component
  63481. */
  63482. get viewDirection(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the bias input component
  63485. */
  63486. get bias(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the camera (or eye) position component
  63489. */
  63490. get power(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the fresnel output component
  63493. */
  63494. get fresnel(): NodeMaterialConnectionPoint;
  63495. autoConfigure(material: NodeMaterial): void;
  63496. protected _buildBlock(state: NodeMaterialBuildState): this;
  63497. }
  63498. }
  63499. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63503. /**
  63504. * Block used to get the max of 2 values
  63505. */
  63506. export class MaxBlock extends NodeMaterialBlock {
  63507. /**
  63508. * Creates a new MaxBlock
  63509. * @param name defines the block name
  63510. */
  63511. constructor(name: string);
  63512. /**
  63513. * Gets the current class name
  63514. * @returns the class name
  63515. */
  63516. getClassName(): string;
  63517. /**
  63518. * Gets the left operand input component
  63519. */
  63520. get left(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the right operand input component
  63523. */
  63524. get right(): NodeMaterialConnectionPoint;
  63525. /**
  63526. * Gets the output component
  63527. */
  63528. get output(): NodeMaterialConnectionPoint;
  63529. protected _buildBlock(state: NodeMaterialBuildState): this;
  63530. }
  63531. }
  63532. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63536. /**
  63537. * Block used to get the min of 2 values
  63538. */
  63539. export class MinBlock extends NodeMaterialBlock {
  63540. /**
  63541. * Creates a new MinBlock
  63542. * @param name defines the block name
  63543. */
  63544. constructor(name: string);
  63545. /**
  63546. * Gets the current class name
  63547. * @returns the class name
  63548. */
  63549. getClassName(): string;
  63550. /**
  63551. * Gets the left operand input component
  63552. */
  63553. get left(): NodeMaterialConnectionPoint;
  63554. /**
  63555. * Gets the right operand input component
  63556. */
  63557. get right(): NodeMaterialConnectionPoint;
  63558. /**
  63559. * Gets the output component
  63560. */
  63561. get output(): NodeMaterialConnectionPoint;
  63562. protected _buildBlock(state: NodeMaterialBuildState): this;
  63563. }
  63564. }
  63565. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63569. /**
  63570. * Block used to get the distance between 2 values
  63571. */
  63572. export class DistanceBlock extends NodeMaterialBlock {
  63573. /**
  63574. * Creates a new DistanceBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the left operand input component
  63585. */
  63586. get left(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the right operand input component
  63589. */
  63590. get right(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the output component
  63593. */
  63594. get output(): NodeMaterialConnectionPoint;
  63595. protected _buildBlock(state: NodeMaterialBuildState): this;
  63596. }
  63597. }
  63598. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63602. /**
  63603. * Block used to get the length of a vector
  63604. */
  63605. export class LengthBlock extends NodeMaterialBlock {
  63606. /**
  63607. * Creates a new LengthBlock
  63608. * @param name defines the block name
  63609. */
  63610. constructor(name: string);
  63611. /**
  63612. * Gets the current class name
  63613. * @returns the class name
  63614. */
  63615. getClassName(): string;
  63616. /**
  63617. * Gets the value input component
  63618. */
  63619. get value(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the output component
  63622. */
  63623. get output(): NodeMaterialConnectionPoint;
  63624. protected _buildBlock(state: NodeMaterialBuildState): this;
  63625. }
  63626. }
  63627. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63631. /**
  63632. * Block used to get negative version of a value (i.e. x * -1)
  63633. */
  63634. export class NegateBlock extends NodeMaterialBlock {
  63635. /**
  63636. * Creates a new NegateBlock
  63637. * @param name defines the block name
  63638. */
  63639. constructor(name: string);
  63640. /**
  63641. * Gets the current class name
  63642. * @returns the class name
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * Gets the value input component
  63647. */
  63648. get value(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the output component
  63651. */
  63652. get output(): NodeMaterialConnectionPoint;
  63653. protected _buildBlock(state: NodeMaterialBuildState): this;
  63654. }
  63655. }
  63656. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63657. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63658. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63660. /**
  63661. * Block used to get the value of the first parameter raised to the power of the second
  63662. */
  63663. export class PowBlock extends NodeMaterialBlock {
  63664. /**
  63665. * Creates a new PowBlock
  63666. * @param name defines the block name
  63667. */
  63668. constructor(name: string);
  63669. /**
  63670. * Gets the current class name
  63671. * @returns the class name
  63672. */
  63673. getClassName(): string;
  63674. /**
  63675. * Gets the value operand input component
  63676. */
  63677. get value(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the power operand input component
  63680. */
  63681. get power(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the output component
  63684. */
  63685. get output(): NodeMaterialConnectionPoint;
  63686. protected _buildBlock(state: NodeMaterialBuildState): this;
  63687. }
  63688. }
  63689. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63693. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63694. /**
  63695. * Block used to get a random number
  63696. */
  63697. export class RandomNumberBlock extends NodeMaterialBlock {
  63698. /**
  63699. * Creates a new RandomNumberBlock
  63700. * @param name defines the block name
  63701. */
  63702. constructor(name: string);
  63703. /**
  63704. * Gets the current class name
  63705. * @returns the class name
  63706. */
  63707. getClassName(): string;
  63708. /**
  63709. * Gets the seed input component
  63710. */
  63711. get seed(): NodeMaterialConnectionPoint;
  63712. /**
  63713. * Gets the output component
  63714. */
  63715. get output(): NodeMaterialConnectionPoint;
  63716. protected _buildBlock(state: NodeMaterialBuildState): this;
  63717. }
  63718. }
  63719. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63723. /**
  63724. * Block used to compute arc tangent of 2 values
  63725. */
  63726. export class ArcTan2Block extends NodeMaterialBlock {
  63727. /**
  63728. * Creates a new ArcTan2Block
  63729. * @param name defines the block name
  63730. */
  63731. constructor(name: string);
  63732. /**
  63733. * Gets the current class name
  63734. * @returns the class name
  63735. */
  63736. getClassName(): string;
  63737. /**
  63738. * Gets the x operand input component
  63739. */
  63740. get x(): NodeMaterialConnectionPoint;
  63741. /**
  63742. * Gets the y operand input component
  63743. */
  63744. get y(): NodeMaterialConnectionPoint;
  63745. /**
  63746. * Gets the output component
  63747. */
  63748. get output(): NodeMaterialConnectionPoint;
  63749. protected _buildBlock(state: NodeMaterialBuildState): this;
  63750. }
  63751. }
  63752. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63756. /**
  63757. * Block used to smooth step a value
  63758. */
  63759. export class SmoothStepBlock extends NodeMaterialBlock {
  63760. /**
  63761. * Creates a new SmoothStepBlock
  63762. * @param name defines the block name
  63763. */
  63764. constructor(name: string);
  63765. /**
  63766. * Gets the current class name
  63767. * @returns the class name
  63768. */
  63769. getClassName(): string;
  63770. /**
  63771. * Gets the value operand input component
  63772. */
  63773. get value(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the first edge operand input component
  63776. */
  63777. get edge0(): NodeMaterialConnectionPoint;
  63778. /**
  63779. * Gets the second edge operand input component
  63780. */
  63781. get edge1(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the output component
  63784. */
  63785. get output(): NodeMaterialConnectionPoint;
  63786. protected _buildBlock(state: NodeMaterialBuildState): this;
  63787. }
  63788. }
  63789. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63793. /**
  63794. * Block used to get the reciprocal (1 / x) of a value
  63795. */
  63796. export class ReciprocalBlock extends NodeMaterialBlock {
  63797. /**
  63798. * Creates a new ReciprocalBlock
  63799. * @param name defines the block name
  63800. */
  63801. constructor(name: string);
  63802. /**
  63803. * Gets the current class name
  63804. * @returns the class name
  63805. */
  63806. getClassName(): string;
  63807. /**
  63808. * Gets the input component
  63809. */
  63810. get input(): NodeMaterialConnectionPoint;
  63811. /**
  63812. * Gets the output component
  63813. */
  63814. get output(): NodeMaterialConnectionPoint;
  63815. protected _buildBlock(state: NodeMaterialBuildState): this;
  63816. }
  63817. }
  63818. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63819. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63820. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63821. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63822. /**
  63823. * Block used to replace a color by another one
  63824. */
  63825. export class ReplaceColorBlock extends NodeMaterialBlock {
  63826. /**
  63827. * Creates a new ReplaceColorBlock
  63828. * @param name defines the block name
  63829. */
  63830. constructor(name: string);
  63831. /**
  63832. * Gets the current class name
  63833. * @returns the class name
  63834. */
  63835. getClassName(): string;
  63836. /**
  63837. * Gets the value input component
  63838. */
  63839. get value(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the reference input component
  63842. */
  63843. get reference(): NodeMaterialConnectionPoint;
  63844. /**
  63845. * Gets the distance input component
  63846. */
  63847. get distance(): NodeMaterialConnectionPoint;
  63848. /**
  63849. * Gets the replacement input component
  63850. */
  63851. get replacement(): NodeMaterialConnectionPoint;
  63852. /**
  63853. * Gets the output component
  63854. */
  63855. get output(): NodeMaterialConnectionPoint;
  63856. protected _buildBlock(state: NodeMaterialBuildState): this;
  63857. }
  63858. }
  63859. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63863. /**
  63864. * Block used to posterize a value
  63865. * @see https://en.wikipedia.org/wiki/Posterization
  63866. */
  63867. export class PosterizeBlock extends NodeMaterialBlock {
  63868. /**
  63869. * Creates a new PosterizeBlock
  63870. * @param name defines the block name
  63871. */
  63872. constructor(name: string);
  63873. /**
  63874. * Gets the current class name
  63875. * @returns the class name
  63876. */
  63877. getClassName(): string;
  63878. /**
  63879. * Gets the value input component
  63880. */
  63881. get value(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the steps input component
  63884. */
  63885. get steps(): NodeMaterialConnectionPoint;
  63886. /**
  63887. * Gets the output component
  63888. */
  63889. get output(): NodeMaterialConnectionPoint;
  63890. protected _buildBlock(state: NodeMaterialBuildState): this;
  63891. }
  63892. }
  63893. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63897. import { Scene } from "babylonjs/scene";
  63898. /**
  63899. * Operations supported by the Wave block
  63900. */
  63901. export enum WaveBlockKind {
  63902. /** SawTooth */
  63903. SawTooth = 0,
  63904. /** Square */
  63905. Square = 1,
  63906. /** Triangle */
  63907. Triangle = 2
  63908. }
  63909. /**
  63910. * Block used to apply wave operation to floats
  63911. */
  63912. export class WaveBlock extends NodeMaterialBlock {
  63913. /**
  63914. * Gets or sets the kibnd of wave to be applied by the block
  63915. */
  63916. kind: WaveBlockKind;
  63917. /**
  63918. * Creates a new WaveBlock
  63919. * @param name defines the block name
  63920. */
  63921. constructor(name: string);
  63922. /**
  63923. * Gets the current class name
  63924. * @returns the class name
  63925. */
  63926. getClassName(): string;
  63927. /**
  63928. * Gets the input component
  63929. */
  63930. get input(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the output component
  63933. */
  63934. get output(): NodeMaterialConnectionPoint;
  63935. protected _buildBlock(state: NodeMaterialBuildState): this;
  63936. serialize(): any;
  63937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63938. }
  63939. }
  63940. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63944. import { Color3 } from "babylonjs/Maths/math.color";
  63945. import { Scene } from "babylonjs/scene";
  63946. /**
  63947. * Class used to store a color step for the GradientBlock
  63948. */
  63949. export class GradientBlockColorStep {
  63950. /**
  63951. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63952. */
  63953. step: number;
  63954. /**
  63955. * Gets or sets the color associated with this step
  63956. */
  63957. color: Color3;
  63958. /**
  63959. * Creates a new GradientBlockColorStep
  63960. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63961. * @param color defines the color associated with this step
  63962. */
  63963. constructor(
  63964. /**
  63965. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63966. */
  63967. step: number,
  63968. /**
  63969. * Gets or sets the color associated with this step
  63970. */
  63971. color: Color3);
  63972. }
  63973. /**
  63974. * Block used to return a color from a gradient based on an input value between 0 and 1
  63975. */
  63976. export class GradientBlock extends NodeMaterialBlock {
  63977. /**
  63978. * Gets or sets the list of color steps
  63979. */
  63980. colorSteps: GradientBlockColorStep[];
  63981. /**
  63982. * Creates a new GradientBlock
  63983. * @param name defines the block name
  63984. */
  63985. constructor(name: string);
  63986. /**
  63987. * Gets the current class name
  63988. * @returns the class name
  63989. */
  63990. getClassName(): string;
  63991. /**
  63992. * Gets the gradient input component
  63993. */
  63994. get gradient(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the output component
  63997. */
  63998. get output(): NodeMaterialConnectionPoint;
  63999. private _writeColorConstant;
  64000. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64001. serialize(): any;
  64002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64003. protected _dumpPropertiesCode(): string;
  64004. }
  64005. }
  64006. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64010. /**
  64011. * Block used to normalize lerp between 2 values
  64012. */
  64013. export class NLerpBlock extends NodeMaterialBlock {
  64014. /**
  64015. * Creates a new NLerpBlock
  64016. * @param name defines the block name
  64017. */
  64018. constructor(name: string);
  64019. /**
  64020. * Gets the current class name
  64021. * @returns the class name
  64022. */
  64023. getClassName(): string;
  64024. /**
  64025. * Gets the left operand input component
  64026. */
  64027. get left(): NodeMaterialConnectionPoint;
  64028. /**
  64029. * Gets the right operand input component
  64030. */
  64031. get right(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the gradient operand input component
  64034. */
  64035. get gradient(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the output component
  64038. */
  64039. get output(): NodeMaterialConnectionPoint;
  64040. protected _buildBlock(state: NodeMaterialBuildState): this;
  64041. }
  64042. }
  64043. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64047. import { Scene } from "babylonjs/scene";
  64048. /**
  64049. * block used to Generate a Worley Noise 3D Noise Pattern
  64050. */
  64051. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64052. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64053. manhattanDistance: boolean;
  64054. /**
  64055. * Creates a new WorleyNoise3DBlock
  64056. * @param name defines the block name
  64057. */
  64058. constructor(name: string);
  64059. /**
  64060. * Gets the current class name
  64061. * @returns the class name
  64062. */
  64063. getClassName(): string;
  64064. /**
  64065. * Gets the seed input component
  64066. */
  64067. get seed(): NodeMaterialConnectionPoint;
  64068. /**
  64069. * Gets the jitter input component
  64070. */
  64071. get jitter(): NodeMaterialConnectionPoint;
  64072. /**
  64073. * Gets the output component
  64074. */
  64075. get output(): NodeMaterialConnectionPoint;
  64076. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64077. /**
  64078. * Exposes the properties to the UI?
  64079. */
  64080. protected _dumpPropertiesCode(): string;
  64081. /**
  64082. * Exposes the properties to the Seralize?
  64083. */
  64084. serialize(): any;
  64085. /**
  64086. * Exposes the properties to the deseralize?
  64087. */
  64088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64089. }
  64090. }
  64091. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64095. /**
  64096. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64097. */
  64098. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64099. /**
  64100. * Creates a new SimplexPerlin3DBlock
  64101. * @param name defines the block name
  64102. */
  64103. constructor(name: string);
  64104. /**
  64105. * Gets the current class name
  64106. * @returns the class name
  64107. */
  64108. getClassName(): string;
  64109. /**
  64110. * Gets the seed operand input component
  64111. */
  64112. get seed(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the output component
  64115. */
  64116. get output(): NodeMaterialConnectionPoint;
  64117. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64118. }
  64119. }
  64120. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64124. /**
  64125. * Block used to blend normals
  64126. */
  64127. export class NormalBlendBlock extends NodeMaterialBlock {
  64128. /**
  64129. * Creates a new NormalBlendBlock
  64130. * @param name defines the block name
  64131. */
  64132. constructor(name: string);
  64133. /**
  64134. * Gets the current class name
  64135. * @returns the class name
  64136. */
  64137. getClassName(): string;
  64138. /**
  64139. * Gets the first input component
  64140. */
  64141. get normalMap0(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the second input component
  64144. */
  64145. get normalMap1(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the output component
  64148. */
  64149. get output(): NodeMaterialConnectionPoint;
  64150. protected _buildBlock(state: NodeMaterialBuildState): this;
  64151. }
  64152. }
  64153. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64157. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64158. /**
  64159. * Block used to rotate a 2d vector by a given angle
  64160. */
  64161. export class Rotate2dBlock extends NodeMaterialBlock {
  64162. /**
  64163. * Creates a new Rotate2dBlock
  64164. * @param name defines the block name
  64165. */
  64166. constructor(name: string);
  64167. /**
  64168. * Gets the current class name
  64169. * @returns the class name
  64170. */
  64171. getClassName(): string;
  64172. /**
  64173. * Gets the input vector
  64174. */
  64175. get input(): NodeMaterialConnectionPoint;
  64176. /**
  64177. * Gets the input angle
  64178. */
  64179. get angle(): NodeMaterialConnectionPoint;
  64180. /**
  64181. * Gets the output component
  64182. */
  64183. get output(): NodeMaterialConnectionPoint;
  64184. autoConfigure(material: NodeMaterial): void;
  64185. protected _buildBlock(state: NodeMaterialBuildState): this;
  64186. }
  64187. }
  64188. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64192. /**
  64193. * Block used to get the reflected vector from a direction and a normal
  64194. */
  64195. export class ReflectBlock extends NodeMaterialBlock {
  64196. /**
  64197. * Creates a new ReflectBlock
  64198. * @param name defines the block name
  64199. */
  64200. constructor(name: string);
  64201. /**
  64202. * Gets the current class name
  64203. * @returns the class name
  64204. */
  64205. getClassName(): string;
  64206. /**
  64207. * Gets the incident component
  64208. */
  64209. get incident(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the normal component
  64212. */
  64213. get normal(): NodeMaterialConnectionPoint;
  64214. /**
  64215. * Gets the output component
  64216. */
  64217. get output(): NodeMaterialConnectionPoint;
  64218. protected _buildBlock(state: NodeMaterialBuildState): this;
  64219. }
  64220. }
  64221. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64225. /**
  64226. * Block used to get the refracted vector from a direction and a normal
  64227. */
  64228. export class RefractBlock extends NodeMaterialBlock {
  64229. /**
  64230. * Creates a new RefractBlock
  64231. * @param name defines the block name
  64232. */
  64233. constructor(name: string);
  64234. /**
  64235. * Gets the current class name
  64236. * @returns the class name
  64237. */
  64238. getClassName(): string;
  64239. /**
  64240. * Gets the incident component
  64241. */
  64242. get incident(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the normal component
  64245. */
  64246. get normal(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the index of refraction component
  64249. */
  64250. get ior(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the output component
  64253. */
  64254. get output(): NodeMaterialConnectionPoint;
  64255. protected _buildBlock(state: NodeMaterialBuildState): this;
  64256. }
  64257. }
  64258. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64262. /**
  64263. * Block used to desaturate a color
  64264. */
  64265. export class DesaturateBlock extends NodeMaterialBlock {
  64266. /**
  64267. * Creates a new DesaturateBlock
  64268. * @param name defines the block name
  64269. */
  64270. constructor(name: string);
  64271. /**
  64272. * Gets the current class name
  64273. * @returns the class name
  64274. */
  64275. getClassName(): string;
  64276. /**
  64277. * Gets the color operand input component
  64278. */
  64279. get color(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the level operand input component
  64282. */
  64283. get level(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the output component
  64286. */
  64287. get output(): NodeMaterialConnectionPoint;
  64288. protected _buildBlock(state: NodeMaterialBuildState): this;
  64289. }
  64290. }
  64291. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64295. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64296. import { Nullable } from "babylonjs/types";
  64297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64298. import { Scene } from "babylonjs/scene";
  64299. /**
  64300. * Block used to implement the ambient occlusion module of the PBR material
  64301. */
  64302. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64303. /**
  64304. * Create a new AmbientOcclusionBlock
  64305. * @param name defines the block name
  64306. */
  64307. constructor(name: string);
  64308. /**
  64309. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64310. */
  64311. useAmbientInGrayScale: boolean;
  64312. /**
  64313. * Initialize the block and prepare the context for build
  64314. * @param state defines the state that will be used for the build
  64315. */
  64316. initialize(state: NodeMaterialBuildState): void;
  64317. /**
  64318. * Gets the current class name
  64319. * @returns the class name
  64320. */
  64321. getClassName(): string;
  64322. /**
  64323. * Gets the texture input component
  64324. */
  64325. get texture(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the texture intensity component
  64328. */
  64329. get intensity(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the direct light intensity input component
  64332. */
  64333. get directLightIntensity(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the ambient occlusion object output component
  64336. */
  64337. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the main code of the block (fragment side)
  64340. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64341. * @returns the shader code
  64342. */
  64343. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64345. protected _buildBlock(state: NodeMaterialBuildState): this;
  64346. protected _dumpPropertiesCode(): string;
  64347. serialize(): any;
  64348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64349. }
  64350. }
  64351. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64354. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64355. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64357. import { Nullable } from "babylonjs/types";
  64358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64359. import { Mesh } from "babylonjs/Meshes/mesh";
  64360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64361. import { Effect } from "babylonjs/Materials/effect";
  64362. import { Scene } from "babylonjs/scene";
  64363. /**
  64364. * Block used to implement the reflection module of the PBR material
  64365. */
  64366. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64367. /** @hidden */
  64368. _defineLODReflectionAlpha: string;
  64369. /** @hidden */
  64370. _defineLinearSpecularReflection: string;
  64371. private _vEnvironmentIrradianceName;
  64372. /** @hidden */
  64373. _vReflectionMicrosurfaceInfosName: string;
  64374. /** @hidden */
  64375. _vReflectionInfosName: string;
  64376. private _scene;
  64377. /**
  64378. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64379. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64380. * It's less burden on the user side in the editor part.
  64381. */
  64382. /** @hidden */
  64383. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64384. /** @hidden */
  64385. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64386. /** @hidden */
  64387. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64388. /**
  64389. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64390. * diffuse part of the IBL.
  64391. */
  64392. useSphericalHarmonics: boolean;
  64393. /**
  64394. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64395. */
  64396. forceIrradianceInFragment: boolean;
  64397. /**
  64398. * Create a new ReflectionBlock
  64399. * @param name defines the block name
  64400. */
  64401. constructor(name: string);
  64402. /**
  64403. * Gets the current class name
  64404. * @returns the class name
  64405. */
  64406. getClassName(): string;
  64407. /**
  64408. * Gets the position input component
  64409. */
  64410. get position(): NodeMaterialConnectionPoint;
  64411. /**
  64412. * Gets the world position input component
  64413. */
  64414. get worldPosition(): NodeMaterialConnectionPoint;
  64415. /**
  64416. * Gets the world normal input component
  64417. */
  64418. get worldNormal(): NodeMaterialConnectionPoint;
  64419. /**
  64420. * Gets the world input component
  64421. */
  64422. get world(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the camera (or eye) position component
  64425. */
  64426. get cameraPosition(): NodeMaterialConnectionPoint;
  64427. /**
  64428. * Gets the view input component
  64429. */
  64430. get view(): NodeMaterialConnectionPoint;
  64431. /**
  64432. * Gets the color input component
  64433. */
  64434. get color(): NodeMaterialConnectionPoint;
  64435. /**
  64436. * Gets the reflection object output component
  64437. */
  64438. get reflection(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64441. */
  64442. get hasTexture(): boolean;
  64443. /**
  64444. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64445. */
  64446. get reflectionColor(): string;
  64447. protected _getTexture(): Nullable<BaseTexture>;
  64448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64450. /**
  64451. * Gets the code to inject in the vertex shader
  64452. * @param state current state of the node material building
  64453. * @returns the shader code
  64454. */
  64455. handleVertexSide(state: NodeMaterialBuildState): string;
  64456. /**
  64457. * Gets the main code of the block (fragment side)
  64458. * @param state current state of the node material building
  64459. * @param normalVarName name of the existing variable corresponding to the normal
  64460. * @returns the shader code
  64461. */
  64462. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64463. protected _buildBlock(state: NodeMaterialBuildState): this;
  64464. protected _dumpPropertiesCode(): string;
  64465. serialize(): any;
  64466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64467. }
  64468. }
  64469. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64475. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64476. import { Scene } from "babylonjs/scene";
  64477. import { Nullable } from "babylonjs/types";
  64478. /**
  64479. * Block used to implement the sheen module of the PBR material
  64480. */
  64481. export class SheenBlock extends NodeMaterialBlock {
  64482. /**
  64483. * Create a new SheenBlock
  64484. * @param name defines the block name
  64485. */
  64486. constructor(name: string);
  64487. /**
  64488. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64489. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64490. * making it easier to setup and tweak the effect
  64491. */
  64492. albedoScaling: boolean;
  64493. /**
  64494. * Defines if the sheen is linked to the sheen color.
  64495. */
  64496. linkSheenWithAlbedo: boolean;
  64497. /**
  64498. * Initialize the block and prepare the context for build
  64499. * @param state defines the state that will be used for the build
  64500. */
  64501. initialize(state: NodeMaterialBuildState): void;
  64502. /**
  64503. * Gets the current class name
  64504. * @returns the class name
  64505. */
  64506. getClassName(): string;
  64507. /**
  64508. * Gets the intensity input component
  64509. */
  64510. get intensity(): NodeMaterialConnectionPoint;
  64511. /**
  64512. * Gets the color input component
  64513. */
  64514. get color(): NodeMaterialConnectionPoint;
  64515. /**
  64516. * Gets the roughness input component
  64517. */
  64518. get roughness(): NodeMaterialConnectionPoint;
  64519. /**
  64520. * Gets the texture input component
  64521. */
  64522. get texture(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the sheen object output component
  64525. */
  64526. get sheen(): NodeMaterialConnectionPoint;
  64527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64528. /**
  64529. * Gets the main code of the block (fragment side)
  64530. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64531. * @returns the shader code
  64532. */
  64533. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64534. protected _buildBlock(state: NodeMaterialBuildState): this;
  64535. protected _dumpPropertiesCode(): string;
  64536. serialize(): any;
  64537. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64538. }
  64539. }
  64540. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64541. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64546. import { Scene } from "babylonjs/scene";
  64547. /**
  64548. * Block used to implement the reflectivity module of the PBR material
  64549. */
  64550. export class ReflectivityBlock extends NodeMaterialBlock {
  64551. /**
  64552. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64553. */
  64554. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64555. /**
  64556. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64557. */
  64558. useMetallnessFromMetallicTextureBlue: boolean;
  64559. /**
  64560. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64561. */
  64562. useRoughnessFromMetallicTextureAlpha: boolean;
  64563. /**
  64564. * Specifies if the metallic texture contains the roughness information in its green channel.
  64565. */
  64566. useRoughnessFromMetallicTextureGreen: boolean;
  64567. /**
  64568. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64569. */
  64570. useMetallicF0FactorFromMetallicTexture: boolean;
  64571. /**
  64572. * Create a new ReflectivityBlock
  64573. * @param name defines the block name
  64574. */
  64575. constructor(name: string);
  64576. /**
  64577. * Initialize the block and prepare the context for build
  64578. * @param state defines the state that will be used for the build
  64579. */
  64580. initialize(state: NodeMaterialBuildState): void;
  64581. /**
  64582. * Gets the current class name
  64583. * @returns the class name
  64584. */
  64585. getClassName(): string;
  64586. /**
  64587. * Gets the metallic input component
  64588. */
  64589. get metallic(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the roughness input component
  64592. */
  64593. get roughness(): NodeMaterialConnectionPoint;
  64594. /**
  64595. * Gets the texture input component
  64596. */
  64597. get texture(): NodeMaterialConnectionPoint;
  64598. /**
  64599. * Gets the reflectivity object output component
  64600. */
  64601. get reflectivity(): NodeMaterialConnectionPoint;
  64602. /**
  64603. * Gets the main code of the block (fragment side)
  64604. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64605. * @returns the shader code
  64606. */
  64607. getCode(aoIntensityVarName: string): string;
  64608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64609. protected _buildBlock(state: NodeMaterialBuildState): this;
  64610. protected _dumpPropertiesCode(): string;
  64611. serialize(): any;
  64612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64613. }
  64614. }
  64615. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64616. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64621. /**
  64622. * Block used to implement the anisotropy module of the PBR material
  64623. */
  64624. export class AnisotropyBlock extends NodeMaterialBlock {
  64625. /**
  64626. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64627. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64628. * It's less burden on the user side in the editor part.
  64629. */
  64630. /** @hidden */
  64631. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64632. /** @hidden */
  64633. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64634. /**
  64635. * Create a new AnisotropyBlock
  64636. * @param name defines the block name
  64637. */
  64638. constructor(name: string);
  64639. /**
  64640. * Initialize the block and prepare the context for build
  64641. * @param state defines the state that will be used for the build
  64642. */
  64643. initialize(state: NodeMaterialBuildState): void;
  64644. /**
  64645. * Gets the current class name
  64646. * @returns the class name
  64647. */
  64648. getClassName(): string;
  64649. /**
  64650. * Gets the intensity input component
  64651. */
  64652. get intensity(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the direction input component
  64655. */
  64656. get direction(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the texture input component
  64659. */
  64660. get texture(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the uv input component
  64663. */
  64664. get uv(): NodeMaterialConnectionPoint;
  64665. /**
  64666. * Gets the worldTangent input component
  64667. */
  64668. get worldTangent(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the anisotropy object output component
  64671. */
  64672. get anisotropy(): NodeMaterialConnectionPoint;
  64673. private _generateTBNSpace;
  64674. /**
  64675. * Gets the main code of the block (fragment side)
  64676. * @param state current state of the node material building
  64677. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64678. * @returns the shader code
  64679. */
  64680. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64682. protected _buildBlock(state: NodeMaterialBuildState): this;
  64683. }
  64684. }
  64685. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64689. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64691. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64692. import { Nullable } from "babylonjs/types";
  64693. import { Mesh } from "babylonjs/Meshes/mesh";
  64694. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64695. import { Effect } from "babylonjs/Materials/effect";
  64696. /**
  64697. * Block used to implement the clear coat module of the PBR material
  64698. */
  64699. export class ClearCoatBlock extends NodeMaterialBlock {
  64700. private _scene;
  64701. /**
  64702. * Create a new ClearCoatBlock
  64703. * @param name defines the block name
  64704. */
  64705. constructor(name: string);
  64706. /**
  64707. * Initialize the block and prepare the context for build
  64708. * @param state defines the state that will be used for the build
  64709. */
  64710. initialize(state: NodeMaterialBuildState): void;
  64711. /**
  64712. * Gets the current class name
  64713. * @returns the class name
  64714. */
  64715. getClassName(): string;
  64716. /**
  64717. * Gets the intensity input component
  64718. */
  64719. get intensity(): NodeMaterialConnectionPoint;
  64720. /**
  64721. * Gets the roughness input component
  64722. */
  64723. get roughness(): NodeMaterialConnectionPoint;
  64724. /**
  64725. * Gets the ior input component
  64726. */
  64727. get ior(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the texture input component
  64730. */
  64731. get texture(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the bump texture input component
  64734. */
  64735. get bumpTexture(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the uv input component
  64738. */
  64739. get uv(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the tint color input component
  64742. */
  64743. get tintColor(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the tint "at distance" input component
  64746. */
  64747. get tintAtDistance(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the tint thickness input component
  64750. */
  64751. get tintThickness(): NodeMaterialConnectionPoint;
  64752. /**
  64753. * Gets the tint texture input component
  64754. */
  64755. get tintTexture(): NodeMaterialConnectionPoint;
  64756. /**
  64757. * Gets the world tangent input component
  64758. */
  64759. get worldTangent(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the clear coat object output component
  64762. */
  64763. get clearcoat(): NodeMaterialConnectionPoint;
  64764. autoConfigure(material: NodeMaterial): void;
  64765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64767. private _generateTBNSpace;
  64768. /**
  64769. * Gets the main code of the block (fragment side)
  64770. * @param state current state of the node material building
  64771. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64772. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64773. * @param worldPosVarName name of the variable holding the world position
  64774. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64775. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64776. * @param worldNormalVarName name of the variable holding the world normal
  64777. * @returns the shader code
  64778. */
  64779. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64780. protected _buildBlock(state: NodeMaterialBuildState): this;
  64781. }
  64782. }
  64783. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  64784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64787. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64789. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64790. import { Nullable } from "babylonjs/types";
  64791. /**
  64792. * Block used to implement the sub surface module of the PBR material
  64793. */
  64794. export class SubSurfaceBlock extends NodeMaterialBlock {
  64795. /**
  64796. * Create a new SubSurfaceBlock
  64797. * @param name defines the block name
  64798. */
  64799. constructor(name: string);
  64800. /**
  64801. * Stores the intensity of the different subsurface effects in the thickness texture.
  64802. * * the green channel is the translucency intensity.
  64803. * * the blue channel is the scattering intensity.
  64804. * * the alpha channel is the refraction intensity.
  64805. */
  64806. useMaskFromThicknessTexture: boolean;
  64807. /**
  64808. * Initialize the block and prepare the context for build
  64809. * @param state defines the state that will be used for the build
  64810. */
  64811. initialize(state: NodeMaterialBuildState): void;
  64812. /**
  64813. * Gets the current class name
  64814. * @returns the class name
  64815. */
  64816. getClassName(): string;
  64817. /**
  64818. * Gets the min thickness input component
  64819. */
  64820. get minThickness(): NodeMaterialConnectionPoint;
  64821. /**
  64822. * Gets the max thickness input component
  64823. */
  64824. get maxThickness(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the thickness texture component
  64827. */
  64828. get thicknessTexture(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the tint color input component
  64831. */
  64832. get tintColor(): NodeMaterialConnectionPoint;
  64833. /**
  64834. * Gets the translucency intensity input component
  64835. */
  64836. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64837. /**
  64838. * Gets the translucency diffusion distance input component
  64839. */
  64840. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the refraction object parameters
  64843. */
  64844. get refraction(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the sub surface object output component
  64847. */
  64848. get subsurface(): NodeMaterialConnectionPoint;
  64849. autoConfigure(material: NodeMaterial): void;
  64850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64851. /**
  64852. * Gets the main code of the block (fragment side)
  64853. * @param state current state of the node material building
  64854. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64855. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64856. * @param worldPosVarName name of the variable holding the world position
  64857. * @returns the shader code
  64858. */
  64859. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. }
  64862. }
  64863. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  64864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64867. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64868. import { Light } from "babylonjs/Lights/light";
  64869. import { Nullable } from "babylonjs/types";
  64870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64871. import { Effect } from "babylonjs/Materials/effect";
  64872. import { Mesh } from "babylonjs/Meshes/mesh";
  64873. import { Scene } from "babylonjs/scene";
  64874. /**
  64875. * Block used to implement the PBR metallic/roughness model
  64876. */
  64877. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64878. /**
  64879. * Gets or sets the light associated with this block
  64880. */
  64881. light: Nullable<Light>;
  64882. private _lightId;
  64883. private _scene;
  64884. private _environmentBRDFTexture;
  64885. private _environmentBrdfSamplerName;
  64886. private _vNormalWName;
  64887. private _invertNormalName;
  64888. /**
  64889. * Create a new ReflectionBlock
  64890. * @param name defines the block name
  64891. */
  64892. constructor(name: string);
  64893. /**
  64894. * Intensity of the direct lights e.g. the four lights available in your scene.
  64895. * This impacts both the direct diffuse and specular highlights.
  64896. */
  64897. directIntensity: number;
  64898. /**
  64899. * Intensity of the environment e.g. how much the environment will light the object
  64900. * either through harmonics for rough material or through the refelction for shiny ones.
  64901. */
  64902. environmentIntensity: number;
  64903. /**
  64904. * This is a special control allowing the reduction of the specular highlights coming from the
  64905. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64906. */
  64907. specularIntensity: number;
  64908. /**
  64909. * Defines the falloff type used in this material.
  64910. * It by default is Physical.
  64911. */
  64912. lightFalloff: number;
  64913. /**
  64914. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64915. */
  64916. useAlphaFromAlbedoTexture: boolean;
  64917. /**
  64918. * Specifies that alpha test should be used
  64919. */
  64920. useAlphaTest: boolean;
  64921. /**
  64922. * Defines the alpha limits in alpha test mode.
  64923. */
  64924. alphaTestCutoff: number;
  64925. /**
  64926. * Specifies that alpha blending should be used
  64927. */
  64928. useAlphaBlending: boolean;
  64929. /**
  64930. * Defines if the alpha value should be determined via the rgb values.
  64931. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64932. */
  64933. opacityRGB: boolean;
  64934. /**
  64935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64937. */
  64938. useRadianceOverAlpha: boolean;
  64939. /**
  64940. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64941. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64942. */
  64943. useSpecularOverAlpha: boolean;
  64944. /**
  64945. * Enables specular anti aliasing in the PBR shader.
  64946. * It will both interacts on the Geometry for analytical and IBL lighting.
  64947. * It also prefilter the roughness map based on the bump values.
  64948. */
  64949. enableSpecularAntiAliasing: boolean;
  64950. /**
  64951. * Defines if the material uses energy conservation.
  64952. */
  64953. useEnergyConservation: boolean;
  64954. /**
  64955. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64956. * too much the area relying on ambient texture to define their ambient occlusion.
  64957. */
  64958. useRadianceOcclusion: boolean;
  64959. /**
  64960. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64961. * makes the reflect vector face the model (under horizon).
  64962. */
  64963. useHorizonOcclusion: boolean;
  64964. /**
  64965. * If set to true, no lighting calculations will be applied.
  64966. */
  64967. unlit: boolean;
  64968. /**
  64969. * Force normal to face away from face.
  64970. */
  64971. forceNormalForward: boolean;
  64972. /**
  64973. * Defines the material debug mode.
  64974. * It helps seeing only some components of the material while troubleshooting.
  64975. */
  64976. debugMode: number;
  64977. /**
  64978. * Specify from where on screen the debug mode should start.
  64979. * The value goes from -1 (full screen) to 1 (not visible)
  64980. * It helps with side by side comparison against the final render
  64981. * This defaults to 0
  64982. */
  64983. debugLimit: number;
  64984. /**
  64985. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64986. * You can use the factor to better multiply the final value.
  64987. */
  64988. debugFactor: number;
  64989. /**
  64990. * Initialize the block and prepare the context for build
  64991. * @param state defines the state that will be used for the build
  64992. */
  64993. initialize(state: NodeMaterialBuildState): void;
  64994. /**
  64995. * Gets the current class name
  64996. * @returns the class name
  64997. */
  64998. getClassName(): string;
  64999. /**
  65000. * Gets the world position input component
  65001. */
  65002. get worldPosition(): NodeMaterialConnectionPoint;
  65003. /**
  65004. * Gets the world normal input component
  65005. */
  65006. get worldNormal(): NodeMaterialConnectionPoint;
  65007. /**
  65008. * Gets the perturbed normal input component
  65009. */
  65010. get perturbedNormal(): NodeMaterialConnectionPoint;
  65011. /**
  65012. * Gets the camera position input component
  65013. */
  65014. get cameraPosition(): NodeMaterialConnectionPoint;
  65015. /**
  65016. * Gets the base color input component
  65017. */
  65018. get baseColor(): NodeMaterialConnectionPoint;
  65019. /**
  65020. * Gets the base texture input component
  65021. */
  65022. get baseTexture(): NodeMaterialConnectionPoint;
  65023. /**
  65024. * Gets the opacity texture input component
  65025. */
  65026. get opacityTexture(): NodeMaterialConnectionPoint;
  65027. /**
  65028. * Gets the ambient color input component
  65029. */
  65030. get ambientColor(): NodeMaterialConnectionPoint;
  65031. /**
  65032. * Gets the reflectivity object parameters
  65033. */
  65034. get reflectivity(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the ambient occlusion object parameters
  65037. */
  65038. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the reflection object parameters
  65041. */
  65042. get reflection(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the sheen object parameters
  65045. */
  65046. get sheen(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the clear coat object parameters
  65049. */
  65050. get clearcoat(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the sub surface object parameters
  65053. */
  65054. get subsurface(): NodeMaterialConnectionPoint;
  65055. /**
  65056. * Gets the anisotropy object parameters
  65057. */
  65058. get anisotropy(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the ambient output component
  65061. */
  65062. get ambient(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the diffuse output component
  65065. */
  65066. get diffuse(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the specular output component
  65069. */
  65070. get specular(): NodeMaterialConnectionPoint;
  65071. /**
  65072. * Gets the sheen output component
  65073. */
  65074. get sheenDir(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the clear coat output component
  65077. */
  65078. get clearcoatDir(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the indirect diffuse output component
  65081. */
  65082. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65083. /**
  65084. * Gets the indirect specular output component
  65085. */
  65086. get specularIndirect(): NodeMaterialConnectionPoint;
  65087. /**
  65088. * Gets the indirect sheen output component
  65089. */
  65090. get sheenIndirect(): NodeMaterialConnectionPoint;
  65091. /**
  65092. * Gets the indirect clear coat output component
  65093. */
  65094. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65095. /**
  65096. * Gets the refraction output component
  65097. */
  65098. get refraction(): NodeMaterialConnectionPoint;
  65099. /**
  65100. * Gets the global lighting output component
  65101. */
  65102. get lighting(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the shadow output component
  65105. */
  65106. get shadow(): NodeMaterialConnectionPoint;
  65107. /**
  65108. * Gets the alpha output component
  65109. */
  65110. get alpha(): NodeMaterialConnectionPoint;
  65111. autoConfigure(material: NodeMaterial): void;
  65112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65113. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65115. private _injectVertexCode;
  65116. /**
  65117. * Gets the code corresponding to the albedo/opacity module
  65118. * @returns the shader code
  65119. */
  65120. getAlbedoOpacityCode(): string;
  65121. protected _buildBlock(state: NodeMaterialBuildState): this;
  65122. protected _dumpPropertiesCode(): string;
  65123. serialize(): any;
  65124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65125. }
  65126. }
  65127. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65128. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65129. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65130. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65131. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65132. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65133. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65134. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65135. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65136. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65137. }
  65138. declare module "babylonjs/Materials/Node/Blocks/index" {
  65139. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65140. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65141. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65142. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65143. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65144. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65145. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65146. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65147. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65148. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65149. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65150. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65151. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65152. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65153. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65154. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65155. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65156. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65157. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65158. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65159. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65160. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65161. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65162. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65163. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65164. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65165. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65166. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65167. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65168. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65169. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65170. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65171. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65172. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65173. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65174. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65175. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65176. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65177. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65178. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65179. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65180. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65181. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65182. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65183. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65184. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65185. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65186. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65187. }
  65188. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65189. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65190. }
  65191. declare module "babylonjs/Materials/Node/index" {
  65192. export * from "babylonjs/Materials/Node/Enums/index";
  65193. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65194. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65195. export * from "babylonjs/Materials/Node/nodeMaterial";
  65196. export * from "babylonjs/Materials/Node/Blocks/index";
  65197. export * from "babylonjs/Materials/Node/Optimizers/index";
  65198. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65199. }
  65200. declare module "babylonjs/Materials/effectRenderer" {
  65201. import { Nullable } from "babylonjs/types";
  65202. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65203. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65204. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65205. import { Viewport } from "babylonjs/Maths/math.viewport";
  65206. import { Observable } from "babylonjs/Misc/observable";
  65207. import { Effect } from "babylonjs/Materials/effect";
  65208. import "babylonjs/Shaders/postprocess.vertex";
  65209. /**
  65210. * Effect Render Options
  65211. */
  65212. export interface IEffectRendererOptions {
  65213. /**
  65214. * Defines the vertices positions.
  65215. */
  65216. positions?: number[];
  65217. /**
  65218. * Defines the indices.
  65219. */
  65220. indices?: number[];
  65221. }
  65222. /**
  65223. * Helper class to render one or more effects.
  65224. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65225. */
  65226. export class EffectRenderer {
  65227. private engine;
  65228. private static _DefaultOptions;
  65229. private _vertexBuffers;
  65230. private _indexBuffer;
  65231. private _fullscreenViewport;
  65232. /**
  65233. * Creates an effect renderer
  65234. * @param engine the engine to use for rendering
  65235. * @param options defines the options of the effect renderer
  65236. */
  65237. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65238. /**
  65239. * Sets the current viewport in normalized coordinates 0-1
  65240. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65241. */
  65242. setViewport(viewport?: Viewport): void;
  65243. /**
  65244. * Binds the embedded attributes buffer to the effect.
  65245. * @param effect Defines the effect to bind the attributes for
  65246. */
  65247. bindBuffers(effect: Effect): void;
  65248. /**
  65249. * Sets the current effect wrapper to use during draw.
  65250. * The effect needs to be ready before calling this api.
  65251. * This also sets the default full screen position attribute.
  65252. * @param effectWrapper Defines the effect to draw with
  65253. */
  65254. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65255. /**
  65256. * Draws a full screen quad.
  65257. */
  65258. draw(): void;
  65259. private isRenderTargetTexture;
  65260. /**
  65261. * renders one or more effects to a specified texture
  65262. * @param effectWrapper the effect to renderer
  65263. * @param outputTexture texture to draw to, if null it will render to the screen.
  65264. */
  65265. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65266. /**
  65267. * Disposes of the effect renderer
  65268. */
  65269. dispose(): void;
  65270. }
  65271. /**
  65272. * Options to create an EffectWrapper
  65273. */
  65274. interface EffectWrapperCreationOptions {
  65275. /**
  65276. * Engine to use to create the effect
  65277. */
  65278. engine: ThinEngine;
  65279. /**
  65280. * Fragment shader for the effect
  65281. */
  65282. fragmentShader: string;
  65283. /**
  65284. * Vertex shader for the effect
  65285. */
  65286. vertexShader?: string;
  65287. /**
  65288. * Attributes to use in the shader
  65289. */
  65290. attributeNames?: Array<string>;
  65291. /**
  65292. * Uniforms to use in the shader
  65293. */
  65294. uniformNames?: Array<string>;
  65295. /**
  65296. * Texture sampler names to use in the shader
  65297. */
  65298. samplerNames?: Array<string>;
  65299. /**
  65300. * The friendly name of the effect displayed in Spector.
  65301. */
  65302. name?: string;
  65303. }
  65304. /**
  65305. * Wraps an effect to be used for rendering
  65306. */
  65307. export class EffectWrapper {
  65308. /**
  65309. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65310. */
  65311. onApplyObservable: Observable<{}>;
  65312. /**
  65313. * The underlying effect
  65314. */
  65315. effect: Effect;
  65316. /**
  65317. * Creates an effect to be renderer
  65318. * @param creationOptions options to create the effect
  65319. */
  65320. constructor(creationOptions: EffectWrapperCreationOptions);
  65321. /**
  65322. * Disposes of the effect wrapper
  65323. */
  65324. dispose(): void;
  65325. }
  65326. }
  65327. declare module "babylonjs/Materials/index" {
  65328. export * from "babylonjs/Materials/Background/index";
  65329. export * from "babylonjs/Materials/colorCurves";
  65330. export * from "babylonjs/Materials/iEffectFallbacks";
  65331. export * from "babylonjs/Materials/effectFallbacks";
  65332. export * from "babylonjs/Materials/effect";
  65333. export * from "babylonjs/Materials/fresnelParameters";
  65334. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65335. export * from "babylonjs/Materials/material";
  65336. export * from "babylonjs/Materials/materialDefines";
  65337. export * from "babylonjs/Materials/materialHelper";
  65338. export * from "babylonjs/Materials/multiMaterial";
  65339. export * from "babylonjs/Materials/PBR/index";
  65340. export * from "babylonjs/Materials/pushMaterial";
  65341. export * from "babylonjs/Materials/shaderMaterial";
  65342. export * from "babylonjs/Materials/standardMaterial";
  65343. export * from "babylonjs/Materials/Textures/index";
  65344. export * from "babylonjs/Materials/uniformBuffer";
  65345. export * from "babylonjs/Materials/materialFlags";
  65346. export * from "babylonjs/Materials/Node/index";
  65347. export * from "babylonjs/Materials/effectRenderer";
  65348. export * from "babylonjs/Materials/shadowDepthWrapper";
  65349. }
  65350. declare module "babylonjs/Maths/index" {
  65351. export * from "babylonjs/Maths/math.scalar";
  65352. export * from "babylonjs/Maths/math";
  65353. export * from "babylonjs/Maths/sphericalPolynomial";
  65354. }
  65355. declare module "babylonjs/Misc/workerPool" {
  65356. import { IDisposable } from "babylonjs/scene";
  65357. /**
  65358. * Helper class to push actions to a pool of workers.
  65359. */
  65360. export class WorkerPool implements IDisposable {
  65361. private _workerInfos;
  65362. private _pendingActions;
  65363. /**
  65364. * Constructor
  65365. * @param workers Array of workers to use for actions
  65366. */
  65367. constructor(workers: Array<Worker>);
  65368. /**
  65369. * Terminates all workers and clears any pending actions.
  65370. */
  65371. dispose(): void;
  65372. /**
  65373. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65374. * pended until a worker has completed its action.
  65375. * @param action The action to perform. Call onComplete when the action is complete.
  65376. */
  65377. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65378. private _execute;
  65379. }
  65380. }
  65381. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65382. import { IDisposable } from "babylonjs/scene";
  65383. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65384. /**
  65385. * Configuration for Draco compression
  65386. */
  65387. export interface IDracoCompressionConfiguration {
  65388. /**
  65389. * Configuration for the decoder.
  65390. */
  65391. decoder: {
  65392. /**
  65393. * The url to the WebAssembly module.
  65394. */
  65395. wasmUrl?: string;
  65396. /**
  65397. * The url to the WebAssembly binary.
  65398. */
  65399. wasmBinaryUrl?: string;
  65400. /**
  65401. * The url to the fallback JavaScript module.
  65402. */
  65403. fallbackUrl?: string;
  65404. };
  65405. }
  65406. /**
  65407. * Draco compression (https://google.github.io/draco/)
  65408. *
  65409. * This class wraps the Draco module.
  65410. *
  65411. * **Encoder**
  65412. *
  65413. * The encoder is not currently implemented.
  65414. *
  65415. * **Decoder**
  65416. *
  65417. * 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.
  65418. *
  65419. * To update the configuration, use the following code:
  65420. * ```javascript
  65421. * DracoCompression.Configuration = {
  65422. * decoder: {
  65423. * wasmUrl: "<url to the WebAssembly library>",
  65424. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65425. * fallbackUrl: "<url to the fallback JavaScript library>",
  65426. * }
  65427. * };
  65428. * ```
  65429. *
  65430. * 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.
  65431. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65432. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65433. *
  65434. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65435. * ```javascript
  65436. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65437. * ```
  65438. *
  65439. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65440. */
  65441. export class DracoCompression implements IDisposable {
  65442. private _workerPoolPromise?;
  65443. private _decoderModulePromise?;
  65444. /**
  65445. * The configuration. Defaults to the following urls:
  65446. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65447. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65448. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65449. */
  65450. static Configuration: IDracoCompressionConfiguration;
  65451. /**
  65452. * Returns true if the decoder configuration is available.
  65453. */
  65454. static get DecoderAvailable(): boolean;
  65455. /**
  65456. * Default number of workers to create when creating the draco compression object.
  65457. */
  65458. static DefaultNumWorkers: number;
  65459. private static GetDefaultNumWorkers;
  65460. private static _Default;
  65461. /**
  65462. * Default instance for the draco compression object.
  65463. */
  65464. static get Default(): DracoCompression;
  65465. /**
  65466. * Constructor
  65467. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65468. */
  65469. constructor(numWorkers?: number);
  65470. /**
  65471. * Stop all async operations and release resources.
  65472. */
  65473. dispose(): void;
  65474. /**
  65475. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65476. * @returns a promise that resolves when ready
  65477. */
  65478. whenReadyAsync(): Promise<void>;
  65479. /**
  65480. * Decode Draco compressed mesh data to vertex data.
  65481. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65482. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65483. * @returns A promise that resolves with the decoded vertex data
  65484. */
  65485. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65486. [kind: string]: number;
  65487. }): Promise<VertexData>;
  65488. }
  65489. }
  65490. declare module "babylonjs/Meshes/Compression/index" {
  65491. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65492. }
  65493. declare module "babylonjs/Meshes/csg" {
  65494. import { Nullable } from "babylonjs/types";
  65495. import { Scene } from "babylonjs/scene";
  65496. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65497. import { Mesh } from "babylonjs/Meshes/mesh";
  65498. import { Material } from "babylonjs/Materials/material";
  65499. /**
  65500. * Class for building Constructive Solid Geometry
  65501. */
  65502. export class CSG {
  65503. private polygons;
  65504. /**
  65505. * The world matrix
  65506. */
  65507. matrix: Matrix;
  65508. /**
  65509. * Stores the position
  65510. */
  65511. position: Vector3;
  65512. /**
  65513. * Stores the rotation
  65514. */
  65515. rotation: Vector3;
  65516. /**
  65517. * Stores the rotation quaternion
  65518. */
  65519. rotationQuaternion: Nullable<Quaternion>;
  65520. /**
  65521. * Stores the scaling vector
  65522. */
  65523. scaling: Vector3;
  65524. /**
  65525. * Convert the Mesh to CSG
  65526. * @param mesh The Mesh to convert to CSG
  65527. * @returns A new CSG from the Mesh
  65528. */
  65529. static FromMesh(mesh: Mesh): CSG;
  65530. /**
  65531. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65532. * @param polygons Polygons used to construct a CSG solid
  65533. */
  65534. private static FromPolygons;
  65535. /**
  65536. * Clones, or makes a deep copy, of the CSG
  65537. * @returns A new CSG
  65538. */
  65539. clone(): CSG;
  65540. /**
  65541. * Unions this CSG with another CSG
  65542. * @param csg The CSG to union against this CSG
  65543. * @returns The unioned CSG
  65544. */
  65545. union(csg: CSG): CSG;
  65546. /**
  65547. * Unions this CSG with another CSG in place
  65548. * @param csg The CSG to union against this CSG
  65549. */
  65550. unionInPlace(csg: CSG): void;
  65551. /**
  65552. * Subtracts this CSG with another CSG
  65553. * @param csg The CSG to subtract against this CSG
  65554. * @returns A new CSG
  65555. */
  65556. subtract(csg: CSG): CSG;
  65557. /**
  65558. * Subtracts this CSG with another CSG in place
  65559. * @param csg The CSG to subtact against this CSG
  65560. */
  65561. subtractInPlace(csg: CSG): void;
  65562. /**
  65563. * Intersect this CSG with another CSG
  65564. * @param csg The CSG to intersect against this CSG
  65565. * @returns A new CSG
  65566. */
  65567. intersect(csg: CSG): CSG;
  65568. /**
  65569. * Intersects this CSG with another CSG in place
  65570. * @param csg The CSG to intersect against this CSG
  65571. */
  65572. intersectInPlace(csg: CSG): void;
  65573. /**
  65574. * Return a new CSG solid with solid and empty space switched. This solid is
  65575. * not modified.
  65576. * @returns A new CSG solid with solid and empty space switched
  65577. */
  65578. inverse(): CSG;
  65579. /**
  65580. * Inverses the CSG in place
  65581. */
  65582. inverseInPlace(): void;
  65583. /**
  65584. * This is used to keep meshes transformations so they can be restored
  65585. * when we build back a Babylon Mesh
  65586. * NB : All CSG operations are performed in world coordinates
  65587. * @param csg The CSG to copy the transform attributes from
  65588. * @returns This CSG
  65589. */
  65590. copyTransformAttributes(csg: CSG): CSG;
  65591. /**
  65592. * Build Raw mesh from CSG
  65593. * Coordinates here are in world space
  65594. * @param name The name of the mesh geometry
  65595. * @param scene The Scene
  65596. * @param keepSubMeshes Specifies if the submeshes should be kept
  65597. * @returns A new Mesh
  65598. */
  65599. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65600. /**
  65601. * Build Mesh from CSG taking material and transforms into account
  65602. * @param name The name of the Mesh
  65603. * @param material The material of the Mesh
  65604. * @param scene The Scene
  65605. * @param keepSubMeshes Specifies if submeshes should be kept
  65606. * @returns The new Mesh
  65607. */
  65608. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65609. }
  65610. }
  65611. declare module "babylonjs/Meshes/trailMesh" {
  65612. import { Mesh } from "babylonjs/Meshes/mesh";
  65613. import { Scene } from "babylonjs/scene";
  65614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65615. /**
  65616. * Class used to create a trail following a mesh
  65617. */
  65618. export class TrailMesh extends Mesh {
  65619. private _generator;
  65620. private _autoStart;
  65621. private _running;
  65622. private _diameter;
  65623. private _length;
  65624. private _sectionPolygonPointsCount;
  65625. private _sectionVectors;
  65626. private _sectionNormalVectors;
  65627. private _beforeRenderObserver;
  65628. /**
  65629. * @constructor
  65630. * @param name The value used by scene.getMeshByName() to do a lookup.
  65631. * @param generator The mesh or transform node to generate a trail.
  65632. * @param scene The scene to add this mesh to.
  65633. * @param diameter Diameter of trailing mesh. Default is 1.
  65634. * @param length Length of trailing mesh. Default is 60.
  65635. * @param autoStart Automatically start trailing mesh. Default true.
  65636. */
  65637. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65638. /**
  65639. * "TrailMesh"
  65640. * @returns "TrailMesh"
  65641. */
  65642. getClassName(): string;
  65643. private _createMesh;
  65644. /**
  65645. * Start trailing mesh.
  65646. */
  65647. start(): void;
  65648. /**
  65649. * Stop trailing mesh.
  65650. */
  65651. stop(): void;
  65652. /**
  65653. * Update trailing mesh geometry.
  65654. */
  65655. update(): void;
  65656. /**
  65657. * Returns a new TrailMesh object.
  65658. * @param name is a string, the name given to the new mesh
  65659. * @param newGenerator use new generator object for cloned trail mesh
  65660. * @returns a new mesh
  65661. */
  65662. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65663. /**
  65664. * Serializes this trail mesh
  65665. * @param serializationObject object to write serialization to
  65666. */
  65667. serialize(serializationObject: any): void;
  65668. /**
  65669. * Parses a serialized trail mesh
  65670. * @param parsedMesh the serialized mesh
  65671. * @param scene the scene to create the trail mesh in
  65672. * @returns the created trail mesh
  65673. */
  65674. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65675. }
  65676. }
  65677. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65678. import { Nullable } from "babylonjs/types";
  65679. import { Scene } from "babylonjs/scene";
  65680. import { Vector4 } from "babylonjs/Maths/math.vector";
  65681. import { Color4 } from "babylonjs/Maths/math.color";
  65682. import { Mesh } from "babylonjs/Meshes/mesh";
  65683. /**
  65684. * Class containing static functions to help procedurally build meshes
  65685. */
  65686. export class TiledBoxBuilder {
  65687. /**
  65688. * Creates a box mesh
  65689. * 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)
  65690. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65694. * @param name defines the name of the mesh
  65695. * @param options defines the options used to create the mesh
  65696. * @param scene defines the hosting scene
  65697. * @returns the box mesh
  65698. */
  65699. static CreateTiledBox(name: string, options: {
  65700. pattern?: number;
  65701. width?: number;
  65702. height?: number;
  65703. depth?: number;
  65704. tileSize?: number;
  65705. tileWidth?: number;
  65706. tileHeight?: number;
  65707. alignHorizontal?: number;
  65708. alignVertical?: number;
  65709. faceUV?: Vector4[];
  65710. faceColors?: Color4[];
  65711. sideOrientation?: number;
  65712. updatable?: boolean;
  65713. }, scene?: Nullable<Scene>): Mesh;
  65714. }
  65715. }
  65716. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65717. import { Vector4 } from "babylonjs/Maths/math.vector";
  65718. import { Mesh } from "babylonjs/Meshes/mesh";
  65719. /**
  65720. * Class containing static functions to help procedurally build meshes
  65721. */
  65722. export class TorusKnotBuilder {
  65723. /**
  65724. * Creates a torus knot mesh
  65725. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65726. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65727. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65728. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65732. * @param name defines the name of the mesh
  65733. * @param options defines the options used to create the mesh
  65734. * @param scene defines the hosting scene
  65735. * @returns the torus knot mesh
  65736. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65737. */
  65738. static CreateTorusKnot(name: string, options: {
  65739. radius?: number;
  65740. tube?: number;
  65741. radialSegments?: number;
  65742. tubularSegments?: number;
  65743. p?: number;
  65744. q?: number;
  65745. updatable?: boolean;
  65746. sideOrientation?: number;
  65747. frontUVs?: Vector4;
  65748. backUVs?: Vector4;
  65749. }, scene: any): Mesh;
  65750. }
  65751. }
  65752. declare module "babylonjs/Meshes/polygonMesh" {
  65753. import { Scene } from "babylonjs/scene";
  65754. import { Vector2 } from "babylonjs/Maths/math.vector";
  65755. import { Mesh } from "babylonjs/Meshes/mesh";
  65756. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65757. import { Path2 } from "babylonjs/Maths/math.path";
  65758. /**
  65759. * Polygon
  65760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65761. */
  65762. export class Polygon {
  65763. /**
  65764. * Creates a rectangle
  65765. * @param xmin bottom X coord
  65766. * @param ymin bottom Y coord
  65767. * @param xmax top X coord
  65768. * @param ymax top Y coord
  65769. * @returns points that make the resulting rectation
  65770. */
  65771. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65772. /**
  65773. * Creates a circle
  65774. * @param radius radius of circle
  65775. * @param cx scale in x
  65776. * @param cy scale in y
  65777. * @param numberOfSides number of sides that make up the circle
  65778. * @returns points that make the resulting circle
  65779. */
  65780. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65781. /**
  65782. * Creates a polygon from input string
  65783. * @param input Input polygon data
  65784. * @returns the parsed points
  65785. */
  65786. static Parse(input: string): Vector2[];
  65787. /**
  65788. * Starts building a polygon from x and y coordinates
  65789. * @param x x coordinate
  65790. * @param y y coordinate
  65791. * @returns the started path2
  65792. */
  65793. static StartingAt(x: number, y: number): Path2;
  65794. }
  65795. /**
  65796. * Builds a polygon
  65797. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65798. */
  65799. export class PolygonMeshBuilder {
  65800. private _points;
  65801. private _outlinepoints;
  65802. private _holes;
  65803. private _name;
  65804. private _scene;
  65805. private _epoints;
  65806. private _eholes;
  65807. private _addToepoint;
  65808. /**
  65809. * Babylon reference to the earcut plugin.
  65810. */
  65811. bjsEarcut: any;
  65812. /**
  65813. * Creates a PolygonMeshBuilder
  65814. * @param name name of the builder
  65815. * @param contours Path of the polygon
  65816. * @param scene scene to add to when creating the mesh
  65817. * @param earcutInjection can be used to inject your own earcut reference
  65818. */
  65819. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65820. /**
  65821. * Adds a whole within the polygon
  65822. * @param hole Array of points defining the hole
  65823. * @returns this
  65824. */
  65825. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65826. /**
  65827. * Creates the polygon
  65828. * @param updatable If the mesh should be updatable
  65829. * @param depth The depth of the mesh created
  65830. * @returns the created mesh
  65831. */
  65832. build(updatable?: boolean, depth?: number): Mesh;
  65833. /**
  65834. * Creates the polygon
  65835. * @param depth The depth of the mesh created
  65836. * @returns the created VertexData
  65837. */
  65838. buildVertexData(depth?: number): VertexData;
  65839. /**
  65840. * Adds a side to the polygon
  65841. * @param positions points that make the polygon
  65842. * @param normals normals of the polygon
  65843. * @param uvs uvs of the polygon
  65844. * @param indices indices of the polygon
  65845. * @param bounds bounds of the polygon
  65846. * @param points points of the polygon
  65847. * @param depth depth of the polygon
  65848. * @param flip flip of the polygon
  65849. */
  65850. private addSide;
  65851. }
  65852. }
  65853. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  65854. import { Scene } from "babylonjs/scene";
  65855. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65856. import { Color4 } from "babylonjs/Maths/math.color";
  65857. import { Mesh } from "babylonjs/Meshes/mesh";
  65858. import { Nullable } from "babylonjs/types";
  65859. /**
  65860. * Class containing static functions to help procedurally build meshes
  65861. */
  65862. export class PolygonBuilder {
  65863. /**
  65864. * Creates a polygon mesh
  65865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65866. * * 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
  65867. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65870. * * Remember you can only change the shape positions, not their number when updating a polygon
  65871. * @param name defines the name of the mesh
  65872. * @param options defines the options used to create the mesh
  65873. * @param scene defines the hosting scene
  65874. * @param earcutInjection can be used to inject your own earcut reference
  65875. * @returns the polygon mesh
  65876. */
  65877. static CreatePolygon(name: string, options: {
  65878. shape: Vector3[];
  65879. holes?: Vector3[][];
  65880. depth?: number;
  65881. faceUV?: Vector4[];
  65882. faceColors?: Color4[];
  65883. updatable?: boolean;
  65884. sideOrientation?: number;
  65885. frontUVs?: Vector4;
  65886. backUVs?: Vector4;
  65887. wrap?: boolean;
  65888. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65889. /**
  65890. * Creates an extruded polygon mesh, with depth in the Y direction.
  65891. * * 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)
  65892. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65893. * @param name defines the name of the mesh
  65894. * @param options defines the options used to create the mesh
  65895. * @param scene defines the hosting scene
  65896. * @param earcutInjection can be used to inject your own earcut reference
  65897. * @returns the polygon mesh
  65898. */
  65899. static ExtrudePolygon(name: string, options: {
  65900. shape: Vector3[];
  65901. holes?: Vector3[][];
  65902. depth?: number;
  65903. faceUV?: Vector4[];
  65904. faceColors?: Color4[];
  65905. updatable?: boolean;
  65906. sideOrientation?: number;
  65907. frontUVs?: Vector4;
  65908. backUVs?: Vector4;
  65909. wrap?: boolean;
  65910. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65911. }
  65912. }
  65913. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  65914. import { Scene } from "babylonjs/scene";
  65915. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65916. import { Mesh } from "babylonjs/Meshes/mesh";
  65917. import { Nullable } from "babylonjs/types";
  65918. /**
  65919. * Class containing static functions to help procedurally build meshes
  65920. */
  65921. export class LatheBuilder {
  65922. /**
  65923. * Creates lathe mesh.
  65924. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65925. * * 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
  65926. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65927. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65928. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65929. * * 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
  65930. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65931. * * 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
  65932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65936. * @param name defines the name of the mesh
  65937. * @param options defines the options used to create the mesh
  65938. * @param scene defines the hosting scene
  65939. * @returns the lathe mesh
  65940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65941. */
  65942. static CreateLathe(name: string, options: {
  65943. shape: Vector3[];
  65944. radius?: number;
  65945. tessellation?: number;
  65946. clip?: number;
  65947. arc?: number;
  65948. closed?: boolean;
  65949. updatable?: boolean;
  65950. sideOrientation?: number;
  65951. frontUVs?: Vector4;
  65952. backUVs?: Vector4;
  65953. cap?: number;
  65954. invertUV?: boolean;
  65955. }, scene?: Nullable<Scene>): Mesh;
  65956. }
  65957. }
  65958. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  65959. import { Nullable } from "babylonjs/types";
  65960. import { Scene } from "babylonjs/scene";
  65961. import { Vector4 } from "babylonjs/Maths/math.vector";
  65962. import { Mesh } from "babylonjs/Meshes/mesh";
  65963. /**
  65964. * Class containing static functions to help procedurally build meshes
  65965. */
  65966. export class TiledPlaneBuilder {
  65967. /**
  65968. * Creates a tiled plane mesh
  65969. * * The parameter `pattern` will, depending on value, do nothing or
  65970. * * * flip (reflect about central vertical) alternate tiles across and up
  65971. * * * flip every tile on alternate rows
  65972. * * * rotate (180 degs) alternate tiles across and up
  65973. * * * rotate every tile on alternate rows
  65974. * * * flip and rotate alternate tiles across and up
  65975. * * * flip and rotate every tile on alternate rows
  65976. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65977. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65980. * * 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)
  65981. * * 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)
  65982. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65983. * @param name defines the name of the mesh
  65984. * @param options defines the options used to create the mesh
  65985. * @param scene defines the hosting scene
  65986. * @returns the box mesh
  65987. */
  65988. static CreateTiledPlane(name: string, options: {
  65989. pattern?: number;
  65990. tileSize?: number;
  65991. tileWidth?: number;
  65992. tileHeight?: number;
  65993. size?: number;
  65994. width?: number;
  65995. height?: number;
  65996. alignHorizontal?: number;
  65997. alignVertical?: number;
  65998. sideOrientation?: number;
  65999. frontUVs?: Vector4;
  66000. backUVs?: Vector4;
  66001. updatable?: boolean;
  66002. }, scene?: Nullable<Scene>): Mesh;
  66003. }
  66004. }
  66005. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66006. import { Nullable } from "babylonjs/types";
  66007. import { Scene } from "babylonjs/scene";
  66008. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66009. import { Mesh } from "babylonjs/Meshes/mesh";
  66010. /**
  66011. * Class containing static functions to help procedurally build meshes
  66012. */
  66013. export class TubeBuilder {
  66014. /**
  66015. * Creates a tube mesh.
  66016. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66017. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66018. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66019. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66020. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66021. * * 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)
  66022. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66023. * * 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
  66024. * * 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
  66025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66029. * @param name defines the name of the mesh
  66030. * @param options defines the options used to create the mesh
  66031. * @param scene defines the hosting scene
  66032. * @returns the tube mesh
  66033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66034. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66035. */
  66036. static CreateTube(name: string, options: {
  66037. path: Vector3[];
  66038. radius?: number;
  66039. tessellation?: number;
  66040. radiusFunction?: {
  66041. (i: number, distance: number): number;
  66042. };
  66043. cap?: number;
  66044. arc?: number;
  66045. updatable?: boolean;
  66046. sideOrientation?: number;
  66047. frontUVs?: Vector4;
  66048. backUVs?: Vector4;
  66049. instance?: Mesh;
  66050. invertUV?: boolean;
  66051. }, scene?: Nullable<Scene>): Mesh;
  66052. }
  66053. }
  66054. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66055. import { Scene } from "babylonjs/scene";
  66056. import { Vector4 } from "babylonjs/Maths/math.vector";
  66057. import { Mesh } from "babylonjs/Meshes/mesh";
  66058. import { Nullable } from "babylonjs/types";
  66059. /**
  66060. * Class containing static functions to help procedurally build meshes
  66061. */
  66062. export class IcoSphereBuilder {
  66063. /**
  66064. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66065. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66066. * * 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`)
  66067. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66068. * * 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
  66069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66072. * @param name defines the name of the mesh
  66073. * @param options defines the options used to create the mesh
  66074. * @param scene defines the hosting scene
  66075. * @returns the icosahedron mesh
  66076. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66077. */
  66078. static CreateIcoSphere(name: string, options: {
  66079. radius?: number;
  66080. radiusX?: number;
  66081. radiusY?: number;
  66082. radiusZ?: number;
  66083. flat?: boolean;
  66084. subdivisions?: number;
  66085. sideOrientation?: number;
  66086. frontUVs?: Vector4;
  66087. backUVs?: Vector4;
  66088. updatable?: boolean;
  66089. }, scene?: Nullable<Scene>): Mesh;
  66090. }
  66091. }
  66092. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66093. import { Vector3 } from "babylonjs/Maths/math.vector";
  66094. import { Mesh } from "babylonjs/Meshes/mesh";
  66095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66096. /**
  66097. * Class containing static functions to help procedurally build meshes
  66098. */
  66099. export class DecalBuilder {
  66100. /**
  66101. * Creates a decal mesh.
  66102. * 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
  66103. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66104. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66105. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66106. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66107. * @param name defines the name of the mesh
  66108. * @param sourceMesh defines the mesh where the decal must be applied
  66109. * @param options defines the options used to create the mesh
  66110. * @param scene defines the hosting scene
  66111. * @returns the decal mesh
  66112. * @see https://doc.babylonjs.com/how_to/decals
  66113. */
  66114. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66115. position?: Vector3;
  66116. normal?: Vector3;
  66117. size?: Vector3;
  66118. angle?: number;
  66119. }): Mesh;
  66120. }
  66121. }
  66122. declare module "babylonjs/Meshes/meshBuilder" {
  66123. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66124. import { Nullable } from "babylonjs/types";
  66125. import { Scene } from "babylonjs/scene";
  66126. import { Mesh } from "babylonjs/Meshes/mesh";
  66127. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66128. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66130. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66131. import { Plane } from "babylonjs/Maths/math.plane";
  66132. /**
  66133. * Class containing static functions to help procedurally build meshes
  66134. */
  66135. export class MeshBuilder {
  66136. /**
  66137. * Creates a box mesh
  66138. * * The parameter `size` sets the size (float) of each box side (default 1)
  66139. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66140. * * 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)
  66141. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66145. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66146. * @param name defines the name of the mesh
  66147. * @param options defines the options used to create the mesh
  66148. * @param scene defines the hosting scene
  66149. * @returns the box mesh
  66150. */
  66151. static CreateBox(name: string, options: {
  66152. size?: number;
  66153. width?: number;
  66154. height?: number;
  66155. depth?: number;
  66156. faceUV?: Vector4[];
  66157. faceColors?: Color4[];
  66158. sideOrientation?: number;
  66159. frontUVs?: Vector4;
  66160. backUVs?: Vector4;
  66161. wrap?: boolean;
  66162. topBaseAt?: number;
  66163. bottomBaseAt?: number;
  66164. updatable?: boolean;
  66165. }, scene?: Nullable<Scene>): Mesh;
  66166. /**
  66167. * Creates a tiled box mesh
  66168. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66170. * @param name defines the name of the mesh
  66171. * @param options defines the options used to create the mesh
  66172. * @param scene defines the hosting scene
  66173. * @returns the tiled box mesh
  66174. */
  66175. static CreateTiledBox(name: string, options: {
  66176. pattern?: number;
  66177. size?: number;
  66178. width?: number;
  66179. height?: number;
  66180. depth: number;
  66181. tileSize?: number;
  66182. tileWidth?: number;
  66183. tileHeight?: number;
  66184. faceUV?: Vector4[];
  66185. faceColors?: Color4[];
  66186. alignHorizontal?: number;
  66187. alignVertical?: number;
  66188. sideOrientation?: number;
  66189. updatable?: boolean;
  66190. }, scene?: Nullable<Scene>): Mesh;
  66191. /**
  66192. * Creates a sphere mesh
  66193. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66194. * * 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`)
  66195. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66196. * * 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
  66197. * * 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)
  66198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66201. * @param name defines the name of the mesh
  66202. * @param options defines the options used to create the mesh
  66203. * @param scene defines the hosting scene
  66204. * @returns the sphere mesh
  66205. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66206. */
  66207. static CreateSphere(name: string, options: {
  66208. segments?: number;
  66209. diameter?: number;
  66210. diameterX?: number;
  66211. diameterY?: number;
  66212. diameterZ?: number;
  66213. arc?: number;
  66214. slice?: number;
  66215. sideOrientation?: number;
  66216. frontUVs?: Vector4;
  66217. backUVs?: Vector4;
  66218. updatable?: boolean;
  66219. }, scene?: Nullable<Scene>): Mesh;
  66220. /**
  66221. * Creates a plane polygonal mesh. By default, this is a disc
  66222. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66223. * * 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
  66224. * * 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
  66225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66228. * @param name defines the name of the mesh
  66229. * @param options defines the options used to create the mesh
  66230. * @param scene defines the hosting scene
  66231. * @returns the plane polygonal mesh
  66232. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66233. */
  66234. static CreateDisc(name: string, options: {
  66235. radius?: number;
  66236. tessellation?: number;
  66237. arc?: number;
  66238. updatable?: boolean;
  66239. sideOrientation?: number;
  66240. frontUVs?: Vector4;
  66241. backUVs?: Vector4;
  66242. }, scene?: Nullable<Scene>): Mesh;
  66243. /**
  66244. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66245. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66246. * * 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`)
  66247. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66248. * * 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
  66249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66252. * @param name defines the name of the mesh
  66253. * @param options defines the options used to create the mesh
  66254. * @param scene defines the hosting scene
  66255. * @returns the icosahedron mesh
  66256. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66257. */
  66258. static CreateIcoSphere(name: string, options: {
  66259. radius?: number;
  66260. radiusX?: number;
  66261. radiusY?: number;
  66262. radiusZ?: number;
  66263. flat?: boolean;
  66264. subdivisions?: number;
  66265. sideOrientation?: number;
  66266. frontUVs?: Vector4;
  66267. backUVs?: Vector4;
  66268. updatable?: boolean;
  66269. }, scene?: Nullable<Scene>): Mesh;
  66270. /**
  66271. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66272. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66273. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66274. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66275. * * 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
  66276. * * 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
  66277. * * 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
  66278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66281. * * 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
  66282. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66283. * * 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
  66284. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66286. * @param name defines the name of the mesh
  66287. * @param options defines the options used to create the mesh
  66288. * @param scene defines the hosting scene
  66289. * @returns the ribbon mesh
  66290. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66292. */
  66293. static CreateRibbon(name: string, options: {
  66294. pathArray: Vector3[][];
  66295. closeArray?: boolean;
  66296. closePath?: boolean;
  66297. offset?: number;
  66298. updatable?: boolean;
  66299. sideOrientation?: number;
  66300. frontUVs?: Vector4;
  66301. backUVs?: Vector4;
  66302. instance?: Mesh;
  66303. invertUV?: boolean;
  66304. uvs?: Vector2[];
  66305. colors?: Color4[];
  66306. }, scene?: Nullable<Scene>): Mesh;
  66307. /**
  66308. * Creates a cylinder or a cone mesh
  66309. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66310. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66311. * * 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.
  66312. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66313. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66314. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66315. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66316. * * 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).
  66317. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66318. * * 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).
  66319. * * 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
  66320. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66321. * * 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
  66322. * * 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.
  66323. * * If `enclose` is false, a ring surface is one element.
  66324. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66325. * * 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
  66326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66329. * @param name defines the name of the mesh
  66330. * @param options defines the options used to create the mesh
  66331. * @param scene defines the hosting scene
  66332. * @returns the cylinder mesh
  66333. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66334. */
  66335. static CreateCylinder(name: string, options: {
  66336. height?: number;
  66337. diameterTop?: number;
  66338. diameterBottom?: number;
  66339. diameter?: number;
  66340. tessellation?: number;
  66341. subdivisions?: number;
  66342. arc?: number;
  66343. faceColors?: Color4[];
  66344. faceUV?: Vector4[];
  66345. updatable?: boolean;
  66346. hasRings?: boolean;
  66347. enclose?: boolean;
  66348. cap?: number;
  66349. sideOrientation?: number;
  66350. frontUVs?: Vector4;
  66351. backUVs?: Vector4;
  66352. }, scene?: Nullable<Scene>): Mesh;
  66353. /**
  66354. * Creates a torus mesh
  66355. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66356. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66357. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66361. * @param name defines the name of the mesh
  66362. * @param options defines the options used to create the mesh
  66363. * @param scene defines the hosting scene
  66364. * @returns the torus mesh
  66365. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66366. */
  66367. static CreateTorus(name: string, options: {
  66368. diameter?: number;
  66369. thickness?: number;
  66370. tessellation?: number;
  66371. updatable?: boolean;
  66372. sideOrientation?: number;
  66373. frontUVs?: Vector4;
  66374. backUVs?: Vector4;
  66375. }, scene?: Nullable<Scene>): Mesh;
  66376. /**
  66377. * Creates a torus knot mesh
  66378. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66379. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66380. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66381. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66385. * @param name defines the name of the mesh
  66386. * @param options defines the options used to create the mesh
  66387. * @param scene defines the hosting scene
  66388. * @returns the torus knot mesh
  66389. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66390. */
  66391. static CreateTorusKnot(name: string, options: {
  66392. radius?: number;
  66393. tube?: number;
  66394. radialSegments?: number;
  66395. tubularSegments?: number;
  66396. p?: number;
  66397. q?: number;
  66398. updatable?: boolean;
  66399. sideOrientation?: number;
  66400. frontUVs?: Vector4;
  66401. backUVs?: Vector4;
  66402. }, scene?: Nullable<Scene>): Mesh;
  66403. /**
  66404. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66405. * * 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
  66406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66407. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66408. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66409. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66410. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66411. * * 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
  66412. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66415. * @param name defines the name of the new line system
  66416. * @param options defines the options used to create the line system
  66417. * @param scene defines the hosting scene
  66418. * @returns a new line system mesh
  66419. */
  66420. static CreateLineSystem(name: string, options: {
  66421. lines: Vector3[][];
  66422. updatable?: boolean;
  66423. instance?: Nullable<LinesMesh>;
  66424. colors?: Nullable<Color4[][]>;
  66425. useVertexAlpha?: boolean;
  66426. }, scene: Nullable<Scene>): LinesMesh;
  66427. /**
  66428. * Creates a line mesh
  66429. * 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
  66430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66431. * * The parameter `points` is an array successive Vector3
  66432. * * 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
  66433. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66434. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66435. * * When updating an instance, remember that only point positions can change, not the number of points
  66436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66438. * @param name defines the name of the new line system
  66439. * @param options defines the options used to create the line system
  66440. * @param scene defines the hosting scene
  66441. * @returns a new line mesh
  66442. */
  66443. static CreateLines(name: string, options: {
  66444. points: Vector3[];
  66445. updatable?: boolean;
  66446. instance?: Nullable<LinesMesh>;
  66447. colors?: Color4[];
  66448. useVertexAlpha?: boolean;
  66449. }, scene?: Nullable<Scene>): LinesMesh;
  66450. /**
  66451. * Creates a dashed line mesh
  66452. * * 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
  66453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66454. * * The parameter `points` is an array successive Vector3
  66455. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66456. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66457. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66458. * * 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
  66459. * * When updating an instance, remember that only point positions can change, not the number of points
  66460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66461. * @param name defines the name of the mesh
  66462. * @param options defines the options used to create the mesh
  66463. * @param scene defines the hosting scene
  66464. * @returns the dashed line mesh
  66465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66466. */
  66467. static CreateDashedLines(name: string, options: {
  66468. points: Vector3[];
  66469. dashSize?: number;
  66470. gapSize?: number;
  66471. dashNb?: number;
  66472. updatable?: boolean;
  66473. instance?: LinesMesh;
  66474. }, scene?: Nullable<Scene>): LinesMesh;
  66475. /**
  66476. * 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.
  66477. * * 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.
  66478. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66479. * * 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.
  66480. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66481. * * 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
  66482. * * 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
  66483. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66488. * @param name defines the name of the mesh
  66489. * @param options defines the options used to create the mesh
  66490. * @param scene defines the hosting scene
  66491. * @returns the extruded shape mesh
  66492. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66494. */
  66495. static ExtrudeShape(name: string, options: {
  66496. shape: Vector3[];
  66497. path: Vector3[];
  66498. scale?: number;
  66499. rotation?: number;
  66500. cap?: number;
  66501. updatable?: boolean;
  66502. sideOrientation?: number;
  66503. frontUVs?: Vector4;
  66504. backUVs?: Vector4;
  66505. instance?: Mesh;
  66506. invertUV?: boolean;
  66507. }, scene?: Nullable<Scene>): Mesh;
  66508. /**
  66509. * Creates an custom extruded shape mesh.
  66510. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66511. * * 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.
  66512. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66513. * * 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
  66514. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66515. * * 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
  66516. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66517. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66518. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66519. * * 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
  66520. * * 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
  66521. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66524. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66526. * @param name defines the name of the mesh
  66527. * @param options defines the options used to create the mesh
  66528. * @param scene defines the hosting scene
  66529. * @returns the custom extruded shape mesh
  66530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66533. */
  66534. static ExtrudeShapeCustom(name: string, options: {
  66535. shape: Vector3[];
  66536. path: Vector3[];
  66537. scaleFunction?: any;
  66538. rotationFunction?: any;
  66539. ribbonCloseArray?: boolean;
  66540. ribbonClosePath?: boolean;
  66541. cap?: number;
  66542. updatable?: boolean;
  66543. sideOrientation?: number;
  66544. frontUVs?: Vector4;
  66545. backUVs?: Vector4;
  66546. instance?: Mesh;
  66547. invertUV?: boolean;
  66548. }, scene?: Nullable<Scene>): Mesh;
  66549. /**
  66550. * Creates lathe mesh.
  66551. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66552. * * 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
  66553. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66554. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66555. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66556. * * 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
  66557. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66558. * * 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
  66559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66563. * @param name defines the name of the mesh
  66564. * @param options defines the options used to create the mesh
  66565. * @param scene defines the hosting scene
  66566. * @returns the lathe mesh
  66567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66568. */
  66569. static CreateLathe(name: string, options: {
  66570. shape: Vector3[];
  66571. radius?: number;
  66572. tessellation?: number;
  66573. clip?: number;
  66574. arc?: number;
  66575. closed?: boolean;
  66576. updatable?: boolean;
  66577. sideOrientation?: number;
  66578. frontUVs?: Vector4;
  66579. backUVs?: Vector4;
  66580. cap?: number;
  66581. invertUV?: boolean;
  66582. }, scene?: Nullable<Scene>): Mesh;
  66583. /**
  66584. * Creates a tiled plane mesh
  66585. * * You can set a limited pattern arrangement with the tiles
  66586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66589. * @param name defines the name of the mesh
  66590. * @param options defines the options used to create the mesh
  66591. * @param scene defines the hosting scene
  66592. * @returns the plane mesh
  66593. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66594. */
  66595. static CreateTiledPlane(name: string, options: {
  66596. pattern?: number;
  66597. tileSize?: number;
  66598. tileWidth?: number;
  66599. tileHeight?: number;
  66600. size?: number;
  66601. width?: number;
  66602. height?: number;
  66603. alignHorizontal?: number;
  66604. alignVertical?: number;
  66605. sideOrientation?: number;
  66606. frontUVs?: Vector4;
  66607. backUVs?: Vector4;
  66608. updatable?: boolean;
  66609. }, scene?: Nullable<Scene>): Mesh;
  66610. /**
  66611. * Creates a plane mesh
  66612. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66613. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66614. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66618. * @param name defines the name of the mesh
  66619. * @param options defines the options used to create the mesh
  66620. * @param scene defines the hosting scene
  66621. * @returns the plane mesh
  66622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66623. */
  66624. static CreatePlane(name: string, options: {
  66625. size?: number;
  66626. width?: number;
  66627. height?: number;
  66628. sideOrientation?: number;
  66629. frontUVs?: Vector4;
  66630. backUVs?: Vector4;
  66631. updatable?: boolean;
  66632. sourcePlane?: Plane;
  66633. }, scene?: Nullable<Scene>): Mesh;
  66634. /**
  66635. * Creates a ground mesh
  66636. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66637. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66639. * @param name defines the name of the mesh
  66640. * @param options defines the options used to create the mesh
  66641. * @param scene defines the hosting scene
  66642. * @returns the ground mesh
  66643. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66644. */
  66645. static CreateGround(name: string, options: {
  66646. width?: number;
  66647. height?: number;
  66648. subdivisions?: number;
  66649. subdivisionsX?: number;
  66650. subdivisionsY?: number;
  66651. updatable?: boolean;
  66652. }, scene?: Nullable<Scene>): Mesh;
  66653. /**
  66654. * Creates a tiled ground mesh
  66655. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66656. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66657. * * 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
  66658. * * 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
  66659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66660. * @param name defines the name of the mesh
  66661. * @param options defines the options used to create the mesh
  66662. * @param scene defines the hosting scene
  66663. * @returns the tiled ground mesh
  66664. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66665. */
  66666. static CreateTiledGround(name: string, options: {
  66667. xmin: number;
  66668. zmin: number;
  66669. xmax: number;
  66670. zmax: number;
  66671. subdivisions?: {
  66672. w: number;
  66673. h: number;
  66674. };
  66675. precision?: {
  66676. w: number;
  66677. h: number;
  66678. };
  66679. updatable?: boolean;
  66680. }, scene?: Nullable<Scene>): Mesh;
  66681. /**
  66682. * Creates a ground mesh from a height map
  66683. * * The parameter `url` sets the URL of the height map image resource.
  66684. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66685. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66686. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66687. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66688. * * 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.
  66689. * * 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).
  66690. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66692. * @param name defines the name of the mesh
  66693. * @param url defines the url to the height map
  66694. * @param options defines the options used to create the mesh
  66695. * @param scene defines the hosting scene
  66696. * @returns the ground mesh
  66697. * @see https://doc.babylonjs.com/babylon101/height_map
  66698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66699. */
  66700. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66701. width?: number;
  66702. height?: number;
  66703. subdivisions?: number;
  66704. minHeight?: number;
  66705. maxHeight?: number;
  66706. colorFilter?: Color3;
  66707. alphaFilter?: number;
  66708. updatable?: boolean;
  66709. onReady?: (mesh: GroundMesh) => void;
  66710. }, scene?: Nullable<Scene>): GroundMesh;
  66711. /**
  66712. * Creates a polygon mesh
  66713. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66714. * * 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
  66715. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66718. * * Remember you can only change the shape positions, not their number when updating a polygon
  66719. * @param name defines the name of the mesh
  66720. * @param options defines the options used to create the mesh
  66721. * @param scene defines the hosting scene
  66722. * @param earcutInjection can be used to inject your own earcut reference
  66723. * @returns the polygon mesh
  66724. */
  66725. static CreatePolygon(name: string, options: {
  66726. shape: Vector3[];
  66727. holes?: Vector3[][];
  66728. depth?: number;
  66729. faceUV?: Vector4[];
  66730. faceColors?: Color4[];
  66731. updatable?: boolean;
  66732. sideOrientation?: number;
  66733. frontUVs?: Vector4;
  66734. backUVs?: Vector4;
  66735. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66736. /**
  66737. * Creates an extruded polygon mesh, with depth in the Y direction.
  66738. * * 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)
  66739. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66740. * @param name defines the name of the mesh
  66741. * @param options defines the options used to create the mesh
  66742. * @param scene defines the hosting scene
  66743. * @param earcutInjection can be used to inject your own earcut reference
  66744. * @returns the polygon mesh
  66745. */
  66746. static ExtrudePolygon(name: string, options: {
  66747. shape: Vector3[];
  66748. holes?: Vector3[][];
  66749. depth?: number;
  66750. faceUV?: Vector4[];
  66751. faceColors?: Color4[];
  66752. updatable?: boolean;
  66753. sideOrientation?: number;
  66754. frontUVs?: Vector4;
  66755. backUVs?: Vector4;
  66756. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66757. /**
  66758. * Creates a tube mesh.
  66759. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66760. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66761. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66762. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66763. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66764. * * 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)
  66765. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66766. * * 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
  66767. * * 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
  66768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66772. * @param name defines the name of the mesh
  66773. * @param options defines the options used to create the mesh
  66774. * @param scene defines the hosting scene
  66775. * @returns the tube mesh
  66776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66777. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66778. */
  66779. static CreateTube(name: string, options: {
  66780. path: Vector3[];
  66781. radius?: number;
  66782. tessellation?: number;
  66783. radiusFunction?: {
  66784. (i: number, distance: number): number;
  66785. };
  66786. cap?: number;
  66787. arc?: number;
  66788. updatable?: boolean;
  66789. sideOrientation?: number;
  66790. frontUVs?: Vector4;
  66791. backUVs?: Vector4;
  66792. instance?: Mesh;
  66793. invertUV?: boolean;
  66794. }, scene?: Nullable<Scene>): Mesh;
  66795. /**
  66796. * Creates a polyhedron mesh
  66797. * * 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
  66798. * * The parameter `size` (positive float, default 1) sets the polygon size
  66799. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66800. * * 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`
  66801. * * 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
  66802. * * 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)`)
  66803. * * 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
  66804. * * 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
  66805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66808. * @param name defines the name of the mesh
  66809. * @param options defines the options used to create the mesh
  66810. * @param scene defines the hosting scene
  66811. * @returns the polyhedron mesh
  66812. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66813. */
  66814. static CreatePolyhedron(name: string, options: {
  66815. type?: number;
  66816. size?: number;
  66817. sizeX?: number;
  66818. sizeY?: number;
  66819. sizeZ?: number;
  66820. custom?: any;
  66821. faceUV?: Vector4[];
  66822. faceColors?: Color4[];
  66823. flat?: boolean;
  66824. updatable?: boolean;
  66825. sideOrientation?: number;
  66826. frontUVs?: Vector4;
  66827. backUVs?: Vector4;
  66828. }, scene?: Nullable<Scene>): Mesh;
  66829. /**
  66830. * Creates a decal mesh.
  66831. * 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
  66832. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66833. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66834. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66835. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66836. * @param name defines the name of the mesh
  66837. * @param sourceMesh defines the mesh where the decal must be applied
  66838. * @param options defines the options used to create the mesh
  66839. * @param scene defines the hosting scene
  66840. * @returns the decal mesh
  66841. * @see https://doc.babylonjs.com/how_to/decals
  66842. */
  66843. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66844. position?: Vector3;
  66845. normal?: Vector3;
  66846. size?: Vector3;
  66847. angle?: number;
  66848. }): Mesh;
  66849. }
  66850. }
  66851. declare module "babylonjs/Meshes/meshSimplification" {
  66852. import { Mesh } from "babylonjs/Meshes/mesh";
  66853. /**
  66854. * A simplifier interface for future simplification implementations
  66855. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66856. */
  66857. export interface ISimplifier {
  66858. /**
  66859. * Simplification of a given mesh according to the given settings.
  66860. * Since this requires computation, it is assumed that the function runs async.
  66861. * @param settings The settings of the simplification, including quality and distance
  66862. * @param successCallback A callback that will be called after the mesh was simplified.
  66863. * @param errorCallback in case of an error, this callback will be called. optional.
  66864. */
  66865. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66866. }
  66867. /**
  66868. * Expected simplification settings.
  66869. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66870. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66871. */
  66872. export interface ISimplificationSettings {
  66873. /**
  66874. * Gets or sets the expected quality
  66875. */
  66876. quality: number;
  66877. /**
  66878. * Gets or sets the distance when this optimized version should be used
  66879. */
  66880. distance: number;
  66881. /**
  66882. * Gets an already optimized mesh
  66883. */
  66884. optimizeMesh?: boolean;
  66885. }
  66886. /**
  66887. * Class used to specify simplification options
  66888. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66889. */
  66890. export class SimplificationSettings implements ISimplificationSettings {
  66891. /** expected quality */
  66892. quality: number;
  66893. /** distance when this optimized version should be used */
  66894. distance: number;
  66895. /** already optimized mesh */
  66896. optimizeMesh?: boolean | undefined;
  66897. /**
  66898. * Creates a SimplificationSettings
  66899. * @param quality expected quality
  66900. * @param distance distance when this optimized version should be used
  66901. * @param optimizeMesh already optimized mesh
  66902. */
  66903. constructor(
  66904. /** expected quality */
  66905. quality: number,
  66906. /** distance when this optimized version should be used */
  66907. distance: number,
  66908. /** already optimized mesh */
  66909. optimizeMesh?: boolean | undefined);
  66910. }
  66911. /**
  66912. * Interface used to define a simplification task
  66913. */
  66914. export interface ISimplificationTask {
  66915. /**
  66916. * Array of settings
  66917. */
  66918. settings: Array<ISimplificationSettings>;
  66919. /**
  66920. * Simplification type
  66921. */
  66922. simplificationType: SimplificationType;
  66923. /**
  66924. * Mesh to simplify
  66925. */
  66926. mesh: Mesh;
  66927. /**
  66928. * Callback called on success
  66929. */
  66930. successCallback?: () => void;
  66931. /**
  66932. * Defines if parallel processing can be used
  66933. */
  66934. parallelProcessing: boolean;
  66935. }
  66936. /**
  66937. * Queue used to order the simplification tasks
  66938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66939. */
  66940. export class SimplificationQueue {
  66941. private _simplificationArray;
  66942. /**
  66943. * Gets a boolean indicating that the process is still running
  66944. */
  66945. running: boolean;
  66946. /**
  66947. * Creates a new queue
  66948. */
  66949. constructor();
  66950. /**
  66951. * Adds a new simplification task
  66952. * @param task defines a task to add
  66953. */
  66954. addTask(task: ISimplificationTask): void;
  66955. /**
  66956. * Execute next task
  66957. */
  66958. executeNext(): void;
  66959. /**
  66960. * Execute a simplification task
  66961. * @param task defines the task to run
  66962. */
  66963. runSimplification(task: ISimplificationTask): void;
  66964. private getSimplifier;
  66965. }
  66966. /**
  66967. * The implemented types of simplification
  66968. * At the moment only Quadratic Error Decimation is implemented
  66969. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66970. */
  66971. export enum SimplificationType {
  66972. /** Quadratic error decimation */
  66973. QUADRATIC = 0
  66974. }
  66975. /**
  66976. * An implementation of the Quadratic Error simplification algorithm.
  66977. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66978. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66979. * @author RaananW
  66980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66981. */
  66982. export class QuadraticErrorSimplification implements ISimplifier {
  66983. private _mesh;
  66984. private triangles;
  66985. private vertices;
  66986. private references;
  66987. private _reconstructedMesh;
  66988. /** Gets or sets the number pf sync interations */
  66989. syncIterations: number;
  66990. /** Gets or sets the aggressiveness of the simplifier */
  66991. aggressiveness: number;
  66992. /** Gets or sets the number of allowed iterations for decimation */
  66993. decimationIterations: number;
  66994. /** Gets or sets the espilon to use for bounding box computation */
  66995. boundingBoxEpsilon: number;
  66996. /**
  66997. * Creates a new QuadraticErrorSimplification
  66998. * @param _mesh defines the target mesh
  66999. */
  67000. constructor(_mesh: Mesh);
  67001. /**
  67002. * Simplification of a given mesh according to the given settings.
  67003. * Since this requires computation, it is assumed that the function runs async.
  67004. * @param settings The settings of the simplification, including quality and distance
  67005. * @param successCallback A callback that will be called after the mesh was simplified.
  67006. */
  67007. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67008. private runDecimation;
  67009. private initWithMesh;
  67010. private init;
  67011. private reconstructMesh;
  67012. private initDecimatedMesh;
  67013. private isFlipped;
  67014. private updateTriangles;
  67015. private identifyBorder;
  67016. private updateMesh;
  67017. private vertexError;
  67018. private calculateError;
  67019. }
  67020. }
  67021. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67022. import { Scene } from "babylonjs/scene";
  67023. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67024. import { ISceneComponent } from "babylonjs/sceneComponent";
  67025. module "babylonjs/scene" {
  67026. interface Scene {
  67027. /** @hidden (Backing field) */
  67028. _simplificationQueue: SimplificationQueue;
  67029. /**
  67030. * Gets or sets the simplification queue attached to the scene
  67031. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67032. */
  67033. simplificationQueue: SimplificationQueue;
  67034. }
  67035. }
  67036. module "babylonjs/Meshes/mesh" {
  67037. interface Mesh {
  67038. /**
  67039. * Simplify the mesh according to the given array of settings.
  67040. * Function will return immediately and will simplify async
  67041. * @param settings a collection of simplification settings
  67042. * @param parallelProcessing should all levels calculate parallel or one after the other
  67043. * @param simplificationType the type of simplification to run
  67044. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67045. * @returns the current mesh
  67046. */
  67047. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67048. }
  67049. }
  67050. /**
  67051. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67052. * created in a scene
  67053. */
  67054. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67055. /**
  67056. * The component name helpfull to identify the component in the list of scene components.
  67057. */
  67058. readonly name: string;
  67059. /**
  67060. * The scene the component belongs to.
  67061. */
  67062. scene: Scene;
  67063. /**
  67064. * Creates a new instance of the component for the given scene
  67065. * @param scene Defines the scene to register the component in
  67066. */
  67067. constructor(scene: Scene);
  67068. /**
  67069. * Registers the component in a given scene
  67070. */
  67071. register(): void;
  67072. /**
  67073. * Rebuilds the elements related to this component in case of
  67074. * context lost for instance.
  67075. */
  67076. rebuild(): void;
  67077. /**
  67078. * Disposes the component and the associated ressources
  67079. */
  67080. dispose(): void;
  67081. private _beforeCameraUpdate;
  67082. }
  67083. }
  67084. declare module "babylonjs/Meshes/Builders/index" {
  67085. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67086. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67087. export * from "babylonjs/Meshes/Builders/discBuilder";
  67088. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67089. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67090. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67091. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67092. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67093. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67094. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67095. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67096. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67097. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67098. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67099. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67100. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67101. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67102. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67103. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67104. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67105. }
  67106. declare module "babylonjs/Meshes/index" {
  67107. export * from "babylonjs/Meshes/abstractMesh";
  67108. export * from "babylonjs/Meshes/buffer";
  67109. export * from "babylonjs/Meshes/Compression/index";
  67110. export * from "babylonjs/Meshes/csg";
  67111. export * from "babylonjs/Meshes/geometry";
  67112. export * from "babylonjs/Meshes/groundMesh";
  67113. export * from "babylonjs/Meshes/trailMesh";
  67114. export * from "babylonjs/Meshes/instancedMesh";
  67115. export * from "babylonjs/Meshes/linesMesh";
  67116. export * from "babylonjs/Meshes/mesh";
  67117. export * from "babylonjs/Meshes/mesh.vertexData";
  67118. export * from "babylonjs/Meshes/meshBuilder";
  67119. export * from "babylonjs/Meshes/meshSimplification";
  67120. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67121. export * from "babylonjs/Meshes/polygonMesh";
  67122. export * from "babylonjs/Meshes/subMesh";
  67123. export * from "babylonjs/Meshes/meshLODLevel";
  67124. export * from "babylonjs/Meshes/transformNode";
  67125. export * from "babylonjs/Meshes/Builders/index";
  67126. export * from "babylonjs/Meshes/dataBuffer";
  67127. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67128. }
  67129. declare module "babylonjs/Morph/index" {
  67130. export * from "babylonjs/Morph/morphTarget";
  67131. export * from "babylonjs/Morph/morphTargetManager";
  67132. }
  67133. declare module "babylonjs/Navigation/INavigationEngine" {
  67134. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67135. import { Vector3 } from "babylonjs/Maths/math";
  67136. import { Mesh } from "babylonjs/Meshes/mesh";
  67137. import { Scene } from "babylonjs/scene";
  67138. /**
  67139. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67140. */
  67141. export interface INavigationEnginePlugin {
  67142. /**
  67143. * plugin name
  67144. */
  67145. name: string;
  67146. /**
  67147. * Creates a navigation mesh
  67148. * @param meshes array of all the geometry used to compute the navigatio mesh
  67149. * @param parameters bunch of parameters used to filter geometry
  67150. */
  67151. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67152. /**
  67153. * Create a navigation mesh debug mesh
  67154. * @param scene is where the mesh will be added
  67155. * @returns debug display mesh
  67156. */
  67157. createDebugNavMesh(scene: Scene): Mesh;
  67158. /**
  67159. * Get a navigation mesh constrained position, closest to the parameter position
  67160. * @param position world position
  67161. * @returns the closest point to position constrained by the navigation mesh
  67162. */
  67163. getClosestPoint(position: Vector3): Vector3;
  67164. /**
  67165. * Get a navigation mesh constrained position, closest to the parameter position
  67166. * @param position world position
  67167. * @param result output the closest point to position constrained by the navigation mesh
  67168. */
  67169. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67170. /**
  67171. * Get a navigation mesh constrained position, within a particular radius
  67172. * @param position world position
  67173. * @param maxRadius the maximum distance to the constrained world position
  67174. * @returns the closest point to position constrained by the navigation mesh
  67175. */
  67176. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67177. /**
  67178. * Get a navigation mesh constrained position, within a particular radius
  67179. * @param position world position
  67180. * @param maxRadius the maximum distance to the constrained world position
  67181. * @param result output the closest point to position constrained by the navigation mesh
  67182. */
  67183. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67184. /**
  67185. * Compute the final position from a segment made of destination-position
  67186. * @param position world position
  67187. * @param destination world position
  67188. * @returns the resulting point along the navmesh
  67189. */
  67190. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67191. /**
  67192. * Compute the final position from a segment made of destination-position
  67193. * @param position world position
  67194. * @param destination world position
  67195. * @param result output the resulting point along the navmesh
  67196. */
  67197. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67198. /**
  67199. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67200. * @param start world position
  67201. * @param end world position
  67202. * @returns array containing world position composing the path
  67203. */
  67204. computePath(start: Vector3, end: Vector3): Vector3[];
  67205. /**
  67206. * If this plugin is supported
  67207. * @returns true if plugin is supported
  67208. */
  67209. isSupported(): boolean;
  67210. /**
  67211. * Create a new Crowd so you can add agents
  67212. * @param maxAgents the maximum agent count in the crowd
  67213. * @param maxAgentRadius the maximum radius an agent can have
  67214. * @param scene to attach the crowd to
  67215. * @returns the crowd you can add agents to
  67216. */
  67217. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67218. /**
  67219. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67220. * The queries will try to find a solution within those bounds
  67221. * default is (1,1,1)
  67222. * @param extent x,y,z value that define the extent around the queries point of reference
  67223. */
  67224. setDefaultQueryExtent(extent: Vector3): void;
  67225. /**
  67226. * Get the Bounding box extent specified by setDefaultQueryExtent
  67227. * @returns the box extent values
  67228. */
  67229. getDefaultQueryExtent(): Vector3;
  67230. /**
  67231. * build the navmesh from a previously saved state using getNavmeshData
  67232. * @param data the Uint8Array returned by getNavmeshData
  67233. */
  67234. buildFromNavmeshData(data: Uint8Array): void;
  67235. /**
  67236. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67237. * @returns data the Uint8Array that can be saved and reused
  67238. */
  67239. getNavmeshData(): Uint8Array;
  67240. /**
  67241. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67242. * @param result output the box extent values
  67243. */
  67244. getDefaultQueryExtentToRef(result: Vector3): void;
  67245. /**
  67246. * Release all resources
  67247. */
  67248. dispose(): void;
  67249. }
  67250. /**
  67251. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67252. */
  67253. export interface ICrowd {
  67254. /**
  67255. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67256. * You can attach anything to that node. The node position is updated in the scene update tick.
  67257. * @param pos world position that will be constrained by the navigation mesh
  67258. * @param parameters agent parameters
  67259. * @param transform hooked to the agent that will be update by the scene
  67260. * @returns agent index
  67261. */
  67262. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67263. /**
  67264. * Returns the agent position in world space
  67265. * @param index agent index returned by addAgent
  67266. * @returns world space position
  67267. */
  67268. getAgentPosition(index: number): Vector3;
  67269. /**
  67270. * Gets the agent position result in world space
  67271. * @param index agent index returned by addAgent
  67272. * @param result output world space position
  67273. */
  67274. getAgentPositionToRef(index: number, result: Vector3): void;
  67275. /**
  67276. * Gets the agent velocity in world space
  67277. * @param index agent index returned by addAgent
  67278. * @returns world space velocity
  67279. */
  67280. getAgentVelocity(index: number): Vector3;
  67281. /**
  67282. * Gets the agent velocity result in world space
  67283. * @param index agent index returned by addAgent
  67284. * @param result output world space velocity
  67285. */
  67286. getAgentVelocityToRef(index: number, result: Vector3): void;
  67287. /**
  67288. * remove a particular agent previously created
  67289. * @param index agent index returned by addAgent
  67290. */
  67291. removeAgent(index: number): void;
  67292. /**
  67293. * get the list of all agents attached to this crowd
  67294. * @returns list of agent indices
  67295. */
  67296. getAgents(): number[];
  67297. /**
  67298. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67299. * @param deltaTime in seconds
  67300. */
  67301. update(deltaTime: number): void;
  67302. /**
  67303. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67304. * @param index agent index returned by addAgent
  67305. * @param destination targeted world position
  67306. */
  67307. agentGoto(index: number, destination: Vector3): void;
  67308. /**
  67309. * Teleport the agent to a new position
  67310. * @param index agent index returned by addAgent
  67311. * @param destination targeted world position
  67312. */
  67313. agentTeleport(index: number, destination: Vector3): void;
  67314. /**
  67315. * Update agent parameters
  67316. * @param index agent index returned by addAgent
  67317. * @param parameters agent parameters
  67318. */
  67319. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67320. /**
  67321. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67322. * The queries will try to find a solution within those bounds
  67323. * default is (1,1,1)
  67324. * @param extent x,y,z value that define the extent around the queries point of reference
  67325. */
  67326. setDefaultQueryExtent(extent: Vector3): void;
  67327. /**
  67328. * Get the Bounding box extent specified by setDefaultQueryExtent
  67329. * @returns the box extent values
  67330. */
  67331. getDefaultQueryExtent(): Vector3;
  67332. /**
  67333. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67334. * @param result output the box extent values
  67335. */
  67336. getDefaultQueryExtentToRef(result: Vector3): void;
  67337. /**
  67338. * Release all resources
  67339. */
  67340. dispose(): void;
  67341. }
  67342. /**
  67343. * Configures an agent
  67344. */
  67345. export interface IAgentParameters {
  67346. /**
  67347. * Agent radius. [Limit: >= 0]
  67348. */
  67349. radius: number;
  67350. /**
  67351. * Agent height. [Limit: > 0]
  67352. */
  67353. height: number;
  67354. /**
  67355. * Maximum allowed acceleration. [Limit: >= 0]
  67356. */
  67357. maxAcceleration: number;
  67358. /**
  67359. * Maximum allowed speed. [Limit: >= 0]
  67360. */
  67361. maxSpeed: number;
  67362. /**
  67363. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67364. */
  67365. collisionQueryRange: number;
  67366. /**
  67367. * The path visibility optimization range. [Limit: > 0]
  67368. */
  67369. pathOptimizationRange: number;
  67370. /**
  67371. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67372. */
  67373. separationWeight: number;
  67374. }
  67375. /**
  67376. * Configures the navigation mesh creation
  67377. */
  67378. export interface INavMeshParameters {
  67379. /**
  67380. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67381. */
  67382. cs: number;
  67383. /**
  67384. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67385. */
  67386. ch: number;
  67387. /**
  67388. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67389. */
  67390. walkableSlopeAngle: number;
  67391. /**
  67392. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67393. * be considered walkable. [Limit: >= 3] [Units: vx]
  67394. */
  67395. walkableHeight: number;
  67396. /**
  67397. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67398. */
  67399. walkableClimb: number;
  67400. /**
  67401. * The distance to erode/shrink the walkable area of the heightfield away from
  67402. * obstructions. [Limit: >=0] [Units: vx]
  67403. */
  67404. walkableRadius: number;
  67405. /**
  67406. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67407. */
  67408. maxEdgeLen: number;
  67409. /**
  67410. * The maximum distance a simplfied contour's border edges should deviate
  67411. * the original raw contour. [Limit: >=0] [Units: vx]
  67412. */
  67413. maxSimplificationError: number;
  67414. /**
  67415. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67416. */
  67417. minRegionArea: number;
  67418. /**
  67419. * Any regions with a span count smaller than this value will, if possible,
  67420. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67421. */
  67422. mergeRegionArea: number;
  67423. /**
  67424. * The maximum number of vertices allowed for polygons generated during the
  67425. * contour to polygon conversion process. [Limit: >= 3]
  67426. */
  67427. maxVertsPerPoly: number;
  67428. /**
  67429. * Sets the sampling distance to use when generating the detail mesh.
  67430. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67431. */
  67432. detailSampleDist: number;
  67433. /**
  67434. * The maximum distance the detail mesh surface should deviate from heightfield
  67435. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67436. */
  67437. detailSampleMaxError: number;
  67438. }
  67439. }
  67440. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67441. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67442. import { Mesh } from "babylonjs/Meshes/mesh";
  67443. import { Scene } from "babylonjs/scene";
  67444. import { Vector3 } from "babylonjs/Maths/math";
  67445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67446. /**
  67447. * RecastJS navigation plugin
  67448. */
  67449. export class RecastJSPlugin implements INavigationEnginePlugin {
  67450. /**
  67451. * Reference to the Recast library
  67452. */
  67453. bjsRECAST: any;
  67454. /**
  67455. * plugin name
  67456. */
  67457. name: string;
  67458. /**
  67459. * the first navmesh created. We might extend this to support multiple navmeshes
  67460. */
  67461. navMesh: any;
  67462. /**
  67463. * Initializes the recastJS plugin
  67464. * @param recastInjection can be used to inject your own recast reference
  67465. */
  67466. constructor(recastInjection?: any);
  67467. /**
  67468. * Creates a navigation mesh
  67469. * @param meshes array of all the geometry used to compute the navigatio mesh
  67470. * @param parameters bunch of parameters used to filter geometry
  67471. */
  67472. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67473. /**
  67474. * Create a navigation mesh debug mesh
  67475. * @param scene is where the mesh will be added
  67476. * @returns debug display mesh
  67477. */
  67478. createDebugNavMesh(scene: Scene): Mesh;
  67479. /**
  67480. * Get a navigation mesh constrained position, closest to the parameter position
  67481. * @param position world position
  67482. * @returns the closest point to position constrained by the navigation mesh
  67483. */
  67484. getClosestPoint(position: Vector3): Vector3;
  67485. /**
  67486. * Get a navigation mesh constrained position, closest to the parameter position
  67487. * @param position world position
  67488. * @param result output the closest point to position constrained by the navigation mesh
  67489. */
  67490. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67491. /**
  67492. * Get a navigation mesh constrained position, within a particular radius
  67493. * @param position world position
  67494. * @param maxRadius the maximum distance to the constrained world position
  67495. * @returns the closest point to position constrained by the navigation mesh
  67496. */
  67497. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67498. /**
  67499. * Get a navigation mesh constrained position, within a particular radius
  67500. * @param position world position
  67501. * @param maxRadius the maximum distance to the constrained world position
  67502. * @param result output the closest point to position constrained by the navigation mesh
  67503. */
  67504. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67505. /**
  67506. * Compute the final position from a segment made of destination-position
  67507. * @param position world position
  67508. * @param destination world position
  67509. * @returns the resulting point along the navmesh
  67510. */
  67511. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67512. /**
  67513. * Compute the final position from a segment made of destination-position
  67514. * @param position world position
  67515. * @param destination world position
  67516. * @param result output the resulting point along the navmesh
  67517. */
  67518. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67519. /**
  67520. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67521. * @param start world position
  67522. * @param end world position
  67523. * @returns array containing world position composing the path
  67524. */
  67525. computePath(start: Vector3, end: Vector3): Vector3[];
  67526. /**
  67527. * Create a new Crowd so you can add agents
  67528. * @param maxAgents the maximum agent count in the crowd
  67529. * @param maxAgentRadius the maximum radius an agent can have
  67530. * @param scene to attach the crowd to
  67531. * @returns the crowd you can add agents to
  67532. */
  67533. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67534. /**
  67535. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67536. * The queries will try to find a solution within those bounds
  67537. * default is (1,1,1)
  67538. * @param extent x,y,z value that define the extent around the queries point of reference
  67539. */
  67540. setDefaultQueryExtent(extent: Vector3): void;
  67541. /**
  67542. * Get the Bounding box extent specified by setDefaultQueryExtent
  67543. * @returns the box extent values
  67544. */
  67545. getDefaultQueryExtent(): Vector3;
  67546. /**
  67547. * build the navmesh from a previously saved state using getNavmeshData
  67548. * @param data the Uint8Array returned by getNavmeshData
  67549. */
  67550. buildFromNavmeshData(data: Uint8Array): void;
  67551. /**
  67552. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67553. * @returns data the Uint8Array that can be saved and reused
  67554. */
  67555. getNavmeshData(): Uint8Array;
  67556. /**
  67557. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67558. * @param result output the box extent values
  67559. */
  67560. getDefaultQueryExtentToRef(result: Vector3): void;
  67561. /**
  67562. * Disposes
  67563. */
  67564. dispose(): void;
  67565. /**
  67566. * If this plugin is supported
  67567. * @returns true if plugin is supported
  67568. */
  67569. isSupported(): boolean;
  67570. }
  67571. /**
  67572. * Recast detour crowd implementation
  67573. */
  67574. export class RecastJSCrowd implements ICrowd {
  67575. /**
  67576. * Recast/detour plugin
  67577. */
  67578. bjsRECASTPlugin: RecastJSPlugin;
  67579. /**
  67580. * Link to the detour crowd
  67581. */
  67582. recastCrowd: any;
  67583. /**
  67584. * One transform per agent
  67585. */
  67586. transforms: TransformNode[];
  67587. /**
  67588. * All agents created
  67589. */
  67590. agents: number[];
  67591. /**
  67592. * Link to the scene is kept to unregister the crowd from the scene
  67593. */
  67594. private _scene;
  67595. /**
  67596. * Observer for crowd updates
  67597. */
  67598. private _onBeforeAnimationsObserver;
  67599. /**
  67600. * Constructor
  67601. * @param plugin recastJS plugin
  67602. * @param maxAgents the maximum agent count in the crowd
  67603. * @param maxAgentRadius the maximum radius an agent can have
  67604. * @param scene to attach the crowd to
  67605. * @returns the crowd you can add agents to
  67606. */
  67607. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67608. /**
  67609. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67610. * You can attach anything to that node. The node position is updated in the scene update tick.
  67611. * @param pos world position that will be constrained by the navigation mesh
  67612. * @param parameters agent parameters
  67613. * @param transform hooked to the agent that will be update by the scene
  67614. * @returns agent index
  67615. */
  67616. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67617. /**
  67618. * Returns the agent position in world space
  67619. * @param index agent index returned by addAgent
  67620. * @returns world space position
  67621. */
  67622. getAgentPosition(index: number): Vector3;
  67623. /**
  67624. * Returns the agent position result in world space
  67625. * @param index agent index returned by addAgent
  67626. * @param result output world space position
  67627. */
  67628. getAgentPositionToRef(index: number, result: Vector3): void;
  67629. /**
  67630. * Returns the agent velocity in world space
  67631. * @param index agent index returned by addAgent
  67632. * @returns world space velocity
  67633. */
  67634. getAgentVelocity(index: number): Vector3;
  67635. /**
  67636. * Returns the agent velocity result in world space
  67637. * @param index agent index returned by addAgent
  67638. * @param result output world space velocity
  67639. */
  67640. getAgentVelocityToRef(index: number, result: Vector3): void;
  67641. /**
  67642. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67643. * @param index agent index returned by addAgent
  67644. * @param destination targeted world position
  67645. */
  67646. agentGoto(index: number, destination: Vector3): void;
  67647. /**
  67648. * Teleport the agent to a new position
  67649. * @param index agent index returned by addAgent
  67650. * @param destination targeted world position
  67651. */
  67652. agentTeleport(index: number, destination: Vector3): void;
  67653. /**
  67654. * Update agent parameters
  67655. * @param index agent index returned by addAgent
  67656. * @param parameters agent parameters
  67657. */
  67658. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67659. /**
  67660. * remove a particular agent previously created
  67661. * @param index agent index returned by addAgent
  67662. */
  67663. removeAgent(index: number): void;
  67664. /**
  67665. * get the list of all agents attached to this crowd
  67666. * @returns list of agent indices
  67667. */
  67668. getAgents(): number[];
  67669. /**
  67670. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67671. * @param deltaTime in seconds
  67672. */
  67673. update(deltaTime: number): void;
  67674. /**
  67675. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67676. * The queries will try to find a solution within those bounds
  67677. * default is (1,1,1)
  67678. * @param extent x,y,z value that define the extent around the queries point of reference
  67679. */
  67680. setDefaultQueryExtent(extent: Vector3): void;
  67681. /**
  67682. * Get the Bounding box extent specified by setDefaultQueryExtent
  67683. * @returns the box extent values
  67684. */
  67685. getDefaultQueryExtent(): Vector3;
  67686. /**
  67687. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67688. * @param result output the box extent values
  67689. */
  67690. getDefaultQueryExtentToRef(result: Vector3): void;
  67691. /**
  67692. * Release all resources
  67693. */
  67694. dispose(): void;
  67695. }
  67696. }
  67697. declare module "babylonjs/Navigation/Plugins/index" {
  67698. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67699. }
  67700. declare module "babylonjs/Navigation/index" {
  67701. export * from "babylonjs/Navigation/INavigationEngine";
  67702. export * from "babylonjs/Navigation/Plugins/index";
  67703. }
  67704. declare module "babylonjs/Offline/database" {
  67705. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67706. /**
  67707. * Class used to enable access to IndexedDB
  67708. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67709. */
  67710. export class Database implements IOfflineProvider {
  67711. private _callbackManifestChecked;
  67712. private _currentSceneUrl;
  67713. private _db;
  67714. private _enableSceneOffline;
  67715. private _enableTexturesOffline;
  67716. private _manifestVersionFound;
  67717. private _mustUpdateRessources;
  67718. private _hasReachedQuota;
  67719. private _isSupported;
  67720. private _idbFactory;
  67721. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67722. private static IsUASupportingBlobStorage;
  67723. /**
  67724. * Gets a boolean indicating if Database storate is enabled (off by default)
  67725. */
  67726. static IDBStorageEnabled: boolean;
  67727. /**
  67728. * Gets a boolean indicating if scene must be saved in the database
  67729. */
  67730. get enableSceneOffline(): boolean;
  67731. /**
  67732. * Gets a boolean indicating if textures must be saved in the database
  67733. */
  67734. get enableTexturesOffline(): boolean;
  67735. /**
  67736. * Creates a new Database
  67737. * @param urlToScene defines the url to load the scene
  67738. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67739. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67740. */
  67741. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67742. private static _ParseURL;
  67743. private static _ReturnFullUrlLocation;
  67744. private _checkManifestFile;
  67745. /**
  67746. * Open the database and make it available
  67747. * @param successCallback defines the callback to call on success
  67748. * @param errorCallback defines the callback to call on error
  67749. */
  67750. open(successCallback: () => void, errorCallback: () => void): void;
  67751. /**
  67752. * Loads an image from the database
  67753. * @param url defines the url to load from
  67754. * @param image defines the target DOM image
  67755. */
  67756. loadImage(url: string, image: HTMLImageElement): void;
  67757. private _loadImageFromDBAsync;
  67758. private _saveImageIntoDBAsync;
  67759. private _checkVersionFromDB;
  67760. private _loadVersionFromDBAsync;
  67761. private _saveVersionIntoDBAsync;
  67762. /**
  67763. * Loads a file from database
  67764. * @param url defines the URL to load from
  67765. * @param sceneLoaded defines a callback to call on success
  67766. * @param progressCallBack defines a callback to call when progress changed
  67767. * @param errorCallback defines a callback to call on error
  67768. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67769. */
  67770. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67771. private _loadFileAsync;
  67772. private _saveFileAsync;
  67773. /**
  67774. * Validates if xhr data is correct
  67775. * @param xhr defines the request to validate
  67776. * @param dataType defines the expected data type
  67777. * @returns true if data is correct
  67778. */
  67779. private static _ValidateXHRData;
  67780. }
  67781. }
  67782. declare module "babylonjs/Offline/index" {
  67783. export * from "babylonjs/Offline/database";
  67784. export * from "babylonjs/Offline/IOfflineProvider";
  67785. }
  67786. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67787. /** @hidden */
  67788. export var gpuUpdateParticlesPixelShader: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  67794. /** @hidden */
  67795. export var gpuUpdateParticlesVertexShader: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  67801. /** @hidden */
  67802. export var clipPlaneFragmentDeclaration2: {
  67803. name: string;
  67804. shader: string;
  67805. };
  67806. }
  67807. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  67808. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  67809. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67810. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67811. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67812. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  67813. /** @hidden */
  67814. export var gpuRenderParticlesPixelShader: {
  67815. name: string;
  67816. shader: string;
  67817. };
  67818. }
  67819. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  67820. /** @hidden */
  67821. export var clipPlaneVertexDeclaration2: {
  67822. name: string;
  67823. shader: string;
  67824. };
  67825. }
  67826. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  67827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  67828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  67829. /** @hidden */
  67830. export var gpuRenderParticlesVertexShader: {
  67831. name: string;
  67832. shader: string;
  67833. };
  67834. }
  67835. declare module "babylonjs/Particles/gpuParticleSystem" {
  67836. import { Nullable } from "babylonjs/types";
  67837. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  67838. import { Observable } from "babylonjs/Misc/observable";
  67839. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67841. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  67842. import { Scene, IDisposable } from "babylonjs/scene";
  67843. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67844. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67845. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  67846. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  67847. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  67848. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  67849. /**
  67850. * This represents a GPU particle system in Babylon
  67851. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67852. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67853. */
  67854. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67855. /**
  67856. * The layer mask we are rendering the particles through.
  67857. */
  67858. layerMask: number;
  67859. private _capacity;
  67860. private _activeCount;
  67861. private _currentActiveCount;
  67862. private _accumulatedCount;
  67863. private _renderEffect;
  67864. private _updateEffect;
  67865. private _buffer0;
  67866. private _buffer1;
  67867. private _spriteBuffer;
  67868. private _updateVAO;
  67869. private _renderVAO;
  67870. private _targetIndex;
  67871. private _sourceBuffer;
  67872. private _targetBuffer;
  67873. private _engine;
  67874. private _currentRenderId;
  67875. private _started;
  67876. private _stopped;
  67877. private _timeDelta;
  67878. private _randomTexture;
  67879. private _randomTexture2;
  67880. private _attributesStrideSize;
  67881. private _updateEffectOptions;
  67882. private _randomTextureSize;
  67883. private _actualFrame;
  67884. private readonly _rawTextureWidth;
  67885. /**
  67886. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67887. */
  67888. static get IsSupported(): boolean;
  67889. /**
  67890. * An event triggered when the system is disposed.
  67891. */
  67892. onDisposeObservable: Observable<GPUParticleSystem>;
  67893. /**
  67894. * Gets the maximum number of particles active at the same time.
  67895. * @returns The max number of active particles.
  67896. */
  67897. getCapacity(): number;
  67898. /**
  67899. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67900. * to override the particles.
  67901. */
  67902. forceDepthWrite: boolean;
  67903. /**
  67904. * Gets or set the number of active particles
  67905. */
  67906. get activeParticleCount(): number;
  67907. set activeParticleCount(value: number);
  67908. private _preWarmDone;
  67909. /**
  67910. * Specifies if the particles are updated in emitter local space or world space.
  67911. */
  67912. isLocal: boolean;
  67913. /**
  67914. * Is this system ready to be used/rendered
  67915. * @return true if the system is ready
  67916. */
  67917. isReady(): boolean;
  67918. /**
  67919. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67920. * @returns True if it has been started, otherwise false.
  67921. */
  67922. isStarted(): boolean;
  67923. /**
  67924. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67925. * @returns True if it has been stopped, otherwise false.
  67926. */
  67927. isStopped(): boolean;
  67928. /**
  67929. * Gets a boolean indicating that the system is stopping
  67930. * @returns true if the system is currently stopping
  67931. */
  67932. isStopping(): boolean;
  67933. /**
  67934. * Gets the number of particles active at the same time.
  67935. * @returns The number of active particles.
  67936. */
  67937. getActiveCount(): number;
  67938. /**
  67939. * Starts the particle system and begins to emit
  67940. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67941. */
  67942. start(delay?: number): void;
  67943. /**
  67944. * Stops the particle system.
  67945. */
  67946. stop(): void;
  67947. /**
  67948. * Remove all active particles
  67949. */
  67950. reset(): void;
  67951. /**
  67952. * Returns the string "GPUParticleSystem"
  67953. * @returns a string containing the class name
  67954. */
  67955. getClassName(): string;
  67956. private _colorGradientsTexture;
  67957. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67958. /**
  67959. * Adds a new color gradient
  67960. * @param gradient defines the gradient to use (between 0 and 1)
  67961. * @param color1 defines the color to affect to the specified gradient
  67962. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67963. * @returns the current particle system
  67964. */
  67965. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67966. private _refreshColorGradient;
  67967. /** Force the system to rebuild all gradients that need to be resync */
  67968. forceRefreshGradients(): void;
  67969. /**
  67970. * Remove a specific color gradient
  67971. * @param gradient defines the gradient to remove
  67972. * @returns the current particle system
  67973. */
  67974. removeColorGradient(gradient: number): GPUParticleSystem;
  67975. private _angularSpeedGradientsTexture;
  67976. private _sizeGradientsTexture;
  67977. private _velocityGradientsTexture;
  67978. private _limitVelocityGradientsTexture;
  67979. private _dragGradientsTexture;
  67980. private _addFactorGradient;
  67981. /**
  67982. * Adds a new size gradient
  67983. * @param gradient defines the gradient to use (between 0 and 1)
  67984. * @param factor defines the size factor to affect to the specified gradient
  67985. * @returns the current particle system
  67986. */
  67987. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67988. /**
  67989. * Remove a specific size gradient
  67990. * @param gradient defines the gradient to remove
  67991. * @returns the current particle system
  67992. */
  67993. removeSizeGradient(gradient: number): GPUParticleSystem;
  67994. private _refreshFactorGradient;
  67995. /**
  67996. * Adds a new angular speed gradient
  67997. * @param gradient defines the gradient to use (between 0 and 1)
  67998. * @param factor defines the angular speed to affect to the specified gradient
  67999. * @returns the current particle system
  68000. */
  68001. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68002. /**
  68003. * Remove a specific angular speed gradient
  68004. * @param gradient defines the gradient to remove
  68005. * @returns the current particle system
  68006. */
  68007. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68008. /**
  68009. * Adds a new velocity gradient
  68010. * @param gradient defines the gradient to use (between 0 and 1)
  68011. * @param factor defines the velocity to affect to the specified gradient
  68012. * @returns the current particle system
  68013. */
  68014. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68015. /**
  68016. * Remove a specific velocity gradient
  68017. * @param gradient defines the gradient to remove
  68018. * @returns the current particle system
  68019. */
  68020. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68021. /**
  68022. * Adds a new limit velocity gradient
  68023. * @param gradient defines the gradient to use (between 0 and 1)
  68024. * @param factor defines the limit velocity value to affect to the specified gradient
  68025. * @returns the current particle system
  68026. */
  68027. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68028. /**
  68029. * Remove a specific limit velocity gradient
  68030. * @param gradient defines the gradient to remove
  68031. * @returns the current particle system
  68032. */
  68033. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68034. /**
  68035. * Adds a new drag gradient
  68036. * @param gradient defines the gradient to use (between 0 and 1)
  68037. * @param factor defines the drag value to affect to the specified gradient
  68038. * @returns the current particle system
  68039. */
  68040. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68041. /**
  68042. * Remove a specific drag gradient
  68043. * @param gradient defines the gradient to remove
  68044. * @returns the current particle system
  68045. */
  68046. removeDragGradient(gradient: number): GPUParticleSystem;
  68047. /**
  68048. * Not supported by GPUParticleSystem
  68049. * @param gradient defines the gradient to use (between 0 and 1)
  68050. * @param factor defines the emit rate value to affect to the specified gradient
  68051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68052. * @returns the current particle system
  68053. */
  68054. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68055. /**
  68056. * Not supported by GPUParticleSystem
  68057. * @param gradient defines the gradient to remove
  68058. * @returns the current particle system
  68059. */
  68060. removeEmitRateGradient(gradient: number): IParticleSystem;
  68061. /**
  68062. * Not supported by GPUParticleSystem
  68063. * @param gradient defines the gradient to use (between 0 and 1)
  68064. * @param factor defines the start size value to affect to the specified gradient
  68065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68066. * @returns the current particle system
  68067. */
  68068. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68069. /**
  68070. * Not supported by GPUParticleSystem
  68071. * @param gradient defines the gradient to remove
  68072. * @returns the current particle system
  68073. */
  68074. removeStartSizeGradient(gradient: number): IParticleSystem;
  68075. /**
  68076. * Not supported by GPUParticleSystem
  68077. * @param gradient defines the gradient to use (between 0 and 1)
  68078. * @param min defines the color remap minimal range
  68079. * @param max defines the color remap maximal range
  68080. * @returns the current particle system
  68081. */
  68082. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68083. /**
  68084. * Not supported by GPUParticleSystem
  68085. * @param gradient defines the gradient to remove
  68086. * @returns the current particle system
  68087. */
  68088. removeColorRemapGradient(): IParticleSystem;
  68089. /**
  68090. * Not supported by GPUParticleSystem
  68091. * @param gradient defines the gradient to use (between 0 and 1)
  68092. * @param min defines the alpha remap minimal range
  68093. * @param max defines the alpha remap maximal range
  68094. * @returns the current particle system
  68095. */
  68096. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68097. /**
  68098. * Not supported by GPUParticleSystem
  68099. * @param gradient defines the gradient to remove
  68100. * @returns the current particle system
  68101. */
  68102. removeAlphaRemapGradient(): IParticleSystem;
  68103. /**
  68104. * Not supported by GPUParticleSystem
  68105. * @param gradient defines the gradient to use (between 0 and 1)
  68106. * @param color defines the color to affect to the specified gradient
  68107. * @returns the current particle system
  68108. */
  68109. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68110. /**
  68111. * Not supported by GPUParticleSystem
  68112. * @param gradient defines the gradient to remove
  68113. * @returns the current particle system
  68114. */
  68115. removeRampGradient(): IParticleSystem;
  68116. /**
  68117. * Not supported by GPUParticleSystem
  68118. * @returns the list of ramp gradients
  68119. */
  68120. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68121. /**
  68122. * Not supported by GPUParticleSystem
  68123. * Gets or sets a boolean indicating that ramp gradients must be used
  68124. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68125. */
  68126. get useRampGradients(): boolean;
  68127. set useRampGradients(value: boolean);
  68128. /**
  68129. * Not supported by GPUParticleSystem
  68130. * @param gradient defines the gradient to use (between 0 and 1)
  68131. * @param factor defines the life time factor to affect to the specified gradient
  68132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68133. * @returns the current particle system
  68134. */
  68135. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68136. /**
  68137. * Not supported by GPUParticleSystem
  68138. * @param gradient defines the gradient to remove
  68139. * @returns the current particle system
  68140. */
  68141. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68142. /**
  68143. * Instantiates a GPU particle system.
  68144. * 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.
  68145. * @param name The name of the particle system
  68146. * @param options The options used to create the system
  68147. * @param scene The scene the particle system belongs to
  68148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68149. */
  68150. constructor(name: string, options: Partial<{
  68151. capacity: number;
  68152. randomTextureSize: number;
  68153. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68154. protected _reset(): void;
  68155. private _createUpdateVAO;
  68156. private _createRenderVAO;
  68157. private _initialize;
  68158. /** @hidden */
  68159. _recreateUpdateEffect(): void;
  68160. /** @hidden */
  68161. _recreateRenderEffect(): void;
  68162. /**
  68163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68164. * @param preWarm defines if we are in the pre-warmimg phase
  68165. */
  68166. animate(preWarm?: boolean): void;
  68167. private _createFactorGradientTexture;
  68168. private _createSizeGradientTexture;
  68169. private _createAngularSpeedGradientTexture;
  68170. private _createVelocityGradientTexture;
  68171. private _createLimitVelocityGradientTexture;
  68172. private _createDragGradientTexture;
  68173. private _createColorGradientTexture;
  68174. /**
  68175. * Renders the particle system in its current state
  68176. * @param preWarm defines if the system should only update the particles but not render them
  68177. * @returns the current number of particles
  68178. */
  68179. render(preWarm?: boolean): number;
  68180. /**
  68181. * Rebuilds the particle system
  68182. */
  68183. rebuild(): void;
  68184. private _releaseBuffers;
  68185. private _releaseVAOs;
  68186. /**
  68187. * Disposes the particle system and free the associated resources
  68188. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68189. */
  68190. dispose(disposeTexture?: boolean): void;
  68191. /**
  68192. * Clones the particle system.
  68193. * @param name The name of the cloned object
  68194. * @param newEmitter The new emitter to use
  68195. * @returns the cloned particle system
  68196. */
  68197. clone(name: string, newEmitter: any): GPUParticleSystem;
  68198. /**
  68199. * Serializes the particle system to a JSON object
  68200. * @param serializeTexture defines if the texture must be serialized as well
  68201. * @returns the JSON object
  68202. */
  68203. serialize(serializeTexture?: boolean): any;
  68204. /**
  68205. * Parses a JSON object to create a GPU particle system.
  68206. * @param parsedParticleSystem The JSON object to parse
  68207. * @param scene The scene to create the particle system in
  68208. * @param rootUrl The root url to use to load external dependencies like texture
  68209. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68210. * @returns the parsed GPU particle system
  68211. */
  68212. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68213. }
  68214. }
  68215. declare module "babylonjs/Particles/particleSystemSet" {
  68216. import { Nullable } from "babylonjs/types";
  68217. import { Color3 } from "babylonjs/Maths/math.color";
  68218. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68220. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68221. import { Scene, IDisposable } from "babylonjs/scene";
  68222. /**
  68223. * Represents a set of particle systems working together to create a specific effect
  68224. */
  68225. export class ParticleSystemSet implements IDisposable {
  68226. /**
  68227. * Gets or sets base Assets URL
  68228. */
  68229. static BaseAssetsUrl: string;
  68230. private _emitterCreationOptions;
  68231. private _emitterNode;
  68232. /**
  68233. * Gets the particle system list
  68234. */
  68235. systems: IParticleSystem[];
  68236. /**
  68237. * Gets the emitter node used with this set
  68238. */
  68239. get emitterNode(): Nullable<TransformNode>;
  68240. /**
  68241. * Creates a new emitter mesh as a sphere
  68242. * @param options defines the options used to create the sphere
  68243. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68244. * @param scene defines the hosting scene
  68245. */
  68246. setEmitterAsSphere(options: {
  68247. diameter: number;
  68248. segments: number;
  68249. color: Color3;
  68250. }, renderingGroupId: number, scene: Scene): void;
  68251. /**
  68252. * Starts all particle systems of the set
  68253. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68254. */
  68255. start(emitter?: AbstractMesh): void;
  68256. /**
  68257. * Release all associated resources
  68258. */
  68259. dispose(): void;
  68260. /**
  68261. * Serialize the set into a JSON compatible object
  68262. * @param serializeTexture defines if the texture must be serialized as well
  68263. * @returns a JSON compatible representation of the set
  68264. */
  68265. serialize(serializeTexture?: boolean): any;
  68266. /**
  68267. * Parse a new ParticleSystemSet from a serialized source
  68268. * @param data defines a JSON compatible representation of the set
  68269. * @param scene defines the hosting scene
  68270. * @param gpu defines if we want GPU particles or CPU particles
  68271. * @returns a new ParticleSystemSet
  68272. */
  68273. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68274. }
  68275. }
  68276. declare module "babylonjs/Particles/particleHelper" {
  68277. import { Nullable } from "babylonjs/types";
  68278. import { Scene } from "babylonjs/scene";
  68279. import { Vector3 } from "babylonjs/Maths/math.vector";
  68280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68281. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68282. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68283. /**
  68284. * This class is made for on one-liner static method to help creating particle system set.
  68285. */
  68286. export class ParticleHelper {
  68287. /**
  68288. * Gets or sets base Assets URL
  68289. */
  68290. static BaseAssetsUrl: string;
  68291. /** Define the Url to load snippets */
  68292. static SnippetUrl: string;
  68293. /**
  68294. * Create a default particle system that you can tweak
  68295. * @param emitter defines the emitter to use
  68296. * @param capacity defines the system capacity (default is 500 particles)
  68297. * @param scene defines the hosting scene
  68298. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68299. * @returns the new Particle system
  68300. */
  68301. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68302. /**
  68303. * This is the main static method (one-liner) of this helper to create different particle systems
  68304. * @param type This string represents the type to the particle system to create
  68305. * @param scene The scene where the particle system should live
  68306. * @param gpu If the system will use gpu
  68307. * @returns the ParticleSystemSet created
  68308. */
  68309. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68310. /**
  68311. * Static function used to export a particle system to a ParticleSystemSet variable.
  68312. * Please note that the emitter shape is not exported
  68313. * @param systems defines the particle systems to export
  68314. * @returns the created particle system set
  68315. */
  68316. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68317. /**
  68318. * Creates a particle system from a snippet saved in a remote file
  68319. * @param name defines the name of the particle system to create
  68320. * @param url defines the url to load from
  68321. * @param scene defines the hosting scene
  68322. * @param gpu If the system will use gpu
  68323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68324. * @returns a promise that will resolve to the new particle system
  68325. */
  68326. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68327. /**
  68328. * Creates a particle system from a snippet saved by the particle system editor
  68329. * @param snippetId defines the snippet to load
  68330. * @param scene defines the hosting scene
  68331. * @param gpu If the system will use gpu
  68332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68333. * @returns a promise that will resolve to the new particle system
  68334. */
  68335. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68336. }
  68337. }
  68338. declare module "babylonjs/Particles/particleSystemComponent" {
  68339. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68340. import { Effect } from "babylonjs/Materials/effect";
  68341. import "babylonjs/Shaders/particles.vertex";
  68342. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68343. module "babylonjs/Engines/engine" {
  68344. interface Engine {
  68345. /**
  68346. * Create an effect to use with particle systems.
  68347. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68348. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68349. * @param uniformsNames defines a list of attribute names
  68350. * @param samplers defines an array of string used to represent textures
  68351. * @param defines defines the string containing the defines to use to compile the shaders
  68352. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68353. * @param onCompiled defines a function to call when the effect creation is successful
  68354. * @param onError defines a function to call when the effect creation has failed
  68355. * @returns the new Effect
  68356. */
  68357. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68358. }
  68359. }
  68360. module "babylonjs/Meshes/mesh" {
  68361. interface Mesh {
  68362. /**
  68363. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68364. * @returns an array of IParticleSystem
  68365. */
  68366. getEmittedParticleSystems(): IParticleSystem[];
  68367. /**
  68368. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68369. * @returns an array of IParticleSystem
  68370. */
  68371. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68372. }
  68373. }
  68374. /**
  68375. * @hidden
  68376. */
  68377. export var _IDoNeedToBeInTheBuild: number;
  68378. }
  68379. declare module "babylonjs/Particles/pointsCloudSystem" {
  68380. import { Color4 } from "babylonjs/Maths/math";
  68381. import { Mesh } from "babylonjs/Meshes/mesh";
  68382. import { Scene, IDisposable } from "babylonjs/scene";
  68383. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68384. /** Defines the 4 color options */
  68385. export enum PointColor {
  68386. /** color value */
  68387. Color = 2,
  68388. /** uv value */
  68389. UV = 1,
  68390. /** random value */
  68391. Random = 0,
  68392. /** stated value */
  68393. Stated = 3
  68394. }
  68395. /**
  68396. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68397. * 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.
  68398. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68399. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68400. *
  68401. * Full documentation here : TO BE ENTERED
  68402. */
  68403. export class PointsCloudSystem implements IDisposable {
  68404. /**
  68405. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68406. * Example : var p = SPS.particles[i];
  68407. */
  68408. particles: CloudPoint[];
  68409. /**
  68410. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68411. */
  68412. nbParticles: number;
  68413. /**
  68414. * This a counter for your own usage. It's not set by any SPS functions.
  68415. */
  68416. counter: number;
  68417. /**
  68418. * The PCS name. This name is also given to the underlying mesh.
  68419. */
  68420. name: string;
  68421. /**
  68422. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68423. */
  68424. mesh: Mesh;
  68425. /**
  68426. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68427. * Please read :
  68428. */
  68429. vars: any;
  68430. /**
  68431. * @hidden
  68432. */
  68433. _size: number;
  68434. private _scene;
  68435. private _promises;
  68436. private _positions;
  68437. private _indices;
  68438. private _normals;
  68439. private _colors;
  68440. private _uvs;
  68441. private _indices32;
  68442. private _positions32;
  68443. private _colors32;
  68444. private _uvs32;
  68445. private _updatable;
  68446. private _isVisibilityBoxLocked;
  68447. private _alwaysVisible;
  68448. private _groups;
  68449. private _groupCounter;
  68450. private _computeParticleColor;
  68451. private _computeParticleTexture;
  68452. private _computeParticleRotation;
  68453. private _computeBoundingBox;
  68454. private _isReady;
  68455. /**
  68456. * Creates a PCS (Points Cloud System) object
  68457. * @param name (String) is the PCS name, this will be the underlying mesh name
  68458. * @param pointSize (number) is the size for each point
  68459. * @param scene (Scene) is the scene in which the PCS is added
  68460. * @param options defines the options of the PCS e.g.
  68461. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68462. */
  68463. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68464. updatable?: boolean;
  68465. });
  68466. /**
  68467. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68468. * If no points were added to the PCS, the returned mesh is just a single point.
  68469. * @returns a promise for the created mesh
  68470. */
  68471. buildMeshAsync(): Promise<Mesh>;
  68472. /**
  68473. * @hidden
  68474. */
  68475. private _buildMesh;
  68476. private _addParticle;
  68477. private _randomUnitVector;
  68478. private _getColorIndicesForCoord;
  68479. private _setPointsColorOrUV;
  68480. private _colorFromTexture;
  68481. private _calculateDensity;
  68482. /**
  68483. * Adds points to the PCS in random positions within a unit sphere
  68484. * @param nb (positive integer) the number of particles to be created from this model
  68485. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68486. * @returns the number of groups in the system
  68487. */
  68488. addPoints(nb: number, pointFunction?: any): number;
  68489. /**
  68490. * Adds points to the PCS from the surface of the model shape
  68491. * @param mesh is any Mesh object that will be used as a surface model for the points
  68492. * @param nb (positive integer) the number of particles to be created from this model
  68493. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68494. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68495. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68496. * @returns the number of groups in the system
  68497. */
  68498. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68499. /**
  68500. * Adds points to the PCS inside the model shape
  68501. * @param mesh is any Mesh object that will be used as a surface model for the points
  68502. * @param nb (positive integer) the number of particles to be created from this model
  68503. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68504. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68505. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68506. * @returns the number of groups in the system
  68507. */
  68508. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68509. /**
  68510. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68511. * This method calls `updateParticle()` for each particle of the SPS.
  68512. * For an animated SPS, it is usually called within the render loop.
  68513. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68514. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68515. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68516. * @returns the PCS.
  68517. */
  68518. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68519. /**
  68520. * Disposes the PCS.
  68521. */
  68522. dispose(): void;
  68523. /**
  68524. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68525. * doc :
  68526. * @returns the PCS.
  68527. */
  68528. refreshVisibleSize(): PointsCloudSystem;
  68529. /**
  68530. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68531. * @param size the size (float) of the visibility box
  68532. * note : this doesn't lock the PCS mesh bounding box.
  68533. * doc :
  68534. */
  68535. setVisibilityBox(size: number): void;
  68536. /**
  68537. * Gets whether the PCS is always visible or not
  68538. * doc :
  68539. */
  68540. get isAlwaysVisible(): boolean;
  68541. /**
  68542. * Sets the PCS as always visible or not
  68543. * doc :
  68544. */
  68545. set isAlwaysVisible(val: boolean);
  68546. /**
  68547. * Tells to `setParticles()` to compute the particle rotations or not
  68548. * Default value : false. The PCS is faster when it's set to false
  68549. * Note : particle rotations are only applied to parent particles
  68550. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68551. */
  68552. set computeParticleRotation(val: boolean);
  68553. /**
  68554. * Tells to `setParticles()` to compute the particle colors or not.
  68555. * Default value : true. The PCS is faster when it's set to false.
  68556. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68557. */
  68558. set computeParticleColor(val: boolean);
  68559. set computeParticleTexture(val: boolean);
  68560. /**
  68561. * Gets if `setParticles()` computes the particle colors or not.
  68562. * Default value : false. The PCS is faster when it's set to false.
  68563. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68564. */
  68565. get computeParticleColor(): boolean;
  68566. /**
  68567. * Gets if `setParticles()` computes the particle textures or not.
  68568. * Default value : false. The PCS is faster when it's set to false.
  68569. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68570. */
  68571. get computeParticleTexture(): boolean;
  68572. /**
  68573. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68574. */
  68575. set computeBoundingBox(val: boolean);
  68576. /**
  68577. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68578. */
  68579. get computeBoundingBox(): boolean;
  68580. /**
  68581. * This function does nothing. It may be overwritten to set all the particle first values.
  68582. * The PCS doesn't call this function, you may have to call it by your own.
  68583. * doc :
  68584. */
  68585. initParticles(): void;
  68586. /**
  68587. * This function does nothing. It may be overwritten to recycle a particle
  68588. * The PCS doesn't call this function, you can to call it
  68589. * doc :
  68590. * @param particle The particle to recycle
  68591. * @returns the recycled particle
  68592. */
  68593. recycleParticle(particle: CloudPoint): CloudPoint;
  68594. /**
  68595. * Updates a particle : this function should be overwritten by the user.
  68596. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68597. * doc :
  68598. * @example : just set a particle position or velocity and recycle conditions
  68599. * @param particle The particle to update
  68600. * @returns the updated particle
  68601. */
  68602. updateParticle(particle: CloudPoint): CloudPoint;
  68603. /**
  68604. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68605. * This does nothing and may be overwritten by the user.
  68606. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68607. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68608. * @param update the boolean update value actually passed to setParticles()
  68609. */
  68610. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68611. /**
  68612. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68613. * This will be passed three parameters.
  68614. * This does nothing and may be overwritten by the user.
  68615. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68617. * @param update the boolean update value actually passed to setParticles()
  68618. */
  68619. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68620. }
  68621. }
  68622. declare module "babylonjs/Particles/cloudPoint" {
  68623. import { Nullable } from "babylonjs/types";
  68624. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68625. import { Mesh } from "babylonjs/Meshes/mesh";
  68626. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68627. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68628. /**
  68629. * Represents one particle of a points cloud system.
  68630. */
  68631. export class CloudPoint {
  68632. /**
  68633. * particle global index
  68634. */
  68635. idx: number;
  68636. /**
  68637. * The color of the particle
  68638. */
  68639. color: Nullable<Color4>;
  68640. /**
  68641. * The world space position of the particle.
  68642. */
  68643. position: Vector3;
  68644. /**
  68645. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68646. */
  68647. rotation: Vector3;
  68648. /**
  68649. * The world space rotation quaternion of the particle.
  68650. */
  68651. rotationQuaternion: Nullable<Quaternion>;
  68652. /**
  68653. * The uv of the particle.
  68654. */
  68655. uv: Nullable<Vector2>;
  68656. /**
  68657. * The current speed of the particle.
  68658. */
  68659. velocity: Vector3;
  68660. /**
  68661. * The pivot point in the particle local space.
  68662. */
  68663. pivot: Vector3;
  68664. /**
  68665. * Must the particle be translated from its pivot point in its local space ?
  68666. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68667. * Default : false
  68668. */
  68669. translateFromPivot: boolean;
  68670. /**
  68671. * Index of this particle in the global "positions" array (Internal use)
  68672. * @hidden
  68673. */
  68674. _pos: number;
  68675. /**
  68676. * @hidden Index of this particle in the global "indices" array (Internal use)
  68677. */
  68678. _ind: number;
  68679. /**
  68680. * Group this particle belongs to
  68681. */
  68682. _group: PointsGroup;
  68683. /**
  68684. * Group id of this particle
  68685. */
  68686. groupId: number;
  68687. /**
  68688. * Index of the particle in its group id (Internal use)
  68689. */
  68690. idxInGroup: number;
  68691. /**
  68692. * @hidden Particle BoundingInfo object (Internal use)
  68693. */
  68694. _boundingInfo: BoundingInfo;
  68695. /**
  68696. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68697. */
  68698. _pcs: PointsCloudSystem;
  68699. /**
  68700. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68701. */
  68702. _stillInvisible: boolean;
  68703. /**
  68704. * @hidden Last computed particle rotation matrix
  68705. */
  68706. _rotationMatrix: number[];
  68707. /**
  68708. * Parent particle Id, if any.
  68709. * Default null.
  68710. */
  68711. parentId: Nullable<number>;
  68712. /**
  68713. * @hidden Internal global position in the PCS.
  68714. */
  68715. _globalPosition: Vector3;
  68716. /**
  68717. * Creates a Point Cloud object.
  68718. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68719. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68720. * @param group (PointsGroup) is the group the particle belongs to
  68721. * @param groupId (integer) is the group identifier in the PCS.
  68722. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68723. * @param pcs defines the PCS it is associated to
  68724. */
  68725. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68726. /**
  68727. * get point size
  68728. */
  68729. get size(): Vector3;
  68730. /**
  68731. * Set point size
  68732. */
  68733. set size(scale: Vector3);
  68734. /**
  68735. * Legacy support, changed quaternion to rotationQuaternion
  68736. */
  68737. get quaternion(): Nullable<Quaternion>;
  68738. /**
  68739. * Legacy support, changed quaternion to rotationQuaternion
  68740. */
  68741. set quaternion(q: Nullable<Quaternion>);
  68742. /**
  68743. * Returns a boolean. True if the particle intersects a mesh, else false
  68744. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68745. * @param target is the object (point or mesh) what the intersection is computed against
  68746. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68747. * @returns true if it intersects
  68748. */
  68749. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68750. /**
  68751. * get the rotation matrix of the particle
  68752. * @hidden
  68753. */
  68754. getRotationMatrix(m: Matrix): void;
  68755. }
  68756. /**
  68757. * Represents a group of points in a points cloud system
  68758. * * PCS internal tool, don't use it manually.
  68759. */
  68760. export class PointsGroup {
  68761. /**
  68762. * The group id
  68763. * @hidden
  68764. */
  68765. groupID: number;
  68766. /**
  68767. * image data for group (internal use)
  68768. * @hidden
  68769. */
  68770. _groupImageData: Nullable<ArrayBufferView>;
  68771. /**
  68772. * Image Width (internal use)
  68773. * @hidden
  68774. */
  68775. _groupImgWidth: number;
  68776. /**
  68777. * Image Height (internal use)
  68778. * @hidden
  68779. */
  68780. _groupImgHeight: number;
  68781. /**
  68782. * Custom position function (internal use)
  68783. * @hidden
  68784. */
  68785. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68786. /**
  68787. * density per facet for surface points
  68788. * @hidden
  68789. */
  68790. _groupDensity: number[];
  68791. /**
  68792. * Only when points are colored by texture carries pointer to texture list array
  68793. * @hidden
  68794. */
  68795. _textureNb: number;
  68796. /**
  68797. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68798. * PCS internal tool, don't use it manually.
  68799. * @hidden
  68800. */
  68801. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68802. }
  68803. }
  68804. declare module "babylonjs/Particles/index" {
  68805. export * from "babylonjs/Particles/baseParticleSystem";
  68806. export * from "babylonjs/Particles/EmitterTypes/index";
  68807. export * from "babylonjs/Particles/gpuParticleSystem";
  68808. export * from "babylonjs/Particles/IParticleSystem";
  68809. export * from "babylonjs/Particles/particle";
  68810. export * from "babylonjs/Particles/particleHelper";
  68811. export * from "babylonjs/Particles/particleSystem";
  68812. export * from "babylonjs/Particles/particleSystemComponent";
  68813. export * from "babylonjs/Particles/particleSystemSet";
  68814. export * from "babylonjs/Particles/solidParticle";
  68815. export * from "babylonjs/Particles/solidParticleSystem";
  68816. export * from "babylonjs/Particles/cloudPoint";
  68817. export * from "babylonjs/Particles/pointsCloudSystem";
  68818. export * from "babylonjs/Particles/subEmitter";
  68819. }
  68820. declare module "babylonjs/Physics/physicsEngineComponent" {
  68821. import { Nullable } from "babylonjs/types";
  68822. import { Observable, Observer } from "babylonjs/Misc/observable";
  68823. import { Vector3 } from "babylonjs/Maths/math.vector";
  68824. import { Mesh } from "babylonjs/Meshes/mesh";
  68825. import { ISceneComponent } from "babylonjs/sceneComponent";
  68826. import { Scene } from "babylonjs/scene";
  68827. import { Node } from "babylonjs/node";
  68828. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  68829. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68830. module "babylonjs/scene" {
  68831. interface Scene {
  68832. /** @hidden (Backing field) */
  68833. _physicsEngine: Nullable<IPhysicsEngine>;
  68834. /** @hidden */
  68835. _physicsTimeAccumulator: number;
  68836. /**
  68837. * Gets the current physics engine
  68838. * @returns a IPhysicsEngine or null if none attached
  68839. */
  68840. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68841. /**
  68842. * Enables physics to the current scene
  68843. * @param gravity defines the scene's gravity for the physics engine
  68844. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68845. * @return a boolean indicating if the physics engine was initialized
  68846. */
  68847. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68848. /**
  68849. * Disables and disposes the physics engine associated with the scene
  68850. */
  68851. disablePhysicsEngine(): void;
  68852. /**
  68853. * Gets a boolean indicating if there is an active physics engine
  68854. * @returns a boolean indicating if there is an active physics engine
  68855. */
  68856. isPhysicsEnabled(): boolean;
  68857. /**
  68858. * Deletes a physics compound impostor
  68859. * @param compound defines the compound to delete
  68860. */
  68861. deleteCompoundImpostor(compound: any): void;
  68862. /**
  68863. * An event triggered when physic simulation is about to be run
  68864. */
  68865. onBeforePhysicsObservable: Observable<Scene>;
  68866. /**
  68867. * An event triggered when physic simulation has been done
  68868. */
  68869. onAfterPhysicsObservable: Observable<Scene>;
  68870. }
  68871. }
  68872. module "babylonjs/Meshes/abstractMesh" {
  68873. interface AbstractMesh {
  68874. /** @hidden */
  68875. _physicsImpostor: Nullable<PhysicsImpostor>;
  68876. /**
  68877. * Gets or sets impostor used for physic simulation
  68878. * @see http://doc.babylonjs.com/features/physics_engine
  68879. */
  68880. physicsImpostor: Nullable<PhysicsImpostor>;
  68881. /**
  68882. * Gets the current physics impostor
  68883. * @see http://doc.babylonjs.com/features/physics_engine
  68884. * @returns a physics impostor or null
  68885. */
  68886. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68887. /** Apply a physic impulse to the mesh
  68888. * @param force defines the force to apply
  68889. * @param contactPoint defines where to apply the force
  68890. * @returns the current mesh
  68891. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  68892. */
  68893. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68894. /**
  68895. * Creates a physic joint between two meshes
  68896. * @param otherMesh defines the other mesh to use
  68897. * @param pivot1 defines the pivot to use on this mesh
  68898. * @param pivot2 defines the pivot to use on the other mesh
  68899. * @param options defines additional options (can be plugin dependent)
  68900. * @returns the current mesh
  68901. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68902. */
  68903. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68904. /** @hidden */
  68905. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68906. }
  68907. }
  68908. /**
  68909. * Defines the physics engine scene component responsible to manage a physics engine
  68910. */
  68911. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68912. /**
  68913. * The component name helpful to identify the component in the list of scene components.
  68914. */
  68915. readonly name: string;
  68916. /**
  68917. * The scene the component belongs to.
  68918. */
  68919. scene: Scene;
  68920. /**
  68921. * Creates a new instance of the component for the given scene
  68922. * @param scene Defines the scene to register the component in
  68923. */
  68924. constructor(scene: Scene);
  68925. /**
  68926. * Registers the component in a given scene
  68927. */
  68928. register(): void;
  68929. /**
  68930. * Rebuilds the elements related to this component in case of
  68931. * context lost for instance.
  68932. */
  68933. rebuild(): void;
  68934. /**
  68935. * Disposes the component and the associated ressources
  68936. */
  68937. dispose(): void;
  68938. }
  68939. }
  68940. declare module "babylonjs/Physics/physicsHelper" {
  68941. import { Nullable } from "babylonjs/types";
  68942. import { Vector3 } from "babylonjs/Maths/math.vector";
  68943. import { Mesh } from "babylonjs/Meshes/mesh";
  68944. import { Scene } from "babylonjs/scene";
  68945. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68946. /**
  68947. * A helper for physics simulations
  68948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68949. */
  68950. export class PhysicsHelper {
  68951. private _scene;
  68952. private _physicsEngine;
  68953. /**
  68954. * Initializes the Physics helper
  68955. * @param scene Babylon.js scene
  68956. */
  68957. constructor(scene: Scene);
  68958. /**
  68959. * Applies a radial explosion impulse
  68960. * @param origin the origin of the explosion
  68961. * @param radiusOrEventOptions the radius or the options of radial explosion
  68962. * @param strength the explosion strength
  68963. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68964. * @returns A physics radial explosion event, or null
  68965. */
  68966. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68967. /**
  68968. * Applies a radial explosion force
  68969. * @param origin the origin of the explosion
  68970. * @param radiusOrEventOptions the radius or the options of radial explosion
  68971. * @param strength the explosion strength
  68972. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68973. * @returns A physics radial explosion event, or null
  68974. */
  68975. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68976. /**
  68977. * Creates a gravitational field
  68978. * @param origin the origin of the explosion
  68979. * @param radiusOrEventOptions the radius or the options of radial explosion
  68980. * @param strength the explosion strength
  68981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68982. * @returns A physics gravitational field event, or null
  68983. */
  68984. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68985. /**
  68986. * Creates a physics updraft event
  68987. * @param origin the origin of the updraft
  68988. * @param radiusOrEventOptions the radius or the options of the updraft
  68989. * @param strength the strength of the updraft
  68990. * @param height the height of the updraft
  68991. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68992. * @returns A physics updraft event, or null
  68993. */
  68994. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68995. /**
  68996. * Creates a physics vortex event
  68997. * @param origin the of the vortex
  68998. * @param radiusOrEventOptions the radius or the options of the vortex
  68999. * @param strength the strength of the vortex
  69000. * @param height the height of the vortex
  69001. * @returns a Physics vortex event, or null
  69002. * A physics vortex event or null
  69003. */
  69004. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69005. }
  69006. /**
  69007. * Represents a physics radial explosion event
  69008. */
  69009. class PhysicsRadialExplosionEvent {
  69010. private _scene;
  69011. private _options;
  69012. private _sphere;
  69013. private _dataFetched;
  69014. /**
  69015. * Initializes a radial explosioin event
  69016. * @param _scene BabylonJS scene
  69017. * @param _options The options for the vortex event
  69018. */
  69019. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69020. /**
  69021. * Returns the data related to the radial explosion event (sphere).
  69022. * @returns The radial explosion event data
  69023. */
  69024. getData(): PhysicsRadialExplosionEventData;
  69025. /**
  69026. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69027. * @param impostor A physics imposter
  69028. * @param origin the origin of the explosion
  69029. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69030. */
  69031. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69032. /**
  69033. * Triggers affecterd impostors callbacks
  69034. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69035. */
  69036. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69037. /**
  69038. * Disposes the sphere.
  69039. * @param force Specifies if the sphere should be disposed by force
  69040. */
  69041. dispose(force?: boolean): void;
  69042. /*** Helpers ***/
  69043. private _prepareSphere;
  69044. private _intersectsWithSphere;
  69045. }
  69046. /**
  69047. * Represents a gravitational field event
  69048. */
  69049. class PhysicsGravitationalFieldEvent {
  69050. private _physicsHelper;
  69051. private _scene;
  69052. private _origin;
  69053. private _options;
  69054. private _tickCallback;
  69055. private _sphere;
  69056. private _dataFetched;
  69057. /**
  69058. * Initializes the physics gravitational field event
  69059. * @param _physicsHelper A physics helper
  69060. * @param _scene BabylonJS scene
  69061. * @param _origin The origin position of the gravitational field event
  69062. * @param _options The options for the vortex event
  69063. */
  69064. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69065. /**
  69066. * Returns the data related to the gravitational field event (sphere).
  69067. * @returns A gravitational field event
  69068. */
  69069. getData(): PhysicsGravitationalFieldEventData;
  69070. /**
  69071. * Enables the gravitational field.
  69072. */
  69073. enable(): void;
  69074. /**
  69075. * Disables the gravitational field.
  69076. */
  69077. disable(): void;
  69078. /**
  69079. * Disposes the sphere.
  69080. * @param force The force to dispose from the gravitational field event
  69081. */
  69082. dispose(force?: boolean): void;
  69083. private _tick;
  69084. }
  69085. /**
  69086. * Represents a physics updraft event
  69087. */
  69088. class PhysicsUpdraftEvent {
  69089. private _scene;
  69090. private _origin;
  69091. private _options;
  69092. private _physicsEngine;
  69093. private _originTop;
  69094. private _originDirection;
  69095. private _tickCallback;
  69096. private _cylinder;
  69097. private _cylinderPosition;
  69098. private _dataFetched;
  69099. /**
  69100. * Initializes the physics updraft event
  69101. * @param _scene BabylonJS scene
  69102. * @param _origin The origin position of the updraft
  69103. * @param _options The options for the updraft event
  69104. */
  69105. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69106. /**
  69107. * Returns the data related to the updraft event (cylinder).
  69108. * @returns A physics updraft event
  69109. */
  69110. getData(): PhysicsUpdraftEventData;
  69111. /**
  69112. * Enables the updraft.
  69113. */
  69114. enable(): void;
  69115. /**
  69116. * Disables the updraft.
  69117. */
  69118. disable(): void;
  69119. /**
  69120. * Disposes the cylinder.
  69121. * @param force Specifies if the updraft should be disposed by force
  69122. */
  69123. dispose(force?: boolean): void;
  69124. private getImpostorHitData;
  69125. private _tick;
  69126. /*** Helpers ***/
  69127. private _prepareCylinder;
  69128. private _intersectsWithCylinder;
  69129. }
  69130. /**
  69131. * Represents a physics vortex event
  69132. */
  69133. class PhysicsVortexEvent {
  69134. private _scene;
  69135. private _origin;
  69136. private _options;
  69137. private _physicsEngine;
  69138. private _originTop;
  69139. private _tickCallback;
  69140. private _cylinder;
  69141. private _cylinderPosition;
  69142. private _dataFetched;
  69143. /**
  69144. * Initializes the physics vortex event
  69145. * @param _scene The BabylonJS scene
  69146. * @param _origin The origin position of the vortex
  69147. * @param _options The options for the vortex event
  69148. */
  69149. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69150. /**
  69151. * Returns the data related to the vortex event (cylinder).
  69152. * @returns The physics vortex event data
  69153. */
  69154. getData(): PhysicsVortexEventData;
  69155. /**
  69156. * Enables the vortex.
  69157. */
  69158. enable(): void;
  69159. /**
  69160. * Disables the cortex.
  69161. */
  69162. disable(): void;
  69163. /**
  69164. * Disposes the sphere.
  69165. * @param force
  69166. */
  69167. dispose(force?: boolean): void;
  69168. private getImpostorHitData;
  69169. private _tick;
  69170. /*** Helpers ***/
  69171. private _prepareCylinder;
  69172. private _intersectsWithCylinder;
  69173. }
  69174. /**
  69175. * Options fot the radial explosion event
  69176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69177. */
  69178. export class PhysicsRadialExplosionEventOptions {
  69179. /**
  69180. * The radius of the sphere for the radial explosion.
  69181. */
  69182. radius: number;
  69183. /**
  69184. * The strenth of the explosion.
  69185. */
  69186. strength: number;
  69187. /**
  69188. * The strenght of the force in correspondence to the distance of the affected object
  69189. */
  69190. falloff: PhysicsRadialImpulseFalloff;
  69191. /**
  69192. * Sphere options for the radial explosion.
  69193. */
  69194. sphere: {
  69195. segments: number;
  69196. diameter: number;
  69197. };
  69198. /**
  69199. * Sphere options for the radial explosion.
  69200. */
  69201. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69202. }
  69203. /**
  69204. * Options fot the updraft event
  69205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69206. */
  69207. export class PhysicsUpdraftEventOptions {
  69208. /**
  69209. * The radius of the cylinder for the vortex
  69210. */
  69211. radius: number;
  69212. /**
  69213. * The strenth of the updraft.
  69214. */
  69215. strength: number;
  69216. /**
  69217. * The height of the cylinder for the updraft.
  69218. */
  69219. height: number;
  69220. /**
  69221. * The mode for the the updraft.
  69222. */
  69223. updraftMode: PhysicsUpdraftMode;
  69224. }
  69225. /**
  69226. * Options fot the vortex event
  69227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69228. */
  69229. export class PhysicsVortexEventOptions {
  69230. /**
  69231. * The radius of the cylinder for the vortex
  69232. */
  69233. radius: number;
  69234. /**
  69235. * The strenth of the vortex.
  69236. */
  69237. strength: number;
  69238. /**
  69239. * The height of the cylinder for the vortex.
  69240. */
  69241. height: number;
  69242. /**
  69243. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69244. */
  69245. centripetalForceThreshold: number;
  69246. /**
  69247. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69248. */
  69249. centripetalForceMultiplier: number;
  69250. /**
  69251. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69252. */
  69253. centrifugalForceMultiplier: number;
  69254. /**
  69255. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69256. */
  69257. updraftForceMultiplier: number;
  69258. }
  69259. /**
  69260. * The strenght of the force in correspondence to the distance of the affected object
  69261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69262. */
  69263. export enum PhysicsRadialImpulseFalloff {
  69264. /** Defines that impulse is constant in strength across it's whole radius */
  69265. Constant = 0,
  69266. /** Defines that impulse gets weaker if it's further from the origin */
  69267. Linear = 1
  69268. }
  69269. /**
  69270. * The strength of the force in correspondence to the distance of the affected object
  69271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69272. */
  69273. export enum PhysicsUpdraftMode {
  69274. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69275. Center = 0,
  69276. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69277. Perpendicular = 1
  69278. }
  69279. /**
  69280. * Interface for a physics hit data
  69281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69282. */
  69283. export interface PhysicsHitData {
  69284. /**
  69285. * The force applied at the contact point
  69286. */
  69287. force: Vector3;
  69288. /**
  69289. * The contact point
  69290. */
  69291. contactPoint: Vector3;
  69292. /**
  69293. * The distance from the origin to the contact point
  69294. */
  69295. distanceFromOrigin: number;
  69296. }
  69297. /**
  69298. * Interface for radial explosion event data
  69299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69300. */
  69301. export interface PhysicsRadialExplosionEventData {
  69302. /**
  69303. * A sphere used for the radial explosion event
  69304. */
  69305. sphere: Mesh;
  69306. }
  69307. /**
  69308. * Interface for gravitational field event data
  69309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69310. */
  69311. export interface PhysicsGravitationalFieldEventData {
  69312. /**
  69313. * A sphere mesh used for the gravitational field event
  69314. */
  69315. sphere: Mesh;
  69316. }
  69317. /**
  69318. * Interface for updraft event data
  69319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69320. */
  69321. export interface PhysicsUpdraftEventData {
  69322. /**
  69323. * A cylinder used for the updraft event
  69324. */
  69325. cylinder: Mesh;
  69326. }
  69327. /**
  69328. * Interface for vortex event data
  69329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69330. */
  69331. export interface PhysicsVortexEventData {
  69332. /**
  69333. * A cylinder used for the vortex event
  69334. */
  69335. cylinder: Mesh;
  69336. }
  69337. /**
  69338. * Interface for an affected physics impostor
  69339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69340. */
  69341. export interface PhysicsAffectedImpostorWithData {
  69342. /**
  69343. * The impostor affected by the effect
  69344. */
  69345. impostor: PhysicsImpostor;
  69346. /**
  69347. * The data about the hit/horce from the explosion
  69348. */
  69349. hitData: PhysicsHitData;
  69350. }
  69351. }
  69352. declare module "babylonjs/Physics/Plugins/index" {
  69353. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69354. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69355. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69356. }
  69357. declare module "babylonjs/Physics/index" {
  69358. export * from "babylonjs/Physics/IPhysicsEngine";
  69359. export * from "babylonjs/Physics/physicsEngine";
  69360. export * from "babylonjs/Physics/physicsEngineComponent";
  69361. export * from "babylonjs/Physics/physicsHelper";
  69362. export * from "babylonjs/Physics/physicsImpostor";
  69363. export * from "babylonjs/Physics/physicsJoint";
  69364. export * from "babylonjs/Physics/Plugins/index";
  69365. }
  69366. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69367. /** @hidden */
  69368. export var blackAndWhitePixelShader: {
  69369. name: string;
  69370. shader: string;
  69371. };
  69372. }
  69373. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69374. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69375. import { Camera } from "babylonjs/Cameras/camera";
  69376. import { Engine } from "babylonjs/Engines/engine";
  69377. import "babylonjs/Shaders/blackAndWhite.fragment";
  69378. /**
  69379. * Post process used to render in black and white
  69380. */
  69381. export class BlackAndWhitePostProcess extends PostProcess {
  69382. /**
  69383. * Linear about to convert he result to black and white (default: 1)
  69384. */
  69385. degree: number;
  69386. /**
  69387. * Creates a black and white post process
  69388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69389. * @param name The name of the effect.
  69390. * @param options The required width/height ratio to downsize to before computing the render pass.
  69391. * @param camera The camera to apply the render pass to.
  69392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69393. * @param engine The engine which the post process will be applied. (default: current engine)
  69394. * @param reusable If the post process can be reused on the same frame. (default: false)
  69395. */
  69396. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69397. }
  69398. }
  69399. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69400. import { Nullable } from "babylonjs/types";
  69401. import { Camera } from "babylonjs/Cameras/camera";
  69402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69403. import { Engine } from "babylonjs/Engines/engine";
  69404. /**
  69405. * This represents a set of one or more post processes in Babylon.
  69406. * A post process can be used to apply a shader to a texture after it is rendered.
  69407. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69408. */
  69409. export class PostProcessRenderEffect {
  69410. private _postProcesses;
  69411. private _getPostProcesses;
  69412. private _singleInstance;
  69413. private _cameras;
  69414. private _indicesForCamera;
  69415. /**
  69416. * Name of the effect
  69417. * @hidden
  69418. */
  69419. _name: string;
  69420. /**
  69421. * Instantiates a post process render effect.
  69422. * A post process can be used to apply a shader to a texture after it is rendered.
  69423. * @param engine The engine the effect is tied to
  69424. * @param name The name of the effect
  69425. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69426. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69427. */
  69428. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69429. /**
  69430. * Checks if all the post processes in the effect are supported.
  69431. */
  69432. get isSupported(): boolean;
  69433. /**
  69434. * Updates the current state of the effect
  69435. * @hidden
  69436. */
  69437. _update(): void;
  69438. /**
  69439. * Attaches the effect on cameras
  69440. * @param cameras The camera to attach to.
  69441. * @hidden
  69442. */
  69443. _attachCameras(cameras: Camera): void;
  69444. /**
  69445. * Attaches the effect on cameras
  69446. * @param cameras The camera to attach to.
  69447. * @hidden
  69448. */
  69449. _attachCameras(cameras: Camera[]): void;
  69450. /**
  69451. * Detaches the effect on cameras
  69452. * @param cameras The camera to detatch from.
  69453. * @hidden
  69454. */
  69455. _detachCameras(cameras: Camera): void;
  69456. /**
  69457. * Detatches the effect on cameras
  69458. * @param cameras The camera to detatch from.
  69459. * @hidden
  69460. */
  69461. _detachCameras(cameras: Camera[]): void;
  69462. /**
  69463. * Enables the effect on given cameras
  69464. * @param cameras The camera to enable.
  69465. * @hidden
  69466. */
  69467. _enable(cameras: Camera): void;
  69468. /**
  69469. * Enables the effect on given cameras
  69470. * @param cameras The camera to enable.
  69471. * @hidden
  69472. */
  69473. _enable(cameras: Nullable<Camera[]>): void;
  69474. /**
  69475. * Disables the effect on the given cameras
  69476. * @param cameras The camera to disable.
  69477. * @hidden
  69478. */
  69479. _disable(cameras: Camera): void;
  69480. /**
  69481. * Disables the effect on the given cameras
  69482. * @param cameras The camera to disable.
  69483. * @hidden
  69484. */
  69485. _disable(cameras: Nullable<Camera[]>): void;
  69486. /**
  69487. * Gets a list of the post processes contained in the effect.
  69488. * @param camera The camera to get the post processes on.
  69489. * @returns The list of the post processes in the effect.
  69490. */
  69491. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69492. }
  69493. }
  69494. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69496. /** @hidden */
  69497. export var extractHighlightsPixelShader: {
  69498. name: string;
  69499. shader: string;
  69500. };
  69501. }
  69502. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69503. import { Nullable } from "babylonjs/types";
  69504. import { Camera } from "babylonjs/Cameras/camera";
  69505. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69506. import { Engine } from "babylonjs/Engines/engine";
  69507. import "babylonjs/Shaders/extractHighlights.fragment";
  69508. /**
  69509. * 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.
  69510. */
  69511. export class ExtractHighlightsPostProcess extends PostProcess {
  69512. /**
  69513. * The luminance threshold, pixels below this value will be set to black.
  69514. */
  69515. threshold: number;
  69516. /** @hidden */
  69517. _exposure: number;
  69518. /**
  69519. * Post process which has the input texture to be used when performing highlight extraction
  69520. * @hidden
  69521. */
  69522. _inputPostProcess: Nullable<PostProcess>;
  69523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69524. }
  69525. }
  69526. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69527. /** @hidden */
  69528. export var bloomMergePixelShader: {
  69529. name: string;
  69530. shader: string;
  69531. };
  69532. }
  69533. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69535. import { Nullable } from "babylonjs/types";
  69536. import { Engine } from "babylonjs/Engines/engine";
  69537. import { Camera } from "babylonjs/Cameras/camera";
  69538. import "babylonjs/Shaders/bloomMerge.fragment";
  69539. /**
  69540. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69541. */
  69542. export class BloomMergePostProcess extends PostProcess {
  69543. /** Weight of the bloom to be added to the original input. */
  69544. weight: number;
  69545. /**
  69546. * Creates a new instance of @see BloomMergePostProcess
  69547. * @param name The name of the effect.
  69548. * @param originalFromInput Post process which's input will be used for the merge.
  69549. * @param blurred Blurred highlights post process which's output will be used.
  69550. * @param weight Weight of the bloom to be added to the original input.
  69551. * @param options The required width/height ratio to downsize to before computing the render pass.
  69552. * @param camera The camera to apply the render pass to.
  69553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69554. * @param engine The engine which the post process will be applied. (default: current engine)
  69555. * @param reusable If the post process can be reused on the same frame. (default: false)
  69556. * @param textureType Type of textures used when performing the post process. (default: 0)
  69557. * @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)
  69558. */
  69559. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69560. /** Weight of the bloom to be added to the original input. */
  69561. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69562. }
  69563. }
  69564. declare module "babylonjs/PostProcesses/bloomEffect" {
  69565. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69567. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69568. import { Camera } from "babylonjs/Cameras/camera";
  69569. import { Scene } from "babylonjs/scene";
  69570. /**
  69571. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69572. */
  69573. export class BloomEffect extends PostProcessRenderEffect {
  69574. private bloomScale;
  69575. /**
  69576. * @hidden Internal
  69577. */
  69578. _effects: Array<PostProcess>;
  69579. /**
  69580. * @hidden Internal
  69581. */
  69582. _downscale: ExtractHighlightsPostProcess;
  69583. private _blurX;
  69584. private _blurY;
  69585. private _merge;
  69586. /**
  69587. * The luminance threshold to find bright areas of the image to bloom.
  69588. */
  69589. get threshold(): number;
  69590. set threshold(value: number);
  69591. /**
  69592. * The strength of the bloom.
  69593. */
  69594. get weight(): number;
  69595. set weight(value: number);
  69596. /**
  69597. * Specifies the size of the bloom blur kernel, relative to the final output size
  69598. */
  69599. get kernel(): number;
  69600. set kernel(value: number);
  69601. /**
  69602. * Creates a new instance of @see BloomEffect
  69603. * @param scene The scene the effect belongs to.
  69604. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69605. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69606. * @param bloomWeight The the strength of bloom.
  69607. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69608. * @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)
  69609. */
  69610. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69611. /**
  69612. * Disposes each of the internal effects for a given camera.
  69613. * @param camera The camera to dispose the effect on.
  69614. */
  69615. disposeEffects(camera: Camera): void;
  69616. /**
  69617. * @hidden Internal
  69618. */
  69619. _updateEffects(): void;
  69620. /**
  69621. * Internal
  69622. * @returns if all the contained post processes are ready.
  69623. * @hidden
  69624. */
  69625. _isReady(): boolean;
  69626. }
  69627. }
  69628. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69629. /** @hidden */
  69630. export var chromaticAberrationPixelShader: {
  69631. name: string;
  69632. shader: string;
  69633. };
  69634. }
  69635. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69636. import { Vector2 } from "babylonjs/Maths/math.vector";
  69637. import { Nullable } from "babylonjs/types";
  69638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69639. import { Camera } from "babylonjs/Cameras/camera";
  69640. import { Engine } from "babylonjs/Engines/engine";
  69641. import "babylonjs/Shaders/chromaticAberration.fragment";
  69642. /**
  69643. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69644. */
  69645. export class ChromaticAberrationPostProcess extends PostProcess {
  69646. /**
  69647. * The amount of seperation of rgb channels (default: 30)
  69648. */
  69649. aberrationAmount: number;
  69650. /**
  69651. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69652. */
  69653. radialIntensity: number;
  69654. /**
  69655. * 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))
  69656. */
  69657. direction: Vector2;
  69658. /**
  69659. * 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))
  69660. */
  69661. centerPosition: Vector2;
  69662. /**
  69663. * Creates a new instance ChromaticAberrationPostProcess
  69664. * @param name The name of the effect.
  69665. * @param screenWidth The width of the screen to apply the effect on.
  69666. * @param screenHeight The height of the screen to apply the effect on.
  69667. * @param options The required width/height ratio to downsize to before computing the render pass.
  69668. * @param camera The camera to apply the render pass to.
  69669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69670. * @param engine The engine which the post process will be applied. (default: current engine)
  69671. * @param reusable If the post process can be reused on the same frame. (default: false)
  69672. * @param textureType Type of textures used when performing the post process. (default: 0)
  69673. * @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)
  69674. */
  69675. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69676. }
  69677. }
  69678. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69679. /** @hidden */
  69680. export var circleOfConfusionPixelShader: {
  69681. name: string;
  69682. shader: string;
  69683. };
  69684. }
  69685. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69686. import { Nullable } from "babylonjs/types";
  69687. import { Engine } from "babylonjs/Engines/engine";
  69688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69690. import { Camera } from "babylonjs/Cameras/camera";
  69691. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69692. /**
  69693. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69694. */
  69695. export class CircleOfConfusionPostProcess extends PostProcess {
  69696. /**
  69697. * 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.
  69698. */
  69699. lensSize: number;
  69700. /**
  69701. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69702. */
  69703. fStop: number;
  69704. /**
  69705. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69706. */
  69707. focusDistance: number;
  69708. /**
  69709. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69710. */
  69711. focalLength: number;
  69712. private _depthTexture;
  69713. /**
  69714. * Creates a new instance CircleOfConfusionPostProcess
  69715. * @param name The name of the effect.
  69716. * @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.
  69717. * @param options The required width/height ratio to downsize to before computing the render pass.
  69718. * @param camera The camera to apply the render pass to.
  69719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69720. * @param engine The engine which the post process will be applied. (default: current engine)
  69721. * @param reusable If the post process can be reused on the same frame. (default: false)
  69722. * @param textureType Type of textures used when performing the post process. (default: 0)
  69723. * @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)
  69724. */
  69725. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69726. /**
  69727. * 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.
  69728. */
  69729. set depthTexture(value: RenderTargetTexture);
  69730. }
  69731. }
  69732. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69733. /** @hidden */
  69734. export var colorCorrectionPixelShader: {
  69735. name: string;
  69736. shader: string;
  69737. };
  69738. }
  69739. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69740. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69741. import { Engine } from "babylonjs/Engines/engine";
  69742. import { Camera } from "babylonjs/Cameras/camera";
  69743. import "babylonjs/Shaders/colorCorrection.fragment";
  69744. /**
  69745. *
  69746. * This post-process allows the modification of rendered colors by using
  69747. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69748. *
  69749. * The object needs to be provided an url to a texture containing the color
  69750. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69751. * Use an image editing software to tweak the LUT to match your needs.
  69752. *
  69753. * For an example of a color LUT, see here:
  69754. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69755. * For explanations on color grading, see here:
  69756. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69757. *
  69758. */
  69759. export class ColorCorrectionPostProcess extends PostProcess {
  69760. private _colorTableTexture;
  69761. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69762. }
  69763. }
  69764. declare module "babylonjs/Shaders/convolution.fragment" {
  69765. /** @hidden */
  69766. export var convolutionPixelShader: {
  69767. name: string;
  69768. shader: string;
  69769. };
  69770. }
  69771. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69772. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69773. import { Nullable } from "babylonjs/types";
  69774. import { Camera } from "babylonjs/Cameras/camera";
  69775. import { Engine } from "babylonjs/Engines/engine";
  69776. import "babylonjs/Shaders/convolution.fragment";
  69777. /**
  69778. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69779. * input texture to perform effects such as edge detection or sharpening
  69780. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69781. */
  69782. export class ConvolutionPostProcess extends PostProcess {
  69783. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69784. kernel: number[];
  69785. /**
  69786. * Creates a new instance ConvolutionPostProcess
  69787. * @param name The name of the effect.
  69788. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69789. * @param options The required width/height ratio to downsize to before computing the render pass.
  69790. * @param camera The camera to apply the render pass to.
  69791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69792. * @param engine The engine which the post process will be applied. (default: current engine)
  69793. * @param reusable If the post process can be reused on the same frame. (default: false)
  69794. * @param textureType Type of textures used when performing the post process. (default: 0)
  69795. */
  69796. constructor(name: string,
  69797. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69798. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69799. /**
  69800. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69801. */
  69802. static EdgeDetect0Kernel: number[];
  69803. /**
  69804. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69805. */
  69806. static EdgeDetect1Kernel: number[];
  69807. /**
  69808. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69809. */
  69810. static EdgeDetect2Kernel: number[];
  69811. /**
  69812. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69813. */
  69814. static SharpenKernel: number[];
  69815. /**
  69816. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69817. */
  69818. static EmbossKernel: number[];
  69819. /**
  69820. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69821. */
  69822. static GaussianKernel: number[];
  69823. }
  69824. }
  69825. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  69826. import { Nullable } from "babylonjs/types";
  69827. import { Vector2 } from "babylonjs/Maths/math.vector";
  69828. import { Camera } from "babylonjs/Cameras/camera";
  69829. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69830. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69831. import { Engine } from "babylonjs/Engines/engine";
  69832. import { Scene } from "babylonjs/scene";
  69833. /**
  69834. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69835. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69836. * based on samples that have a large difference in distance than the center pixel.
  69837. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69838. */
  69839. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69840. direction: Vector2;
  69841. /**
  69842. * Creates a new instance CircleOfConfusionPostProcess
  69843. * @param name The name of the effect.
  69844. * @param scene The scene the effect belongs to.
  69845. * @param direction The direction the blur should be applied.
  69846. * @param kernel The size of the kernel used to blur.
  69847. * @param options The required width/height ratio to downsize to before computing the render pass.
  69848. * @param camera The camera to apply the render pass to.
  69849. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69850. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69852. * @param engine The engine which the post process will be applied. (default: current engine)
  69853. * @param reusable If the post process can be reused on the same frame. (default: false)
  69854. * @param textureType Type of textures used when performing the post process. (default: 0)
  69855. * @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)
  69856. */
  69857. 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);
  69858. }
  69859. }
  69860. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  69861. /** @hidden */
  69862. export var depthOfFieldMergePixelShader: {
  69863. name: string;
  69864. shader: string;
  69865. };
  69866. }
  69867. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  69868. import { Nullable } from "babylonjs/types";
  69869. import { Camera } from "babylonjs/Cameras/camera";
  69870. import { Effect } from "babylonjs/Materials/effect";
  69871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69872. import { Engine } from "babylonjs/Engines/engine";
  69873. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  69874. /**
  69875. * Options to be set when merging outputs from the default pipeline.
  69876. */
  69877. export class DepthOfFieldMergePostProcessOptions {
  69878. /**
  69879. * The original image to merge on top of
  69880. */
  69881. originalFromInput: PostProcess;
  69882. /**
  69883. * Parameters to perform the merge of the depth of field effect
  69884. */
  69885. depthOfField?: {
  69886. circleOfConfusion: PostProcess;
  69887. blurSteps: Array<PostProcess>;
  69888. };
  69889. /**
  69890. * Parameters to perform the merge of bloom effect
  69891. */
  69892. bloom?: {
  69893. blurred: PostProcess;
  69894. weight: number;
  69895. };
  69896. }
  69897. /**
  69898. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69899. */
  69900. export class DepthOfFieldMergePostProcess extends PostProcess {
  69901. private blurSteps;
  69902. /**
  69903. * Creates a new instance of DepthOfFieldMergePostProcess
  69904. * @param name The name of the effect.
  69905. * @param originalFromInput Post process which's input will be used for the merge.
  69906. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69907. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69908. * @param options The required width/height ratio to downsize to before computing the render pass.
  69909. * @param camera The camera to apply the render pass to.
  69910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69911. * @param engine The engine which the post process will be applied. (default: current engine)
  69912. * @param reusable If the post process can be reused on the same frame. (default: false)
  69913. * @param textureType Type of textures used when performing the post process. (default: 0)
  69914. * @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)
  69915. */
  69916. 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);
  69917. /**
  69918. * Updates the effect with the current post process compile time values and recompiles the shader.
  69919. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69920. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69921. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69922. * @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
  69923. * @param onCompiled Called when the shader has been compiled.
  69924. * @param onError Called if there is an error when compiling a shader.
  69925. */
  69926. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69927. }
  69928. }
  69929. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  69930. import { Nullable } from "babylonjs/types";
  69931. import { Camera } from "babylonjs/Cameras/camera";
  69932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69934. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69935. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69936. import { Scene } from "babylonjs/scene";
  69937. /**
  69938. * Specifies the level of max blur that should be applied when using the depth of field effect
  69939. */
  69940. export enum DepthOfFieldEffectBlurLevel {
  69941. /**
  69942. * Subtle blur
  69943. */
  69944. Low = 0,
  69945. /**
  69946. * Medium blur
  69947. */
  69948. Medium = 1,
  69949. /**
  69950. * Large blur
  69951. */
  69952. High = 2
  69953. }
  69954. /**
  69955. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69956. */
  69957. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69958. private _circleOfConfusion;
  69959. /**
  69960. * @hidden Internal, blurs from high to low
  69961. */
  69962. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69963. private _depthOfFieldBlurY;
  69964. private _dofMerge;
  69965. /**
  69966. * @hidden Internal post processes in depth of field effect
  69967. */
  69968. _effects: Array<PostProcess>;
  69969. /**
  69970. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69971. */
  69972. set focalLength(value: number);
  69973. get focalLength(): number;
  69974. /**
  69975. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69976. */
  69977. set fStop(value: number);
  69978. get fStop(): number;
  69979. /**
  69980. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69981. */
  69982. set focusDistance(value: number);
  69983. get focusDistance(): number;
  69984. /**
  69985. * 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.
  69986. */
  69987. set lensSize(value: number);
  69988. get lensSize(): number;
  69989. /**
  69990. * Creates a new instance DepthOfFieldEffect
  69991. * @param scene The scene the effect belongs to.
  69992. * @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.
  69993. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69994. * @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)
  69995. */
  69996. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69997. /**
  69998. * Get the current class name of the current effet
  69999. * @returns "DepthOfFieldEffect"
  70000. */
  70001. getClassName(): string;
  70002. /**
  70003. * 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.
  70004. */
  70005. set depthTexture(value: RenderTargetTexture);
  70006. /**
  70007. * Disposes each of the internal effects for a given camera.
  70008. * @param camera The camera to dispose the effect on.
  70009. */
  70010. disposeEffects(camera: Camera): void;
  70011. /**
  70012. * @hidden Internal
  70013. */
  70014. _updateEffects(): void;
  70015. /**
  70016. * Internal
  70017. * @returns if all the contained post processes are ready.
  70018. * @hidden
  70019. */
  70020. _isReady(): boolean;
  70021. }
  70022. }
  70023. declare module "babylonjs/Shaders/displayPass.fragment" {
  70024. /** @hidden */
  70025. export var displayPassPixelShader: {
  70026. name: string;
  70027. shader: string;
  70028. };
  70029. }
  70030. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70031. import { Nullable } from "babylonjs/types";
  70032. import { Camera } from "babylonjs/Cameras/camera";
  70033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70034. import { Engine } from "babylonjs/Engines/engine";
  70035. import "babylonjs/Shaders/displayPass.fragment";
  70036. /**
  70037. * DisplayPassPostProcess which produces an output the same as it's input
  70038. */
  70039. export class DisplayPassPostProcess extends PostProcess {
  70040. /**
  70041. * Creates the DisplayPassPostProcess
  70042. * @param name The name of the effect.
  70043. * @param options The required width/height ratio to downsize to before computing the render pass.
  70044. * @param camera The camera to apply the render pass to.
  70045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70046. * @param engine The engine which the post process will be applied. (default: current engine)
  70047. * @param reusable If the post process can be reused on the same frame. (default: false)
  70048. */
  70049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70050. }
  70051. }
  70052. declare module "babylonjs/Shaders/filter.fragment" {
  70053. /** @hidden */
  70054. export var filterPixelShader: {
  70055. name: string;
  70056. shader: string;
  70057. };
  70058. }
  70059. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70060. import { Nullable } from "babylonjs/types";
  70061. import { Matrix } from "babylonjs/Maths/math.vector";
  70062. import { Camera } from "babylonjs/Cameras/camera";
  70063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70064. import { Engine } from "babylonjs/Engines/engine";
  70065. import "babylonjs/Shaders/filter.fragment";
  70066. /**
  70067. * Applies a kernel filter to the image
  70068. */
  70069. export class FilterPostProcess extends PostProcess {
  70070. /** The matrix to be applied to the image */
  70071. kernelMatrix: Matrix;
  70072. /**
  70073. *
  70074. * @param name The name of the effect.
  70075. * @param kernelMatrix The matrix to be applied to the image
  70076. * @param options The required width/height ratio to downsize to before computing the render pass.
  70077. * @param camera The camera to apply the render pass to.
  70078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70079. * @param engine The engine which the post process will be applied. (default: current engine)
  70080. * @param reusable If the post process can be reused on the same frame. (default: false)
  70081. */
  70082. constructor(name: string,
  70083. /** The matrix to be applied to the image */
  70084. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70085. }
  70086. }
  70087. declare module "babylonjs/Shaders/fxaa.fragment" {
  70088. /** @hidden */
  70089. export var fxaaPixelShader: {
  70090. name: string;
  70091. shader: string;
  70092. };
  70093. }
  70094. declare module "babylonjs/Shaders/fxaa.vertex" {
  70095. /** @hidden */
  70096. export var fxaaVertexShader: {
  70097. name: string;
  70098. shader: string;
  70099. };
  70100. }
  70101. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70102. import { Nullable } from "babylonjs/types";
  70103. import { Camera } from "babylonjs/Cameras/camera";
  70104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70105. import { Engine } from "babylonjs/Engines/engine";
  70106. import "babylonjs/Shaders/fxaa.fragment";
  70107. import "babylonjs/Shaders/fxaa.vertex";
  70108. /**
  70109. * Fxaa post process
  70110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70111. */
  70112. export class FxaaPostProcess extends PostProcess {
  70113. /** @hidden */
  70114. texelWidth: number;
  70115. /** @hidden */
  70116. texelHeight: number;
  70117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70118. private _getDefines;
  70119. }
  70120. }
  70121. declare module "babylonjs/Shaders/grain.fragment" {
  70122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70123. /** @hidden */
  70124. export var grainPixelShader: {
  70125. name: string;
  70126. shader: string;
  70127. };
  70128. }
  70129. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70130. import { Nullable } from "babylonjs/types";
  70131. import { Camera } from "babylonjs/Cameras/camera";
  70132. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70133. import { Engine } from "babylonjs/Engines/engine";
  70134. import "babylonjs/Shaders/grain.fragment";
  70135. /**
  70136. * The GrainPostProcess adds noise to the image at mid luminance levels
  70137. */
  70138. export class GrainPostProcess extends PostProcess {
  70139. /**
  70140. * The intensity of the grain added (default: 30)
  70141. */
  70142. intensity: number;
  70143. /**
  70144. * If the grain should be randomized on every frame
  70145. */
  70146. animated: boolean;
  70147. /**
  70148. * Creates a new instance of @see GrainPostProcess
  70149. * @param name The name of the effect.
  70150. * @param options The required width/height ratio to downsize to before computing the render pass.
  70151. * @param camera The camera to apply the render pass to.
  70152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70153. * @param engine The engine which the post process will be applied. (default: current engine)
  70154. * @param reusable If the post process can be reused on the same frame. (default: false)
  70155. * @param textureType Type of textures used when performing the post process. (default: 0)
  70156. * @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)
  70157. */
  70158. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70159. }
  70160. }
  70161. declare module "babylonjs/Shaders/highlights.fragment" {
  70162. /** @hidden */
  70163. export var highlightsPixelShader: {
  70164. name: string;
  70165. shader: string;
  70166. };
  70167. }
  70168. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70169. import { Nullable } from "babylonjs/types";
  70170. import { Camera } from "babylonjs/Cameras/camera";
  70171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70172. import { Engine } from "babylonjs/Engines/engine";
  70173. import "babylonjs/Shaders/highlights.fragment";
  70174. /**
  70175. * Extracts highlights from the image
  70176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70177. */
  70178. export class HighlightsPostProcess extends PostProcess {
  70179. /**
  70180. * Extracts highlights from the image
  70181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70182. * @param name The name of the effect.
  70183. * @param options The required width/height ratio to downsize to before computing the render pass.
  70184. * @param camera The camera to apply the render pass to.
  70185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70186. * @param engine The engine which the post process will be applied. (default: current engine)
  70187. * @param reusable If the post process can be reused on the same frame. (default: false)
  70188. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70189. */
  70190. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70191. }
  70192. }
  70193. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70194. /** @hidden */
  70195. export var mrtFragmentDeclaration: {
  70196. name: string;
  70197. shader: string;
  70198. };
  70199. }
  70200. declare module "babylonjs/Shaders/geometry.fragment" {
  70201. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70202. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70203. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70204. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70205. /** @hidden */
  70206. export var geometryPixelShader: {
  70207. name: string;
  70208. shader: string;
  70209. };
  70210. }
  70211. declare module "babylonjs/Shaders/geometry.vertex" {
  70212. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70213. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70214. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70215. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70217. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70218. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70219. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70220. /** @hidden */
  70221. export var geometryVertexShader: {
  70222. name: string;
  70223. shader: string;
  70224. };
  70225. }
  70226. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70227. import { Matrix } from "babylonjs/Maths/math.vector";
  70228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70229. import { Mesh } from "babylonjs/Meshes/mesh";
  70230. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70231. import { Effect } from "babylonjs/Materials/effect";
  70232. import { Scene } from "babylonjs/scene";
  70233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70234. import "babylonjs/Shaders/geometry.fragment";
  70235. import "babylonjs/Shaders/geometry.vertex";
  70236. /** @hidden */
  70237. interface ISavedTransformationMatrix {
  70238. world: Matrix;
  70239. viewProjection: Matrix;
  70240. }
  70241. /**
  70242. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70243. */
  70244. export class GeometryBufferRenderer {
  70245. /**
  70246. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70247. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70248. */
  70249. static readonly POSITION_TEXTURE_TYPE: number;
  70250. /**
  70251. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70252. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70253. */
  70254. static readonly VELOCITY_TEXTURE_TYPE: number;
  70255. /**
  70256. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70257. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70258. */
  70259. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70260. /**
  70261. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70262. * in order to compute objects velocities when enableVelocity is set to "true"
  70263. * @hidden
  70264. */
  70265. _previousTransformationMatrices: {
  70266. [index: number]: ISavedTransformationMatrix;
  70267. };
  70268. /**
  70269. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70270. * in order to compute objects velocities when enableVelocity is set to "true"
  70271. * @hidden
  70272. */
  70273. _previousBonesTransformationMatrices: {
  70274. [index: number]: Float32Array;
  70275. };
  70276. /**
  70277. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70278. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70279. */
  70280. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70281. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70282. renderTransparentMeshes: boolean;
  70283. private _scene;
  70284. private _multiRenderTarget;
  70285. private _ratio;
  70286. private _enablePosition;
  70287. private _enableVelocity;
  70288. private _enableReflectivity;
  70289. private _positionIndex;
  70290. private _velocityIndex;
  70291. private _reflectivityIndex;
  70292. protected _effect: Effect;
  70293. protected _cachedDefines: string;
  70294. /**
  70295. * Set the render list (meshes to be rendered) used in the G buffer.
  70296. */
  70297. set renderList(meshes: Mesh[]);
  70298. /**
  70299. * Gets wether or not G buffer are supported by the running hardware.
  70300. * This requires draw buffer supports
  70301. */
  70302. get isSupported(): boolean;
  70303. /**
  70304. * Returns the index of the given texture type in the G-Buffer textures array
  70305. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70306. * @returns the index of the given texture type in the G-Buffer textures array
  70307. */
  70308. getTextureIndex(textureType: number): number;
  70309. /**
  70310. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70311. */
  70312. get enablePosition(): boolean;
  70313. /**
  70314. * Sets whether or not objects positions are enabled for the G buffer.
  70315. */
  70316. set enablePosition(enable: boolean);
  70317. /**
  70318. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70319. */
  70320. get enableVelocity(): boolean;
  70321. /**
  70322. * Sets wether or not objects velocities are enabled for the G buffer.
  70323. */
  70324. set enableVelocity(enable: boolean);
  70325. /**
  70326. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70327. */
  70328. get enableReflectivity(): boolean;
  70329. /**
  70330. * Sets wether or not objects roughness are enabled for the G buffer.
  70331. */
  70332. set enableReflectivity(enable: boolean);
  70333. /**
  70334. * Gets the scene associated with the buffer.
  70335. */
  70336. get scene(): Scene;
  70337. /**
  70338. * Gets the ratio used by the buffer during its creation.
  70339. * How big is the buffer related to the main canvas.
  70340. */
  70341. get ratio(): number;
  70342. /** @hidden */
  70343. static _SceneComponentInitialization: (scene: Scene) => void;
  70344. /**
  70345. * Creates a new G Buffer for the scene
  70346. * @param scene The scene the buffer belongs to
  70347. * @param ratio How big is the buffer related to the main canvas.
  70348. */
  70349. constructor(scene: Scene, ratio?: number);
  70350. /**
  70351. * Checks wether everything is ready to render a submesh to the G buffer.
  70352. * @param subMesh the submesh to check readiness for
  70353. * @param useInstances is the mesh drawn using instance or not
  70354. * @returns true if ready otherwise false
  70355. */
  70356. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70357. /**
  70358. * Gets the current underlying G Buffer.
  70359. * @returns the buffer
  70360. */
  70361. getGBuffer(): MultiRenderTarget;
  70362. /**
  70363. * Gets the number of samples used to render the buffer (anti aliasing).
  70364. */
  70365. get samples(): number;
  70366. /**
  70367. * Sets the number of samples used to render the buffer (anti aliasing).
  70368. */
  70369. set samples(value: number);
  70370. /**
  70371. * Disposes the renderer and frees up associated resources.
  70372. */
  70373. dispose(): void;
  70374. protected _createRenderTargets(): void;
  70375. private _copyBonesTransformationMatrices;
  70376. }
  70377. }
  70378. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70379. import { Nullable } from "babylonjs/types";
  70380. import { Scene } from "babylonjs/scene";
  70381. import { ISceneComponent } from "babylonjs/sceneComponent";
  70382. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70383. module "babylonjs/scene" {
  70384. interface Scene {
  70385. /** @hidden (Backing field) */
  70386. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70387. /**
  70388. * Gets or Sets the current geometry buffer associated to the scene.
  70389. */
  70390. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70391. /**
  70392. * Enables a GeometryBufferRender and associates it with the scene
  70393. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70394. * @returns the GeometryBufferRenderer
  70395. */
  70396. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70397. /**
  70398. * Disables the GeometryBufferRender associated with the scene
  70399. */
  70400. disableGeometryBufferRenderer(): void;
  70401. }
  70402. }
  70403. /**
  70404. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70405. * in several rendering techniques.
  70406. */
  70407. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70408. /**
  70409. * The component name helpful to identify the component in the list of scene components.
  70410. */
  70411. readonly name: string;
  70412. /**
  70413. * The scene the component belongs to.
  70414. */
  70415. scene: Scene;
  70416. /**
  70417. * Creates a new instance of the component for the given scene
  70418. * @param scene Defines the scene to register the component in
  70419. */
  70420. constructor(scene: Scene);
  70421. /**
  70422. * Registers the component in a given scene
  70423. */
  70424. register(): void;
  70425. /**
  70426. * Rebuilds the elements related to this component in case of
  70427. * context lost for instance.
  70428. */
  70429. rebuild(): void;
  70430. /**
  70431. * Disposes the component and the associated ressources
  70432. */
  70433. dispose(): void;
  70434. private _gatherRenderTargets;
  70435. }
  70436. }
  70437. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70438. /** @hidden */
  70439. export var motionBlurPixelShader: {
  70440. name: string;
  70441. shader: string;
  70442. };
  70443. }
  70444. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70445. import { Nullable } from "babylonjs/types";
  70446. import { Camera } from "babylonjs/Cameras/camera";
  70447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70448. import { Scene } from "babylonjs/scene";
  70449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70450. import "babylonjs/Animations/animatable";
  70451. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70452. import "babylonjs/Shaders/motionBlur.fragment";
  70453. import { Engine } from "babylonjs/Engines/engine";
  70454. /**
  70455. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70456. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70457. * As an example, all you have to do is to create the post-process:
  70458. * var mb = new BABYLON.MotionBlurPostProcess(
  70459. * 'mb', // The name of the effect.
  70460. * scene, // The scene containing the objects to blur according to their velocity.
  70461. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70462. * camera // The camera to apply the render pass to.
  70463. * );
  70464. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70465. */
  70466. export class MotionBlurPostProcess extends PostProcess {
  70467. /**
  70468. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70469. */
  70470. motionStrength: number;
  70471. /**
  70472. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70473. */
  70474. get motionBlurSamples(): number;
  70475. /**
  70476. * Sets the number of iterations to be used for motion blur quality
  70477. */
  70478. set motionBlurSamples(samples: number);
  70479. private _motionBlurSamples;
  70480. private _geometryBufferRenderer;
  70481. /**
  70482. * Creates a new instance MotionBlurPostProcess
  70483. * @param name The name of the effect.
  70484. * @param scene The scene containing the objects to blur according to their velocity.
  70485. * @param options The required width/height ratio to downsize to before computing the render pass.
  70486. * @param camera The camera to apply the render pass to.
  70487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70488. * @param engine The engine which the post process will be applied. (default: current engine)
  70489. * @param reusable If the post process can be reused on the same frame. (default: false)
  70490. * @param textureType Type of textures used when performing the post process. (default: 0)
  70491. * @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)
  70492. */
  70493. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70494. /**
  70495. * Excludes the given skinned mesh from computing bones velocities.
  70496. * 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.
  70497. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70498. */
  70499. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70500. /**
  70501. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70502. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70503. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70504. */
  70505. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70506. /**
  70507. * Disposes the post process.
  70508. * @param camera The camera to dispose the post process on.
  70509. */
  70510. dispose(camera?: Camera): void;
  70511. }
  70512. }
  70513. declare module "babylonjs/Shaders/refraction.fragment" {
  70514. /** @hidden */
  70515. export var refractionPixelShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70521. import { Color3 } from "babylonjs/Maths/math.color";
  70522. import { Camera } from "babylonjs/Cameras/camera";
  70523. import { Texture } from "babylonjs/Materials/Textures/texture";
  70524. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70525. import { Engine } from "babylonjs/Engines/engine";
  70526. import "babylonjs/Shaders/refraction.fragment";
  70527. /**
  70528. * Post process which applies a refractin texture
  70529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70530. */
  70531. export class RefractionPostProcess extends PostProcess {
  70532. /** the base color of the refraction (used to taint the rendering) */
  70533. color: Color3;
  70534. /** simulated refraction depth */
  70535. depth: number;
  70536. /** the coefficient of the base color (0 to remove base color tainting) */
  70537. colorLevel: number;
  70538. private _refTexture;
  70539. private _ownRefractionTexture;
  70540. /**
  70541. * Gets or sets the refraction texture
  70542. * Please note that you are responsible for disposing the texture if you set it manually
  70543. */
  70544. get refractionTexture(): Texture;
  70545. set refractionTexture(value: Texture);
  70546. /**
  70547. * Initializes the RefractionPostProcess
  70548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70549. * @param name The name of the effect.
  70550. * @param refractionTextureUrl Url of the refraction texture to use
  70551. * @param color the base color of the refraction (used to taint the rendering)
  70552. * @param depth simulated refraction depth
  70553. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70554. * @param camera The camera to apply the render pass to.
  70555. * @param options The required width/height ratio to downsize to before computing the render pass.
  70556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70557. * @param engine The engine which the post process will be applied. (default: current engine)
  70558. * @param reusable If the post process can be reused on the same frame. (default: false)
  70559. */
  70560. constructor(name: string, refractionTextureUrl: string,
  70561. /** the base color of the refraction (used to taint the rendering) */
  70562. color: Color3,
  70563. /** simulated refraction depth */
  70564. depth: number,
  70565. /** the coefficient of the base color (0 to remove base color tainting) */
  70566. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70567. /**
  70568. * Disposes of the post process
  70569. * @param camera Camera to dispose post process on
  70570. */
  70571. dispose(camera: Camera): void;
  70572. }
  70573. }
  70574. declare module "babylonjs/Shaders/sharpen.fragment" {
  70575. /** @hidden */
  70576. export var sharpenPixelShader: {
  70577. name: string;
  70578. shader: string;
  70579. };
  70580. }
  70581. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70582. import { Nullable } from "babylonjs/types";
  70583. import { Camera } from "babylonjs/Cameras/camera";
  70584. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70585. import "babylonjs/Shaders/sharpen.fragment";
  70586. import { Engine } from "babylonjs/Engines/engine";
  70587. /**
  70588. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70589. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70590. */
  70591. export class SharpenPostProcess extends PostProcess {
  70592. /**
  70593. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70594. */
  70595. colorAmount: number;
  70596. /**
  70597. * How much sharpness should be applied (default: 0.3)
  70598. */
  70599. edgeAmount: number;
  70600. /**
  70601. * Creates a new instance ConvolutionPostProcess
  70602. * @param name The name of the effect.
  70603. * @param options The required width/height ratio to downsize to before computing the render pass.
  70604. * @param camera The camera to apply the render pass to.
  70605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70606. * @param engine The engine which the post process will be applied. (default: current engine)
  70607. * @param reusable If the post process can be reused on the same frame. (default: false)
  70608. * @param textureType Type of textures used when performing the post process. (default: 0)
  70609. * @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)
  70610. */
  70611. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70612. }
  70613. }
  70614. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70615. import { Nullable } from "babylonjs/types";
  70616. import { Camera } from "babylonjs/Cameras/camera";
  70617. import { Engine } from "babylonjs/Engines/engine";
  70618. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70619. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70620. /**
  70621. * PostProcessRenderPipeline
  70622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70623. */
  70624. export class PostProcessRenderPipeline {
  70625. private engine;
  70626. private _renderEffects;
  70627. private _renderEffectsForIsolatedPass;
  70628. /**
  70629. * List of inspectable custom properties (used by the Inspector)
  70630. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70631. */
  70632. inspectableCustomProperties: IInspectable[];
  70633. /**
  70634. * @hidden
  70635. */
  70636. protected _cameras: Camera[];
  70637. /** @hidden */
  70638. _name: string;
  70639. /**
  70640. * Gets pipeline name
  70641. */
  70642. get name(): string;
  70643. /** Gets the list of attached cameras */
  70644. get cameras(): Camera[];
  70645. /**
  70646. * Initializes a PostProcessRenderPipeline
  70647. * @param engine engine to add the pipeline to
  70648. * @param name name of the pipeline
  70649. */
  70650. constructor(engine: Engine, name: string);
  70651. /**
  70652. * Gets the class name
  70653. * @returns "PostProcessRenderPipeline"
  70654. */
  70655. getClassName(): string;
  70656. /**
  70657. * If all the render effects in the pipeline are supported
  70658. */
  70659. get isSupported(): boolean;
  70660. /**
  70661. * Adds an effect to the pipeline
  70662. * @param renderEffect the effect to add
  70663. */
  70664. addEffect(renderEffect: PostProcessRenderEffect): void;
  70665. /** @hidden */
  70666. _rebuild(): void;
  70667. /** @hidden */
  70668. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70669. /** @hidden */
  70670. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70671. /** @hidden */
  70672. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70673. /** @hidden */
  70674. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70675. /** @hidden */
  70676. _attachCameras(cameras: Camera, unique: boolean): void;
  70677. /** @hidden */
  70678. _attachCameras(cameras: Camera[], unique: boolean): void;
  70679. /** @hidden */
  70680. _detachCameras(cameras: Camera): void;
  70681. /** @hidden */
  70682. _detachCameras(cameras: Nullable<Camera[]>): void;
  70683. /** @hidden */
  70684. _update(): void;
  70685. /** @hidden */
  70686. _reset(): void;
  70687. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70688. /**
  70689. * Disposes of the pipeline
  70690. */
  70691. dispose(): void;
  70692. }
  70693. }
  70694. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70695. import { Camera } from "babylonjs/Cameras/camera";
  70696. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70697. /**
  70698. * PostProcessRenderPipelineManager class
  70699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70700. */
  70701. export class PostProcessRenderPipelineManager {
  70702. private _renderPipelines;
  70703. /**
  70704. * Initializes a PostProcessRenderPipelineManager
  70705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70706. */
  70707. constructor();
  70708. /**
  70709. * Gets the list of supported render pipelines
  70710. */
  70711. get supportedPipelines(): PostProcessRenderPipeline[];
  70712. /**
  70713. * Adds a pipeline to the manager
  70714. * @param renderPipeline The pipeline to add
  70715. */
  70716. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70717. /**
  70718. * Attaches a camera to the pipeline
  70719. * @param renderPipelineName The name of the pipeline to attach to
  70720. * @param cameras the camera to attach
  70721. * @param unique if the camera can be attached multiple times to the pipeline
  70722. */
  70723. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70724. /**
  70725. * Detaches a camera from the pipeline
  70726. * @param renderPipelineName The name of the pipeline to detach from
  70727. * @param cameras the camera to detach
  70728. */
  70729. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70730. /**
  70731. * Enables an effect by name on a pipeline
  70732. * @param renderPipelineName the name of the pipeline to enable the effect in
  70733. * @param renderEffectName the name of the effect to enable
  70734. * @param cameras the cameras that the effect should be enabled on
  70735. */
  70736. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70737. /**
  70738. * Disables an effect by name on a pipeline
  70739. * @param renderPipelineName the name of the pipeline to disable the effect in
  70740. * @param renderEffectName the name of the effect to disable
  70741. * @param cameras the cameras that the effect should be disabled on
  70742. */
  70743. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70744. /**
  70745. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70746. */
  70747. update(): void;
  70748. /** @hidden */
  70749. _rebuild(): void;
  70750. /**
  70751. * Disposes of the manager and pipelines
  70752. */
  70753. dispose(): void;
  70754. }
  70755. }
  70756. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70757. import { ISceneComponent } from "babylonjs/sceneComponent";
  70758. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70759. import { Scene } from "babylonjs/scene";
  70760. module "babylonjs/scene" {
  70761. interface Scene {
  70762. /** @hidden (Backing field) */
  70763. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70764. /**
  70765. * Gets the postprocess render pipeline manager
  70766. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70767. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70768. */
  70769. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70770. }
  70771. }
  70772. /**
  70773. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70774. */
  70775. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70776. /**
  70777. * The component name helpfull to identify the component in the list of scene components.
  70778. */
  70779. readonly name: string;
  70780. /**
  70781. * The scene the component belongs to.
  70782. */
  70783. scene: Scene;
  70784. /**
  70785. * Creates a new instance of the component for the given scene
  70786. * @param scene Defines the scene to register the component in
  70787. */
  70788. constructor(scene: Scene);
  70789. /**
  70790. * Registers the component in a given scene
  70791. */
  70792. register(): void;
  70793. /**
  70794. * Rebuilds the elements related to this component in case of
  70795. * context lost for instance.
  70796. */
  70797. rebuild(): void;
  70798. /**
  70799. * Disposes the component and the associated ressources
  70800. */
  70801. dispose(): void;
  70802. private _gatherRenderTargets;
  70803. }
  70804. }
  70805. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  70806. import { Nullable } from "babylonjs/types";
  70807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70808. import { Camera } from "babylonjs/Cameras/camera";
  70809. import { IDisposable } from "babylonjs/scene";
  70810. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  70811. import { Scene } from "babylonjs/scene";
  70812. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  70813. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70814. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70815. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  70816. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70817. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70818. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  70819. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70820. import { Animation } from "babylonjs/Animations/animation";
  70821. /**
  70822. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70823. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70824. */
  70825. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70826. private _scene;
  70827. private _camerasToBeAttached;
  70828. /**
  70829. * ID of the sharpen post process,
  70830. */
  70831. private readonly SharpenPostProcessId;
  70832. /**
  70833. * @ignore
  70834. * ID of the image processing post process;
  70835. */
  70836. readonly ImageProcessingPostProcessId: string;
  70837. /**
  70838. * @ignore
  70839. * ID of the Fast Approximate Anti-Aliasing post process;
  70840. */
  70841. readonly FxaaPostProcessId: string;
  70842. /**
  70843. * ID of the chromatic aberration post process,
  70844. */
  70845. private readonly ChromaticAberrationPostProcessId;
  70846. /**
  70847. * ID of the grain post process
  70848. */
  70849. private readonly GrainPostProcessId;
  70850. /**
  70851. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70852. */
  70853. sharpen: SharpenPostProcess;
  70854. private _sharpenEffect;
  70855. private bloom;
  70856. /**
  70857. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70858. */
  70859. depthOfField: DepthOfFieldEffect;
  70860. /**
  70861. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70862. */
  70863. fxaa: FxaaPostProcess;
  70864. /**
  70865. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70866. */
  70867. imageProcessing: ImageProcessingPostProcess;
  70868. /**
  70869. * Chromatic aberration post process which will shift rgb colors in the image
  70870. */
  70871. chromaticAberration: ChromaticAberrationPostProcess;
  70872. private _chromaticAberrationEffect;
  70873. /**
  70874. * Grain post process which add noise to the image
  70875. */
  70876. grain: GrainPostProcess;
  70877. private _grainEffect;
  70878. /**
  70879. * Glow post process which adds a glow to emissive areas of the image
  70880. */
  70881. private _glowLayer;
  70882. /**
  70883. * Animations which can be used to tweak settings over a period of time
  70884. */
  70885. animations: Animation[];
  70886. private _imageProcessingConfigurationObserver;
  70887. private _sharpenEnabled;
  70888. private _bloomEnabled;
  70889. private _depthOfFieldEnabled;
  70890. private _depthOfFieldBlurLevel;
  70891. private _fxaaEnabled;
  70892. private _imageProcessingEnabled;
  70893. private _defaultPipelineTextureType;
  70894. private _bloomScale;
  70895. private _chromaticAberrationEnabled;
  70896. private _grainEnabled;
  70897. private _buildAllowed;
  70898. /**
  70899. * Gets active scene
  70900. */
  70901. get scene(): Scene;
  70902. /**
  70903. * Enable or disable the sharpen process from the pipeline
  70904. */
  70905. set sharpenEnabled(enabled: boolean);
  70906. get sharpenEnabled(): boolean;
  70907. private _resizeObserver;
  70908. private _hardwareScaleLevel;
  70909. private _bloomKernel;
  70910. /**
  70911. * Specifies the size of the bloom blur kernel, relative to the final output size
  70912. */
  70913. get bloomKernel(): number;
  70914. set bloomKernel(value: number);
  70915. /**
  70916. * Specifies the weight of the bloom in the final rendering
  70917. */
  70918. private _bloomWeight;
  70919. /**
  70920. * Specifies the luma threshold for the area that will be blurred by the bloom
  70921. */
  70922. private _bloomThreshold;
  70923. private _hdr;
  70924. /**
  70925. * The strength of the bloom.
  70926. */
  70927. set bloomWeight(value: number);
  70928. get bloomWeight(): number;
  70929. /**
  70930. * The strength of the bloom.
  70931. */
  70932. set bloomThreshold(value: number);
  70933. get bloomThreshold(): number;
  70934. /**
  70935. * The scale of the bloom, lower value will provide better performance.
  70936. */
  70937. set bloomScale(value: number);
  70938. get bloomScale(): number;
  70939. /**
  70940. * Enable or disable the bloom from the pipeline
  70941. */
  70942. set bloomEnabled(enabled: boolean);
  70943. get bloomEnabled(): boolean;
  70944. private _rebuildBloom;
  70945. /**
  70946. * If the depth of field is enabled.
  70947. */
  70948. get depthOfFieldEnabled(): boolean;
  70949. set depthOfFieldEnabled(enabled: boolean);
  70950. /**
  70951. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70952. */
  70953. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70954. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70955. /**
  70956. * If the anti aliasing is enabled.
  70957. */
  70958. set fxaaEnabled(enabled: boolean);
  70959. get fxaaEnabled(): boolean;
  70960. private _samples;
  70961. /**
  70962. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70963. */
  70964. set samples(sampleCount: number);
  70965. get samples(): number;
  70966. /**
  70967. * If image processing is enabled.
  70968. */
  70969. set imageProcessingEnabled(enabled: boolean);
  70970. get imageProcessingEnabled(): boolean;
  70971. /**
  70972. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70973. */
  70974. set glowLayerEnabled(enabled: boolean);
  70975. get glowLayerEnabled(): boolean;
  70976. /**
  70977. * Gets the glow layer (or null if not defined)
  70978. */
  70979. get glowLayer(): Nullable<GlowLayer>;
  70980. /**
  70981. * Enable or disable the chromaticAberration process from the pipeline
  70982. */
  70983. set chromaticAberrationEnabled(enabled: boolean);
  70984. get chromaticAberrationEnabled(): boolean;
  70985. /**
  70986. * Enable or disable the grain process from the pipeline
  70987. */
  70988. set grainEnabled(enabled: boolean);
  70989. get grainEnabled(): boolean;
  70990. /**
  70991. * @constructor
  70992. * @param name - The rendering pipeline name (default: "")
  70993. * @param hdr - If high dynamic range textures should be used (default: true)
  70994. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70995. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70996. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70997. */
  70998. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70999. /**
  71000. * Get the class name
  71001. * @returns "DefaultRenderingPipeline"
  71002. */
  71003. getClassName(): string;
  71004. /**
  71005. * Force the compilation of the entire pipeline.
  71006. */
  71007. prepare(): void;
  71008. private _hasCleared;
  71009. private _prevPostProcess;
  71010. private _prevPrevPostProcess;
  71011. private _setAutoClearAndTextureSharing;
  71012. private _depthOfFieldSceneObserver;
  71013. private _buildPipeline;
  71014. private _disposePostProcesses;
  71015. /**
  71016. * Adds a camera to the pipeline
  71017. * @param camera the camera to be added
  71018. */
  71019. addCamera(camera: Camera): void;
  71020. /**
  71021. * Removes a camera from the pipeline
  71022. * @param camera the camera to remove
  71023. */
  71024. removeCamera(camera: Camera): void;
  71025. /**
  71026. * Dispose of the pipeline and stop all post processes
  71027. */
  71028. dispose(): void;
  71029. /**
  71030. * Serialize the rendering pipeline (Used when exporting)
  71031. * @returns the serialized object
  71032. */
  71033. serialize(): any;
  71034. /**
  71035. * Parse the serialized pipeline
  71036. * @param source Source pipeline.
  71037. * @param scene The scene to load the pipeline to.
  71038. * @param rootUrl The URL of the serialized pipeline.
  71039. * @returns An instantiated pipeline from the serialized object.
  71040. */
  71041. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71042. }
  71043. }
  71044. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71045. /** @hidden */
  71046. export var lensHighlightsPixelShader: {
  71047. name: string;
  71048. shader: string;
  71049. };
  71050. }
  71051. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71052. /** @hidden */
  71053. export var depthOfFieldPixelShader: {
  71054. name: string;
  71055. shader: string;
  71056. };
  71057. }
  71058. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71059. import { Camera } from "babylonjs/Cameras/camera";
  71060. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71061. import { Scene } from "babylonjs/scene";
  71062. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71063. import "babylonjs/Shaders/chromaticAberration.fragment";
  71064. import "babylonjs/Shaders/lensHighlights.fragment";
  71065. import "babylonjs/Shaders/depthOfField.fragment";
  71066. /**
  71067. * BABYLON.JS Chromatic Aberration GLSL Shader
  71068. * Author: Olivier Guyot
  71069. * Separates very slightly R, G and B colors on the edges of the screen
  71070. * Inspired by Francois Tarlier & Martins Upitis
  71071. */
  71072. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71073. /**
  71074. * @ignore
  71075. * The chromatic aberration PostProcess id in the pipeline
  71076. */
  71077. LensChromaticAberrationEffect: string;
  71078. /**
  71079. * @ignore
  71080. * The highlights enhancing PostProcess id in the pipeline
  71081. */
  71082. HighlightsEnhancingEffect: string;
  71083. /**
  71084. * @ignore
  71085. * The depth-of-field PostProcess id in the pipeline
  71086. */
  71087. LensDepthOfFieldEffect: string;
  71088. private _scene;
  71089. private _depthTexture;
  71090. private _grainTexture;
  71091. private _chromaticAberrationPostProcess;
  71092. private _highlightsPostProcess;
  71093. private _depthOfFieldPostProcess;
  71094. private _edgeBlur;
  71095. private _grainAmount;
  71096. private _chromaticAberration;
  71097. private _distortion;
  71098. private _highlightsGain;
  71099. private _highlightsThreshold;
  71100. private _dofDistance;
  71101. private _dofAperture;
  71102. private _dofDarken;
  71103. private _dofPentagon;
  71104. private _blurNoise;
  71105. /**
  71106. * @constructor
  71107. *
  71108. * Effect parameters are as follow:
  71109. * {
  71110. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71111. * edge_blur: number; // from 0 to x (1 for realism)
  71112. * distortion: number; // from 0 to x (1 for realism)
  71113. * grain_amount: number; // from 0 to 1
  71114. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71115. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71116. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71117. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71118. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71119. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71120. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71121. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71122. * }
  71123. * Note: if an effect parameter is unset, effect is disabled
  71124. *
  71125. * @param name The rendering pipeline name
  71126. * @param parameters - An object containing all parameters (see above)
  71127. * @param scene The scene linked to this pipeline
  71128. * @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)
  71129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71130. */
  71131. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71132. /**
  71133. * Get the class name
  71134. * @returns "LensRenderingPipeline"
  71135. */
  71136. getClassName(): string;
  71137. /**
  71138. * Gets associated scene
  71139. */
  71140. get scene(): Scene;
  71141. /**
  71142. * Gets or sets the edge blur
  71143. */
  71144. get edgeBlur(): number;
  71145. set edgeBlur(value: number);
  71146. /**
  71147. * Gets or sets the grain amount
  71148. */
  71149. get grainAmount(): number;
  71150. set grainAmount(value: number);
  71151. /**
  71152. * Gets or sets the chromatic aberration amount
  71153. */
  71154. get chromaticAberration(): number;
  71155. set chromaticAberration(value: number);
  71156. /**
  71157. * Gets or sets the depth of field aperture
  71158. */
  71159. get dofAperture(): number;
  71160. set dofAperture(value: number);
  71161. /**
  71162. * Gets or sets the edge distortion
  71163. */
  71164. get edgeDistortion(): number;
  71165. set edgeDistortion(value: number);
  71166. /**
  71167. * Gets or sets the depth of field distortion
  71168. */
  71169. get dofDistortion(): number;
  71170. set dofDistortion(value: number);
  71171. /**
  71172. * Gets or sets the darken out of focus amount
  71173. */
  71174. get darkenOutOfFocus(): number;
  71175. set darkenOutOfFocus(value: number);
  71176. /**
  71177. * Gets or sets a boolean indicating if blur noise is enabled
  71178. */
  71179. get blurNoise(): boolean;
  71180. set blurNoise(value: boolean);
  71181. /**
  71182. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71183. */
  71184. get pentagonBokeh(): boolean;
  71185. set pentagonBokeh(value: boolean);
  71186. /**
  71187. * Gets or sets the highlight grain amount
  71188. */
  71189. get highlightsGain(): number;
  71190. set highlightsGain(value: number);
  71191. /**
  71192. * Gets or sets the highlight threshold
  71193. */
  71194. get highlightsThreshold(): number;
  71195. set highlightsThreshold(value: number);
  71196. /**
  71197. * Sets the amount of blur at the edges
  71198. * @param amount blur amount
  71199. */
  71200. setEdgeBlur(amount: number): void;
  71201. /**
  71202. * Sets edge blur to 0
  71203. */
  71204. disableEdgeBlur(): void;
  71205. /**
  71206. * Sets the amout of grain
  71207. * @param amount Amount of grain
  71208. */
  71209. setGrainAmount(amount: number): void;
  71210. /**
  71211. * Set grain amount to 0
  71212. */
  71213. disableGrain(): void;
  71214. /**
  71215. * Sets the chromatic aberration amount
  71216. * @param amount amount of chromatic aberration
  71217. */
  71218. setChromaticAberration(amount: number): void;
  71219. /**
  71220. * Sets chromatic aberration amount to 0
  71221. */
  71222. disableChromaticAberration(): void;
  71223. /**
  71224. * Sets the EdgeDistortion amount
  71225. * @param amount amount of EdgeDistortion
  71226. */
  71227. setEdgeDistortion(amount: number): void;
  71228. /**
  71229. * Sets edge distortion to 0
  71230. */
  71231. disableEdgeDistortion(): void;
  71232. /**
  71233. * Sets the FocusDistance amount
  71234. * @param amount amount of FocusDistance
  71235. */
  71236. setFocusDistance(amount: number): void;
  71237. /**
  71238. * Disables depth of field
  71239. */
  71240. disableDepthOfField(): void;
  71241. /**
  71242. * Sets the Aperture amount
  71243. * @param amount amount of Aperture
  71244. */
  71245. setAperture(amount: number): void;
  71246. /**
  71247. * Sets the DarkenOutOfFocus amount
  71248. * @param amount amount of DarkenOutOfFocus
  71249. */
  71250. setDarkenOutOfFocus(amount: number): void;
  71251. private _pentagonBokehIsEnabled;
  71252. /**
  71253. * Creates a pentagon bokeh effect
  71254. */
  71255. enablePentagonBokeh(): void;
  71256. /**
  71257. * Disables the pentagon bokeh effect
  71258. */
  71259. disablePentagonBokeh(): void;
  71260. /**
  71261. * Enables noise blur
  71262. */
  71263. enableNoiseBlur(): void;
  71264. /**
  71265. * Disables noise blur
  71266. */
  71267. disableNoiseBlur(): void;
  71268. /**
  71269. * Sets the HighlightsGain amount
  71270. * @param amount amount of HighlightsGain
  71271. */
  71272. setHighlightsGain(amount: number): void;
  71273. /**
  71274. * Sets the HighlightsThreshold amount
  71275. * @param amount amount of HighlightsThreshold
  71276. */
  71277. setHighlightsThreshold(amount: number): void;
  71278. /**
  71279. * Disables highlights
  71280. */
  71281. disableHighlights(): void;
  71282. /**
  71283. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71284. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71285. */
  71286. dispose(disableDepthRender?: boolean): void;
  71287. private _createChromaticAberrationPostProcess;
  71288. private _createHighlightsPostProcess;
  71289. private _createDepthOfFieldPostProcess;
  71290. private _createGrainTexture;
  71291. }
  71292. }
  71293. declare module "babylonjs/Shaders/ssao2.fragment" {
  71294. /** @hidden */
  71295. export var ssao2PixelShader: {
  71296. name: string;
  71297. shader: string;
  71298. };
  71299. }
  71300. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71301. /** @hidden */
  71302. export var ssaoCombinePixelShader: {
  71303. name: string;
  71304. shader: string;
  71305. };
  71306. }
  71307. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71308. import { Camera } from "babylonjs/Cameras/camera";
  71309. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71310. import { Scene } from "babylonjs/scene";
  71311. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71312. import "babylonjs/Shaders/ssao2.fragment";
  71313. import "babylonjs/Shaders/ssaoCombine.fragment";
  71314. /**
  71315. * Render pipeline to produce ssao effect
  71316. */
  71317. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71318. /**
  71319. * @ignore
  71320. * The PassPostProcess id in the pipeline that contains the original scene color
  71321. */
  71322. SSAOOriginalSceneColorEffect: string;
  71323. /**
  71324. * @ignore
  71325. * The SSAO PostProcess id in the pipeline
  71326. */
  71327. SSAORenderEffect: string;
  71328. /**
  71329. * @ignore
  71330. * The horizontal blur PostProcess id in the pipeline
  71331. */
  71332. SSAOBlurHRenderEffect: string;
  71333. /**
  71334. * @ignore
  71335. * The vertical blur PostProcess id in the pipeline
  71336. */
  71337. SSAOBlurVRenderEffect: string;
  71338. /**
  71339. * @ignore
  71340. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71341. */
  71342. SSAOCombineRenderEffect: string;
  71343. /**
  71344. * The output strength of the SSAO post-process. Default value is 1.0.
  71345. */
  71346. totalStrength: number;
  71347. /**
  71348. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71349. */
  71350. maxZ: number;
  71351. /**
  71352. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71353. */
  71354. minZAspect: number;
  71355. private _samples;
  71356. /**
  71357. * Number of samples used for the SSAO calculations. Default value is 8
  71358. */
  71359. set samples(n: number);
  71360. get samples(): number;
  71361. private _textureSamples;
  71362. /**
  71363. * Number of samples to use for antialiasing
  71364. */
  71365. set textureSamples(n: number);
  71366. get textureSamples(): number;
  71367. /**
  71368. * Ratio object used for SSAO ratio and blur ratio
  71369. */
  71370. private _ratio;
  71371. /**
  71372. * Dynamically generated sphere sampler.
  71373. */
  71374. private _sampleSphere;
  71375. /**
  71376. * Blur filter offsets
  71377. */
  71378. private _samplerOffsets;
  71379. private _expensiveBlur;
  71380. /**
  71381. * If bilateral blur should be used
  71382. */
  71383. set expensiveBlur(b: boolean);
  71384. get expensiveBlur(): boolean;
  71385. /**
  71386. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71387. */
  71388. radius: number;
  71389. /**
  71390. * The base color of the SSAO post-process
  71391. * The final result is "base + ssao" between [0, 1]
  71392. */
  71393. base: number;
  71394. /**
  71395. * Support test.
  71396. */
  71397. static get IsSupported(): boolean;
  71398. private _scene;
  71399. private _depthTexture;
  71400. private _normalTexture;
  71401. private _randomTexture;
  71402. private _originalColorPostProcess;
  71403. private _ssaoPostProcess;
  71404. private _blurHPostProcess;
  71405. private _blurVPostProcess;
  71406. private _ssaoCombinePostProcess;
  71407. /**
  71408. * Gets active scene
  71409. */
  71410. get scene(): Scene;
  71411. /**
  71412. * @constructor
  71413. * @param name The rendering pipeline name
  71414. * @param scene The scene linked to this pipeline
  71415. * @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 }
  71416. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71417. */
  71418. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71419. /**
  71420. * Get the class name
  71421. * @returns "SSAO2RenderingPipeline"
  71422. */
  71423. getClassName(): string;
  71424. /**
  71425. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71426. */
  71427. dispose(disableGeometryBufferRenderer?: boolean): void;
  71428. private _createBlurPostProcess;
  71429. /** @hidden */
  71430. _rebuild(): void;
  71431. private _bits;
  71432. private _radicalInverse_VdC;
  71433. private _hammersley;
  71434. private _hemisphereSample_uniform;
  71435. private _generateHemisphere;
  71436. private _createSSAOPostProcess;
  71437. private _createSSAOCombinePostProcess;
  71438. private _createRandomTexture;
  71439. /**
  71440. * Serialize the rendering pipeline (Used when exporting)
  71441. * @returns the serialized object
  71442. */
  71443. serialize(): any;
  71444. /**
  71445. * Parse the serialized pipeline
  71446. * @param source Source pipeline.
  71447. * @param scene The scene to load the pipeline to.
  71448. * @param rootUrl The URL of the serialized pipeline.
  71449. * @returns An instantiated pipeline from the serialized object.
  71450. */
  71451. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71452. }
  71453. }
  71454. declare module "babylonjs/Shaders/ssao.fragment" {
  71455. /** @hidden */
  71456. export var ssaoPixelShader: {
  71457. name: string;
  71458. shader: string;
  71459. };
  71460. }
  71461. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71462. import { Camera } from "babylonjs/Cameras/camera";
  71463. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71464. import { Scene } from "babylonjs/scene";
  71465. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71466. import "babylonjs/Shaders/ssao.fragment";
  71467. import "babylonjs/Shaders/ssaoCombine.fragment";
  71468. /**
  71469. * Render pipeline to produce ssao effect
  71470. */
  71471. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71472. /**
  71473. * @ignore
  71474. * The PassPostProcess id in the pipeline that contains the original scene color
  71475. */
  71476. SSAOOriginalSceneColorEffect: string;
  71477. /**
  71478. * @ignore
  71479. * The SSAO PostProcess id in the pipeline
  71480. */
  71481. SSAORenderEffect: string;
  71482. /**
  71483. * @ignore
  71484. * The horizontal blur PostProcess id in the pipeline
  71485. */
  71486. SSAOBlurHRenderEffect: string;
  71487. /**
  71488. * @ignore
  71489. * The vertical blur PostProcess id in the pipeline
  71490. */
  71491. SSAOBlurVRenderEffect: string;
  71492. /**
  71493. * @ignore
  71494. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71495. */
  71496. SSAOCombineRenderEffect: string;
  71497. /**
  71498. * The output strength of the SSAO post-process. Default value is 1.0.
  71499. */
  71500. totalStrength: number;
  71501. /**
  71502. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71503. */
  71504. radius: number;
  71505. /**
  71506. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71507. * Must not be equal to fallOff and superior to fallOff.
  71508. * Default value is 0.0075
  71509. */
  71510. area: number;
  71511. /**
  71512. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71513. * Must not be equal to area and inferior to area.
  71514. * Default value is 0.000001
  71515. */
  71516. fallOff: number;
  71517. /**
  71518. * The base color of the SSAO post-process
  71519. * The final result is "base + ssao" between [0, 1]
  71520. */
  71521. base: number;
  71522. private _scene;
  71523. private _depthTexture;
  71524. private _randomTexture;
  71525. private _originalColorPostProcess;
  71526. private _ssaoPostProcess;
  71527. private _blurHPostProcess;
  71528. private _blurVPostProcess;
  71529. private _ssaoCombinePostProcess;
  71530. private _firstUpdate;
  71531. /**
  71532. * Gets active scene
  71533. */
  71534. get scene(): Scene;
  71535. /**
  71536. * @constructor
  71537. * @param name - The rendering pipeline name
  71538. * @param scene - The scene linked to this pipeline
  71539. * @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 }
  71540. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71541. */
  71542. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71543. /**
  71544. * Get the class name
  71545. * @returns "SSAORenderingPipeline"
  71546. */
  71547. getClassName(): string;
  71548. /**
  71549. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71550. */
  71551. dispose(disableDepthRender?: boolean): void;
  71552. private _createBlurPostProcess;
  71553. /** @hidden */
  71554. _rebuild(): void;
  71555. private _createSSAOPostProcess;
  71556. private _createSSAOCombinePostProcess;
  71557. private _createRandomTexture;
  71558. }
  71559. }
  71560. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71561. /** @hidden */
  71562. export var screenSpaceReflectionPixelShader: {
  71563. name: string;
  71564. shader: string;
  71565. };
  71566. }
  71567. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71568. import { Nullable } from "babylonjs/types";
  71569. import { Camera } from "babylonjs/Cameras/camera";
  71570. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71571. import { Scene } from "babylonjs/scene";
  71572. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71573. import { Engine } from "babylonjs/Engines/engine";
  71574. /**
  71575. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71576. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71577. */
  71578. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71579. /**
  71580. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71581. */
  71582. threshold: number;
  71583. /**
  71584. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71585. */
  71586. strength: number;
  71587. /**
  71588. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71589. */
  71590. reflectionSpecularFalloffExponent: number;
  71591. /**
  71592. * 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]
  71593. */
  71594. step: number;
  71595. /**
  71596. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71597. */
  71598. roughnessFactor: number;
  71599. private _geometryBufferRenderer;
  71600. private _enableSmoothReflections;
  71601. private _reflectionSamples;
  71602. private _smoothSteps;
  71603. /**
  71604. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71605. * @param name The name of the effect.
  71606. * @param scene The scene containing the objects to calculate reflections.
  71607. * @param options The required width/height ratio to downsize to before computing the render pass.
  71608. * @param camera The camera to apply the render pass to.
  71609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71610. * @param engine The engine which the post process will be applied. (default: current engine)
  71611. * @param reusable If the post process can be reused on the same frame. (default: false)
  71612. * @param textureType Type of textures used when performing the post process. (default: 0)
  71613. * @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)
  71614. */
  71615. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71616. /**
  71617. * Gets wether or not smoothing reflections is enabled.
  71618. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71619. */
  71620. get enableSmoothReflections(): boolean;
  71621. /**
  71622. * Sets wether or not smoothing reflections is enabled.
  71623. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71624. */
  71625. set enableSmoothReflections(enabled: boolean);
  71626. /**
  71627. * Gets the number of samples taken while computing reflections. More samples count is high,
  71628. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71629. */
  71630. get reflectionSamples(): number;
  71631. /**
  71632. * Sets the number of samples taken while computing reflections. More samples count is high,
  71633. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71634. */
  71635. set reflectionSamples(samples: number);
  71636. /**
  71637. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71638. * more the post-process will require GPU power and can generate a drop in FPS.
  71639. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71640. */
  71641. get smoothSteps(): number;
  71642. set smoothSteps(steps: number);
  71643. private _updateEffectDefines;
  71644. }
  71645. }
  71646. declare module "babylonjs/Shaders/standard.fragment" {
  71647. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71648. /** @hidden */
  71649. export var standardPixelShader: {
  71650. name: string;
  71651. shader: string;
  71652. };
  71653. }
  71654. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71655. import { Nullable } from "babylonjs/types";
  71656. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71657. import { Camera } from "babylonjs/Cameras/camera";
  71658. import { Texture } from "babylonjs/Materials/Textures/texture";
  71659. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71660. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71661. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71662. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71663. import { IDisposable } from "babylonjs/scene";
  71664. import { SpotLight } from "babylonjs/Lights/spotLight";
  71665. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71666. import { Scene } from "babylonjs/scene";
  71667. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71668. import { Animation } from "babylonjs/Animations/animation";
  71669. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71670. import "babylonjs/Shaders/standard.fragment";
  71671. /**
  71672. * Standard rendering pipeline
  71673. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71674. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71675. */
  71676. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71677. /**
  71678. * Public members
  71679. */
  71680. /**
  71681. * Post-process which contains the original scene color before the pipeline applies all the effects
  71682. */
  71683. originalPostProcess: Nullable<PostProcess>;
  71684. /**
  71685. * Post-process used to down scale an image x4
  71686. */
  71687. downSampleX4PostProcess: Nullable<PostProcess>;
  71688. /**
  71689. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71690. */
  71691. brightPassPostProcess: Nullable<PostProcess>;
  71692. /**
  71693. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71694. */
  71695. blurHPostProcesses: PostProcess[];
  71696. /**
  71697. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71698. */
  71699. blurVPostProcesses: PostProcess[];
  71700. /**
  71701. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71702. */
  71703. textureAdderPostProcess: Nullable<PostProcess>;
  71704. /**
  71705. * Post-process used to create volumetric lighting effect
  71706. */
  71707. volumetricLightPostProcess: Nullable<PostProcess>;
  71708. /**
  71709. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71710. */
  71711. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71712. /**
  71713. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71714. */
  71715. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71716. /**
  71717. * Post-process used to merge the volumetric light effect and the real scene color
  71718. */
  71719. volumetricLightMergePostProces: Nullable<PostProcess>;
  71720. /**
  71721. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71722. */
  71723. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71724. /**
  71725. * Base post-process used to calculate the average luminance of the final image for HDR
  71726. */
  71727. luminancePostProcess: Nullable<PostProcess>;
  71728. /**
  71729. * Post-processes used to create down sample post-processes in order to get
  71730. * the average luminance of the final image for HDR
  71731. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71732. */
  71733. luminanceDownSamplePostProcesses: PostProcess[];
  71734. /**
  71735. * Post-process used to create a HDR effect (light adaptation)
  71736. */
  71737. hdrPostProcess: Nullable<PostProcess>;
  71738. /**
  71739. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71740. */
  71741. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71742. /**
  71743. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71744. */
  71745. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71746. /**
  71747. * Post-process used to merge the final HDR post-process and the real scene color
  71748. */
  71749. hdrFinalPostProcess: Nullable<PostProcess>;
  71750. /**
  71751. * Post-process used to create a lens flare effect
  71752. */
  71753. lensFlarePostProcess: Nullable<PostProcess>;
  71754. /**
  71755. * Post-process that merges the result of the lens flare post-process and the real scene color
  71756. */
  71757. lensFlareComposePostProcess: Nullable<PostProcess>;
  71758. /**
  71759. * Post-process used to create a motion blur effect
  71760. */
  71761. motionBlurPostProcess: Nullable<PostProcess>;
  71762. /**
  71763. * Post-process used to create a depth of field effect
  71764. */
  71765. depthOfFieldPostProcess: Nullable<PostProcess>;
  71766. /**
  71767. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71768. */
  71769. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71770. /**
  71771. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71772. */
  71773. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71774. /**
  71775. * Represents the brightness threshold in order to configure the illuminated surfaces
  71776. */
  71777. brightThreshold: number;
  71778. /**
  71779. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71780. */
  71781. blurWidth: number;
  71782. /**
  71783. * Sets if the blur for highlighted surfaces must be only horizontal
  71784. */
  71785. horizontalBlur: boolean;
  71786. /**
  71787. * Gets the overall exposure used by the pipeline
  71788. */
  71789. get exposure(): number;
  71790. /**
  71791. * Sets the overall exposure used by the pipeline
  71792. */
  71793. set exposure(value: number);
  71794. /**
  71795. * Texture used typically to simulate "dirty" on camera lens
  71796. */
  71797. lensTexture: Nullable<Texture>;
  71798. /**
  71799. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71800. */
  71801. volumetricLightCoefficient: number;
  71802. /**
  71803. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71804. */
  71805. volumetricLightPower: number;
  71806. /**
  71807. * Used the set the blur intensity to smooth the volumetric lights
  71808. */
  71809. volumetricLightBlurScale: number;
  71810. /**
  71811. * Light (spot or directional) used to generate the volumetric lights rays
  71812. * The source light must have a shadow generate so the pipeline can get its
  71813. * depth map
  71814. */
  71815. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71816. /**
  71817. * For eye adaptation, represents the minimum luminance the eye can see
  71818. */
  71819. hdrMinimumLuminance: number;
  71820. /**
  71821. * For eye adaptation, represents the decrease luminance speed
  71822. */
  71823. hdrDecreaseRate: number;
  71824. /**
  71825. * For eye adaptation, represents the increase luminance speed
  71826. */
  71827. hdrIncreaseRate: number;
  71828. /**
  71829. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71830. */
  71831. get hdrAutoExposure(): boolean;
  71832. /**
  71833. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71834. */
  71835. set hdrAutoExposure(value: boolean);
  71836. /**
  71837. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71838. */
  71839. lensColorTexture: Nullable<Texture>;
  71840. /**
  71841. * The overall strengh for the lens flare effect
  71842. */
  71843. lensFlareStrength: number;
  71844. /**
  71845. * Dispersion coefficient for lens flare ghosts
  71846. */
  71847. lensFlareGhostDispersal: number;
  71848. /**
  71849. * Main lens flare halo width
  71850. */
  71851. lensFlareHaloWidth: number;
  71852. /**
  71853. * Based on the lens distortion effect, defines how much the lens flare result
  71854. * is distorted
  71855. */
  71856. lensFlareDistortionStrength: number;
  71857. /**
  71858. * Configures the blur intensity used for for lens flare (halo)
  71859. */
  71860. lensFlareBlurWidth: number;
  71861. /**
  71862. * Lens star texture must be used to simulate rays on the flares and is available
  71863. * in the documentation
  71864. */
  71865. lensStarTexture: Nullable<Texture>;
  71866. /**
  71867. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71868. * flare effect by taking account of the dirt texture
  71869. */
  71870. lensFlareDirtTexture: Nullable<Texture>;
  71871. /**
  71872. * Represents the focal length for the depth of field effect
  71873. */
  71874. depthOfFieldDistance: number;
  71875. /**
  71876. * Represents the blur intensity for the blurred part of the depth of field effect
  71877. */
  71878. depthOfFieldBlurWidth: number;
  71879. /**
  71880. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71881. */
  71882. get motionStrength(): number;
  71883. /**
  71884. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71885. */
  71886. set motionStrength(strength: number);
  71887. /**
  71888. * Gets wether or not the motion blur post-process is object based or screen based.
  71889. */
  71890. get objectBasedMotionBlur(): boolean;
  71891. /**
  71892. * Sets wether or not the motion blur post-process should be object based or screen based
  71893. */
  71894. set objectBasedMotionBlur(value: boolean);
  71895. /**
  71896. * List of animations for the pipeline (IAnimatable implementation)
  71897. */
  71898. animations: Animation[];
  71899. /**
  71900. * Private members
  71901. */
  71902. private _scene;
  71903. private _currentDepthOfFieldSource;
  71904. private _basePostProcess;
  71905. private _fixedExposure;
  71906. private _currentExposure;
  71907. private _hdrAutoExposure;
  71908. private _hdrCurrentLuminance;
  71909. private _motionStrength;
  71910. private _isObjectBasedMotionBlur;
  71911. private _floatTextureType;
  71912. private _camerasToBeAttached;
  71913. private _ratio;
  71914. private _bloomEnabled;
  71915. private _depthOfFieldEnabled;
  71916. private _vlsEnabled;
  71917. private _lensFlareEnabled;
  71918. private _hdrEnabled;
  71919. private _motionBlurEnabled;
  71920. private _fxaaEnabled;
  71921. private _screenSpaceReflectionsEnabled;
  71922. private _motionBlurSamples;
  71923. private _volumetricLightStepsCount;
  71924. private _samples;
  71925. /**
  71926. * @ignore
  71927. * Specifies if the bloom pipeline is enabled
  71928. */
  71929. get BloomEnabled(): boolean;
  71930. set BloomEnabled(enabled: boolean);
  71931. /**
  71932. * @ignore
  71933. * Specifies if the depth of field pipeline is enabed
  71934. */
  71935. get DepthOfFieldEnabled(): boolean;
  71936. set DepthOfFieldEnabled(enabled: boolean);
  71937. /**
  71938. * @ignore
  71939. * Specifies if the lens flare pipeline is enabed
  71940. */
  71941. get LensFlareEnabled(): boolean;
  71942. set LensFlareEnabled(enabled: boolean);
  71943. /**
  71944. * @ignore
  71945. * Specifies if the HDR pipeline is enabled
  71946. */
  71947. get HDREnabled(): boolean;
  71948. set HDREnabled(enabled: boolean);
  71949. /**
  71950. * @ignore
  71951. * Specifies if the volumetric lights scattering effect is enabled
  71952. */
  71953. get VLSEnabled(): boolean;
  71954. set VLSEnabled(enabled: boolean);
  71955. /**
  71956. * @ignore
  71957. * Specifies if the motion blur effect is enabled
  71958. */
  71959. get MotionBlurEnabled(): boolean;
  71960. set MotionBlurEnabled(enabled: boolean);
  71961. /**
  71962. * Specifies if anti-aliasing is enabled
  71963. */
  71964. get fxaaEnabled(): boolean;
  71965. set fxaaEnabled(enabled: boolean);
  71966. /**
  71967. * Specifies if screen space reflections are enabled.
  71968. */
  71969. get screenSpaceReflectionsEnabled(): boolean;
  71970. set screenSpaceReflectionsEnabled(enabled: boolean);
  71971. /**
  71972. * Specifies the number of steps used to calculate the volumetric lights
  71973. * Typically in interval [50, 200]
  71974. */
  71975. get volumetricLightStepsCount(): number;
  71976. set volumetricLightStepsCount(count: number);
  71977. /**
  71978. * Specifies the number of samples used for the motion blur effect
  71979. * Typically in interval [16, 64]
  71980. */
  71981. get motionBlurSamples(): number;
  71982. set motionBlurSamples(samples: number);
  71983. /**
  71984. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71985. */
  71986. get samples(): number;
  71987. set samples(sampleCount: number);
  71988. /**
  71989. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71990. * @constructor
  71991. * @param name The rendering pipeline name
  71992. * @param scene The scene linked to this pipeline
  71993. * @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)
  71994. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71995. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71996. */
  71997. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71998. private _buildPipeline;
  71999. private _createDownSampleX4PostProcess;
  72000. private _createBrightPassPostProcess;
  72001. private _createBlurPostProcesses;
  72002. private _createTextureAdderPostProcess;
  72003. private _createVolumetricLightPostProcess;
  72004. private _createLuminancePostProcesses;
  72005. private _createHdrPostProcess;
  72006. private _createLensFlarePostProcess;
  72007. private _createDepthOfFieldPostProcess;
  72008. private _createMotionBlurPostProcess;
  72009. private _getDepthTexture;
  72010. private _disposePostProcesses;
  72011. /**
  72012. * Dispose of the pipeline and stop all post processes
  72013. */
  72014. dispose(): void;
  72015. /**
  72016. * Serialize the rendering pipeline (Used when exporting)
  72017. * @returns the serialized object
  72018. */
  72019. serialize(): any;
  72020. /**
  72021. * Parse the serialized pipeline
  72022. * @param source Source pipeline.
  72023. * @param scene The scene to load the pipeline to.
  72024. * @param rootUrl The URL of the serialized pipeline.
  72025. * @returns An instantiated pipeline from the serialized object.
  72026. */
  72027. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72028. /**
  72029. * Luminance steps
  72030. */
  72031. static LuminanceSteps: number;
  72032. }
  72033. }
  72034. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72035. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72036. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72037. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72038. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72039. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72040. }
  72041. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72042. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72043. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72044. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72045. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72046. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72047. }
  72048. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72049. /** @hidden */
  72050. export var stereoscopicInterlacePixelShader: {
  72051. name: string;
  72052. shader: string;
  72053. };
  72054. }
  72055. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72056. import { Camera } from "babylonjs/Cameras/camera";
  72057. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72058. import { Engine } from "babylonjs/Engines/engine";
  72059. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72060. /**
  72061. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72062. */
  72063. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72064. private _stepSize;
  72065. private _passedProcess;
  72066. /**
  72067. * Initializes a StereoscopicInterlacePostProcessI
  72068. * @param name The name of the effect.
  72069. * @param rigCameras The rig cameras to be appled to the post process
  72070. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72071. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72073. * @param engine The engine which the post process will be applied. (default: current engine)
  72074. * @param reusable If the post process can be reused on the same frame. (default: false)
  72075. */
  72076. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72077. }
  72078. /**
  72079. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72080. */
  72081. export class StereoscopicInterlacePostProcess extends PostProcess {
  72082. private _stepSize;
  72083. private _passedProcess;
  72084. /**
  72085. * Initializes a StereoscopicInterlacePostProcess
  72086. * @param name The name of the effect.
  72087. * @param rigCameras The rig cameras to be appled to the post process
  72088. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72090. * @param engine The engine which the post process will be applied. (default: current engine)
  72091. * @param reusable If the post process can be reused on the same frame. (default: false)
  72092. */
  72093. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72094. }
  72095. }
  72096. declare module "babylonjs/Shaders/tonemap.fragment" {
  72097. /** @hidden */
  72098. export var tonemapPixelShader: {
  72099. name: string;
  72100. shader: string;
  72101. };
  72102. }
  72103. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72104. import { Camera } from "babylonjs/Cameras/camera";
  72105. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72106. import "babylonjs/Shaders/tonemap.fragment";
  72107. import { Engine } from "babylonjs/Engines/engine";
  72108. /** Defines operator used for tonemapping */
  72109. export enum TonemappingOperator {
  72110. /** Hable */
  72111. Hable = 0,
  72112. /** Reinhard */
  72113. Reinhard = 1,
  72114. /** HejiDawson */
  72115. HejiDawson = 2,
  72116. /** Photographic */
  72117. Photographic = 3
  72118. }
  72119. /**
  72120. * Defines a post process to apply tone mapping
  72121. */
  72122. export class TonemapPostProcess extends PostProcess {
  72123. private _operator;
  72124. /** Defines the required exposure adjustement */
  72125. exposureAdjustment: number;
  72126. /**
  72127. * Creates a new TonemapPostProcess
  72128. * @param name defines the name of the postprocess
  72129. * @param _operator defines the operator to use
  72130. * @param exposureAdjustment defines the required exposure adjustement
  72131. * @param camera defines the camera to use (can be null)
  72132. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72133. * @param engine defines the hosting engine (can be ignore if camera is set)
  72134. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72135. */
  72136. constructor(name: string, _operator: TonemappingOperator,
  72137. /** Defines the required exposure adjustement */
  72138. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72139. }
  72140. }
  72141. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72142. /** @hidden */
  72143. export var volumetricLightScatteringPixelShader: {
  72144. name: string;
  72145. shader: string;
  72146. };
  72147. }
  72148. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72149. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72150. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72151. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72152. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72154. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72155. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72156. /** @hidden */
  72157. export var volumetricLightScatteringPassVertexShader: {
  72158. name: string;
  72159. shader: string;
  72160. };
  72161. }
  72162. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72163. /** @hidden */
  72164. export var volumetricLightScatteringPassPixelShader: {
  72165. name: string;
  72166. shader: string;
  72167. };
  72168. }
  72169. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72170. import { Vector3 } from "babylonjs/Maths/math.vector";
  72171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72172. import { Mesh } from "babylonjs/Meshes/mesh";
  72173. import { Camera } from "babylonjs/Cameras/camera";
  72174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72175. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72176. import { Scene } from "babylonjs/scene";
  72177. import "babylonjs/Meshes/Builders/planeBuilder";
  72178. import "babylonjs/Shaders/depth.vertex";
  72179. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72180. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72181. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72182. import { Engine } from "babylonjs/Engines/engine";
  72183. /**
  72184. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72185. */
  72186. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72187. private _volumetricLightScatteringPass;
  72188. private _volumetricLightScatteringRTT;
  72189. private _viewPort;
  72190. private _screenCoordinates;
  72191. private _cachedDefines;
  72192. /**
  72193. * If not undefined, the mesh position is computed from the attached node position
  72194. */
  72195. attachedNode: {
  72196. position: Vector3;
  72197. };
  72198. /**
  72199. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72200. */
  72201. customMeshPosition: Vector3;
  72202. /**
  72203. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72204. */
  72205. useCustomMeshPosition: boolean;
  72206. /**
  72207. * If the post-process should inverse the light scattering direction
  72208. */
  72209. invert: boolean;
  72210. /**
  72211. * The internal mesh used by the post-process
  72212. */
  72213. mesh: Mesh;
  72214. /**
  72215. * @hidden
  72216. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72217. */
  72218. get useDiffuseColor(): boolean;
  72219. set useDiffuseColor(useDiffuseColor: boolean);
  72220. /**
  72221. * Array containing the excluded meshes not rendered in the internal pass
  72222. */
  72223. excludedMeshes: AbstractMesh[];
  72224. /**
  72225. * Controls the overall intensity of the post-process
  72226. */
  72227. exposure: number;
  72228. /**
  72229. * Dissipates each sample's contribution in range [0, 1]
  72230. */
  72231. decay: number;
  72232. /**
  72233. * Controls the overall intensity of each sample
  72234. */
  72235. weight: number;
  72236. /**
  72237. * Controls the density of each sample
  72238. */
  72239. density: number;
  72240. /**
  72241. * @constructor
  72242. * @param name The post-process name
  72243. * @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)
  72244. * @param camera The camera that the post-process will be attached to
  72245. * @param mesh The mesh used to create the light scattering
  72246. * @param samples The post-process quality, default 100
  72247. * @param samplingModeThe post-process filtering mode
  72248. * @param engine The babylon engine
  72249. * @param reusable If the post-process is reusable
  72250. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72251. */
  72252. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72253. /**
  72254. * Returns the string "VolumetricLightScatteringPostProcess"
  72255. * @returns "VolumetricLightScatteringPostProcess"
  72256. */
  72257. getClassName(): string;
  72258. private _isReady;
  72259. /**
  72260. * Sets the new light position for light scattering effect
  72261. * @param position The new custom light position
  72262. */
  72263. setCustomMeshPosition(position: Vector3): void;
  72264. /**
  72265. * Returns the light position for light scattering effect
  72266. * @return Vector3 The custom light position
  72267. */
  72268. getCustomMeshPosition(): Vector3;
  72269. /**
  72270. * Disposes the internal assets and detaches the post-process from the camera
  72271. */
  72272. dispose(camera: Camera): void;
  72273. /**
  72274. * Returns the render target texture used by the post-process
  72275. * @return the render target texture used by the post-process
  72276. */
  72277. getPass(): RenderTargetTexture;
  72278. private _meshExcluded;
  72279. private _createPass;
  72280. private _updateMeshScreenCoordinates;
  72281. /**
  72282. * Creates a default mesh for the Volumeric Light Scattering post-process
  72283. * @param name The mesh name
  72284. * @param scene The scene where to create the mesh
  72285. * @return the default mesh
  72286. */
  72287. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72288. }
  72289. }
  72290. declare module "babylonjs/PostProcesses/index" {
  72291. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72292. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72293. export * from "babylonjs/PostProcesses/bloomEffect";
  72294. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72295. export * from "babylonjs/PostProcesses/blurPostProcess";
  72296. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72297. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72298. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72299. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72300. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72301. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72302. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72303. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72304. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72305. export * from "babylonjs/PostProcesses/filterPostProcess";
  72306. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72307. export * from "babylonjs/PostProcesses/grainPostProcess";
  72308. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72309. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72310. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72311. export * from "babylonjs/PostProcesses/passPostProcess";
  72312. export * from "babylonjs/PostProcesses/postProcess";
  72313. export * from "babylonjs/PostProcesses/postProcessManager";
  72314. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72315. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72316. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72317. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72318. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72319. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72320. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72321. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72322. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72323. }
  72324. declare module "babylonjs/Probes/index" {
  72325. export * from "babylonjs/Probes/reflectionProbe";
  72326. }
  72327. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72328. import { Scene } from "babylonjs/scene";
  72329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72330. import { SmartArray } from "babylonjs/Misc/smartArray";
  72331. import { ISceneComponent } from "babylonjs/sceneComponent";
  72332. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72333. import "babylonjs/Meshes/Builders/boxBuilder";
  72334. import "babylonjs/Shaders/color.fragment";
  72335. import "babylonjs/Shaders/color.vertex";
  72336. import { Color3 } from "babylonjs/Maths/math.color";
  72337. module "babylonjs/scene" {
  72338. interface Scene {
  72339. /** @hidden (Backing field) */
  72340. _boundingBoxRenderer: BoundingBoxRenderer;
  72341. /** @hidden (Backing field) */
  72342. _forceShowBoundingBoxes: boolean;
  72343. /**
  72344. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72345. */
  72346. forceShowBoundingBoxes: boolean;
  72347. /**
  72348. * Gets the bounding box renderer associated with the scene
  72349. * @returns a BoundingBoxRenderer
  72350. */
  72351. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72352. }
  72353. }
  72354. module "babylonjs/Meshes/abstractMesh" {
  72355. interface AbstractMesh {
  72356. /** @hidden (Backing field) */
  72357. _showBoundingBox: boolean;
  72358. /**
  72359. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72360. */
  72361. showBoundingBox: boolean;
  72362. }
  72363. }
  72364. /**
  72365. * Component responsible of rendering the bounding box of the meshes in a scene.
  72366. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72367. */
  72368. export class BoundingBoxRenderer implements ISceneComponent {
  72369. /**
  72370. * The component name helpfull to identify the component in the list of scene components.
  72371. */
  72372. readonly name: string;
  72373. /**
  72374. * The scene the component belongs to.
  72375. */
  72376. scene: Scene;
  72377. /**
  72378. * Color of the bounding box lines placed in front of an object
  72379. */
  72380. frontColor: Color3;
  72381. /**
  72382. * Color of the bounding box lines placed behind an object
  72383. */
  72384. backColor: Color3;
  72385. /**
  72386. * Defines if the renderer should show the back lines or not
  72387. */
  72388. showBackLines: boolean;
  72389. /**
  72390. * @hidden
  72391. */
  72392. renderList: SmartArray<BoundingBox>;
  72393. private _colorShader;
  72394. private _vertexBuffers;
  72395. private _indexBuffer;
  72396. private _fillIndexBuffer;
  72397. private _fillIndexData;
  72398. /**
  72399. * Instantiates a new bounding box renderer in a scene.
  72400. * @param scene the scene the renderer renders in
  72401. */
  72402. constructor(scene: Scene);
  72403. /**
  72404. * Registers the component in a given scene
  72405. */
  72406. register(): void;
  72407. private _evaluateSubMesh;
  72408. private _activeMesh;
  72409. private _prepareRessources;
  72410. private _createIndexBuffer;
  72411. /**
  72412. * Rebuilds the elements related to this component in case of
  72413. * context lost for instance.
  72414. */
  72415. rebuild(): void;
  72416. /**
  72417. * @hidden
  72418. */
  72419. reset(): void;
  72420. /**
  72421. * Render the bounding boxes of a specific rendering group
  72422. * @param renderingGroupId defines the rendering group to render
  72423. */
  72424. render(renderingGroupId: number): void;
  72425. /**
  72426. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72427. * @param mesh Define the mesh to render the occlusion bounding box for
  72428. */
  72429. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72430. /**
  72431. * Dispose and release the resources attached to this renderer.
  72432. */
  72433. dispose(): void;
  72434. }
  72435. }
  72436. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72437. import { Nullable } from "babylonjs/types";
  72438. import { Scene } from "babylonjs/scene";
  72439. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72440. import { Camera } from "babylonjs/Cameras/camera";
  72441. import { ISceneComponent } from "babylonjs/sceneComponent";
  72442. module "babylonjs/scene" {
  72443. interface Scene {
  72444. /** @hidden (Backing field) */
  72445. _depthRenderer: {
  72446. [id: string]: DepthRenderer;
  72447. };
  72448. /**
  72449. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72450. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72451. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72452. * @returns the created depth renderer
  72453. */
  72454. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72455. /**
  72456. * Disables a depth renderer for a given camera
  72457. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72458. */
  72459. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72460. }
  72461. }
  72462. /**
  72463. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72464. * in several rendering techniques.
  72465. */
  72466. export class DepthRendererSceneComponent implements ISceneComponent {
  72467. /**
  72468. * The component name helpfull to identify the component in the list of scene components.
  72469. */
  72470. readonly name: string;
  72471. /**
  72472. * The scene the component belongs to.
  72473. */
  72474. scene: Scene;
  72475. /**
  72476. * Creates a new instance of the component for the given scene
  72477. * @param scene Defines the scene to register the component in
  72478. */
  72479. constructor(scene: Scene);
  72480. /**
  72481. * Registers the component in a given scene
  72482. */
  72483. register(): void;
  72484. /**
  72485. * Rebuilds the elements related to this component in case of
  72486. * context lost for instance.
  72487. */
  72488. rebuild(): void;
  72489. /**
  72490. * Disposes the component and the associated ressources
  72491. */
  72492. dispose(): void;
  72493. private _gatherRenderTargets;
  72494. private _gatherActiveCameraRenderTargets;
  72495. }
  72496. }
  72497. declare module "babylonjs/Shaders/outline.fragment" {
  72498. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72499. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72500. /** @hidden */
  72501. export var outlinePixelShader: {
  72502. name: string;
  72503. shader: string;
  72504. };
  72505. }
  72506. declare module "babylonjs/Shaders/outline.vertex" {
  72507. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72510. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72511. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72515. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72516. /** @hidden */
  72517. export var outlineVertexShader: {
  72518. name: string;
  72519. shader: string;
  72520. };
  72521. }
  72522. declare module "babylonjs/Rendering/outlineRenderer" {
  72523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72524. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72525. import { Scene } from "babylonjs/scene";
  72526. import { ISceneComponent } from "babylonjs/sceneComponent";
  72527. import "babylonjs/Shaders/outline.fragment";
  72528. import "babylonjs/Shaders/outline.vertex";
  72529. module "babylonjs/scene" {
  72530. interface Scene {
  72531. /** @hidden */
  72532. _outlineRenderer: OutlineRenderer;
  72533. /**
  72534. * Gets the outline renderer associated with the scene
  72535. * @returns a OutlineRenderer
  72536. */
  72537. getOutlineRenderer(): OutlineRenderer;
  72538. }
  72539. }
  72540. module "babylonjs/Meshes/abstractMesh" {
  72541. interface AbstractMesh {
  72542. /** @hidden (Backing field) */
  72543. _renderOutline: boolean;
  72544. /**
  72545. * Gets or sets a boolean indicating if the outline must be rendered as well
  72546. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72547. */
  72548. renderOutline: boolean;
  72549. /** @hidden (Backing field) */
  72550. _renderOverlay: boolean;
  72551. /**
  72552. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72553. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72554. */
  72555. renderOverlay: boolean;
  72556. }
  72557. }
  72558. /**
  72559. * This class is responsible to draw bothe outline/overlay of meshes.
  72560. * It should not be used directly but through the available method on mesh.
  72561. */
  72562. export class OutlineRenderer implements ISceneComponent {
  72563. /**
  72564. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72565. */
  72566. private static _StencilReference;
  72567. /**
  72568. * The name of the component. Each component must have a unique name.
  72569. */
  72570. name: string;
  72571. /**
  72572. * The scene the component belongs to.
  72573. */
  72574. scene: Scene;
  72575. /**
  72576. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72577. */
  72578. zOffset: number;
  72579. private _engine;
  72580. private _effect;
  72581. private _cachedDefines;
  72582. private _savedDepthWrite;
  72583. /**
  72584. * Instantiates a new outline renderer. (There could be only one per scene).
  72585. * @param scene Defines the scene it belongs to
  72586. */
  72587. constructor(scene: Scene);
  72588. /**
  72589. * Register the component to one instance of a scene.
  72590. */
  72591. register(): void;
  72592. /**
  72593. * Rebuilds the elements related to this component in case of
  72594. * context lost for instance.
  72595. */
  72596. rebuild(): void;
  72597. /**
  72598. * Disposes the component and the associated ressources.
  72599. */
  72600. dispose(): void;
  72601. /**
  72602. * Renders the outline in the canvas.
  72603. * @param subMesh Defines the sumesh to render
  72604. * @param batch Defines the batch of meshes in case of instances
  72605. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72606. */
  72607. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72608. /**
  72609. * Returns whether or not the outline renderer is ready for a given submesh.
  72610. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72611. * @param subMesh Defines the submesh to check readyness for
  72612. * @param useInstances Defines wheter wee are trying to render instances or not
  72613. * @returns true if ready otherwise false
  72614. */
  72615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72616. private _beforeRenderingMesh;
  72617. private _afterRenderingMesh;
  72618. }
  72619. }
  72620. declare module "babylonjs/Rendering/index" {
  72621. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72622. export * from "babylonjs/Rendering/depthRenderer";
  72623. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72624. export * from "babylonjs/Rendering/edgesRenderer";
  72625. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72626. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72627. export * from "babylonjs/Rendering/outlineRenderer";
  72628. export * from "babylonjs/Rendering/renderingGroup";
  72629. export * from "babylonjs/Rendering/renderingManager";
  72630. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72631. }
  72632. declare module "babylonjs/Sprites/ISprites" {
  72633. /**
  72634. * Defines the basic options interface of a Sprite Frame Source Size.
  72635. */
  72636. export interface ISpriteJSONSpriteSourceSize {
  72637. /**
  72638. * number of the original width of the Frame
  72639. */
  72640. w: number;
  72641. /**
  72642. * number of the original height of the Frame
  72643. */
  72644. h: number;
  72645. }
  72646. /**
  72647. * Defines the basic options interface of a Sprite Frame Data.
  72648. */
  72649. export interface ISpriteJSONSpriteFrameData {
  72650. /**
  72651. * number of the x offset of the Frame
  72652. */
  72653. x: number;
  72654. /**
  72655. * number of the y offset of the Frame
  72656. */
  72657. y: number;
  72658. /**
  72659. * number of the width of the Frame
  72660. */
  72661. w: number;
  72662. /**
  72663. * number of the height of the Frame
  72664. */
  72665. h: number;
  72666. }
  72667. /**
  72668. * Defines the basic options interface of a JSON Sprite.
  72669. */
  72670. export interface ISpriteJSONSprite {
  72671. /**
  72672. * string name of the Frame
  72673. */
  72674. filename: string;
  72675. /**
  72676. * ISpriteJSONSpriteFrame basic object of the frame data
  72677. */
  72678. frame: ISpriteJSONSpriteFrameData;
  72679. /**
  72680. * boolean to flag is the frame was rotated.
  72681. */
  72682. rotated: boolean;
  72683. /**
  72684. * boolean to flag is the frame was trimmed.
  72685. */
  72686. trimmed: boolean;
  72687. /**
  72688. * ISpriteJSONSpriteFrame basic object of the source data
  72689. */
  72690. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72691. /**
  72692. * ISpriteJSONSpriteFrame basic object of the source data
  72693. */
  72694. sourceSize: ISpriteJSONSpriteSourceSize;
  72695. }
  72696. /**
  72697. * Defines the basic options interface of a JSON atlas.
  72698. */
  72699. export interface ISpriteJSONAtlas {
  72700. /**
  72701. * Array of objects that contain the frame data.
  72702. */
  72703. frames: Array<ISpriteJSONSprite>;
  72704. /**
  72705. * object basic object containing the sprite meta data.
  72706. */
  72707. meta?: object;
  72708. }
  72709. }
  72710. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72711. /** @hidden */
  72712. export var spriteMapPixelShader: {
  72713. name: string;
  72714. shader: string;
  72715. };
  72716. }
  72717. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72718. /** @hidden */
  72719. export var spriteMapVertexShader: {
  72720. name: string;
  72721. shader: string;
  72722. };
  72723. }
  72724. declare module "babylonjs/Sprites/spriteMap" {
  72725. import { IDisposable, Scene } from "babylonjs/scene";
  72726. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72727. import { Texture } from "babylonjs/Materials/Textures/texture";
  72728. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72729. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72730. import "babylonjs/Meshes/Builders/planeBuilder";
  72731. import "babylonjs/Shaders/spriteMap.fragment";
  72732. import "babylonjs/Shaders/spriteMap.vertex";
  72733. /**
  72734. * Defines the basic options interface of a SpriteMap
  72735. */
  72736. export interface ISpriteMapOptions {
  72737. /**
  72738. * Vector2 of the number of cells in the grid.
  72739. */
  72740. stageSize?: Vector2;
  72741. /**
  72742. * Vector2 of the size of the output plane in World Units.
  72743. */
  72744. outputSize?: Vector2;
  72745. /**
  72746. * Vector3 of the position of the output plane in World Units.
  72747. */
  72748. outputPosition?: Vector3;
  72749. /**
  72750. * Vector3 of the rotation of the output plane.
  72751. */
  72752. outputRotation?: Vector3;
  72753. /**
  72754. * number of layers that the system will reserve in resources.
  72755. */
  72756. layerCount?: number;
  72757. /**
  72758. * number of max animation frames a single cell will reserve in resources.
  72759. */
  72760. maxAnimationFrames?: number;
  72761. /**
  72762. * number cell index of the base tile when the system compiles.
  72763. */
  72764. baseTile?: number;
  72765. /**
  72766. * boolean flip the sprite after its been repositioned by the framing data.
  72767. */
  72768. flipU?: boolean;
  72769. /**
  72770. * Vector3 scalar of the global RGB values of the SpriteMap.
  72771. */
  72772. colorMultiply?: Vector3;
  72773. }
  72774. /**
  72775. * Defines the IDisposable interface in order to be cleanable from resources.
  72776. */
  72777. export interface ISpriteMap extends IDisposable {
  72778. /**
  72779. * String name of the SpriteMap.
  72780. */
  72781. name: string;
  72782. /**
  72783. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72784. */
  72785. atlasJSON: ISpriteJSONAtlas;
  72786. /**
  72787. * Texture of the SpriteMap.
  72788. */
  72789. spriteSheet: Texture;
  72790. /**
  72791. * The parameters to initialize the SpriteMap with.
  72792. */
  72793. options: ISpriteMapOptions;
  72794. }
  72795. /**
  72796. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72797. */
  72798. export class SpriteMap implements ISpriteMap {
  72799. /** The Name of the spriteMap */
  72800. name: string;
  72801. /** The JSON file with the frame and meta data */
  72802. atlasJSON: ISpriteJSONAtlas;
  72803. /** The systems Sprite Sheet Texture */
  72804. spriteSheet: Texture;
  72805. /** Arguments passed with the Constructor */
  72806. options: ISpriteMapOptions;
  72807. /** Public Sprite Storage array, parsed from atlasJSON */
  72808. sprites: Array<ISpriteJSONSprite>;
  72809. /** Returns the Number of Sprites in the System */
  72810. get spriteCount(): number;
  72811. /** Returns the Position of Output Plane*/
  72812. get position(): Vector3;
  72813. /** Returns the Position of Output Plane*/
  72814. set position(v: Vector3);
  72815. /** Returns the Rotation of Output Plane*/
  72816. get rotation(): Vector3;
  72817. /** Returns the Rotation of Output Plane*/
  72818. set rotation(v: Vector3);
  72819. /** Sets the AnimationMap*/
  72820. get animationMap(): RawTexture;
  72821. /** Sets the AnimationMap*/
  72822. set animationMap(v: RawTexture);
  72823. /** Scene that the SpriteMap was created in */
  72824. private _scene;
  72825. /** Texture Buffer of Float32 that holds tile frame data*/
  72826. private _frameMap;
  72827. /** Texture Buffers of Float32 that holds tileMap data*/
  72828. private _tileMaps;
  72829. /** Texture Buffer of Float32 that holds Animation Data*/
  72830. private _animationMap;
  72831. /** Custom ShaderMaterial Central to the System*/
  72832. private _material;
  72833. /** Custom ShaderMaterial Central to the System*/
  72834. private _output;
  72835. /** Systems Time Ticker*/
  72836. private _time;
  72837. /**
  72838. * Creates a new SpriteMap
  72839. * @param name defines the SpriteMaps Name
  72840. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72841. * @param spriteSheet is the Texture that the Sprites are on.
  72842. * @param options a basic deployment configuration
  72843. * @param scene The Scene that the map is deployed on
  72844. */
  72845. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72846. /**
  72847. * Returns tileID location
  72848. * @returns Vector2 the cell position ID
  72849. */
  72850. getTileID(): Vector2;
  72851. /**
  72852. * Gets the UV location of the mouse over the SpriteMap.
  72853. * @returns Vector2 the UV position of the mouse interaction
  72854. */
  72855. getMousePosition(): Vector2;
  72856. /**
  72857. * Creates the "frame" texture Buffer
  72858. * -------------------------------------
  72859. * Structure of frames
  72860. * "filename": "Falling-Water-2.png",
  72861. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72862. * "rotated": true,
  72863. * "trimmed": true,
  72864. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72865. * "sourceSize": {"w":32,"h":32}
  72866. * @returns RawTexture of the frameMap
  72867. */
  72868. private _createFrameBuffer;
  72869. /**
  72870. * Creates the tileMap texture Buffer
  72871. * @param buffer normally and array of numbers, or a false to generate from scratch
  72872. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72873. * @returns RawTexture of the tileMap
  72874. */
  72875. private _createTileBuffer;
  72876. /**
  72877. * Modifies the data of the tileMaps
  72878. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72879. * @param pos is the iVector2 Coordinates of the Tile
  72880. * @param tile The SpriteIndex of the new Tile
  72881. */
  72882. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72883. /**
  72884. * Creates the animationMap texture Buffer
  72885. * @param buffer normally and array of numbers, or a false to generate from scratch
  72886. * @returns RawTexture of the animationMap
  72887. */
  72888. private _createTileAnimationBuffer;
  72889. /**
  72890. * Modifies the data of the animationMap
  72891. * @param cellID is the Index of the Sprite
  72892. * @param _frame is the target Animation frame
  72893. * @param toCell is the Target Index of the next frame of the animation
  72894. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72895. * @param speed is a global scalar of the time variable on the map.
  72896. */
  72897. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72898. /**
  72899. * Exports the .tilemaps file
  72900. */
  72901. saveTileMaps(): void;
  72902. /**
  72903. * Imports the .tilemaps file
  72904. * @param url of the .tilemaps file
  72905. */
  72906. loadTileMaps(url: string): void;
  72907. /**
  72908. * Release associated resources
  72909. */
  72910. dispose(): void;
  72911. }
  72912. }
  72913. declare module "babylonjs/Sprites/spritePackedManager" {
  72914. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  72915. import { Scene } from "babylonjs/scene";
  72916. /**
  72917. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72918. * @see http://doc.babylonjs.com/babylon101/sprites
  72919. */
  72920. export class SpritePackedManager extends SpriteManager {
  72921. /** defines the packed manager's name */
  72922. name: string;
  72923. /**
  72924. * Creates a new sprite manager from a packed sprite sheet
  72925. * @param name defines the manager's name
  72926. * @param imgUrl defines the sprite sheet url
  72927. * @param capacity defines the maximum allowed number of sprites
  72928. * @param scene defines the hosting scene
  72929. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72930. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72931. * @param samplingMode defines the smapling mode to use with spritesheet
  72932. * @param fromPacked set to true; do not alter
  72933. */
  72934. constructor(
  72935. /** defines the packed manager's name */
  72936. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72937. }
  72938. }
  72939. declare module "babylonjs/Sprites/index" {
  72940. export * from "babylonjs/Sprites/sprite";
  72941. export * from "babylonjs/Sprites/ISprites";
  72942. export * from "babylonjs/Sprites/spriteManager";
  72943. export * from "babylonjs/Sprites/spriteMap";
  72944. export * from "babylonjs/Sprites/spritePackedManager";
  72945. export * from "babylonjs/Sprites/spriteSceneComponent";
  72946. }
  72947. declare module "babylonjs/States/index" {
  72948. export * from "babylonjs/States/alphaCullingState";
  72949. export * from "babylonjs/States/depthCullingState";
  72950. export * from "babylonjs/States/stencilState";
  72951. }
  72952. declare module "babylonjs/Misc/assetsManager" {
  72953. import { Scene } from "babylonjs/scene";
  72954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72956. import { Skeleton } from "babylonjs/Bones/skeleton";
  72957. import { Observable } from "babylonjs/Misc/observable";
  72958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72959. import { Texture } from "babylonjs/Materials/Textures/texture";
  72960. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  72961. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  72962. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  72963. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  72964. /**
  72965. * Defines the list of states available for a task inside a AssetsManager
  72966. */
  72967. export enum AssetTaskState {
  72968. /**
  72969. * Initialization
  72970. */
  72971. INIT = 0,
  72972. /**
  72973. * Running
  72974. */
  72975. RUNNING = 1,
  72976. /**
  72977. * Done
  72978. */
  72979. DONE = 2,
  72980. /**
  72981. * Error
  72982. */
  72983. ERROR = 3
  72984. }
  72985. /**
  72986. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72987. */
  72988. export abstract class AbstractAssetTask {
  72989. /**
  72990. * Task name
  72991. */ name: string;
  72992. /**
  72993. * Callback called when the task is successful
  72994. */
  72995. onSuccess: (task: any) => void;
  72996. /**
  72997. * Callback called when the task is not successful
  72998. */
  72999. onError: (task: any, message?: string, exception?: any) => void;
  73000. /**
  73001. * Creates a new AssetsManager
  73002. * @param name defines the name of the task
  73003. */
  73004. constructor(
  73005. /**
  73006. * Task name
  73007. */ name: string);
  73008. private _isCompleted;
  73009. private _taskState;
  73010. private _errorObject;
  73011. /**
  73012. * Get if the task is completed
  73013. */
  73014. get isCompleted(): boolean;
  73015. /**
  73016. * Gets the current state of the task
  73017. */
  73018. get taskState(): AssetTaskState;
  73019. /**
  73020. * Gets the current error object (if task is in error)
  73021. */
  73022. get errorObject(): {
  73023. message?: string;
  73024. exception?: any;
  73025. };
  73026. /**
  73027. * Internal only
  73028. * @hidden
  73029. */
  73030. _setErrorObject(message?: string, exception?: any): void;
  73031. /**
  73032. * Execute the current task
  73033. * @param scene defines the scene where you want your assets to be loaded
  73034. * @param onSuccess is a callback called when the task is successfully executed
  73035. * @param onError is a callback called if an error occurs
  73036. */
  73037. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73038. /**
  73039. * Execute the current task
  73040. * @param scene defines the scene where you want your assets to be loaded
  73041. * @param onSuccess is a callback called when the task is successfully executed
  73042. * @param onError is a callback called if an error occurs
  73043. */
  73044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73045. /**
  73046. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73047. * This can be used with failed tasks that have the reason for failure fixed.
  73048. */
  73049. reset(): void;
  73050. private onErrorCallback;
  73051. private onDoneCallback;
  73052. }
  73053. /**
  73054. * Define the interface used by progress events raised during assets loading
  73055. */
  73056. export interface IAssetsProgressEvent {
  73057. /**
  73058. * Defines the number of remaining tasks to process
  73059. */
  73060. remainingCount: number;
  73061. /**
  73062. * Defines the total number of tasks
  73063. */
  73064. totalCount: number;
  73065. /**
  73066. * Defines the task that was just processed
  73067. */
  73068. task: AbstractAssetTask;
  73069. }
  73070. /**
  73071. * Class used to share progress information about assets loading
  73072. */
  73073. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73074. /**
  73075. * Defines the number of remaining tasks to process
  73076. */
  73077. remainingCount: number;
  73078. /**
  73079. * Defines the total number of tasks
  73080. */
  73081. totalCount: number;
  73082. /**
  73083. * Defines the task that was just processed
  73084. */
  73085. task: AbstractAssetTask;
  73086. /**
  73087. * Creates a AssetsProgressEvent
  73088. * @param remainingCount defines the number of remaining tasks to process
  73089. * @param totalCount defines the total number of tasks
  73090. * @param task defines the task that was just processed
  73091. */
  73092. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73093. }
  73094. /**
  73095. * Define a task used by AssetsManager to load meshes
  73096. */
  73097. export class MeshAssetTask extends AbstractAssetTask {
  73098. /**
  73099. * Defines the name of the task
  73100. */
  73101. name: string;
  73102. /**
  73103. * Defines the list of mesh's names you want to load
  73104. */
  73105. meshesNames: any;
  73106. /**
  73107. * Defines the root url to use as a base to load your meshes and associated resources
  73108. */
  73109. rootUrl: string;
  73110. /**
  73111. * Defines the filename or File of the scene to load from
  73112. */
  73113. sceneFilename: string | File;
  73114. /**
  73115. * Gets the list of loaded meshes
  73116. */
  73117. loadedMeshes: Array<AbstractMesh>;
  73118. /**
  73119. * Gets the list of loaded particle systems
  73120. */
  73121. loadedParticleSystems: Array<IParticleSystem>;
  73122. /**
  73123. * Gets the list of loaded skeletons
  73124. */
  73125. loadedSkeletons: Array<Skeleton>;
  73126. /**
  73127. * Gets the list of loaded animation groups
  73128. */
  73129. loadedAnimationGroups: Array<AnimationGroup>;
  73130. /**
  73131. * Callback called when the task is successful
  73132. */
  73133. onSuccess: (task: MeshAssetTask) => void;
  73134. /**
  73135. * Callback called when the task is successful
  73136. */
  73137. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73138. /**
  73139. * Creates a new MeshAssetTask
  73140. * @param name defines the name of the task
  73141. * @param meshesNames defines the list of mesh's names you want to load
  73142. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73143. * @param sceneFilename defines the filename or File of the scene to load from
  73144. */
  73145. constructor(
  73146. /**
  73147. * Defines the name of the task
  73148. */
  73149. name: string,
  73150. /**
  73151. * Defines the list of mesh's names you want to load
  73152. */
  73153. meshesNames: any,
  73154. /**
  73155. * Defines the root url to use as a base to load your meshes and associated resources
  73156. */
  73157. rootUrl: string,
  73158. /**
  73159. * Defines the filename or File of the scene to load from
  73160. */
  73161. sceneFilename: string | File);
  73162. /**
  73163. * Execute the current task
  73164. * @param scene defines the scene where you want your assets to be loaded
  73165. * @param onSuccess is a callback called when the task is successfully executed
  73166. * @param onError is a callback called if an error occurs
  73167. */
  73168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73169. }
  73170. /**
  73171. * Define a task used by AssetsManager to load text content
  73172. */
  73173. export class TextFileAssetTask extends AbstractAssetTask {
  73174. /**
  73175. * Defines the name of the task
  73176. */
  73177. name: string;
  73178. /**
  73179. * Defines the location of the file to load
  73180. */
  73181. url: string;
  73182. /**
  73183. * Gets the loaded text string
  73184. */
  73185. text: string;
  73186. /**
  73187. * Callback called when the task is successful
  73188. */
  73189. onSuccess: (task: TextFileAssetTask) => void;
  73190. /**
  73191. * Callback called when the task is successful
  73192. */
  73193. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73194. /**
  73195. * Creates a new TextFileAssetTask object
  73196. * @param name defines the name of the task
  73197. * @param url defines the location of the file to load
  73198. */
  73199. constructor(
  73200. /**
  73201. * Defines the name of the task
  73202. */
  73203. name: string,
  73204. /**
  73205. * Defines the location of the file to load
  73206. */
  73207. url: string);
  73208. /**
  73209. * Execute the current task
  73210. * @param scene defines the scene where you want your assets to be loaded
  73211. * @param onSuccess is a callback called when the task is successfully executed
  73212. * @param onError is a callback called if an error occurs
  73213. */
  73214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73215. }
  73216. /**
  73217. * Define a task used by AssetsManager to load binary data
  73218. */
  73219. export class BinaryFileAssetTask extends AbstractAssetTask {
  73220. /**
  73221. * Defines the name of the task
  73222. */
  73223. name: string;
  73224. /**
  73225. * Defines the location of the file to load
  73226. */
  73227. url: string;
  73228. /**
  73229. * Gets the lodaded data (as an array buffer)
  73230. */
  73231. data: ArrayBuffer;
  73232. /**
  73233. * Callback called when the task is successful
  73234. */
  73235. onSuccess: (task: BinaryFileAssetTask) => void;
  73236. /**
  73237. * Callback called when the task is successful
  73238. */
  73239. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73240. /**
  73241. * Creates a new BinaryFileAssetTask object
  73242. * @param name defines the name of the new task
  73243. * @param url defines the location of the file to load
  73244. */
  73245. constructor(
  73246. /**
  73247. * Defines the name of the task
  73248. */
  73249. name: string,
  73250. /**
  73251. * Defines the location of the file to load
  73252. */
  73253. url: string);
  73254. /**
  73255. * Execute the current task
  73256. * @param scene defines the scene where you want your assets to be loaded
  73257. * @param onSuccess is a callback called when the task is successfully executed
  73258. * @param onError is a callback called if an error occurs
  73259. */
  73260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73261. }
  73262. /**
  73263. * Define a task used by AssetsManager to load images
  73264. */
  73265. export class ImageAssetTask extends AbstractAssetTask {
  73266. /**
  73267. * Defines the name of the task
  73268. */
  73269. name: string;
  73270. /**
  73271. * Defines the location of the image to load
  73272. */
  73273. url: string;
  73274. /**
  73275. * Gets the loaded images
  73276. */
  73277. image: HTMLImageElement;
  73278. /**
  73279. * Callback called when the task is successful
  73280. */
  73281. onSuccess: (task: ImageAssetTask) => void;
  73282. /**
  73283. * Callback called when the task is successful
  73284. */
  73285. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73286. /**
  73287. * Creates a new ImageAssetTask
  73288. * @param name defines the name of the task
  73289. * @param url defines the location of the image to load
  73290. */
  73291. constructor(
  73292. /**
  73293. * Defines the name of the task
  73294. */
  73295. name: string,
  73296. /**
  73297. * Defines the location of the image to load
  73298. */
  73299. url: string);
  73300. /**
  73301. * Execute the current task
  73302. * @param scene defines the scene where you want your assets to be loaded
  73303. * @param onSuccess is a callback called when the task is successfully executed
  73304. * @param onError is a callback called if an error occurs
  73305. */
  73306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73307. }
  73308. /**
  73309. * Defines the interface used by texture loading tasks
  73310. */
  73311. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73312. /**
  73313. * Gets the loaded texture
  73314. */
  73315. texture: TEX;
  73316. }
  73317. /**
  73318. * Define a task used by AssetsManager to load 2D textures
  73319. */
  73320. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73321. /**
  73322. * Defines the name of the task
  73323. */
  73324. name: string;
  73325. /**
  73326. * Defines the location of the file to load
  73327. */
  73328. url: string;
  73329. /**
  73330. * Defines if mipmap should not be generated (default is false)
  73331. */
  73332. noMipmap?: boolean | undefined;
  73333. /**
  73334. * Defines if texture must be inverted on Y axis (default is true)
  73335. */
  73336. invertY: boolean;
  73337. /**
  73338. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73339. */
  73340. samplingMode: number;
  73341. /**
  73342. * Gets the loaded texture
  73343. */
  73344. texture: Texture;
  73345. /**
  73346. * Callback called when the task is successful
  73347. */
  73348. onSuccess: (task: TextureAssetTask) => void;
  73349. /**
  73350. * Callback called when the task is successful
  73351. */
  73352. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73353. /**
  73354. * Creates a new TextureAssetTask object
  73355. * @param name defines the name of the task
  73356. * @param url defines the location of the file to load
  73357. * @param noMipmap defines if mipmap should not be generated (default is false)
  73358. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73359. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73360. */
  73361. constructor(
  73362. /**
  73363. * Defines the name of the task
  73364. */
  73365. name: string,
  73366. /**
  73367. * Defines the location of the file to load
  73368. */
  73369. url: string,
  73370. /**
  73371. * Defines if mipmap should not be generated (default is false)
  73372. */
  73373. noMipmap?: boolean | undefined,
  73374. /**
  73375. * Defines if texture must be inverted on Y axis (default is true)
  73376. */
  73377. invertY?: boolean,
  73378. /**
  73379. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73380. */
  73381. samplingMode?: number);
  73382. /**
  73383. * Execute the current task
  73384. * @param scene defines the scene where you want your assets to be loaded
  73385. * @param onSuccess is a callback called when the task is successfully executed
  73386. * @param onError is a callback called if an error occurs
  73387. */
  73388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73389. }
  73390. /**
  73391. * Define a task used by AssetsManager to load cube textures
  73392. */
  73393. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73394. /**
  73395. * Defines the name of the task
  73396. */
  73397. name: string;
  73398. /**
  73399. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73400. */
  73401. url: string;
  73402. /**
  73403. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73404. */
  73405. extensions?: string[] | undefined;
  73406. /**
  73407. * Defines if mipmaps should not be generated (default is false)
  73408. */
  73409. noMipmap?: boolean | undefined;
  73410. /**
  73411. * Defines the explicit list of files (undefined by default)
  73412. */
  73413. files?: string[] | undefined;
  73414. /**
  73415. * Gets the loaded texture
  73416. */
  73417. texture: CubeTexture;
  73418. /**
  73419. * Callback called when the task is successful
  73420. */
  73421. onSuccess: (task: CubeTextureAssetTask) => void;
  73422. /**
  73423. * Callback called when the task is successful
  73424. */
  73425. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73426. /**
  73427. * Creates a new CubeTextureAssetTask
  73428. * @param name defines the name of the task
  73429. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73430. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73431. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73432. * @param files defines the explicit list of files (undefined by default)
  73433. */
  73434. constructor(
  73435. /**
  73436. * Defines the name of the task
  73437. */
  73438. name: string,
  73439. /**
  73440. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73441. */
  73442. url: string,
  73443. /**
  73444. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73445. */
  73446. extensions?: string[] | undefined,
  73447. /**
  73448. * Defines if mipmaps should not be generated (default is false)
  73449. */
  73450. noMipmap?: boolean | undefined,
  73451. /**
  73452. * Defines the explicit list of files (undefined by default)
  73453. */
  73454. files?: string[] | undefined);
  73455. /**
  73456. * Execute the current task
  73457. * @param scene defines the scene where you want your assets to be loaded
  73458. * @param onSuccess is a callback called when the task is successfully executed
  73459. * @param onError is a callback called if an error occurs
  73460. */
  73461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73462. }
  73463. /**
  73464. * Define a task used by AssetsManager to load HDR cube textures
  73465. */
  73466. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73467. /**
  73468. * Defines the name of the task
  73469. */
  73470. name: string;
  73471. /**
  73472. * Defines the location of the file to load
  73473. */
  73474. url: string;
  73475. /**
  73476. * Defines the desired size (the more it increases the longer the generation will be)
  73477. */
  73478. size: number;
  73479. /**
  73480. * Defines if mipmaps should not be generated (default is false)
  73481. */
  73482. noMipmap: boolean;
  73483. /**
  73484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73485. */
  73486. generateHarmonics: boolean;
  73487. /**
  73488. * 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)
  73489. */
  73490. gammaSpace: boolean;
  73491. /**
  73492. * Internal Use Only
  73493. */
  73494. reserved: boolean;
  73495. /**
  73496. * Gets the loaded texture
  73497. */
  73498. texture: HDRCubeTexture;
  73499. /**
  73500. * Callback called when the task is successful
  73501. */
  73502. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73503. /**
  73504. * Callback called when the task is successful
  73505. */
  73506. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73507. /**
  73508. * Creates a new HDRCubeTextureAssetTask object
  73509. * @param name defines the name of the task
  73510. * @param url defines the location of the file to load
  73511. * @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.
  73512. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73513. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73514. * @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)
  73515. * @param reserved Internal use only
  73516. */
  73517. constructor(
  73518. /**
  73519. * Defines the name of the task
  73520. */
  73521. name: string,
  73522. /**
  73523. * Defines the location of the file to load
  73524. */
  73525. url: string,
  73526. /**
  73527. * Defines the desired size (the more it increases the longer the generation will be)
  73528. */
  73529. size: number,
  73530. /**
  73531. * Defines if mipmaps should not be generated (default is false)
  73532. */
  73533. noMipmap?: boolean,
  73534. /**
  73535. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73536. */
  73537. generateHarmonics?: boolean,
  73538. /**
  73539. * 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)
  73540. */
  73541. gammaSpace?: boolean,
  73542. /**
  73543. * Internal Use Only
  73544. */
  73545. reserved?: boolean);
  73546. /**
  73547. * Execute the current task
  73548. * @param scene defines the scene where you want your assets to be loaded
  73549. * @param onSuccess is a callback called when the task is successfully executed
  73550. * @param onError is a callback called if an error occurs
  73551. */
  73552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73553. }
  73554. /**
  73555. * Define a task used by AssetsManager to load Equirectangular cube textures
  73556. */
  73557. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73558. /**
  73559. * Defines the name of the task
  73560. */
  73561. name: string;
  73562. /**
  73563. * Defines the location of the file to load
  73564. */
  73565. url: string;
  73566. /**
  73567. * Defines the desired size (the more it increases the longer the generation will be)
  73568. */
  73569. size: number;
  73570. /**
  73571. * Defines if mipmaps should not be generated (default is false)
  73572. */
  73573. noMipmap: boolean;
  73574. /**
  73575. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73576. * but the standard material would require them in Gamma space) (default is true)
  73577. */
  73578. gammaSpace: boolean;
  73579. /**
  73580. * Gets the loaded texture
  73581. */
  73582. texture: EquiRectangularCubeTexture;
  73583. /**
  73584. * Callback called when the task is successful
  73585. */
  73586. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73587. /**
  73588. * Callback called when the task is successful
  73589. */
  73590. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73591. /**
  73592. * Creates a new EquiRectangularCubeTextureAssetTask object
  73593. * @param name defines the name of the task
  73594. * @param url defines the location of the file to load
  73595. * @param size defines the desired size (the more it increases the longer the generation will be)
  73596. * If the size is omitted this implies you are using a preprocessed cubemap.
  73597. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73598. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73599. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73600. * (default is true)
  73601. */
  73602. constructor(
  73603. /**
  73604. * Defines the name of the task
  73605. */
  73606. name: string,
  73607. /**
  73608. * Defines the location of the file to load
  73609. */
  73610. url: string,
  73611. /**
  73612. * Defines the desired size (the more it increases the longer the generation will be)
  73613. */
  73614. size: number,
  73615. /**
  73616. * Defines if mipmaps should not be generated (default is false)
  73617. */
  73618. noMipmap?: boolean,
  73619. /**
  73620. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73621. * but the standard material would require them in Gamma space) (default is true)
  73622. */
  73623. gammaSpace?: boolean);
  73624. /**
  73625. * Execute the current task
  73626. * @param scene defines the scene where you want your assets to be loaded
  73627. * @param onSuccess is a callback called when the task is successfully executed
  73628. * @param onError is a callback called if an error occurs
  73629. */
  73630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73631. }
  73632. /**
  73633. * This class can be used to easily import assets into a scene
  73634. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73635. */
  73636. export class AssetsManager {
  73637. private _scene;
  73638. private _isLoading;
  73639. protected _tasks: AbstractAssetTask[];
  73640. protected _waitingTasksCount: number;
  73641. protected _totalTasksCount: number;
  73642. /**
  73643. * Callback called when all tasks are processed
  73644. */
  73645. onFinish: (tasks: AbstractAssetTask[]) => void;
  73646. /**
  73647. * Callback called when a task is successful
  73648. */
  73649. onTaskSuccess: (task: AbstractAssetTask) => void;
  73650. /**
  73651. * Callback called when a task had an error
  73652. */
  73653. onTaskError: (task: AbstractAssetTask) => void;
  73654. /**
  73655. * Callback called when a task is done (whatever the result is)
  73656. */
  73657. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73658. /**
  73659. * Observable called when all tasks are processed
  73660. */
  73661. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73662. /**
  73663. * Observable called when a task had an error
  73664. */
  73665. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73666. /**
  73667. * Observable called when all tasks were executed
  73668. */
  73669. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73670. /**
  73671. * Observable called when a task is done (whatever the result is)
  73672. */
  73673. onProgressObservable: Observable<IAssetsProgressEvent>;
  73674. /**
  73675. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73676. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73677. */
  73678. useDefaultLoadingScreen: boolean;
  73679. /**
  73680. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73681. * when all assets have been downloaded.
  73682. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73683. */
  73684. autoHideLoadingUI: boolean;
  73685. /**
  73686. * Creates a new AssetsManager
  73687. * @param scene defines the scene to work on
  73688. */
  73689. constructor(scene: Scene);
  73690. /**
  73691. * Add a MeshAssetTask to the list of active tasks
  73692. * @param taskName defines the name of the new task
  73693. * @param meshesNames defines the name of meshes to load
  73694. * @param rootUrl defines the root url to use to locate files
  73695. * @param sceneFilename defines the filename of the scene file
  73696. * @returns a new MeshAssetTask object
  73697. */
  73698. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73699. /**
  73700. * Add a TextFileAssetTask to the list of active tasks
  73701. * @param taskName defines the name of the new task
  73702. * @param url defines the url of the file to load
  73703. * @returns a new TextFileAssetTask object
  73704. */
  73705. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73706. /**
  73707. * Add a BinaryFileAssetTask to the list of active tasks
  73708. * @param taskName defines the name of the new task
  73709. * @param url defines the url of the file to load
  73710. * @returns a new BinaryFileAssetTask object
  73711. */
  73712. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73713. /**
  73714. * Add a ImageAssetTask to the list of active tasks
  73715. * @param taskName defines the name of the new task
  73716. * @param url defines the url of the file to load
  73717. * @returns a new ImageAssetTask object
  73718. */
  73719. addImageTask(taskName: string, url: string): ImageAssetTask;
  73720. /**
  73721. * Add a TextureAssetTask to the list of active tasks
  73722. * @param taskName defines the name of the new task
  73723. * @param url defines the url of the file to load
  73724. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73725. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73726. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73727. * @returns a new TextureAssetTask object
  73728. */
  73729. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73730. /**
  73731. * Add a CubeTextureAssetTask to the list of active tasks
  73732. * @param taskName defines the name of the new task
  73733. * @param url defines the url of the file to load
  73734. * @param extensions defines the extension to use to load the cube map (can be null)
  73735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73736. * @param files defines the list of files to load (can be null)
  73737. * @returns a new CubeTextureAssetTask object
  73738. */
  73739. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73740. /**
  73741. *
  73742. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73743. * @param taskName defines the name of the new task
  73744. * @param url defines the url of the file to load
  73745. * @param size defines the size you want for the cubemap (can be null)
  73746. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73747. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73748. * @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)
  73749. * @param reserved Internal use only
  73750. * @returns a new HDRCubeTextureAssetTask object
  73751. */
  73752. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73753. /**
  73754. *
  73755. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73756. * @param taskName defines the name of the new task
  73757. * @param url defines the url of the file to load
  73758. * @param size defines the size you want for the cubemap (can be null)
  73759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73760. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73761. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73762. * @returns a new EquiRectangularCubeTextureAssetTask object
  73763. */
  73764. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73765. /**
  73766. * Remove a task from the assets manager.
  73767. * @param task the task to remove
  73768. */
  73769. removeTask(task: AbstractAssetTask): void;
  73770. private _decreaseWaitingTasksCount;
  73771. private _runTask;
  73772. /**
  73773. * Reset the AssetsManager and remove all tasks
  73774. * @return the current instance of the AssetsManager
  73775. */
  73776. reset(): AssetsManager;
  73777. /**
  73778. * Start the loading process
  73779. * @return the current instance of the AssetsManager
  73780. */
  73781. load(): AssetsManager;
  73782. /**
  73783. * Start the loading process as an async operation
  73784. * @return a promise returning the list of failed tasks
  73785. */
  73786. loadAsync(): Promise<void>;
  73787. }
  73788. }
  73789. declare module "babylonjs/Misc/deferred" {
  73790. /**
  73791. * Wrapper class for promise with external resolve and reject.
  73792. */
  73793. export class Deferred<T> {
  73794. /**
  73795. * The promise associated with this deferred object.
  73796. */
  73797. readonly promise: Promise<T>;
  73798. private _resolve;
  73799. private _reject;
  73800. /**
  73801. * The resolve method of the promise associated with this deferred object.
  73802. */
  73803. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73804. /**
  73805. * The reject method of the promise associated with this deferred object.
  73806. */
  73807. get reject(): (reason?: any) => void;
  73808. /**
  73809. * Constructor for this deferred object.
  73810. */
  73811. constructor();
  73812. }
  73813. }
  73814. declare module "babylonjs/Misc/meshExploder" {
  73815. import { Mesh } from "babylonjs/Meshes/mesh";
  73816. /**
  73817. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73818. */
  73819. export class MeshExploder {
  73820. private _centerMesh;
  73821. private _meshes;
  73822. private _meshesOrigins;
  73823. private _toCenterVectors;
  73824. private _scaledDirection;
  73825. private _newPosition;
  73826. private _centerPosition;
  73827. /**
  73828. * Explodes meshes from a center mesh.
  73829. * @param meshes The meshes to explode.
  73830. * @param centerMesh The mesh to be center of explosion.
  73831. */
  73832. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73833. private _setCenterMesh;
  73834. /**
  73835. * Get class name
  73836. * @returns "MeshExploder"
  73837. */
  73838. getClassName(): string;
  73839. /**
  73840. * "Exploded meshes"
  73841. * @returns Array of meshes with the centerMesh at index 0.
  73842. */
  73843. getMeshes(): Array<Mesh>;
  73844. /**
  73845. * Explodes meshes giving a specific direction
  73846. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73847. */
  73848. explode(direction?: number): void;
  73849. }
  73850. }
  73851. declare module "babylonjs/Misc/filesInput" {
  73852. import { Engine } from "babylonjs/Engines/engine";
  73853. import { Scene } from "babylonjs/scene";
  73854. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  73855. /**
  73856. * Class used to help managing file picking and drag'n'drop
  73857. */
  73858. export class FilesInput {
  73859. /**
  73860. * List of files ready to be loaded
  73861. */
  73862. static get FilesToLoad(): {
  73863. [key: string]: File;
  73864. };
  73865. /**
  73866. * Callback called when a file is processed
  73867. */
  73868. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  73869. private _engine;
  73870. private _currentScene;
  73871. private _sceneLoadedCallback;
  73872. private _progressCallback;
  73873. private _additionalRenderLoopLogicCallback;
  73874. private _textureLoadingCallback;
  73875. private _startingProcessingFilesCallback;
  73876. private _onReloadCallback;
  73877. private _errorCallback;
  73878. private _elementToMonitor;
  73879. private _sceneFileToLoad;
  73880. private _filesToLoad;
  73881. /**
  73882. * Creates a new FilesInput
  73883. * @param engine defines the rendering engine
  73884. * @param scene defines the hosting scene
  73885. * @param sceneLoadedCallback callback called when scene is loaded
  73886. * @param progressCallback callback called to track progress
  73887. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73888. * @param textureLoadingCallback callback called when a texture is loading
  73889. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73890. * @param onReloadCallback callback called when a reload is requested
  73891. * @param errorCallback callback call if an error occurs
  73892. */
  73893. 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);
  73894. private _dragEnterHandler;
  73895. private _dragOverHandler;
  73896. private _dropHandler;
  73897. /**
  73898. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73899. * @param elementToMonitor defines the DOM element to track
  73900. */
  73901. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73902. /**
  73903. * Release all associated resources
  73904. */
  73905. dispose(): void;
  73906. private renderFunction;
  73907. private drag;
  73908. private drop;
  73909. private _traverseFolder;
  73910. private _processFiles;
  73911. /**
  73912. * Load files from a drop event
  73913. * @param event defines the drop event to use as source
  73914. */
  73915. loadFiles(event: any): void;
  73916. private _processReload;
  73917. /**
  73918. * Reload the current scene from the loaded files
  73919. */
  73920. reload(): void;
  73921. }
  73922. }
  73923. declare module "babylonjs/Misc/HighDynamicRange/index" {
  73924. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  73925. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  73926. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  73927. }
  73928. declare module "babylonjs/Misc/sceneOptimizer" {
  73929. import { Scene, IDisposable } from "babylonjs/scene";
  73930. import { Observable } from "babylonjs/Misc/observable";
  73931. /**
  73932. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73934. */
  73935. export class SceneOptimization {
  73936. /**
  73937. * Defines the priority of this optimization (0 by default which means first in the list)
  73938. */
  73939. priority: number;
  73940. /**
  73941. * Gets a string describing the action executed by the current optimization
  73942. * @returns description string
  73943. */
  73944. getDescription(): string;
  73945. /**
  73946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73947. * @param scene defines the current scene where to apply this optimization
  73948. * @param optimizer defines the current optimizer
  73949. * @returns true if everything that can be done was applied
  73950. */
  73951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73952. /**
  73953. * Creates the SceneOptimization object
  73954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73955. * @param desc defines the description associated with the optimization
  73956. */
  73957. constructor(
  73958. /**
  73959. * Defines the priority of this optimization (0 by default which means first in the list)
  73960. */
  73961. priority?: number);
  73962. }
  73963. /**
  73964. * Defines an optimization used to reduce the size of render target textures
  73965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73966. */
  73967. export class TextureOptimization extends SceneOptimization {
  73968. /**
  73969. * Defines the priority of this optimization (0 by default which means first in the list)
  73970. */
  73971. priority: number;
  73972. /**
  73973. * 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
  73974. */
  73975. maximumSize: number;
  73976. /**
  73977. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73978. */
  73979. step: number;
  73980. /**
  73981. * Gets a string describing the action executed by the current optimization
  73982. * @returns description string
  73983. */
  73984. getDescription(): string;
  73985. /**
  73986. * Creates the TextureOptimization object
  73987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73988. * @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
  73989. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73990. */
  73991. constructor(
  73992. /**
  73993. * Defines the priority of this optimization (0 by default which means first in the list)
  73994. */
  73995. priority?: number,
  73996. /**
  73997. * 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
  73998. */
  73999. maximumSize?: number,
  74000. /**
  74001. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74002. */
  74003. step?: number);
  74004. /**
  74005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74006. * @param scene defines the current scene where to apply this optimization
  74007. * @param optimizer defines the current optimizer
  74008. * @returns true if everything that can be done was applied
  74009. */
  74010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74011. }
  74012. /**
  74013. * Defines an optimization used to increase or decrease the rendering resolution
  74014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74015. */
  74016. export class HardwareScalingOptimization extends SceneOptimization {
  74017. /**
  74018. * Defines the priority of this optimization (0 by default which means first in the list)
  74019. */
  74020. priority: number;
  74021. /**
  74022. * Defines the maximum scale to use (2 by default)
  74023. */
  74024. maximumScale: number;
  74025. /**
  74026. * Defines the step to use between two passes (0.5 by default)
  74027. */
  74028. step: number;
  74029. private _currentScale;
  74030. private _directionOffset;
  74031. /**
  74032. * Gets a string describing the action executed by the current optimization
  74033. * @return description string
  74034. */
  74035. getDescription(): string;
  74036. /**
  74037. * Creates the HardwareScalingOptimization object
  74038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74039. * @param maximumScale defines the maximum scale to use (2 by default)
  74040. * @param step defines the step to use between two passes (0.5 by default)
  74041. */
  74042. constructor(
  74043. /**
  74044. * Defines the priority of this optimization (0 by default which means first in the list)
  74045. */
  74046. priority?: number,
  74047. /**
  74048. * Defines the maximum scale to use (2 by default)
  74049. */
  74050. maximumScale?: number,
  74051. /**
  74052. * Defines the step to use between two passes (0.5 by default)
  74053. */
  74054. step?: number);
  74055. /**
  74056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74057. * @param scene defines the current scene where to apply this optimization
  74058. * @param optimizer defines the current optimizer
  74059. * @returns true if everything that can be done was applied
  74060. */
  74061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74062. }
  74063. /**
  74064. * Defines an optimization used to remove shadows
  74065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74066. */
  74067. export class ShadowsOptimization extends SceneOptimization {
  74068. /**
  74069. * Gets a string describing the action executed by the current optimization
  74070. * @return description string
  74071. */
  74072. getDescription(): string;
  74073. /**
  74074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74075. * @param scene defines the current scene where to apply this optimization
  74076. * @param optimizer defines the current optimizer
  74077. * @returns true if everything that can be done was applied
  74078. */
  74079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74080. }
  74081. /**
  74082. * Defines an optimization used to turn post-processes off
  74083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74084. */
  74085. export class PostProcessesOptimization extends SceneOptimization {
  74086. /**
  74087. * Gets a string describing the action executed by the current optimization
  74088. * @return description string
  74089. */
  74090. getDescription(): string;
  74091. /**
  74092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74093. * @param scene defines the current scene where to apply this optimization
  74094. * @param optimizer defines the current optimizer
  74095. * @returns true if everything that can be done was applied
  74096. */
  74097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74098. }
  74099. /**
  74100. * Defines an optimization used to turn lens flares off
  74101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74102. */
  74103. export class LensFlaresOptimization extends SceneOptimization {
  74104. /**
  74105. * Gets a string describing the action executed by the current optimization
  74106. * @return description string
  74107. */
  74108. getDescription(): string;
  74109. /**
  74110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74111. * @param scene defines the current scene where to apply this optimization
  74112. * @param optimizer defines the current optimizer
  74113. * @returns true if everything that can be done was applied
  74114. */
  74115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74116. }
  74117. /**
  74118. * Defines an optimization based on user defined callback.
  74119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74120. */
  74121. export class CustomOptimization extends SceneOptimization {
  74122. /**
  74123. * Callback called to apply the custom optimization.
  74124. */
  74125. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74126. /**
  74127. * Callback called to get custom description
  74128. */
  74129. onGetDescription: () => string;
  74130. /**
  74131. * Gets a string describing the action executed by the current optimization
  74132. * @returns description string
  74133. */
  74134. getDescription(): string;
  74135. /**
  74136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74137. * @param scene defines the current scene where to apply this optimization
  74138. * @param optimizer defines the current optimizer
  74139. * @returns true if everything that can be done was applied
  74140. */
  74141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74142. }
  74143. /**
  74144. * Defines an optimization used to turn particles off
  74145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74146. */
  74147. export class ParticlesOptimization extends SceneOptimization {
  74148. /**
  74149. * Gets a string describing the action executed by the current optimization
  74150. * @return description string
  74151. */
  74152. getDescription(): string;
  74153. /**
  74154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74155. * @param scene defines the current scene where to apply this optimization
  74156. * @param optimizer defines the current optimizer
  74157. * @returns true if everything that can be done was applied
  74158. */
  74159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74160. }
  74161. /**
  74162. * Defines an optimization used to turn render targets off
  74163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74164. */
  74165. export class RenderTargetsOptimization extends SceneOptimization {
  74166. /**
  74167. * Gets a string describing the action executed by the current optimization
  74168. * @return description string
  74169. */
  74170. getDescription(): string;
  74171. /**
  74172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74173. * @param scene defines the current scene where to apply this optimization
  74174. * @param optimizer defines the current optimizer
  74175. * @returns true if everything that can be done was applied
  74176. */
  74177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74178. }
  74179. /**
  74180. * Defines an optimization used to merge meshes with compatible materials
  74181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74182. */
  74183. export class MergeMeshesOptimization extends SceneOptimization {
  74184. private static _UpdateSelectionTree;
  74185. /**
  74186. * Gets or sets a boolean which defines if optimization octree has to be updated
  74187. */
  74188. static get UpdateSelectionTree(): boolean;
  74189. /**
  74190. * Gets or sets a boolean which defines if optimization octree has to be updated
  74191. */
  74192. static set UpdateSelectionTree(value: boolean);
  74193. /**
  74194. * Gets a string describing the action executed by the current optimization
  74195. * @return description string
  74196. */
  74197. getDescription(): string;
  74198. private _canBeMerged;
  74199. /**
  74200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74201. * @param scene defines the current scene where to apply this optimization
  74202. * @param optimizer defines the current optimizer
  74203. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74204. * @returns true if everything that can be done was applied
  74205. */
  74206. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74207. }
  74208. /**
  74209. * Defines a list of options used by SceneOptimizer
  74210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74211. */
  74212. export class SceneOptimizerOptions {
  74213. /**
  74214. * Defines the target frame rate to reach (60 by default)
  74215. */
  74216. targetFrameRate: number;
  74217. /**
  74218. * Defines the interval between two checkes (2000ms by default)
  74219. */
  74220. trackerDuration: number;
  74221. /**
  74222. * Gets the list of optimizations to apply
  74223. */
  74224. optimizations: SceneOptimization[];
  74225. /**
  74226. * Creates a new list of options used by SceneOptimizer
  74227. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74228. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74229. */
  74230. constructor(
  74231. /**
  74232. * Defines the target frame rate to reach (60 by default)
  74233. */
  74234. targetFrameRate?: number,
  74235. /**
  74236. * Defines the interval between two checkes (2000ms by default)
  74237. */
  74238. trackerDuration?: number);
  74239. /**
  74240. * Add a new optimization
  74241. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74242. * @returns the current SceneOptimizerOptions
  74243. */
  74244. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74245. /**
  74246. * Add a new custom optimization
  74247. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74248. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74250. * @returns the current SceneOptimizerOptions
  74251. */
  74252. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74253. /**
  74254. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74255. * @param targetFrameRate defines the target frame rate (60 by default)
  74256. * @returns a SceneOptimizerOptions object
  74257. */
  74258. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74259. /**
  74260. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74261. * @param targetFrameRate defines the target frame rate (60 by default)
  74262. * @returns a SceneOptimizerOptions object
  74263. */
  74264. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74265. /**
  74266. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74267. * @param targetFrameRate defines the target frame rate (60 by default)
  74268. * @returns a SceneOptimizerOptions object
  74269. */
  74270. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74271. }
  74272. /**
  74273. * Class used to run optimizations in order to reach a target frame rate
  74274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74275. */
  74276. export class SceneOptimizer implements IDisposable {
  74277. private _isRunning;
  74278. private _options;
  74279. private _scene;
  74280. private _currentPriorityLevel;
  74281. private _targetFrameRate;
  74282. private _trackerDuration;
  74283. private _currentFrameRate;
  74284. private _sceneDisposeObserver;
  74285. private _improvementMode;
  74286. /**
  74287. * Defines an observable called when the optimizer reaches the target frame rate
  74288. */
  74289. onSuccessObservable: Observable<SceneOptimizer>;
  74290. /**
  74291. * Defines an observable called when the optimizer enables an optimization
  74292. */
  74293. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74294. /**
  74295. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74296. */
  74297. onFailureObservable: Observable<SceneOptimizer>;
  74298. /**
  74299. * Gets a boolean indicating if the optimizer is in improvement mode
  74300. */
  74301. get isInImprovementMode(): boolean;
  74302. /**
  74303. * Gets the current priority level (0 at start)
  74304. */
  74305. get currentPriorityLevel(): number;
  74306. /**
  74307. * Gets the current frame rate checked by the SceneOptimizer
  74308. */
  74309. get currentFrameRate(): number;
  74310. /**
  74311. * Gets or sets the current target frame rate (60 by default)
  74312. */
  74313. get targetFrameRate(): number;
  74314. /**
  74315. * Gets or sets the current target frame rate (60 by default)
  74316. */
  74317. set targetFrameRate(value: number);
  74318. /**
  74319. * Gets or sets the current interval between two checks (every 2000ms by default)
  74320. */
  74321. get trackerDuration(): number;
  74322. /**
  74323. * Gets or sets the current interval between two checks (every 2000ms by default)
  74324. */
  74325. set trackerDuration(value: number);
  74326. /**
  74327. * Gets the list of active optimizations
  74328. */
  74329. get optimizations(): SceneOptimization[];
  74330. /**
  74331. * Creates a new SceneOptimizer
  74332. * @param scene defines the scene to work on
  74333. * @param options defines the options to use with the SceneOptimizer
  74334. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74335. * @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)
  74336. */
  74337. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74338. /**
  74339. * Stops the current optimizer
  74340. */
  74341. stop(): void;
  74342. /**
  74343. * Reset the optimizer to initial step (current priority level = 0)
  74344. */
  74345. reset(): void;
  74346. /**
  74347. * Start the optimizer. By default it will try to reach a specific framerate
  74348. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74349. */
  74350. start(): void;
  74351. private _checkCurrentState;
  74352. /**
  74353. * Release all resources
  74354. */
  74355. dispose(): void;
  74356. /**
  74357. * Helper function to create a SceneOptimizer with one single line of code
  74358. * @param scene defines the scene to work on
  74359. * @param options defines the options to use with the SceneOptimizer
  74360. * @param onSuccess defines a callback to call on success
  74361. * @param onFailure defines a callback to call on failure
  74362. * @returns the new SceneOptimizer object
  74363. */
  74364. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74365. }
  74366. }
  74367. declare module "babylonjs/Misc/sceneSerializer" {
  74368. import { Scene } from "babylonjs/scene";
  74369. /**
  74370. * Class used to serialize a scene into a string
  74371. */
  74372. export class SceneSerializer {
  74373. /**
  74374. * Clear cache used by a previous serialization
  74375. */
  74376. static ClearCache(): void;
  74377. /**
  74378. * Serialize a scene into a JSON compatible object
  74379. * @param scene defines the scene to serialize
  74380. * @returns a JSON compatible object
  74381. */
  74382. static Serialize(scene: Scene): any;
  74383. /**
  74384. * Serialize a mesh into a JSON compatible object
  74385. * @param toSerialize defines the mesh to serialize
  74386. * @param withParents defines if parents must be serialized as well
  74387. * @param withChildren defines if children must be serialized as well
  74388. * @returns a JSON compatible object
  74389. */
  74390. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74391. }
  74392. }
  74393. declare module "babylonjs/Misc/textureTools" {
  74394. import { Texture } from "babylonjs/Materials/Textures/texture";
  74395. /**
  74396. * Class used to host texture specific utilities
  74397. */
  74398. export class TextureTools {
  74399. /**
  74400. * Uses the GPU to create a copy texture rescaled at a given size
  74401. * @param texture Texture to copy from
  74402. * @param width defines the desired width
  74403. * @param height defines the desired height
  74404. * @param useBilinearMode defines if bilinear mode has to be used
  74405. * @return the generated texture
  74406. */
  74407. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74408. }
  74409. }
  74410. declare module "babylonjs/Misc/videoRecorder" {
  74411. import { Nullable } from "babylonjs/types";
  74412. import { Engine } from "babylonjs/Engines/engine";
  74413. /**
  74414. * This represents the different options available for the video capture.
  74415. */
  74416. export interface VideoRecorderOptions {
  74417. /** Defines the mime type of the video. */
  74418. mimeType: string;
  74419. /** Defines the FPS the video should be recorded at. */
  74420. fps: number;
  74421. /** Defines the chunk size for the recording data. */
  74422. recordChunckSize: number;
  74423. /** The audio tracks to attach to the recording. */
  74424. audioTracks?: MediaStreamTrack[];
  74425. }
  74426. /**
  74427. * This can help with recording videos from BabylonJS.
  74428. * This is based on the available WebRTC functionalities of the browser.
  74429. *
  74430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74431. */
  74432. export class VideoRecorder {
  74433. private static readonly _defaultOptions;
  74434. /**
  74435. * Returns whether or not the VideoRecorder is available in your browser.
  74436. * @param engine Defines the Babylon Engine.
  74437. * @returns true if supported otherwise false.
  74438. */
  74439. static IsSupported(engine: Engine): boolean;
  74440. private readonly _options;
  74441. private _canvas;
  74442. private _mediaRecorder;
  74443. private _recordedChunks;
  74444. private _fileName;
  74445. private _resolve;
  74446. private _reject;
  74447. /**
  74448. * True when a recording is already in progress.
  74449. */
  74450. get isRecording(): boolean;
  74451. /**
  74452. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74453. * @param engine Defines the BabylonJS Engine you wish to record.
  74454. * @param options Defines options that can be used to customize the capture.
  74455. */
  74456. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74457. /**
  74458. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74459. */
  74460. stopRecording(): void;
  74461. /**
  74462. * Starts recording the canvas for a max duration specified in parameters.
  74463. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74464. * If null no automatic download will start and you can rely on the promise to get the data back.
  74465. * @param maxDuration Defines the maximum recording time in seconds.
  74466. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74467. * @return A promise callback at the end of the recording with the video data in Blob.
  74468. */
  74469. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74470. /**
  74471. * Releases internal resources used during the recording.
  74472. */
  74473. dispose(): void;
  74474. private _handleDataAvailable;
  74475. private _handleError;
  74476. private _handleStop;
  74477. }
  74478. }
  74479. declare module "babylonjs/Misc/screenshotTools" {
  74480. import { Camera } from "babylonjs/Cameras/camera";
  74481. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74482. import { Engine } from "babylonjs/Engines/engine";
  74483. /**
  74484. * Class containing a set of static utilities functions for screenshots
  74485. */
  74486. export class ScreenshotTools {
  74487. /**
  74488. * Captures a screenshot of the current rendering
  74489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74490. * @param engine defines the rendering engine
  74491. * @param camera defines the source camera
  74492. * @param size This parameter can be set to a single number or to an object with the
  74493. * following (optional) properties: precision, width, height. If a single number is passed,
  74494. * it will be used for both width and height. If an object is passed, the screenshot size
  74495. * will be derived from the parameters. The precision property is a multiplier allowing
  74496. * rendering at a higher or lower resolution
  74497. * @param successCallback defines the callback receives a single parameter which contains the
  74498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74499. * src parameter of an <img> to display it
  74500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74501. * Check your browser for supported MIME types
  74502. */
  74503. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74504. /**
  74505. * Captures a screenshot of the current rendering
  74506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74507. * @param engine defines the rendering engine
  74508. * @param camera defines the source camera
  74509. * @param size This parameter can be set to a single number or to an object with the
  74510. * following (optional) properties: precision, width, height. If a single number is passed,
  74511. * it will be used for both width and height. If an object is passed, the screenshot size
  74512. * will be derived from the parameters. The precision property is a multiplier allowing
  74513. * rendering at a higher or lower resolution
  74514. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74515. * Check your browser for supported MIME types
  74516. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74517. * to the src parameter of an <img> to display it
  74518. */
  74519. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74520. /**
  74521. * Generates an image screenshot from the specified camera.
  74522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74523. * @param engine The engine to use for rendering
  74524. * @param camera The camera to use for rendering
  74525. * @param size This parameter can be set to a single number or to an object with the
  74526. * following (optional) properties: precision, width, height. If a single number is passed,
  74527. * it will be used for both width and height. If an object is passed, the screenshot size
  74528. * will be derived from the parameters. The precision property is a multiplier allowing
  74529. * rendering at a higher or lower resolution
  74530. * @param successCallback The callback receives a single parameter which contains the
  74531. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74532. * src parameter of an <img> to display it
  74533. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74534. * Check your browser for supported MIME types
  74535. * @param samples Texture samples (default: 1)
  74536. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74537. * @param fileName A name for for the downloaded file.
  74538. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74539. */
  74540. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74541. /**
  74542. * Generates an image screenshot from the specified camera.
  74543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74544. * @param engine The engine to use for rendering
  74545. * @param camera The camera to use for rendering
  74546. * @param size This parameter can be set to a single number or to an object with the
  74547. * following (optional) properties: precision, width, height. If a single number is passed,
  74548. * it will be used for both width and height. If an object is passed, the screenshot size
  74549. * will be derived from the parameters. The precision property is a multiplier allowing
  74550. * rendering at a higher or lower resolution
  74551. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74552. * Check your browser for supported MIME types
  74553. * @param samples Texture samples (default: 1)
  74554. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74555. * @param fileName A name for for the downloaded file.
  74556. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74557. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74558. * to the src parameter of an <img> to display it
  74559. */
  74560. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74561. /**
  74562. * Gets height and width for screenshot size
  74563. * @private
  74564. */
  74565. private static _getScreenshotSize;
  74566. }
  74567. }
  74568. declare module "babylonjs/Misc/dataReader" {
  74569. /**
  74570. * Interface for a data buffer
  74571. */
  74572. export interface IDataBuffer {
  74573. /**
  74574. * Reads bytes from the data buffer.
  74575. * @param byteOffset The byte offset to read
  74576. * @param byteLength The byte length to read
  74577. * @returns A promise that resolves when the bytes are read
  74578. */
  74579. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74580. /**
  74581. * The byte length of the buffer.
  74582. */
  74583. readonly byteLength: number;
  74584. }
  74585. /**
  74586. * Utility class for reading from a data buffer
  74587. */
  74588. export class DataReader {
  74589. /**
  74590. * The data buffer associated with this data reader.
  74591. */
  74592. readonly buffer: IDataBuffer;
  74593. /**
  74594. * The current byte offset from the beginning of the data buffer.
  74595. */
  74596. byteOffset: number;
  74597. private _dataView;
  74598. private _dataByteOffset;
  74599. /**
  74600. * Constructor
  74601. * @param buffer The buffer to read
  74602. */
  74603. constructor(buffer: IDataBuffer);
  74604. /**
  74605. * Loads the given byte length.
  74606. * @param byteLength The byte length to load
  74607. * @returns A promise that resolves when the load is complete
  74608. */
  74609. loadAsync(byteLength: number): Promise<void>;
  74610. /**
  74611. * Read a unsigned 32-bit integer from the currently loaded data range.
  74612. * @returns The 32-bit integer read
  74613. */
  74614. readUint32(): number;
  74615. /**
  74616. * Read a byte array from the currently loaded data range.
  74617. * @param byteLength The byte length to read
  74618. * @returns The byte array read
  74619. */
  74620. readUint8Array(byteLength: number): Uint8Array;
  74621. /**
  74622. * Read a string from the currently loaded data range.
  74623. * @param byteLength The byte length to read
  74624. * @returns The string read
  74625. */
  74626. readString(byteLength: number): string;
  74627. /**
  74628. * Skips the given byte length the currently loaded data range.
  74629. * @param byteLength The byte length to skip
  74630. */
  74631. skipBytes(byteLength: number): void;
  74632. }
  74633. }
  74634. declare module "babylonjs/Misc/dataStorage" {
  74635. /**
  74636. * Class for storing data to local storage if available or in-memory storage otherwise
  74637. */
  74638. export class DataStorage {
  74639. private static _Storage;
  74640. private static _GetStorage;
  74641. /**
  74642. * Reads a string from the data storage
  74643. * @param key The key to read
  74644. * @param defaultValue The value if the key doesn't exist
  74645. * @returns The string value
  74646. */
  74647. static ReadString(key: string, defaultValue: string): string;
  74648. /**
  74649. * Writes a string to the data storage
  74650. * @param key The key to write
  74651. * @param value The value to write
  74652. */
  74653. static WriteString(key: string, value: string): void;
  74654. /**
  74655. * Reads a boolean from the data storage
  74656. * @param key The key to read
  74657. * @param defaultValue The value if the key doesn't exist
  74658. * @returns The boolean value
  74659. */
  74660. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74661. /**
  74662. * Writes a boolean to the data storage
  74663. * @param key The key to write
  74664. * @param value The value to write
  74665. */
  74666. static WriteBoolean(key: string, value: boolean): void;
  74667. /**
  74668. * Reads a number from the data storage
  74669. * @param key The key to read
  74670. * @param defaultValue The value if the key doesn't exist
  74671. * @returns The number value
  74672. */
  74673. static ReadNumber(key: string, defaultValue: number): number;
  74674. /**
  74675. * Writes a number to the data storage
  74676. * @param key The key to write
  74677. * @param value The value to write
  74678. */
  74679. static WriteNumber(key: string, value: number): void;
  74680. }
  74681. }
  74682. declare module "babylonjs/Misc/index" {
  74683. export * from "babylonjs/Misc/andOrNotEvaluator";
  74684. export * from "babylonjs/Misc/assetsManager";
  74685. export * from "babylonjs/Misc/basis";
  74686. export * from "babylonjs/Misc/dds";
  74687. export * from "babylonjs/Misc/decorators";
  74688. export * from "babylonjs/Misc/deferred";
  74689. export * from "babylonjs/Misc/environmentTextureTools";
  74690. export * from "babylonjs/Misc/meshExploder";
  74691. export * from "babylonjs/Misc/filesInput";
  74692. export * from "babylonjs/Misc/HighDynamicRange/index";
  74693. export * from "babylonjs/Misc/khronosTextureContainer";
  74694. export * from "babylonjs/Misc/observable";
  74695. export * from "babylonjs/Misc/performanceMonitor";
  74696. export * from "babylonjs/Misc/promise";
  74697. export * from "babylonjs/Misc/sceneOptimizer";
  74698. export * from "babylonjs/Misc/sceneSerializer";
  74699. export * from "babylonjs/Misc/smartArray";
  74700. export * from "babylonjs/Misc/stringDictionary";
  74701. export * from "babylonjs/Misc/tags";
  74702. export * from "babylonjs/Misc/textureTools";
  74703. export * from "babylonjs/Misc/tga";
  74704. export * from "babylonjs/Misc/tools";
  74705. export * from "babylonjs/Misc/videoRecorder";
  74706. export * from "babylonjs/Misc/virtualJoystick";
  74707. export * from "babylonjs/Misc/workerPool";
  74708. export * from "babylonjs/Misc/logger";
  74709. export * from "babylonjs/Misc/typeStore";
  74710. export * from "babylonjs/Misc/filesInputStore";
  74711. export * from "babylonjs/Misc/deepCopier";
  74712. export * from "babylonjs/Misc/pivotTools";
  74713. export * from "babylonjs/Misc/precisionDate";
  74714. export * from "babylonjs/Misc/screenshotTools";
  74715. export * from "babylonjs/Misc/typeStore";
  74716. export * from "babylonjs/Misc/webRequest";
  74717. export * from "babylonjs/Misc/iInspectable";
  74718. export * from "babylonjs/Misc/brdfTextureTools";
  74719. export * from "babylonjs/Misc/rgbdTextureTools";
  74720. export * from "babylonjs/Misc/gradients";
  74721. export * from "babylonjs/Misc/perfCounter";
  74722. export * from "babylonjs/Misc/fileRequest";
  74723. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74724. export * from "babylonjs/Misc/retryStrategy";
  74725. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74726. export * from "babylonjs/Misc/canvasGenerator";
  74727. export * from "babylonjs/Misc/fileTools";
  74728. export * from "babylonjs/Misc/stringTools";
  74729. export * from "babylonjs/Misc/dataReader";
  74730. export * from "babylonjs/Misc/minMaxReducer";
  74731. export * from "babylonjs/Misc/depthReducer";
  74732. export * from "babylonjs/Misc/dataStorage";
  74733. }
  74734. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74735. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74736. import { Observable } from "babylonjs/Misc/observable";
  74737. import { Matrix } from "babylonjs/Maths/math.vector";
  74738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74739. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74740. /**
  74741. * Options used for hit testing
  74742. */
  74743. export interface IWebXRLegacyHitTestOptions {
  74744. /**
  74745. * Only test when user interacted with the scene. Default - hit test every frame
  74746. */
  74747. testOnPointerDownOnly?: boolean;
  74748. /**
  74749. * The node to use to transform the local results to world coordinates
  74750. */
  74751. worldParentNode?: TransformNode;
  74752. }
  74753. /**
  74754. * Interface defining the babylon result of raycasting/hit-test
  74755. */
  74756. export interface IWebXRLegacyHitResult {
  74757. /**
  74758. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74759. */
  74760. transformationMatrix: Matrix;
  74761. /**
  74762. * The native hit test result
  74763. */
  74764. xrHitResult: XRHitResult | XRHitTestResult;
  74765. }
  74766. /**
  74767. * The currently-working hit-test module.
  74768. * Hit test (or Ray-casting) is used to interact with the real world.
  74769. * For further information read here - https://github.com/immersive-web/hit-test
  74770. */
  74771. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74772. /**
  74773. * options to use when constructing this feature
  74774. */
  74775. readonly options: IWebXRLegacyHitTestOptions;
  74776. private _direction;
  74777. private _mat;
  74778. private _onSelectEnabled;
  74779. private _origin;
  74780. /**
  74781. * The module's name
  74782. */
  74783. static readonly Name: string;
  74784. /**
  74785. * The (Babylon) version of this module.
  74786. * This is an integer representing the implementation version.
  74787. * This number does not correspond to the WebXR specs version
  74788. */
  74789. static readonly Version: number;
  74790. /**
  74791. * Populated with the last native XR Hit Results
  74792. */
  74793. lastNativeXRHitResults: XRHitResult[];
  74794. /**
  74795. * Triggered when new babylon (transformed) hit test results are available
  74796. */
  74797. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74798. /**
  74799. * Creates a new instance of the (legacy version) hit test feature
  74800. * @param _xrSessionManager an instance of WebXRSessionManager
  74801. * @param options options to use when constructing this feature
  74802. */
  74803. constructor(_xrSessionManager: WebXRSessionManager,
  74804. /**
  74805. * options to use when constructing this feature
  74806. */
  74807. options?: IWebXRLegacyHitTestOptions);
  74808. /**
  74809. * execute a hit test with an XR Ray
  74810. *
  74811. * @param xrSession a native xrSession that will execute this hit test
  74812. * @param xrRay the ray (position and direction) to use for ray-casting
  74813. * @param referenceSpace native XR reference space to use for the hit-test
  74814. * @param filter filter function that will filter the results
  74815. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74816. */
  74817. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74818. /**
  74819. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74820. * @param event the (select) event to use to select with
  74821. * @param referenceSpace the reference space to use for this hit test
  74822. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74823. */
  74824. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74825. /**
  74826. * attach this feature
  74827. * Will usually be called by the features manager
  74828. *
  74829. * @returns true if successful.
  74830. */
  74831. attach(): boolean;
  74832. /**
  74833. * detach this feature.
  74834. * Will usually be called by the features manager
  74835. *
  74836. * @returns true if successful.
  74837. */
  74838. detach(): boolean;
  74839. /**
  74840. * Dispose this feature and all of the resources attached
  74841. */
  74842. dispose(): void;
  74843. protected _onXRFrame(frame: XRFrame): void;
  74844. private _onHitTestResults;
  74845. private _onSelect;
  74846. }
  74847. }
  74848. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  74849. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74850. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74851. import { Observable } from "babylonjs/Misc/observable";
  74852. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  74853. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74854. /**
  74855. * Options used in the plane detector module
  74856. */
  74857. export interface IWebXRPlaneDetectorOptions {
  74858. /**
  74859. * The node to use to transform the local results to world coordinates
  74860. */
  74861. worldParentNode?: TransformNode;
  74862. }
  74863. /**
  74864. * A babylon interface for a WebXR plane.
  74865. * A Plane is actually a polygon, built from N points in space
  74866. *
  74867. * Supported in chrome 79, not supported in canary 81 ATM
  74868. */
  74869. export interface IWebXRPlane {
  74870. /**
  74871. * a babylon-assigned ID for this polygon
  74872. */
  74873. id: number;
  74874. /**
  74875. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74876. */
  74877. polygonDefinition: Array<Vector3>;
  74878. /**
  74879. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74880. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74881. */
  74882. transformationMatrix: Matrix;
  74883. /**
  74884. * the native xr-plane object
  74885. */
  74886. xrPlane: XRPlane;
  74887. }
  74888. /**
  74889. * The plane detector is used to detect planes in the real world when in AR
  74890. * For more information see https://github.com/immersive-web/real-world-geometry/
  74891. */
  74892. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74893. private _options;
  74894. private _detectedPlanes;
  74895. private _enabled;
  74896. private _lastFrameDetected;
  74897. /**
  74898. * The module's name
  74899. */
  74900. static readonly Name: string;
  74901. /**
  74902. * The (Babylon) version of this module.
  74903. * This is an integer representing the implementation version.
  74904. * This number does not correspond to the WebXR specs version
  74905. */
  74906. static readonly Version: number;
  74907. /**
  74908. * Observers registered here will be executed when a new plane was added to the session
  74909. */
  74910. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74911. /**
  74912. * Observers registered here will be executed when a plane is no longer detected in the session
  74913. */
  74914. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74915. /**
  74916. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74917. * This can execute N times every frame
  74918. */
  74919. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74920. /**
  74921. * construct a new Plane Detector
  74922. * @param _xrSessionManager an instance of xr Session manager
  74923. * @param _options configuration to use when constructing this feature
  74924. */
  74925. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74926. /**
  74927. * Dispose this feature and all of the resources attached
  74928. */
  74929. dispose(): void;
  74930. protected _onXRFrame(frame: XRFrame): void;
  74931. private _init;
  74932. private _updatePlaneWithXRPlane;
  74933. /**
  74934. * avoiding using Array.find for global support.
  74935. * @param xrPlane the plane to find in the array
  74936. */
  74937. private findIndexInPlaneArray;
  74938. }
  74939. }
  74940. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  74941. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74942. import { Observable } from "babylonjs/Misc/observable";
  74943. import { Matrix } from "babylonjs/Maths/math.vector";
  74944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74945. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  74946. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  74947. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74948. /**
  74949. * Configuration options of the anchor system
  74950. */
  74951. export interface IWebXRAnchorSystemOptions {
  74952. /**
  74953. * Should a new anchor be added every time a select event is triggered
  74954. */
  74955. addAnchorOnSelect?: boolean;
  74956. /**
  74957. * should the anchor system use plane detection.
  74958. * If set to true, the plane-detection feature should be set using setPlaneDetector
  74959. */
  74960. usePlaneDetection?: boolean;
  74961. /**
  74962. * a node that will be used to convert local to world coordinates
  74963. */
  74964. worldParentNode?: TransformNode;
  74965. }
  74966. /**
  74967. * A babylon container for an XR Anchor
  74968. */
  74969. export interface IWebXRAnchor {
  74970. /**
  74971. * A babylon-assigned ID for this anchor
  74972. */
  74973. id: number;
  74974. /**
  74975. * Transformation matrix to apply to an object attached to this anchor
  74976. */
  74977. transformationMatrix: Matrix;
  74978. /**
  74979. * The native anchor object
  74980. */
  74981. xrAnchor: XRAnchor;
  74982. }
  74983. /**
  74984. * An implementation of the anchor system of WebXR.
  74985. * Note that the current documented implementation is not available in any browser. Future implementations
  74986. * will use the frame to create an anchor and not the session or a detected plane
  74987. * For further information see https://github.com/immersive-web/anchors/
  74988. */
  74989. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74990. private _options;
  74991. private _enabled;
  74992. private _hitTestModule;
  74993. private _lastFrameDetected;
  74994. private _onSelect;
  74995. private _planeDetector;
  74996. private _trackedAnchors;
  74997. /**
  74998. * The module's name
  74999. */
  75000. static readonly Name: string;
  75001. /**
  75002. * The (Babylon) version of this module.
  75003. * This is an integer representing the implementation version.
  75004. * This number does not correspond to the WebXR specs version
  75005. */
  75006. static readonly Version: number;
  75007. /**
  75008. * Observers registered here will be executed when a new anchor was added to the session
  75009. */
  75010. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75011. /**
  75012. * Observers registered here will be executed when an anchor was removed from the session
  75013. */
  75014. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75015. /**
  75016. * Observers registered here will be executed when an existing anchor updates
  75017. * This can execute N times every frame
  75018. */
  75019. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75020. /**
  75021. * constructs a new anchor system
  75022. * @param _xrSessionManager an instance of WebXRSessionManager
  75023. * @param _options configuration object for this feature
  75024. */
  75025. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75026. /**
  75027. * Add anchor at a specific XR point.
  75028. *
  75029. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75030. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75031. * @returns a promise the fulfills when the anchor was created
  75032. */
  75033. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75034. /**
  75035. * attach this feature
  75036. * Will usually be called by the features manager
  75037. *
  75038. * @returns true if successful.
  75039. */
  75040. attach(): boolean;
  75041. /**
  75042. * detach this feature.
  75043. * Will usually be called by the features manager
  75044. *
  75045. * @returns true if successful.
  75046. */
  75047. detach(): boolean;
  75048. /**
  75049. * Dispose this feature and all of the resources attached
  75050. */
  75051. dispose(): void;
  75052. /**
  75053. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75054. * @param hitTestModule the hit-test module to use.
  75055. */
  75056. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75057. /**
  75058. * set the plane detector to use in order to create anchors from frames
  75059. * @param planeDetector the plane-detector module to use
  75060. * @param enable enable plane-anchors. default is true
  75061. */
  75062. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75063. protected _onXRFrame(frame: XRFrame): void;
  75064. /**
  75065. * avoiding using Array.find for global support.
  75066. * @param xrAnchor the plane to find in the array
  75067. */
  75068. private _findIndexInAnchorArray;
  75069. private _updateAnchorWithXRFrame;
  75070. }
  75071. }
  75072. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75073. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75075. import { Observable } from "babylonjs/Misc/observable";
  75076. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75077. /**
  75078. * Options interface for the background remover plugin
  75079. */
  75080. export interface IWebXRBackgroundRemoverOptions {
  75081. /**
  75082. * Further background meshes to disable when entering AR
  75083. */
  75084. backgroundMeshes?: AbstractMesh[];
  75085. /**
  75086. * flags to configure the removal of the environment helper.
  75087. * If not set, the entire background will be removed. If set, flags should be set as well.
  75088. */
  75089. environmentHelperRemovalFlags?: {
  75090. /**
  75091. * Should the skybox be removed (default false)
  75092. */
  75093. skyBox?: boolean;
  75094. /**
  75095. * Should the ground be removed (default false)
  75096. */
  75097. ground?: boolean;
  75098. };
  75099. /**
  75100. * don't disable the environment helper
  75101. */
  75102. ignoreEnvironmentHelper?: boolean;
  75103. }
  75104. /**
  75105. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75106. */
  75107. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75108. /**
  75109. * read-only options to be used in this module
  75110. */
  75111. readonly options: IWebXRBackgroundRemoverOptions;
  75112. /**
  75113. * The module's name
  75114. */
  75115. static readonly Name: string;
  75116. /**
  75117. * The (Babylon) version of this module.
  75118. * This is an integer representing the implementation version.
  75119. * This number does not correspond to the WebXR specs version
  75120. */
  75121. static readonly Version: number;
  75122. /**
  75123. * registered observers will be triggered when the background state changes
  75124. */
  75125. onBackgroundStateChangedObservable: Observable<boolean>;
  75126. /**
  75127. * constructs a new background remover module
  75128. * @param _xrSessionManager the session manager for this module
  75129. * @param options read-only options to be used in this module
  75130. */
  75131. constructor(_xrSessionManager: WebXRSessionManager,
  75132. /**
  75133. * read-only options to be used in this module
  75134. */
  75135. options?: IWebXRBackgroundRemoverOptions);
  75136. /**
  75137. * attach this feature
  75138. * Will usually be called by the features manager
  75139. *
  75140. * @returns true if successful.
  75141. */
  75142. attach(): boolean;
  75143. /**
  75144. * detach this feature.
  75145. * Will usually be called by the features manager
  75146. *
  75147. * @returns true if successful.
  75148. */
  75149. detach(): boolean;
  75150. /**
  75151. * Dispose this feature and all of the resources attached
  75152. */
  75153. dispose(): void;
  75154. protected _onXRFrame(_xrFrame: XRFrame): void;
  75155. private _setBackgroundState;
  75156. }
  75157. }
  75158. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75159. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75160. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75161. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75162. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75163. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75164. import { Nullable } from "babylonjs/types";
  75165. /**
  75166. * Options for the controller physics feature
  75167. */
  75168. export class IWebXRControllerPhysicsOptions {
  75169. /**
  75170. * Should the headset get its own impostor
  75171. */
  75172. enableHeadsetImpostor?: boolean;
  75173. /**
  75174. * Optional parameters for the headset impostor
  75175. */
  75176. headsetImpostorParams?: {
  75177. /**
  75178. * The type of impostor to create. Default is sphere
  75179. */
  75180. impostorType: number;
  75181. /**
  75182. * the size of the impostor. Defaults to 10cm
  75183. */
  75184. impostorSize?: number | {
  75185. width: number;
  75186. height: number;
  75187. depth: number;
  75188. };
  75189. /**
  75190. * Friction definitions
  75191. */
  75192. friction?: number;
  75193. /**
  75194. * Restitution
  75195. */
  75196. restitution?: number;
  75197. };
  75198. /**
  75199. * The physics properties of the future impostors
  75200. */
  75201. physicsProperties?: {
  75202. /**
  75203. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75204. * Note that this requires a physics engine that supports mesh impostors!
  75205. */
  75206. useControllerMesh?: boolean;
  75207. /**
  75208. * The type of impostor to create. Default is sphere
  75209. */
  75210. impostorType?: number;
  75211. /**
  75212. * the size of the impostor. Defaults to 10cm
  75213. */
  75214. impostorSize?: number | {
  75215. width: number;
  75216. height: number;
  75217. depth: number;
  75218. };
  75219. /**
  75220. * Friction definitions
  75221. */
  75222. friction?: number;
  75223. /**
  75224. * Restitution
  75225. */
  75226. restitution?: number;
  75227. };
  75228. /**
  75229. * the xr input to use with this pointer selection
  75230. */
  75231. xrInput: WebXRInput;
  75232. }
  75233. /**
  75234. * Add physics impostor to your webxr controllers,
  75235. * including naive calculation of their linear and angular velocity
  75236. */
  75237. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75238. private readonly _options;
  75239. private _attachController;
  75240. private _controllers;
  75241. private _debugMode;
  75242. private _delta;
  75243. private _headsetImpostor?;
  75244. private _headsetMesh?;
  75245. private _lastTimestamp;
  75246. private _tmpQuaternion;
  75247. private _tmpVector;
  75248. /**
  75249. * The module's name
  75250. */
  75251. static readonly Name: string;
  75252. /**
  75253. * The (Babylon) version of this module.
  75254. * This is an integer representing the implementation version.
  75255. * This number does not correspond to the webxr specs version
  75256. */
  75257. static readonly Version: number;
  75258. /**
  75259. * Construct a new Controller Physics Feature
  75260. * @param _xrSessionManager the corresponding xr session manager
  75261. * @param _options options to create this feature with
  75262. */
  75263. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75264. /**
  75265. * @hidden
  75266. * enable debugging - will show console outputs and the impostor mesh
  75267. */
  75268. _enablePhysicsDebug(): void;
  75269. /**
  75270. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75271. * @param xrController the controller to add
  75272. */
  75273. addController(xrController: WebXRInputSource): void;
  75274. /**
  75275. * attach this feature
  75276. * Will usually be called by the features manager
  75277. *
  75278. * @returns true if successful.
  75279. */
  75280. attach(): boolean;
  75281. /**
  75282. * detach this feature.
  75283. * Will usually be called by the features manager
  75284. *
  75285. * @returns true if successful.
  75286. */
  75287. detach(): boolean;
  75288. /**
  75289. * Get the headset impostor, if enabled
  75290. * @returns the impostor
  75291. */
  75292. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75293. /**
  75294. * Get the physics impostor of a specific controller.
  75295. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75296. * @param controller the controller or the controller id of which to get the impostor
  75297. * @returns the impostor or null
  75298. */
  75299. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75300. /**
  75301. * Update the physics properties provided in the constructor
  75302. * @param newProperties the new properties object
  75303. */
  75304. setPhysicsProperties(newProperties: {
  75305. impostorType?: number;
  75306. impostorSize?: number | {
  75307. width: number;
  75308. height: number;
  75309. depth: number;
  75310. };
  75311. friction?: number;
  75312. restitution?: number;
  75313. }): void;
  75314. protected _onXRFrame(_xrFrame: any): void;
  75315. private _detachController;
  75316. }
  75317. }
  75318. declare module "babylonjs/XR/features/WebXRHitTest" {
  75319. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75320. import { Observable } from "babylonjs/Misc/observable";
  75321. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75322. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75323. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75324. /**
  75325. * Options used for hit testing (version 2)
  75326. */
  75327. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75328. /**
  75329. * Do not create a permanent hit test. Will usually be used when only
  75330. * transient inputs are needed.
  75331. */
  75332. disablePermanentHitTest?: boolean;
  75333. /**
  75334. * Enable transient (for example touch-based) hit test inspections
  75335. */
  75336. enableTransientHitTest?: boolean;
  75337. /**
  75338. * Offset ray for the permanent hit test
  75339. */
  75340. offsetRay?: Vector3;
  75341. /**
  75342. * Offset ray for the transient hit test
  75343. */
  75344. transientOffsetRay?: Vector3;
  75345. /**
  75346. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75347. */
  75348. useReferenceSpace?: boolean;
  75349. }
  75350. /**
  75351. * Interface defining the babylon result of hit-test
  75352. */
  75353. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75354. /**
  75355. * The input source that generated this hit test (if transient)
  75356. */
  75357. inputSource?: XRInputSource;
  75358. /**
  75359. * Is this a transient hit test
  75360. */
  75361. isTransient?: boolean;
  75362. /**
  75363. * Position of the hit test result
  75364. */
  75365. position: Vector3;
  75366. /**
  75367. * Rotation of the hit test result
  75368. */
  75369. rotationQuaternion: Quaternion;
  75370. }
  75371. /**
  75372. * The currently-working hit-test module.
  75373. * Hit test (or Ray-casting) is used to interact with the real world.
  75374. * For further information read here - https://github.com/immersive-web/hit-test
  75375. *
  75376. * Tested on chrome (mobile) 80.
  75377. */
  75378. export class WebXRHitTest extends WebXRAbstractFeature {
  75379. /**
  75380. * options to use when constructing this feature
  75381. */
  75382. readonly options: IWebXRHitTestOptions;
  75383. private _tmpMat;
  75384. private _tmpPos;
  75385. private _tmpQuat;
  75386. private _transientXrHitTestSource;
  75387. private _xrHitTestSource;
  75388. private initHitTestSource;
  75389. /**
  75390. * The module's name
  75391. */
  75392. static readonly Name: string;
  75393. /**
  75394. * The (Babylon) version of this module.
  75395. * This is an integer representing the implementation version.
  75396. * This number does not correspond to the WebXR specs version
  75397. */
  75398. static readonly Version: number;
  75399. /**
  75400. * When set to true, each hit test will have its own position/rotation objects
  75401. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75402. * the developers will clone them or copy them as they see fit.
  75403. */
  75404. autoCloneTransformation: boolean;
  75405. /**
  75406. * Populated with the last native XR Hit Results
  75407. */
  75408. lastNativeXRHitResults: XRHitResult[];
  75409. /**
  75410. * Triggered when new babylon (transformed) hit test results are available
  75411. */
  75412. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75413. /**
  75414. * Use this to temporarily pause hit test checks.
  75415. */
  75416. paused: boolean;
  75417. /**
  75418. * Creates a new instance of the hit test feature
  75419. * @param _xrSessionManager an instance of WebXRSessionManager
  75420. * @param options options to use when constructing this feature
  75421. */
  75422. constructor(_xrSessionManager: WebXRSessionManager,
  75423. /**
  75424. * options to use when constructing this feature
  75425. */
  75426. options?: IWebXRHitTestOptions);
  75427. /**
  75428. * attach this feature
  75429. * Will usually be called by the features manager
  75430. *
  75431. * @returns true if successful.
  75432. */
  75433. attach(): boolean;
  75434. /**
  75435. * detach this feature.
  75436. * Will usually be called by the features manager
  75437. *
  75438. * @returns true if successful.
  75439. */
  75440. detach(): boolean;
  75441. /**
  75442. * Dispose this feature and all of the resources attached
  75443. */
  75444. dispose(): void;
  75445. protected _onXRFrame(frame: XRFrame): void;
  75446. private _processWebXRHitTestResult;
  75447. }
  75448. }
  75449. declare module "babylonjs/XR/features/index" {
  75450. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75451. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75452. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75453. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75454. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75455. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75456. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75457. export * from "babylonjs/XR/features/WebXRHitTest";
  75458. }
  75459. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75460. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75462. import { Scene } from "babylonjs/scene";
  75463. /**
  75464. * The motion controller class for all microsoft mixed reality controllers
  75465. */
  75466. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75467. protected readonly _mapping: {
  75468. defaultButton: {
  75469. valueNodeName: string;
  75470. unpressedNodeName: string;
  75471. pressedNodeName: string;
  75472. };
  75473. defaultAxis: {
  75474. valueNodeName: string;
  75475. minNodeName: string;
  75476. maxNodeName: string;
  75477. };
  75478. buttons: {
  75479. "xr-standard-trigger": {
  75480. rootNodeName: string;
  75481. componentProperty: string;
  75482. states: string[];
  75483. };
  75484. "xr-standard-squeeze": {
  75485. rootNodeName: string;
  75486. componentProperty: string;
  75487. states: string[];
  75488. };
  75489. "xr-standard-touchpad": {
  75490. rootNodeName: string;
  75491. labelAnchorNodeName: string;
  75492. touchPointNodeName: string;
  75493. };
  75494. "xr-standard-thumbstick": {
  75495. rootNodeName: string;
  75496. componentProperty: string;
  75497. states: string[];
  75498. };
  75499. };
  75500. axes: {
  75501. "xr-standard-touchpad": {
  75502. "x-axis": {
  75503. rootNodeName: string;
  75504. };
  75505. "y-axis": {
  75506. rootNodeName: string;
  75507. };
  75508. };
  75509. "xr-standard-thumbstick": {
  75510. "x-axis": {
  75511. rootNodeName: string;
  75512. };
  75513. "y-axis": {
  75514. rootNodeName: string;
  75515. };
  75516. };
  75517. };
  75518. };
  75519. /**
  75520. * The base url used to load the left and right controller models
  75521. */
  75522. static MODEL_BASE_URL: string;
  75523. /**
  75524. * The name of the left controller model file
  75525. */
  75526. static MODEL_LEFT_FILENAME: string;
  75527. /**
  75528. * The name of the right controller model file
  75529. */
  75530. static MODEL_RIGHT_FILENAME: string;
  75531. profileId: string;
  75532. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75533. protected _getFilenameAndPath(): {
  75534. filename: string;
  75535. path: string;
  75536. };
  75537. protected _getModelLoadingConstraints(): boolean;
  75538. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75539. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75540. protected _updateModel(): void;
  75541. }
  75542. }
  75543. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75544. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75546. import { Scene } from "babylonjs/scene";
  75547. /**
  75548. * The motion controller class for oculus touch (quest, rift).
  75549. * This class supports legacy mapping as well the standard xr mapping
  75550. */
  75551. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75552. private _forceLegacyControllers;
  75553. private _modelRootNode;
  75554. /**
  75555. * The base url used to load the left and right controller models
  75556. */
  75557. static MODEL_BASE_URL: string;
  75558. /**
  75559. * The name of the left controller model file
  75560. */
  75561. static MODEL_LEFT_FILENAME: string;
  75562. /**
  75563. * The name of the right controller model file
  75564. */
  75565. static MODEL_RIGHT_FILENAME: string;
  75566. /**
  75567. * Base Url for the Quest controller model.
  75568. */
  75569. static QUEST_MODEL_BASE_URL: string;
  75570. profileId: string;
  75571. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75572. protected _getFilenameAndPath(): {
  75573. filename: string;
  75574. path: string;
  75575. };
  75576. protected _getModelLoadingConstraints(): boolean;
  75577. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75578. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75579. protected _updateModel(): void;
  75580. /**
  75581. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75582. * between the touch and touch 2.
  75583. */
  75584. private _isQuest;
  75585. }
  75586. }
  75587. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75588. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75589. import { Scene } from "babylonjs/scene";
  75590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75591. /**
  75592. * The motion controller class for the standard HTC-Vive controllers
  75593. */
  75594. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75595. private _modelRootNode;
  75596. /**
  75597. * The base url used to load the left and right controller models
  75598. */
  75599. static MODEL_BASE_URL: string;
  75600. /**
  75601. * File name for the controller model.
  75602. */
  75603. static MODEL_FILENAME: string;
  75604. profileId: string;
  75605. /**
  75606. * Create a new Vive motion controller object
  75607. * @param scene the scene to use to create this controller
  75608. * @param gamepadObject the corresponding gamepad object
  75609. * @param handedness the handedness of the controller
  75610. */
  75611. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75612. protected _getFilenameAndPath(): {
  75613. filename: string;
  75614. path: string;
  75615. };
  75616. protected _getModelLoadingConstraints(): boolean;
  75617. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75618. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75619. protected _updateModel(): void;
  75620. }
  75621. }
  75622. declare module "babylonjs/XR/motionController/index" {
  75623. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75624. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75625. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75626. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75627. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75628. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75629. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75630. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75631. }
  75632. declare module "babylonjs/XR/index" {
  75633. export * from "babylonjs/XR/webXRCamera";
  75634. export * from "babylonjs/XR/webXREnterExitUI";
  75635. export * from "babylonjs/XR/webXRExperienceHelper";
  75636. export * from "babylonjs/XR/webXRInput";
  75637. export * from "babylonjs/XR/webXRInputSource";
  75638. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75639. export * from "babylonjs/XR/webXRTypes";
  75640. export * from "babylonjs/XR/webXRSessionManager";
  75641. export * from "babylonjs/XR/webXRDefaultExperience";
  75642. export * from "babylonjs/XR/webXRFeaturesManager";
  75643. export * from "babylonjs/XR/features/index";
  75644. export * from "babylonjs/XR/motionController/index";
  75645. }
  75646. declare module "babylonjs/index" {
  75647. export * from "babylonjs/abstractScene";
  75648. export * from "babylonjs/Actions/index";
  75649. export * from "babylonjs/Animations/index";
  75650. export * from "babylonjs/assetContainer";
  75651. export * from "babylonjs/Audio/index";
  75652. export * from "babylonjs/Behaviors/index";
  75653. export * from "babylonjs/Bones/index";
  75654. export * from "babylonjs/Cameras/index";
  75655. export * from "babylonjs/Collisions/index";
  75656. export * from "babylonjs/Culling/index";
  75657. export * from "babylonjs/Debug/index";
  75658. export * from "babylonjs/DeviceInput/index";
  75659. export * from "babylonjs/Engines/index";
  75660. export * from "babylonjs/Events/index";
  75661. export * from "babylonjs/Gamepads/index";
  75662. export * from "babylonjs/Gizmos/index";
  75663. export * from "babylonjs/Helpers/index";
  75664. export * from "babylonjs/Instrumentation/index";
  75665. export * from "babylonjs/Layers/index";
  75666. export * from "babylonjs/LensFlares/index";
  75667. export * from "babylonjs/Lights/index";
  75668. export * from "babylonjs/Loading/index";
  75669. export * from "babylonjs/Materials/index";
  75670. export * from "babylonjs/Maths/index";
  75671. export * from "babylonjs/Meshes/index";
  75672. export * from "babylonjs/Morph/index";
  75673. export * from "babylonjs/Navigation/index";
  75674. export * from "babylonjs/node";
  75675. export * from "babylonjs/Offline/index";
  75676. export * from "babylonjs/Particles/index";
  75677. export * from "babylonjs/Physics/index";
  75678. export * from "babylonjs/PostProcesses/index";
  75679. export * from "babylonjs/Probes/index";
  75680. export * from "babylonjs/Rendering/index";
  75681. export * from "babylonjs/scene";
  75682. export * from "babylonjs/sceneComponent";
  75683. export * from "babylonjs/Sprites/index";
  75684. export * from "babylonjs/States/index";
  75685. export * from "babylonjs/Misc/index";
  75686. export * from "babylonjs/XR/index";
  75687. export * from "babylonjs/types";
  75688. }
  75689. declare module "babylonjs/Animations/pathCursor" {
  75690. import { Vector3 } from "babylonjs/Maths/math.vector";
  75691. import { Path2 } from "babylonjs/Maths/math.path";
  75692. /**
  75693. * A cursor which tracks a point on a path
  75694. */
  75695. export class PathCursor {
  75696. private path;
  75697. /**
  75698. * Stores path cursor callbacks for when an onchange event is triggered
  75699. */
  75700. private _onchange;
  75701. /**
  75702. * The value of the path cursor
  75703. */
  75704. value: number;
  75705. /**
  75706. * The animation array of the path cursor
  75707. */
  75708. animations: Animation[];
  75709. /**
  75710. * Initializes the path cursor
  75711. * @param path The path to track
  75712. */
  75713. constructor(path: Path2);
  75714. /**
  75715. * Gets the cursor point on the path
  75716. * @returns A point on the path cursor at the cursor location
  75717. */
  75718. getPoint(): Vector3;
  75719. /**
  75720. * Moves the cursor ahead by the step amount
  75721. * @param step The amount to move the cursor forward
  75722. * @returns This path cursor
  75723. */
  75724. moveAhead(step?: number): PathCursor;
  75725. /**
  75726. * Moves the cursor behind by the step amount
  75727. * @param step The amount to move the cursor back
  75728. * @returns This path cursor
  75729. */
  75730. moveBack(step?: number): PathCursor;
  75731. /**
  75732. * Moves the cursor by the step amount
  75733. * If the step amount is greater than one, an exception is thrown
  75734. * @param step The amount to move the cursor
  75735. * @returns This path cursor
  75736. */
  75737. move(step: number): PathCursor;
  75738. /**
  75739. * Ensures that the value is limited between zero and one
  75740. * @returns This path cursor
  75741. */
  75742. private ensureLimits;
  75743. /**
  75744. * Runs onchange callbacks on change (used by the animation engine)
  75745. * @returns This path cursor
  75746. */
  75747. private raiseOnChange;
  75748. /**
  75749. * Executes a function on change
  75750. * @param f A path cursor onchange callback
  75751. * @returns This path cursor
  75752. */
  75753. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75754. }
  75755. }
  75756. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75757. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75758. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75759. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75760. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75761. }
  75762. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75763. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75764. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75765. }
  75766. declare module "babylonjs/Engines/Processors/index" {
  75767. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75768. export * from "babylonjs/Engines/Processors/Expressions/index";
  75769. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75770. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75771. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75772. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75773. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75774. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75775. }
  75776. declare module "babylonjs/Legacy/legacy" {
  75777. import * as Babylon from "babylonjs/index";
  75778. export * from "babylonjs/index";
  75779. }
  75780. declare module "babylonjs/Shaders/blur.fragment" {
  75781. /** @hidden */
  75782. export var blurPixelShader: {
  75783. name: string;
  75784. shader: string;
  75785. };
  75786. }
  75787. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75788. /** @hidden */
  75789. export var pointCloudVertexDeclaration: {
  75790. name: string;
  75791. shader: string;
  75792. };
  75793. }
  75794. declare module "babylonjs" {
  75795. export * from "babylonjs/Legacy/legacy";
  75796. }
  75797. declare module BABYLON {
  75798. /** Alias type for value that can be null */
  75799. export type Nullable<T> = T | null;
  75800. /**
  75801. * Alias type for number that are floats
  75802. * @ignorenaming
  75803. */
  75804. export type float = number;
  75805. /**
  75806. * Alias type for number that are doubles.
  75807. * @ignorenaming
  75808. */
  75809. export type double = number;
  75810. /**
  75811. * Alias type for number that are integer
  75812. * @ignorenaming
  75813. */
  75814. export type int = number;
  75815. /** Alias type for number array or Float32Array */
  75816. export type FloatArray = number[] | Float32Array;
  75817. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  75818. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  75819. /**
  75820. * Alias for types that can be used by a Buffer or VertexBuffer.
  75821. */
  75822. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  75823. /**
  75824. * Alias type for primitive types
  75825. * @ignorenaming
  75826. */
  75827. type Primitive = undefined | null | boolean | string | number | Function;
  75828. /**
  75829. * Type modifier to make all the properties of an object Readonly
  75830. */
  75831. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  75832. /**
  75833. * Type modifier to make all the properties of an object Readonly recursively
  75834. */
  75835. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  75836. /**
  75837. * Type modifier to make object properties readonly.
  75838. */
  75839. export type DeepImmutableObject<T> = {
  75840. readonly [K in keyof T]: DeepImmutable<T[K]>;
  75841. };
  75842. /** @hidden */
  75843. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  75844. }
  75845. }
  75846. declare module BABYLON {
  75847. /**
  75848. * A class serves as a medium between the observable and its observers
  75849. */
  75850. export class EventState {
  75851. /**
  75852. * Create a new EventState
  75853. * @param mask defines the mask associated with this state
  75854. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75855. * @param target defines the original target of the state
  75856. * @param currentTarget defines the current target of the state
  75857. */
  75858. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  75859. /**
  75860. * Initialize the current event state
  75861. * @param mask defines the mask associated with this state
  75862. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75863. * @param target defines the original target of the state
  75864. * @param currentTarget defines the current target of the state
  75865. * @returns the current event state
  75866. */
  75867. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  75868. /**
  75869. * An Observer can set this property to true to prevent subsequent observers of being notified
  75870. */
  75871. skipNextObservers: boolean;
  75872. /**
  75873. * Get the mask value that were used to trigger the event corresponding to this EventState object
  75874. */
  75875. mask: number;
  75876. /**
  75877. * The object that originally notified the event
  75878. */
  75879. target?: any;
  75880. /**
  75881. * The current object in the bubbling phase
  75882. */
  75883. currentTarget?: any;
  75884. /**
  75885. * This will be populated with the return value of the last function that was executed.
  75886. * If it is the first function in the callback chain it will be the event data.
  75887. */
  75888. lastReturnValue?: any;
  75889. }
  75890. /**
  75891. * Represent an Observer registered to a given Observable object.
  75892. */
  75893. export class Observer<T> {
  75894. /**
  75895. * Defines the callback to call when the observer is notified
  75896. */
  75897. callback: (eventData: T, eventState: EventState) => void;
  75898. /**
  75899. * Defines the mask of the observer (used to filter notifications)
  75900. */
  75901. mask: number;
  75902. /**
  75903. * Defines the current scope used to restore the JS context
  75904. */
  75905. scope: any;
  75906. /** @hidden */
  75907. _willBeUnregistered: boolean;
  75908. /**
  75909. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  75910. */
  75911. unregisterOnNextCall: boolean;
  75912. /**
  75913. * Creates a new observer
  75914. * @param callback defines the callback to call when the observer is notified
  75915. * @param mask defines the mask of the observer (used to filter notifications)
  75916. * @param scope defines the current scope used to restore the JS context
  75917. */
  75918. constructor(
  75919. /**
  75920. * Defines the callback to call when the observer is notified
  75921. */
  75922. callback: (eventData: T, eventState: EventState) => void,
  75923. /**
  75924. * Defines the mask of the observer (used to filter notifications)
  75925. */
  75926. mask: number,
  75927. /**
  75928. * Defines the current scope used to restore the JS context
  75929. */
  75930. scope?: any);
  75931. }
  75932. /**
  75933. * Represent a list of observers registered to multiple Observables object.
  75934. */
  75935. export class MultiObserver<T> {
  75936. private _observers;
  75937. private _observables;
  75938. /**
  75939. * Release associated resources
  75940. */
  75941. dispose(): void;
  75942. /**
  75943. * Raise a callback when one of the observable will notify
  75944. * @param observables defines a list of observables to watch
  75945. * @param callback defines the callback to call on notification
  75946. * @param mask defines the mask used to filter notifications
  75947. * @param scope defines the current scope used to restore the JS context
  75948. * @returns the new MultiObserver
  75949. */
  75950. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  75951. }
  75952. /**
  75953. * The Observable class is a simple implementation of the Observable pattern.
  75954. *
  75955. * 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.
  75956. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  75957. * 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).
  75958. * 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.
  75959. */
  75960. export class Observable<T> {
  75961. private _observers;
  75962. private _eventState;
  75963. private _onObserverAdded;
  75964. /**
  75965. * Gets the list of observers
  75966. */
  75967. get observers(): Array<Observer<T>>;
  75968. /**
  75969. * Creates a new observable
  75970. * @param onObserverAdded defines a callback to call when a new observer is added
  75971. */
  75972. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  75973. /**
  75974. * Create a new Observer with the specified callback
  75975. * @param callback the callback that will be executed for that Observer
  75976. * @param mask the mask used to filter observers
  75977. * @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.
  75978. * @param scope optional scope for the callback to be called from
  75979. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  75980. * @returns the new observer created for the callback
  75981. */
  75982. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  75983. /**
  75984. * Create a new Observer with the specified callback and unregisters after the next notification
  75985. * @param callback the callback that will be executed for that Observer
  75986. * @returns the new observer created for the callback
  75987. */
  75988. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  75989. /**
  75990. * Remove an Observer from the Observable object
  75991. * @param observer the instance of the Observer to remove
  75992. * @returns false if it doesn't belong to this Observable
  75993. */
  75994. remove(observer: Nullable<Observer<T>>): boolean;
  75995. /**
  75996. * Remove a callback from the Observable object
  75997. * @param callback the callback to remove
  75998. * @param scope optional scope. If used only the callbacks with this scope will be removed
  75999. * @returns false if it doesn't belong to this Observable
  76000. */
  76001. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  76002. private _deferUnregister;
  76003. private _remove;
  76004. /**
  76005. * Moves the observable to the top of the observer list making it get called first when notified
  76006. * @param observer the observer to move
  76007. */
  76008. makeObserverTopPriority(observer: Observer<T>): void;
  76009. /**
  76010. * Moves the observable to the bottom of the observer list making it get called last when notified
  76011. * @param observer the observer to move
  76012. */
  76013. makeObserverBottomPriority(observer: Observer<T>): void;
  76014. /**
  76015. * Notify all Observers by calling their respective callback with the given data
  76016. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76017. * @param eventData defines the data to send to all observers
  76018. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76019. * @param target defines the original target of the state
  76020. * @param currentTarget defines the current target of the state
  76021. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76022. */
  76023. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76024. /**
  76025. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76026. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76027. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76028. * and it is crucial that all callbacks will be executed.
  76029. * The order of the callbacks is kept, callbacks are not executed parallel.
  76030. *
  76031. * @param eventData The data to be sent to each callback
  76032. * @param mask is used to filter observers defaults to -1
  76033. * @param target defines the callback target (see EventState)
  76034. * @param currentTarget defines he current object in the bubbling phase
  76035. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76036. */
  76037. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76038. /**
  76039. * Notify a specific observer
  76040. * @param observer defines the observer to notify
  76041. * @param eventData defines the data to be sent to each callback
  76042. * @param mask is used to filter observers defaults to -1
  76043. */
  76044. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76045. /**
  76046. * Gets a boolean indicating if the observable has at least one observer
  76047. * @returns true is the Observable has at least one Observer registered
  76048. */
  76049. hasObservers(): boolean;
  76050. /**
  76051. * Clear the list of observers
  76052. */
  76053. clear(): void;
  76054. /**
  76055. * Clone the current observable
  76056. * @returns a new observable
  76057. */
  76058. clone(): Observable<T>;
  76059. /**
  76060. * Does this observable handles observer registered with a given mask
  76061. * @param mask defines the mask to be tested
  76062. * @return whether or not one observer registered with the given mask is handeled
  76063. **/
  76064. hasSpecificMask(mask?: number): boolean;
  76065. }
  76066. }
  76067. declare module BABYLON {
  76068. /**
  76069. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76070. * Babylon.js
  76071. */
  76072. export class DomManagement {
  76073. /**
  76074. * Checks if the window object exists
  76075. * @returns true if the window object exists
  76076. */
  76077. static IsWindowObjectExist(): boolean;
  76078. /**
  76079. * Checks if the navigator object exists
  76080. * @returns true if the navigator object exists
  76081. */
  76082. static IsNavigatorAvailable(): boolean;
  76083. /**
  76084. * Check if the document object exists
  76085. * @returns true if the document object exists
  76086. */
  76087. static IsDocumentAvailable(): boolean;
  76088. /**
  76089. * Extracts text content from a DOM element hierarchy
  76090. * @param element defines the root element
  76091. * @returns a string
  76092. */
  76093. static GetDOMTextContent(element: HTMLElement): string;
  76094. }
  76095. }
  76096. declare module BABYLON {
  76097. /**
  76098. * Logger used througouht the application to allow configuration of
  76099. * the log level required for the messages.
  76100. */
  76101. export class Logger {
  76102. /**
  76103. * No log
  76104. */
  76105. static readonly NoneLogLevel: number;
  76106. /**
  76107. * Only message logs
  76108. */
  76109. static readonly MessageLogLevel: number;
  76110. /**
  76111. * Only warning logs
  76112. */
  76113. static readonly WarningLogLevel: number;
  76114. /**
  76115. * Only error logs
  76116. */
  76117. static readonly ErrorLogLevel: number;
  76118. /**
  76119. * All logs
  76120. */
  76121. static readonly AllLogLevel: number;
  76122. private static _LogCache;
  76123. /**
  76124. * Gets a value indicating the number of loading errors
  76125. * @ignorenaming
  76126. */
  76127. static errorsCount: number;
  76128. /**
  76129. * Callback called when a new log is added
  76130. */
  76131. static OnNewCacheEntry: (entry: string) => void;
  76132. private static _AddLogEntry;
  76133. private static _FormatMessage;
  76134. private static _LogDisabled;
  76135. private static _LogEnabled;
  76136. private static _WarnDisabled;
  76137. private static _WarnEnabled;
  76138. private static _ErrorDisabled;
  76139. private static _ErrorEnabled;
  76140. /**
  76141. * Log a message to the console
  76142. */
  76143. static Log: (message: string) => void;
  76144. /**
  76145. * Write a warning message to the console
  76146. */
  76147. static Warn: (message: string) => void;
  76148. /**
  76149. * Write an error message to the console
  76150. */
  76151. static Error: (message: string) => void;
  76152. /**
  76153. * Gets current log cache (list of logs)
  76154. */
  76155. static get LogCache(): string;
  76156. /**
  76157. * Clears the log cache
  76158. */
  76159. static ClearLogCache(): void;
  76160. /**
  76161. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76162. */
  76163. static set LogLevels(level: number);
  76164. }
  76165. }
  76166. declare module BABYLON {
  76167. /** @hidden */
  76168. export class _TypeStore {
  76169. /** @hidden */
  76170. static RegisteredTypes: {
  76171. [key: string]: Object;
  76172. };
  76173. /** @hidden */
  76174. static GetClass(fqdn: string): any;
  76175. }
  76176. }
  76177. declare module BABYLON {
  76178. /**
  76179. * Helper to manipulate strings
  76180. */
  76181. export class StringTools {
  76182. /**
  76183. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76184. * @param str Source string
  76185. * @param suffix Suffix to search for in the source string
  76186. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76187. */
  76188. static EndsWith(str: string, suffix: string): boolean;
  76189. /**
  76190. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76191. * @param str Source string
  76192. * @param suffix Suffix to search for in the source string
  76193. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76194. */
  76195. static StartsWith(str: string, suffix: string): boolean;
  76196. /**
  76197. * Decodes a buffer into a string
  76198. * @param buffer The buffer to decode
  76199. * @returns The decoded string
  76200. */
  76201. static Decode(buffer: Uint8Array | Uint16Array): string;
  76202. /**
  76203. * Encode a buffer to a base64 string
  76204. * @param buffer defines the buffer to encode
  76205. * @returns the encoded string
  76206. */
  76207. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76208. /**
  76209. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76210. * @param num the number to convert and pad
  76211. * @param length the expected length of the string
  76212. * @returns the padded string
  76213. */
  76214. static PadNumber(num: number, length: number): string;
  76215. }
  76216. }
  76217. declare module BABYLON {
  76218. /**
  76219. * Class containing a set of static utilities functions for deep copy.
  76220. */
  76221. export class DeepCopier {
  76222. /**
  76223. * Tries to copy an object by duplicating every property
  76224. * @param source defines the source object
  76225. * @param destination defines the target object
  76226. * @param doNotCopyList defines a list of properties to avoid
  76227. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76228. */
  76229. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76230. }
  76231. }
  76232. declare module BABYLON {
  76233. /**
  76234. * Class containing a set of static utilities functions for precision date
  76235. */
  76236. export class PrecisionDate {
  76237. /**
  76238. * Gets either window.performance.now() if supported or Date.now() else
  76239. */
  76240. static get Now(): number;
  76241. }
  76242. }
  76243. declare module BABYLON {
  76244. /** @hidden */
  76245. export class _DevTools {
  76246. static WarnImport(name: string): string;
  76247. }
  76248. }
  76249. declare module BABYLON {
  76250. /**
  76251. * Interface used to define the mechanism to get data from the network
  76252. */
  76253. export interface IWebRequest {
  76254. /**
  76255. * Returns client's response url
  76256. */
  76257. responseURL: string;
  76258. /**
  76259. * Returns client's status
  76260. */
  76261. status: number;
  76262. /**
  76263. * Returns client's status as a text
  76264. */
  76265. statusText: string;
  76266. }
  76267. }
  76268. declare module BABYLON {
  76269. /**
  76270. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76271. */
  76272. export class WebRequest implements IWebRequest {
  76273. private _xhr;
  76274. /**
  76275. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76276. * i.e. when loading files, where the server/service expects an Authorization header
  76277. */
  76278. static CustomRequestHeaders: {
  76279. [key: string]: string;
  76280. };
  76281. /**
  76282. * Add callback functions in this array to update all the requests before they get sent to the network
  76283. */
  76284. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76285. private _injectCustomRequestHeaders;
  76286. /**
  76287. * Gets or sets a function to be called when loading progress changes
  76288. */
  76289. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76290. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76291. /**
  76292. * Returns client's state
  76293. */
  76294. get readyState(): number;
  76295. /**
  76296. * Returns client's status
  76297. */
  76298. get status(): number;
  76299. /**
  76300. * Returns client's status as a text
  76301. */
  76302. get statusText(): string;
  76303. /**
  76304. * Returns client's response
  76305. */
  76306. get response(): any;
  76307. /**
  76308. * Returns client's response url
  76309. */
  76310. get responseURL(): string;
  76311. /**
  76312. * Returns client's response as text
  76313. */
  76314. get responseText(): string;
  76315. /**
  76316. * Gets or sets the expected response type
  76317. */
  76318. get responseType(): XMLHttpRequestResponseType;
  76319. set responseType(value: XMLHttpRequestResponseType);
  76320. /** @hidden */
  76321. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76322. /** @hidden */
  76323. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76324. /**
  76325. * Cancels any network activity
  76326. */
  76327. abort(): void;
  76328. /**
  76329. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76330. * @param body defines an optional request body
  76331. */
  76332. send(body?: Document | BodyInit | null): void;
  76333. /**
  76334. * Sets the request method, request URL
  76335. * @param method defines the method to use (GET, POST, etc..)
  76336. * @param url defines the url to connect with
  76337. */
  76338. open(method: string, url: string): void;
  76339. /**
  76340. * Sets the value of a request header.
  76341. * @param name The name of the header whose value is to be set
  76342. * @param value The value to set as the body of the header
  76343. */
  76344. setRequestHeader(name: string, value: string): void;
  76345. /**
  76346. * Get the string containing the text of a particular header's value.
  76347. * @param name The name of the header
  76348. * @returns The string containing the text of the given header name
  76349. */
  76350. getResponseHeader(name: string): Nullable<string>;
  76351. }
  76352. }
  76353. declare module BABYLON {
  76354. /**
  76355. * File request interface
  76356. */
  76357. export interface IFileRequest {
  76358. /**
  76359. * Raised when the request is complete (success or error).
  76360. */
  76361. onCompleteObservable: Observable<IFileRequest>;
  76362. /**
  76363. * Aborts the request for a file.
  76364. */
  76365. abort: () => void;
  76366. }
  76367. }
  76368. declare module BABYLON {
  76369. /**
  76370. * Define options used to create a render target texture
  76371. */
  76372. export class RenderTargetCreationOptions {
  76373. /**
  76374. * Specifies is mipmaps must be generated
  76375. */
  76376. generateMipMaps?: boolean;
  76377. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76378. generateDepthBuffer?: boolean;
  76379. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76380. generateStencilBuffer?: boolean;
  76381. /** Defines texture type (int by default) */
  76382. type?: number;
  76383. /** Defines sampling mode (trilinear by default) */
  76384. samplingMode?: number;
  76385. /** Defines format (RGBA by default) */
  76386. format?: number;
  76387. }
  76388. }
  76389. declare module BABYLON {
  76390. /** Defines the cross module used constants to avoid circular dependncies */
  76391. export class Constants {
  76392. /** Defines that alpha blending is disabled */
  76393. static readonly ALPHA_DISABLE: number;
  76394. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76395. static readonly ALPHA_ADD: number;
  76396. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76397. static readonly ALPHA_COMBINE: number;
  76398. /** Defines that alpha blending is DEST - SRC * DEST */
  76399. static readonly ALPHA_SUBTRACT: number;
  76400. /** Defines that alpha blending is SRC * DEST */
  76401. static readonly ALPHA_MULTIPLY: number;
  76402. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76403. static readonly ALPHA_MAXIMIZED: number;
  76404. /** Defines that alpha blending is SRC + DEST */
  76405. static readonly ALPHA_ONEONE: number;
  76406. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76407. static readonly ALPHA_PREMULTIPLIED: number;
  76408. /**
  76409. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76410. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76411. */
  76412. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76413. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76414. static readonly ALPHA_INTERPOLATE: number;
  76415. /**
  76416. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76417. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76418. */
  76419. static readonly ALPHA_SCREENMODE: number;
  76420. /**
  76421. * Defines that alpha blending is SRC + DST
  76422. * Alpha will be set to SRC ALPHA + DST ALPHA
  76423. */
  76424. static readonly ALPHA_ONEONE_ONEONE: number;
  76425. /**
  76426. * Defines that alpha blending is SRC * DST ALPHA + DST
  76427. * Alpha will be set to 0
  76428. */
  76429. static readonly ALPHA_ALPHATOCOLOR: number;
  76430. /**
  76431. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76432. */
  76433. static readonly ALPHA_REVERSEONEMINUS: number;
  76434. /**
  76435. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76436. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76437. */
  76438. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76439. /**
  76440. * Defines that alpha blending is SRC + DST
  76441. * Alpha will be set to SRC ALPHA
  76442. */
  76443. static readonly ALPHA_ONEONE_ONEZERO: number;
  76444. /**
  76445. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76446. * Alpha will be set to DST ALPHA
  76447. */
  76448. static readonly ALPHA_EXCLUSION: number;
  76449. /** Defines that alpha blending equation a SUM */
  76450. static readonly ALPHA_EQUATION_ADD: number;
  76451. /** Defines that alpha blending equation a SUBSTRACTION */
  76452. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76453. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76454. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76455. /** Defines that alpha blending equation a MAX operation */
  76456. static readonly ALPHA_EQUATION_MAX: number;
  76457. /** Defines that alpha blending equation a MIN operation */
  76458. static readonly ALPHA_EQUATION_MIN: number;
  76459. /**
  76460. * Defines that alpha blending equation a DARKEN operation:
  76461. * It takes the min of the src and sums the alpha channels.
  76462. */
  76463. static readonly ALPHA_EQUATION_DARKEN: number;
  76464. /** Defines that the ressource is not delayed*/
  76465. static readonly DELAYLOADSTATE_NONE: number;
  76466. /** Defines that the ressource was successfully delay loaded */
  76467. static readonly DELAYLOADSTATE_LOADED: number;
  76468. /** Defines that the ressource is currently delay loading */
  76469. static readonly DELAYLOADSTATE_LOADING: number;
  76470. /** Defines that the ressource is delayed and has not started loading */
  76471. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76473. static readonly NEVER: number;
  76474. /** 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 */
  76475. static readonly ALWAYS: number;
  76476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76477. static readonly LESS: number;
  76478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76479. static readonly EQUAL: number;
  76480. /** 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 */
  76481. static readonly LEQUAL: number;
  76482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76483. static readonly GREATER: number;
  76484. /** 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 */
  76485. static readonly GEQUAL: number;
  76486. /** 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 */
  76487. static readonly NOTEQUAL: number;
  76488. /** Passed to stencilOperation to specify that stencil value must be kept */
  76489. static readonly KEEP: number;
  76490. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76491. static readonly REPLACE: number;
  76492. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76493. static readonly INCR: number;
  76494. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76495. static readonly DECR: number;
  76496. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76497. static readonly INVERT: number;
  76498. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76499. static readonly INCR_WRAP: number;
  76500. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76501. static readonly DECR_WRAP: number;
  76502. /** Texture is not repeating outside of 0..1 UVs */
  76503. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76504. /** Texture is repeating outside of 0..1 UVs */
  76505. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76506. /** Texture is repeating and mirrored */
  76507. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76508. /** ALPHA */
  76509. static readonly TEXTUREFORMAT_ALPHA: number;
  76510. /** LUMINANCE */
  76511. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76512. /** LUMINANCE_ALPHA */
  76513. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76514. /** RGB */
  76515. static readonly TEXTUREFORMAT_RGB: number;
  76516. /** RGBA */
  76517. static readonly TEXTUREFORMAT_RGBA: number;
  76518. /** RED */
  76519. static readonly TEXTUREFORMAT_RED: number;
  76520. /** RED (2nd reference) */
  76521. static readonly TEXTUREFORMAT_R: number;
  76522. /** RG */
  76523. static readonly TEXTUREFORMAT_RG: number;
  76524. /** RED_INTEGER */
  76525. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76526. /** RED_INTEGER (2nd reference) */
  76527. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76528. /** RG_INTEGER */
  76529. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76530. /** RGB_INTEGER */
  76531. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76532. /** RGBA_INTEGER */
  76533. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76534. /** UNSIGNED_BYTE */
  76535. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76536. /** UNSIGNED_BYTE (2nd reference) */
  76537. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76538. /** FLOAT */
  76539. static readonly TEXTURETYPE_FLOAT: number;
  76540. /** HALF_FLOAT */
  76541. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76542. /** BYTE */
  76543. static readonly TEXTURETYPE_BYTE: number;
  76544. /** SHORT */
  76545. static readonly TEXTURETYPE_SHORT: number;
  76546. /** UNSIGNED_SHORT */
  76547. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76548. /** INT */
  76549. static readonly TEXTURETYPE_INT: number;
  76550. /** UNSIGNED_INT */
  76551. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76552. /** UNSIGNED_SHORT_4_4_4_4 */
  76553. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76554. /** UNSIGNED_SHORT_5_5_5_1 */
  76555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76556. /** UNSIGNED_SHORT_5_6_5 */
  76557. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76558. /** UNSIGNED_INT_2_10_10_10_REV */
  76559. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76560. /** UNSIGNED_INT_24_8 */
  76561. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76562. /** UNSIGNED_INT_10F_11F_11F_REV */
  76563. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76564. /** UNSIGNED_INT_5_9_9_9_REV */
  76565. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76566. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76567. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76568. /** nearest is mag = nearest and min = nearest and no mip */
  76569. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76570. /** mag = nearest and min = nearest and mip = none */
  76571. static readonly TEXTURE_NEAREST_NEAREST: number;
  76572. /** Bilinear is mag = linear and min = linear and no mip */
  76573. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76574. /** mag = linear and min = linear and mip = none */
  76575. static readonly TEXTURE_LINEAR_LINEAR: number;
  76576. /** Trilinear is mag = linear and min = linear and mip = linear */
  76577. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76578. /** Trilinear is mag = linear and min = linear and mip = linear */
  76579. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76580. /** mag = nearest and min = nearest and mip = nearest */
  76581. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76582. /** mag = nearest and min = linear and mip = nearest */
  76583. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76584. /** mag = nearest and min = linear and mip = linear */
  76585. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76586. /** mag = nearest and min = linear and mip = none */
  76587. static readonly TEXTURE_NEAREST_LINEAR: number;
  76588. /** nearest is mag = nearest and min = nearest and mip = linear */
  76589. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76590. /** mag = linear and min = nearest and mip = nearest */
  76591. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76592. /** mag = linear and min = nearest and mip = linear */
  76593. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76595. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76596. /** mag = linear and min = nearest and mip = none */
  76597. static readonly TEXTURE_LINEAR_NEAREST: number;
  76598. /** Explicit coordinates mode */
  76599. static readonly TEXTURE_EXPLICIT_MODE: number;
  76600. /** Spherical coordinates mode */
  76601. static readonly TEXTURE_SPHERICAL_MODE: number;
  76602. /** Planar coordinates mode */
  76603. static readonly TEXTURE_PLANAR_MODE: number;
  76604. /** Cubic coordinates mode */
  76605. static readonly TEXTURE_CUBIC_MODE: number;
  76606. /** Projection coordinates mode */
  76607. static readonly TEXTURE_PROJECTION_MODE: number;
  76608. /** Skybox coordinates mode */
  76609. static readonly TEXTURE_SKYBOX_MODE: number;
  76610. /** Inverse Cubic coordinates mode */
  76611. static readonly TEXTURE_INVCUBIC_MODE: number;
  76612. /** Equirectangular coordinates mode */
  76613. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76614. /** Equirectangular Fixed coordinates mode */
  76615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76616. /** Equirectangular Fixed Mirrored coordinates mode */
  76617. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76618. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76619. static readonly SCALEMODE_FLOOR: number;
  76620. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76621. static readonly SCALEMODE_NEAREST: number;
  76622. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76623. static readonly SCALEMODE_CEILING: number;
  76624. /**
  76625. * The dirty texture flag value
  76626. */
  76627. static readonly MATERIAL_TextureDirtyFlag: number;
  76628. /**
  76629. * The dirty light flag value
  76630. */
  76631. static readonly MATERIAL_LightDirtyFlag: number;
  76632. /**
  76633. * The dirty fresnel flag value
  76634. */
  76635. static readonly MATERIAL_FresnelDirtyFlag: number;
  76636. /**
  76637. * The dirty attribute flag value
  76638. */
  76639. static readonly MATERIAL_AttributesDirtyFlag: number;
  76640. /**
  76641. * The dirty misc flag value
  76642. */
  76643. static readonly MATERIAL_MiscDirtyFlag: number;
  76644. /**
  76645. * The all dirty flag value
  76646. */
  76647. static readonly MATERIAL_AllDirtyFlag: number;
  76648. /**
  76649. * Returns the triangle fill mode
  76650. */
  76651. static readonly MATERIAL_TriangleFillMode: number;
  76652. /**
  76653. * Returns the wireframe mode
  76654. */
  76655. static readonly MATERIAL_WireFrameFillMode: number;
  76656. /**
  76657. * Returns the point fill mode
  76658. */
  76659. static readonly MATERIAL_PointFillMode: number;
  76660. /**
  76661. * Returns the point list draw mode
  76662. */
  76663. static readonly MATERIAL_PointListDrawMode: number;
  76664. /**
  76665. * Returns the line list draw mode
  76666. */
  76667. static readonly MATERIAL_LineListDrawMode: number;
  76668. /**
  76669. * Returns the line loop draw mode
  76670. */
  76671. static readonly MATERIAL_LineLoopDrawMode: number;
  76672. /**
  76673. * Returns the line strip draw mode
  76674. */
  76675. static readonly MATERIAL_LineStripDrawMode: number;
  76676. /**
  76677. * Returns the triangle strip draw mode
  76678. */
  76679. static readonly MATERIAL_TriangleStripDrawMode: number;
  76680. /**
  76681. * Returns the triangle fan draw mode
  76682. */
  76683. static readonly MATERIAL_TriangleFanDrawMode: number;
  76684. /**
  76685. * Stores the clock-wise side orientation
  76686. */
  76687. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76688. /**
  76689. * Stores the counter clock-wise side orientation
  76690. */
  76691. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76692. /**
  76693. * Nothing
  76694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76695. */
  76696. static readonly ACTION_NothingTrigger: number;
  76697. /**
  76698. * On pick
  76699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76700. */
  76701. static readonly ACTION_OnPickTrigger: number;
  76702. /**
  76703. * On left pick
  76704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76705. */
  76706. static readonly ACTION_OnLeftPickTrigger: number;
  76707. /**
  76708. * On right pick
  76709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76710. */
  76711. static readonly ACTION_OnRightPickTrigger: number;
  76712. /**
  76713. * On center pick
  76714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76715. */
  76716. static readonly ACTION_OnCenterPickTrigger: number;
  76717. /**
  76718. * On pick down
  76719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76720. */
  76721. static readonly ACTION_OnPickDownTrigger: number;
  76722. /**
  76723. * On double pick
  76724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76725. */
  76726. static readonly ACTION_OnDoublePickTrigger: number;
  76727. /**
  76728. * On pick up
  76729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76730. */
  76731. static readonly ACTION_OnPickUpTrigger: number;
  76732. /**
  76733. * On pick out.
  76734. * This trigger will only be raised if you also declared a OnPickDown
  76735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76736. */
  76737. static readonly ACTION_OnPickOutTrigger: number;
  76738. /**
  76739. * On long press
  76740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76741. */
  76742. static readonly ACTION_OnLongPressTrigger: number;
  76743. /**
  76744. * On pointer over
  76745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76746. */
  76747. static readonly ACTION_OnPointerOverTrigger: number;
  76748. /**
  76749. * On pointer out
  76750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76751. */
  76752. static readonly ACTION_OnPointerOutTrigger: number;
  76753. /**
  76754. * On every frame
  76755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76756. */
  76757. static readonly ACTION_OnEveryFrameTrigger: number;
  76758. /**
  76759. * On intersection enter
  76760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76761. */
  76762. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76763. /**
  76764. * On intersection exit
  76765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76766. */
  76767. static readonly ACTION_OnIntersectionExitTrigger: number;
  76768. /**
  76769. * On key down
  76770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76771. */
  76772. static readonly ACTION_OnKeyDownTrigger: number;
  76773. /**
  76774. * On key up
  76775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76776. */
  76777. static readonly ACTION_OnKeyUpTrigger: number;
  76778. /**
  76779. * Billboard mode will only apply to Y axis
  76780. */
  76781. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76782. /**
  76783. * Billboard mode will apply to all axes
  76784. */
  76785. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76786. /**
  76787. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76788. */
  76789. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  76790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76791. * Test order :
  76792. * Is the bounding sphere outside the frustum ?
  76793. * If not, are the bounding box vertices outside the frustum ?
  76794. * It not, then the cullable object is in the frustum.
  76795. */
  76796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  76797. /** Culling strategy : Bounding Sphere Only.
  76798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76799. * It's also less accurate than the standard because some not visible objects can still be selected.
  76800. * Test : is the bounding sphere outside the frustum ?
  76801. * If not, then the cullable object is in the frustum.
  76802. */
  76803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  76804. /** Culling strategy : Optimistic Inclusion.
  76805. * This in an inclusion test first, then the standard exclusion test.
  76806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76807. * 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.
  76808. * Anyway, it's as accurate as the standard strategy.
  76809. * Test :
  76810. * Is the cullable object bounding sphere center in the frustum ?
  76811. * If not, apply the default culling strategy.
  76812. */
  76813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  76814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76817. * 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.
  76818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76819. * Test :
  76820. * Is the cullable object bounding sphere center in the frustum ?
  76821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  76822. */
  76823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  76824. /**
  76825. * No logging while loading
  76826. */
  76827. static readonly SCENELOADER_NO_LOGGING: number;
  76828. /**
  76829. * Minimal logging while loading
  76830. */
  76831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  76832. /**
  76833. * Summary logging while loading
  76834. */
  76835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  76836. /**
  76837. * Detailled logging while loading
  76838. */
  76839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  76840. }
  76841. }
  76842. declare module BABYLON {
  76843. /**
  76844. * This represents the required contract to create a new type of texture loader.
  76845. */
  76846. export interface IInternalTextureLoader {
  76847. /**
  76848. * Defines wether the loader supports cascade loading the different faces.
  76849. */
  76850. supportCascades: boolean;
  76851. /**
  76852. * This returns if the loader support the current file information.
  76853. * @param extension defines the file extension of the file being loaded
  76854. * @returns true if the loader can load the specified file
  76855. */
  76856. canLoad(extension: string): boolean;
  76857. /**
  76858. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  76859. * @param data contains the texture data
  76860. * @param texture defines the BabylonJS internal texture
  76861. * @param createPolynomials will be true if polynomials have been requested
  76862. * @param onLoad defines the callback to trigger once the texture is ready
  76863. * @param onError defines the callback to trigger in case of error
  76864. */
  76865. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  76866. /**
  76867. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  76868. * @param data contains the texture data
  76869. * @param texture defines the BabylonJS internal texture
  76870. * @param callback defines the method to call once ready to upload
  76871. */
  76872. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  76873. }
  76874. }
  76875. declare module BABYLON {
  76876. /**
  76877. * Class used to store and describe the pipeline context associated with an effect
  76878. */
  76879. export interface IPipelineContext {
  76880. /**
  76881. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  76882. */
  76883. isAsync: boolean;
  76884. /**
  76885. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  76886. */
  76887. isReady: boolean;
  76888. /** @hidden */
  76889. _getVertexShaderCode(): string | null;
  76890. /** @hidden */
  76891. _getFragmentShaderCode(): string | null;
  76892. /** @hidden */
  76893. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  76894. }
  76895. }
  76896. declare module BABYLON {
  76897. /**
  76898. * Class used to store gfx data (like WebGLBuffer)
  76899. */
  76900. export class DataBuffer {
  76901. /**
  76902. * Gets or sets the number of objects referencing this buffer
  76903. */
  76904. references: number;
  76905. /** Gets or sets the size of the underlying buffer */
  76906. capacity: number;
  76907. /**
  76908. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  76909. */
  76910. is32Bits: boolean;
  76911. /**
  76912. * Gets the underlying buffer
  76913. */
  76914. get underlyingResource(): any;
  76915. }
  76916. }
  76917. declare module BABYLON {
  76918. /** @hidden */
  76919. export interface IShaderProcessor {
  76920. attributeProcessor?: (attribute: string) => string;
  76921. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  76922. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  76923. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  76924. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  76925. lineProcessor?: (line: string, isFragment: boolean) => string;
  76926. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76927. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76928. }
  76929. }
  76930. declare module BABYLON {
  76931. /** @hidden */
  76932. export interface ProcessingOptions {
  76933. defines: string[];
  76934. indexParameters: any;
  76935. isFragment: boolean;
  76936. shouldUseHighPrecisionShader: boolean;
  76937. supportsUniformBuffers: boolean;
  76938. shadersRepository: string;
  76939. includesShadersStore: {
  76940. [key: string]: string;
  76941. };
  76942. processor?: IShaderProcessor;
  76943. version: string;
  76944. platformName: string;
  76945. lookForClosingBracketForUniformBuffer?: boolean;
  76946. }
  76947. }
  76948. declare module BABYLON {
  76949. /** @hidden */
  76950. export class ShaderCodeNode {
  76951. line: string;
  76952. children: ShaderCodeNode[];
  76953. additionalDefineKey?: string;
  76954. additionalDefineValue?: string;
  76955. isValid(preprocessors: {
  76956. [key: string]: string;
  76957. }): boolean;
  76958. process(preprocessors: {
  76959. [key: string]: string;
  76960. }, options: ProcessingOptions): string;
  76961. }
  76962. }
  76963. declare module BABYLON {
  76964. /** @hidden */
  76965. export class ShaderCodeCursor {
  76966. private _lines;
  76967. lineIndex: number;
  76968. get currentLine(): string;
  76969. get canRead(): boolean;
  76970. set lines(value: string[]);
  76971. }
  76972. }
  76973. declare module BABYLON {
  76974. /** @hidden */
  76975. export class ShaderCodeConditionNode extends ShaderCodeNode {
  76976. process(preprocessors: {
  76977. [key: string]: string;
  76978. }, options: ProcessingOptions): string;
  76979. }
  76980. }
  76981. declare module BABYLON {
  76982. /** @hidden */
  76983. export class ShaderDefineExpression {
  76984. isTrue(preprocessors: {
  76985. [key: string]: string;
  76986. }): boolean;
  76987. private static _OperatorPriority;
  76988. private static _Stack;
  76989. static postfixToInfix(postfix: string[]): string;
  76990. static infixToPostfix(infix: string): string[];
  76991. }
  76992. }
  76993. declare module BABYLON {
  76994. /** @hidden */
  76995. export class ShaderCodeTestNode extends ShaderCodeNode {
  76996. testExpression: ShaderDefineExpression;
  76997. isValid(preprocessors: {
  76998. [key: string]: string;
  76999. }): boolean;
  77000. }
  77001. }
  77002. declare module BABYLON {
  77003. /** @hidden */
  77004. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77005. define: string;
  77006. not: boolean;
  77007. constructor(define: string, not?: boolean);
  77008. isTrue(preprocessors: {
  77009. [key: string]: string;
  77010. }): boolean;
  77011. }
  77012. }
  77013. declare module BABYLON {
  77014. /** @hidden */
  77015. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77016. leftOperand: ShaderDefineExpression;
  77017. rightOperand: ShaderDefineExpression;
  77018. isTrue(preprocessors: {
  77019. [key: string]: string;
  77020. }): boolean;
  77021. }
  77022. }
  77023. declare module BABYLON {
  77024. /** @hidden */
  77025. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77026. leftOperand: ShaderDefineExpression;
  77027. rightOperand: ShaderDefineExpression;
  77028. isTrue(preprocessors: {
  77029. [key: string]: string;
  77030. }): boolean;
  77031. }
  77032. }
  77033. declare module BABYLON {
  77034. /** @hidden */
  77035. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77036. define: string;
  77037. operand: string;
  77038. testValue: string;
  77039. constructor(define: string, operand: string, testValue: string);
  77040. isTrue(preprocessors: {
  77041. [key: string]: string;
  77042. }): boolean;
  77043. }
  77044. }
  77045. declare module BABYLON {
  77046. /**
  77047. * Class used to enable access to offline support
  77048. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77049. */
  77050. export interface IOfflineProvider {
  77051. /**
  77052. * Gets a boolean indicating if scene must be saved in the database
  77053. */
  77054. enableSceneOffline: boolean;
  77055. /**
  77056. * Gets a boolean indicating if textures must be saved in the database
  77057. */
  77058. enableTexturesOffline: boolean;
  77059. /**
  77060. * Open the offline support and make it available
  77061. * @param successCallback defines the callback to call on success
  77062. * @param errorCallback defines the callback to call on error
  77063. */
  77064. open(successCallback: () => void, errorCallback: () => void): void;
  77065. /**
  77066. * Loads an image from the offline support
  77067. * @param url defines the url to load from
  77068. * @param image defines the target DOM image
  77069. */
  77070. loadImage(url: string, image: HTMLImageElement): void;
  77071. /**
  77072. * Loads a file from offline support
  77073. * @param url defines the URL to load from
  77074. * @param sceneLoaded defines a callback to call on success
  77075. * @param progressCallBack defines a callback to call when progress changed
  77076. * @param errorCallback defines a callback to call on error
  77077. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77078. */
  77079. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77080. }
  77081. }
  77082. declare module BABYLON {
  77083. /**
  77084. * Class used to help managing file picking and drag'n'drop
  77085. * File Storage
  77086. */
  77087. export class FilesInputStore {
  77088. /**
  77089. * List of files ready to be loaded
  77090. */
  77091. static FilesToLoad: {
  77092. [key: string]: File;
  77093. };
  77094. }
  77095. }
  77096. declare module BABYLON {
  77097. /**
  77098. * Class used to define a retry strategy when error happens while loading assets
  77099. */
  77100. export class RetryStrategy {
  77101. /**
  77102. * Function used to defines an exponential back off strategy
  77103. * @param maxRetries defines the maximum number of retries (3 by default)
  77104. * @param baseInterval defines the interval between retries
  77105. * @returns the strategy function to use
  77106. */
  77107. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77108. }
  77109. }
  77110. declare module BABYLON {
  77111. /**
  77112. * @ignore
  77113. * Application error to support additional information when loading a file
  77114. */
  77115. export abstract class BaseError extends Error {
  77116. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77117. }
  77118. }
  77119. declare module BABYLON {
  77120. /** @ignore */
  77121. export class LoadFileError extends BaseError {
  77122. request?: WebRequest;
  77123. file?: File;
  77124. /**
  77125. * Creates a new LoadFileError
  77126. * @param message defines the message of the error
  77127. * @param request defines the optional web request
  77128. * @param file defines the optional file
  77129. */
  77130. constructor(message: string, object?: WebRequest | File);
  77131. }
  77132. /** @ignore */
  77133. export class RequestFileError extends BaseError {
  77134. request: WebRequest;
  77135. /**
  77136. * Creates a new LoadFileError
  77137. * @param message defines the message of the error
  77138. * @param request defines the optional web request
  77139. */
  77140. constructor(message: string, request: WebRequest);
  77141. }
  77142. /** @ignore */
  77143. export class ReadFileError extends BaseError {
  77144. file: File;
  77145. /**
  77146. * Creates a new ReadFileError
  77147. * @param message defines the message of the error
  77148. * @param file defines the optional file
  77149. */
  77150. constructor(message: string, file: File);
  77151. }
  77152. /**
  77153. * @hidden
  77154. */
  77155. export class FileTools {
  77156. /**
  77157. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77158. */
  77159. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77160. /**
  77161. * Gets or sets the base URL to use to load assets
  77162. */
  77163. static BaseUrl: string;
  77164. /**
  77165. * Default behaviour for cors in the application.
  77166. * It can be a string if the expected behavior is identical in the entire app.
  77167. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77168. */
  77169. static CorsBehavior: string | ((url: string | string[]) => string);
  77170. /**
  77171. * Gets or sets a function used to pre-process url before using them to load assets
  77172. */
  77173. static PreprocessUrl: (url: string) => string;
  77174. /**
  77175. * Removes unwanted characters from an url
  77176. * @param url defines the url to clean
  77177. * @returns the cleaned url
  77178. */
  77179. private static _CleanUrl;
  77180. /**
  77181. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77182. * @param url define the url we are trying
  77183. * @param element define the dom element where to configure the cors policy
  77184. */
  77185. static SetCorsBehavior(url: string | string[], element: {
  77186. crossOrigin: string | null;
  77187. }): void;
  77188. /**
  77189. * Loads an image as an HTMLImageElement.
  77190. * @param input url string, ArrayBuffer, or Blob to load
  77191. * @param onLoad callback called when the image successfully loads
  77192. * @param onError callback called when the image fails to load
  77193. * @param offlineProvider offline provider for caching
  77194. * @param mimeType optional mime type
  77195. * @returns the HTMLImageElement of the loaded image
  77196. */
  77197. 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>;
  77198. /**
  77199. * Reads a file from a File object
  77200. * @param file defines the file to load
  77201. * @param onSuccess defines the callback to call when data is loaded
  77202. * @param onProgress defines the callback to call during loading process
  77203. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77204. * @param onError defines the callback to call when an error occurs
  77205. * @returns a file request object
  77206. */
  77207. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77208. /**
  77209. * Loads a file from a url
  77210. * @param url url to load
  77211. * @param onSuccess callback called when the file successfully loads
  77212. * @param onProgress callback called while file is loading (if the server supports this mode)
  77213. * @param offlineProvider defines the offline provider for caching
  77214. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77215. * @param onError callback called when the file fails to load
  77216. * @returns a file request object
  77217. */
  77218. 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;
  77219. /**
  77220. * Loads a file
  77221. * @param url url to load
  77222. * @param onSuccess callback called when the file successfully loads
  77223. * @param onProgress callback called while file is loading (if the server supports this mode)
  77224. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77225. * @param onError callback called when the file fails to load
  77226. * @param onOpened callback called when the web request is opened
  77227. * @returns a file request object
  77228. */
  77229. 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;
  77230. /**
  77231. * Checks if the loaded document was accessed via `file:`-Protocol.
  77232. * @returns boolean
  77233. */
  77234. static IsFileURL(): boolean;
  77235. }
  77236. }
  77237. declare module BABYLON {
  77238. /** @hidden */
  77239. export class ShaderProcessor {
  77240. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77241. private static _ProcessPrecision;
  77242. private static _ExtractOperation;
  77243. private static _BuildSubExpression;
  77244. private static _BuildExpression;
  77245. private static _MoveCursorWithinIf;
  77246. private static _MoveCursor;
  77247. private static _EvaluatePreProcessors;
  77248. private static _PreparePreProcessors;
  77249. private static _ProcessShaderConversion;
  77250. private static _ProcessIncludes;
  77251. /**
  77252. * Loads a file from a url
  77253. * @param url url to load
  77254. * @param onSuccess callback called when the file successfully loads
  77255. * @param onProgress callback called while file is loading (if the server supports this mode)
  77256. * @param offlineProvider defines the offline provider for caching
  77257. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77258. * @param onError callback called when the file fails to load
  77259. * @returns a file request object
  77260. * @hidden
  77261. */
  77262. 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;
  77263. }
  77264. }
  77265. declare module BABYLON {
  77266. /**
  77267. * @hidden
  77268. */
  77269. export interface IColor4Like {
  77270. r: float;
  77271. g: float;
  77272. b: float;
  77273. a: float;
  77274. }
  77275. /**
  77276. * @hidden
  77277. */
  77278. export interface IColor3Like {
  77279. r: float;
  77280. g: float;
  77281. b: float;
  77282. }
  77283. /**
  77284. * @hidden
  77285. */
  77286. export interface IVector4Like {
  77287. x: float;
  77288. y: float;
  77289. z: float;
  77290. w: float;
  77291. }
  77292. /**
  77293. * @hidden
  77294. */
  77295. export interface IVector3Like {
  77296. x: float;
  77297. y: float;
  77298. z: float;
  77299. }
  77300. /**
  77301. * @hidden
  77302. */
  77303. export interface IVector2Like {
  77304. x: float;
  77305. y: float;
  77306. }
  77307. /**
  77308. * @hidden
  77309. */
  77310. export interface IMatrixLike {
  77311. toArray(): DeepImmutable<Float32Array>;
  77312. updateFlag: int;
  77313. }
  77314. /**
  77315. * @hidden
  77316. */
  77317. export interface IViewportLike {
  77318. x: float;
  77319. y: float;
  77320. width: float;
  77321. height: float;
  77322. }
  77323. /**
  77324. * @hidden
  77325. */
  77326. export interface IPlaneLike {
  77327. normal: IVector3Like;
  77328. d: float;
  77329. normalize(): void;
  77330. }
  77331. }
  77332. declare module BABYLON {
  77333. /**
  77334. * Interface used to define common properties for effect fallbacks
  77335. */
  77336. export interface IEffectFallbacks {
  77337. /**
  77338. * Removes the defines that should be removed when falling back.
  77339. * @param currentDefines defines the current define statements for the shader.
  77340. * @param effect defines the current effect we try to compile
  77341. * @returns The resulting defines with defines of the current rank removed.
  77342. */
  77343. reduce(currentDefines: string, effect: Effect): string;
  77344. /**
  77345. * Removes the fallback from the bound mesh.
  77346. */
  77347. unBindMesh(): void;
  77348. /**
  77349. * Checks to see if more fallbacks are still availible.
  77350. */
  77351. hasMoreFallbacks: boolean;
  77352. }
  77353. }
  77354. declare module BABYLON {
  77355. /**
  77356. * Class used to evalaute queries containing `and` and `or` operators
  77357. */
  77358. export class AndOrNotEvaluator {
  77359. /**
  77360. * Evaluate a query
  77361. * @param query defines the query to evaluate
  77362. * @param evaluateCallback defines the callback used to filter result
  77363. * @returns true if the query matches
  77364. */
  77365. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77366. private static _HandleParenthesisContent;
  77367. private static _SimplifyNegation;
  77368. }
  77369. }
  77370. declare module BABYLON {
  77371. /**
  77372. * Class used to store custom tags
  77373. */
  77374. export class Tags {
  77375. /**
  77376. * Adds support for tags on the given object
  77377. * @param obj defines the object to use
  77378. */
  77379. static EnableFor(obj: any): void;
  77380. /**
  77381. * Removes tags support
  77382. * @param obj defines the object to use
  77383. */
  77384. static DisableFor(obj: any): void;
  77385. /**
  77386. * Gets a boolean indicating if the given object has tags
  77387. * @param obj defines the object to use
  77388. * @returns a boolean
  77389. */
  77390. static HasTags(obj: any): boolean;
  77391. /**
  77392. * Gets the tags available on a given object
  77393. * @param obj defines the object to use
  77394. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77395. * @returns the tags
  77396. */
  77397. static GetTags(obj: any, asString?: boolean): any;
  77398. /**
  77399. * Adds tags to an object
  77400. * @param obj defines the object to use
  77401. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77402. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77403. */
  77404. static AddTagsTo(obj: any, tagsString: string): void;
  77405. /**
  77406. * @hidden
  77407. */
  77408. static _AddTagTo(obj: any, tag: string): void;
  77409. /**
  77410. * Removes specific tags from a specific object
  77411. * @param obj defines the object to use
  77412. * @param tagsString defines the tags to remove
  77413. */
  77414. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77415. /**
  77416. * @hidden
  77417. */
  77418. static _RemoveTagFrom(obj: any, tag: string): void;
  77419. /**
  77420. * Defines if tags hosted on an object match a given query
  77421. * @param obj defines the object to use
  77422. * @param tagsQuery defines the tag query
  77423. * @returns a boolean
  77424. */
  77425. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77426. }
  77427. }
  77428. declare module BABYLON {
  77429. /**
  77430. * Scalar computation library
  77431. */
  77432. export class Scalar {
  77433. /**
  77434. * Two pi constants convenient for computation.
  77435. */
  77436. static TwoPi: number;
  77437. /**
  77438. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77439. * @param a number
  77440. * @param b number
  77441. * @param epsilon (default = 1.401298E-45)
  77442. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77443. */
  77444. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77445. /**
  77446. * Returns a string : the upper case translation of the number i to hexadecimal.
  77447. * @param i number
  77448. * @returns the upper case translation of the number i to hexadecimal.
  77449. */
  77450. static ToHex(i: number): string;
  77451. /**
  77452. * Returns -1 if value is negative and +1 is value is positive.
  77453. * @param value the value
  77454. * @returns the value itself if it's equal to zero.
  77455. */
  77456. static Sign(value: number): number;
  77457. /**
  77458. * Returns the value itself if it's between min and max.
  77459. * Returns min if the value is lower than min.
  77460. * Returns max if the value is greater than max.
  77461. * @param value the value to clmap
  77462. * @param min the min value to clamp to (default: 0)
  77463. * @param max the max value to clamp to (default: 1)
  77464. * @returns the clamped value
  77465. */
  77466. static Clamp(value: number, min?: number, max?: number): number;
  77467. /**
  77468. * the log2 of value.
  77469. * @param value the value to compute log2 of
  77470. * @returns the log2 of value.
  77471. */
  77472. static Log2(value: number): number;
  77473. /**
  77474. * Loops the value, so that it is never larger than length and never smaller than 0.
  77475. *
  77476. * This is similar to the modulo operator but it works with floating point numbers.
  77477. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77478. * With t = 5 and length = 2.5, the result would be 0.0.
  77479. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77480. * @param value the value
  77481. * @param length the length
  77482. * @returns the looped value
  77483. */
  77484. static Repeat(value: number, length: number): number;
  77485. /**
  77486. * Normalize the value between 0.0 and 1.0 using min and max values
  77487. * @param value value to normalize
  77488. * @param min max to normalize between
  77489. * @param max min to normalize between
  77490. * @returns the normalized value
  77491. */
  77492. static Normalize(value: number, min: number, max: number): number;
  77493. /**
  77494. * Denormalize the value from 0.0 and 1.0 using min and max values
  77495. * @param normalized value to denormalize
  77496. * @param min max to denormalize between
  77497. * @param max min to denormalize between
  77498. * @returns the denormalized value
  77499. */
  77500. static Denormalize(normalized: number, min: number, max: number): number;
  77501. /**
  77502. * Calculates the shortest difference between two given angles given in degrees.
  77503. * @param current current angle in degrees
  77504. * @param target target angle in degrees
  77505. * @returns the delta
  77506. */
  77507. static DeltaAngle(current: number, target: number): number;
  77508. /**
  77509. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77510. * @param tx value
  77511. * @param length length
  77512. * @returns The returned value will move back and forth between 0 and length
  77513. */
  77514. static PingPong(tx: number, length: number): number;
  77515. /**
  77516. * Interpolates between min and max with smoothing at the limits.
  77517. *
  77518. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77519. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77520. * @param from from
  77521. * @param to to
  77522. * @param tx value
  77523. * @returns the smooth stepped value
  77524. */
  77525. static SmoothStep(from: number, to: number, tx: number): number;
  77526. /**
  77527. * Moves a value current towards target.
  77528. *
  77529. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77530. * Negative values of maxDelta pushes the value away from target.
  77531. * @param current current value
  77532. * @param target target value
  77533. * @param maxDelta max distance to move
  77534. * @returns resulting value
  77535. */
  77536. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77537. /**
  77538. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77539. *
  77540. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77541. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77542. * @param current current value
  77543. * @param target target value
  77544. * @param maxDelta max distance to move
  77545. * @returns resulting angle
  77546. */
  77547. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77548. /**
  77549. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77550. * @param start start value
  77551. * @param end target value
  77552. * @param amount amount to lerp between
  77553. * @returns the lerped value
  77554. */
  77555. static Lerp(start: number, end: number, amount: number): number;
  77556. /**
  77557. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77558. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77559. * @param start start value
  77560. * @param end target value
  77561. * @param amount amount to lerp between
  77562. * @returns the lerped value
  77563. */
  77564. static LerpAngle(start: number, end: number, amount: number): number;
  77565. /**
  77566. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77567. * @param a start value
  77568. * @param b target value
  77569. * @param value value between a and b
  77570. * @returns the inverseLerp value
  77571. */
  77572. static InverseLerp(a: number, b: number, value: number): number;
  77573. /**
  77574. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77575. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77576. * @param value1 spline value
  77577. * @param tangent1 spline value
  77578. * @param value2 spline value
  77579. * @param tangent2 spline value
  77580. * @param amount input value
  77581. * @returns hermite result
  77582. */
  77583. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77584. /**
  77585. * Returns a random float number between and min and max values
  77586. * @param min min value of random
  77587. * @param max max value of random
  77588. * @returns random value
  77589. */
  77590. static RandomRange(min: number, max: number): number;
  77591. /**
  77592. * This function returns percentage of a number in a given range.
  77593. *
  77594. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77595. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77596. * @param number to convert to percentage
  77597. * @param min min range
  77598. * @param max max range
  77599. * @returns the percentage
  77600. */
  77601. static RangeToPercent(number: number, min: number, max: number): number;
  77602. /**
  77603. * This function returns number that corresponds to the percentage in a given range.
  77604. *
  77605. * PercentToRange(0.34,0,100) will return 34.
  77606. * @param percent to convert to number
  77607. * @param min min range
  77608. * @param max max range
  77609. * @returns the number
  77610. */
  77611. static PercentToRange(percent: number, min: number, max: number): number;
  77612. /**
  77613. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77614. * @param angle The angle to normalize in radian.
  77615. * @return The converted angle.
  77616. */
  77617. static NormalizeRadians(angle: number): number;
  77618. }
  77619. }
  77620. declare module BABYLON {
  77621. /**
  77622. * Constant used to convert a value to gamma space
  77623. * @ignorenaming
  77624. */
  77625. export const ToGammaSpace: number;
  77626. /**
  77627. * Constant used to convert a value to linear space
  77628. * @ignorenaming
  77629. */
  77630. export const ToLinearSpace = 2.2;
  77631. /**
  77632. * Constant used to define the minimal number value in Babylon.js
  77633. * @ignorenaming
  77634. */
  77635. let Epsilon: number;
  77636. }
  77637. declare module BABYLON {
  77638. /**
  77639. * Class used to represent a viewport on screen
  77640. */
  77641. export class Viewport {
  77642. /** viewport left coordinate */
  77643. x: number;
  77644. /** viewport top coordinate */
  77645. y: number;
  77646. /**viewport width */
  77647. width: number;
  77648. /** viewport height */
  77649. height: number;
  77650. /**
  77651. * Creates a Viewport object located at (x, y) and sized (width, height)
  77652. * @param x defines viewport left coordinate
  77653. * @param y defines viewport top coordinate
  77654. * @param width defines the viewport width
  77655. * @param height defines the viewport height
  77656. */
  77657. constructor(
  77658. /** viewport left coordinate */
  77659. x: number,
  77660. /** viewport top coordinate */
  77661. y: number,
  77662. /**viewport width */
  77663. width: number,
  77664. /** viewport height */
  77665. height: number);
  77666. /**
  77667. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77668. * @param renderWidth defines the rendering width
  77669. * @param renderHeight defines the rendering height
  77670. * @returns a new Viewport
  77671. */
  77672. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77673. /**
  77674. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77675. * @param renderWidth defines the rendering width
  77676. * @param renderHeight defines the rendering height
  77677. * @param ref defines the target viewport
  77678. * @returns the current viewport
  77679. */
  77680. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77681. /**
  77682. * Returns a new Viewport copied from the current one
  77683. * @returns a new Viewport
  77684. */
  77685. clone(): Viewport;
  77686. }
  77687. }
  77688. declare module BABYLON {
  77689. /**
  77690. * Class containing a set of static utilities functions for arrays.
  77691. */
  77692. export class ArrayTools {
  77693. /**
  77694. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77695. * @param size the number of element to construct and put in the array
  77696. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77697. * @returns a new array filled with new objects
  77698. */
  77699. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77700. }
  77701. }
  77702. declare module BABYLON {
  77703. /**
  77704. * Represens a plane by the equation ax + by + cz + d = 0
  77705. */
  77706. export class Plane {
  77707. private static _TmpMatrix;
  77708. /**
  77709. * Normal of the plane (a,b,c)
  77710. */
  77711. normal: Vector3;
  77712. /**
  77713. * d component of the plane
  77714. */
  77715. d: number;
  77716. /**
  77717. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77718. * @param a a component of the plane
  77719. * @param b b component of the plane
  77720. * @param c c component of the plane
  77721. * @param d d component of the plane
  77722. */
  77723. constructor(a: number, b: number, c: number, d: number);
  77724. /**
  77725. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77726. */
  77727. asArray(): number[];
  77728. /**
  77729. * @returns a new plane copied from the current Plane.
  77730. */
  77731. clone(): Plane;
  77732. /**
  77733. * @returns the string "Plane".
  77734. */
  77735. getClassName(): string;
  77736. /**
  77737. * @returns the Plane hash code.
  77738. */
  77739. getHashCode(): number;
  77740. /**
  77741. * Normalize the current Plane in place.
  77742. * @returns the updated Plane.
  77743. */
  77744. normalize(): Plane;
  77745. /**
  77746. * Applies a transformation the plane and returns the result
  77747. * @param transformation the transformation matrix to be applied to the plane
  77748. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77749. */
  77750. transform(transformation: DeepImmutable<Matrix>): Plane;
  77751. /**
  77752. * Compute the dot product between the point and the plane normal
  77753. * @param point point to calculate the dot product with
  77754. * @returns the dot product (float) of the point coordinates and the plane normal.
  77755. */
  77756. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77757. /**
  77758. * Updates the current Plane from the plane defined by the three given points.
  77759. * @param point1 one of the points used to contruct the plane
  77760. * @param point2 one of the points used to contruct the plane
  77761. * @param point3 one of the points used to contruct the plane
  77762. * @returns the updated Plane.
  77763. */
  77764. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77765. /**
  77766. * Checks if the plane is facing a given direction
  77767. * @param direction the direction to check if the plane is facing
  77768. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77769. * @returns True is the vector "direction" is the same side than the plane normal.
  77770. */
  77771. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77772. /**
  77773. * Calculates the distance to a point
  77774. * @param point point to calculate distance to
  77775. * @returns the signed distance (float) from the given point to the Plane.
  77776. */
  77777. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77778. /**
  77779. * Creates a plane from an array
  77780. * @param array the array to create a plane from
  77781. * @returns a new Plane from the given array.
  77782. */
  77783. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77784. /**
  77785. * Creates a plane from three points
  77786. * @param point1 point used to create the plane
  77787. * @param point2 point used to create the plane
  77788. * @param point3 point used to create the plane
  77789. * @returns a new Plane defined by the three given points.
  77790. */
  77791. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77792. /**
  77793. * Creates a plane from an origin point and a normal
  77794. * @param origin origin of the plane to be constructed
  77795. * @param normal normal of the plane to be constructed
  77796. * @returns a new Plane the normal vector to this plane at the given origin point.
  77797. * Note : the vector "normal" is updated because normalized.
  77798. */
  77799. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77800. /**
  77801. * Calculates the distance from a plane and a point
  77802. * @param origin origin of the plane to be constructed
  77803. * @param normal normal of the plane to be constructed
  77804. * @param point point to calculate distance to
  77805. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77806. */
  77807. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77808. }
  77809. }
  77810. declare module BABYLON {
  77811. /**
  77812. * Class representing a vector containing 2 coordinates
  77813. */
  77814. export class Vector2 {
  77815. /** defines the first coordinate */
  77816. x: number;
  77817. /** defines the second coordinate */
  77818. y: number;
  77819. /**
  77820. * Creates a new Vector2 from the given x and y coordinates
  77821. * @param x defines the first coordinate
  77822. * @param y defines the second coordinate
  77823. */
  77824. constructor(
  77825. /** defines the first coordinate */
  77826. x?: number,
  77827. /** defines the second coordinate */
  77828. y?: number);
  77829. /**
  77830. * Gets a string with the Vector2 coordinates
  77831. * @returns a string with the Vector2 coordinates
  77832. */
  77833. toString(): string;
  77834. /**
  77835. * Gets class name
  77836. * @returns the string "Vector2"
  77837. */
  77838. getClassName(): string;
  77839. /**
  77840. * Gets current vector hash code
  77841. * @returns the Vector2 hash code as a number
  77842. */
  77843. getHashCode(): number;
  77844. /**
  77845. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  77846. * @param array defines the source array
  77847. * @param index defines the offset in source array
  77848. * @returns the current Vector2
  77849. */
  77850. toArray(array: FloatArray, index?: number): Vector2;
  77851. /**
  77852. * Copy the current vector to an array
  77853. * @returns a new array with 2 elements: the Vector2 coordinates.
  77854. */
  77855. asArray(): number[];
  77856. /**
  77857. * Sets the Vector2 coordinates with the given Vector2 coordinates
  77858. * @param source defines the source Vector2
  77859. * @returns the current updated Vector2
  77860. */
  77861. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  77862. /**
  77863. * Sets the Vector2 coordinates with the given floats
  77864. * @param x defines the first coordinate
  77865. * @param y defines the second coordinate
  77866. * @returns the current updated Vector2
  77867. */
  77868. copyFromFloats(x: number, y: number): Vector2;
  77869. /**
  77870. * Sets the Vector2 coordinates with the given floats
  77871. * @param x defines the first coordinate
  77872. * @param y defines the second coordinate
  77873. * @returns the current updated Vector2
  77874. */
  77875. set(x: number, y: number): Vector2;
  77876. /**
  77877. * Add another vector with the current one
  77878. * @param otherVector defines the other vector
  77879. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  77880. */
  77881. add(otherVector: DeepImmutable<Vector2>): Vector2;
  77882. /**
  77883. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  77884. * @param otherVector defines the other vector
  77885. * @param result defines the target vector
  77886. * @returns the unmodified current Vector2
  77887. */
  77888. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77889. /**
  77890. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  77891. * @param otherVector defines the other vector
  77892. * @returns the current updated Vector2
  77893. */
  77894. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77895. /**
  77896. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  77897. * @param otherVector defines the other vector
  77898. * @returns a new Vector2
  77899. */
  77900. addVector3(otherVector: Vector3): Vector2;
  77901. /**
  77902. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  77903. * @param otherVector defines the other vector
  77904. * @returns a new Vector2
  77905. */
  77906. subtract(otherVector: Vector2): Vector2;
  77907. /**
  77908. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  77909. * @param otherVector defines the other vector
  77910. * @param result defines the target vector
  77911. * @returns the unmodified current Vector2
  77912. */
  77913. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77914. /**
  77915. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  77916. * @param otherVector defines the other vector
  77917. * @returns the current updated Vector2
  77918. */
  77919. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77920. /**
  77921. * Multiplies in place the current Vector2 coordinates by the given ones
  77922. * @param otherVector defines the other vector
  77923. * @returns the current updated Vector2
  77924. */
  77925. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77926. /**
  77927. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  77928. * @param otherVector defines the other vector
  77929. * @returns a new Vector2
  77930. */
  77931. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  77932. /**
  77933. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  77934. * @param otherVector defines the other vector
  77935. * @param result defines the target vector
  77936. * @returns the unmodified current Vector2
  77937. */
  77938. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77939. /**
  77940. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  77941. * @param x defines the first coordinate
  77942. * @param y defines the second coordinate
  77943. * @returns a new Vector2
  77944. */
  77945. multiplyByFloats(x: number, y: number): Vector2;
  77946. /**
  77947. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  77948. * @param otherVector defines the other vector
  77949. * @returns a new Vector2
  77950. */
  77951. divide(otherVector: Vector2): Vector2;
  77952. /**
  77953. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  77954. * @param otherVector defines the other vector
  77955. * @param result defines the target vector
  77956. * @returns the unmodified current Vector2
  77957. */
  77958. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77959. /**
  77960. * Divides the current Vector2 coordinates by the given ones
  77961. * @param otherVector defines the other vector
  77962. * @returns the current updated Vector2
  77963. */
  77964. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77965. /**
  77966. * Gets a new Vector2 with current Vector2 negated coordinates
  77967. * @returns a new Vector2
  77968. */
  77969. negate(): Vector2;
  77970. /**
  77971. * Negate this vector in place
  77972. * @returns this
  77973. */
  77974. negateInPlace(): Vector2;
  77975. /**
  77976. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  77977. * @param result defines the Vector3 object where to store the result
  77978. * @returns the current Vector2
  77979. */
  77980. negateToRef(result: Vector2): Vector2;
  77981. /**
  77982. * Multiply the Vector2 coordinates by scale
  77983. * @param scale defines the scaling factor
  77984. * @returns the current updated Vector2
  77985. */
  77986. scaleInPlace(scale: number): Vector2;
  77987. /**
  77988. * Returns a new Vector2 scaled by "scale" from the current Vector2
  77989. * @param scale defines the scaling factor
  77990. * @returns a new Vector2
  77991. */
  77992. scale(scale: number): Vector2;
  77993. /**
  77994. * Scale the current Vector2 values by a factor to a given Vector2
  77995. * @param scale defines the scale factor
  77996. * @param result defines the Vector2 object where to store the result
  77997. * @returns the unmodified current Vector2
  77998. */
  77999. scaleToRef(scale: number, result: Vector2): Vector2;
  78000. /**
  78001. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  78002. * @param scale defines the scale factor
  78003. * @param result defines the Vector2 object where to store the result
  78004. * @returns the unmodified current Vector2
  78005. */
  78006. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78007. /**
  78008. * Gets a boolean if two vectors are equals
  78009. * @param otherVector defines the other vector
  78010. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78011. */
  78012. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78013. /**
  78014. * Gets a boolean if two vectors are equals (using an epsilon value)
  78015. * @param otherVector defines the other vector
  78016. * @param epsilon defines the minimal distance to consider equality
  78017. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78018. */
  78019. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78020. /**
  78021. * Gets a new Vector2 from current Vector2 floored values
  78022. * @returns a new Vector2
  78023. */
  78024. floor(): Vector2;
  78025. /**
  78026. * Gets a new Vector2 from current Vector2 floored values
  78027. * @returns a new Vector2
  78028. */
  78029. fract(): Vector2;
  78030. /**
  78031. * Gets the length of the vector
  78032. * @returns the vector length (float)
  78033. */
  78034. length(): number;
  78035. /**
  78036. * Gets the vector squared length
  78037. * @returns the vector squared length (float)
  78038. */
  78039. lengthSquared(): number;
  78040. /**
  78041. * Normalize the vector
  78042. * @returns the current updated Vector2
  78043. */
  78044. normalize(): Vector2;
  78045. /**
  78046. * Gets a new Vector2 copied from the Vector2
  78047. * @returns a new Vector2
  78048. */
  78049. clone(): Vector2;
  78050. /**
  78051. * Gets a new Vector2(0, 0)
  78052. * @returns a new Vector2
  78053. */
  78054. static Zero(): Vector2;
  78055. /**
  78056. * Gets a new Vector2(1, 1)
  78057. * @returns a new Vector2
  78058. */
  78059. static One(): Vector2;
  78060. /**
  78061. * Gets a new Vector2 set from the given index element of the given array
  78062. * @param array defines the data source
  78063. * @param offset defines the offset in the data source
  78064. * @returns a new Vector2
  78065. */
  78066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78067. /**
  78068. * Sets "result" from the given index element of the given array
  78069. * @param array defines the data source
  78070. * @param offset defines the offset in the data source
  78071. * @param result defines the target vector
  78072. */
  78073. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78074. /**
  78075. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78076. * @param value1 defines 1st point of control
  78077. * @param value2 defines 2nd point of control
  78078. * @param value3 defines 3rd point of control
  78079. * @param value4 defines 4th point of control
  78080. * @param amount defines the interpolation factor
  78081. * @returns a new Vector2
  78082. */
  78083. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78084. /**
  78085. * 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".
  78086. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78087. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78088. * @param value defines the value to clamp
  78089. * @param min defines the lower limit
  78090. * @param max defines the upper limit
  78091. * @returns a new Vector2
  78092. */
  78093. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78094. /**
  78095. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78096. * @param value1 defines the 1st control point
  78097. * @param tangent1 defines the outgoing tangent
  78098. * @param value2 defines the 2nd control point
  78099. * @param tangent2 defines the incoming tangent
  78100. * @param amount defines the interpolation factor
  78101. * @returns a new Vector2
  78102. */
  78103. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78104. /**
  78105. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78106. * @param start defines the start vector
  78107. * @param end defines the end vector
  78108. * @param amount defines the interpolation factor
  78109. * @returns a new Vector2
  78110. */
  78111. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78112. /**
  78113. * Gets the dot product of the vector "left" and the vector "right"
  78114. * @param left defines first vector
  78115. * @param right defines second vector
  78116. * @returns the dot product (float)
  78117. */
  78118. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78119. /**
  78120. * Returns a new Vector2 equal to the normalized given vector
  78121. * @param vector defines the vector to normalize
  78122. * @returns a new Vector2
  78123. */
  78124. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78125. /**
  78126. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78127. * @param left defines 1st vector
  78128. * @param right defines 2nd vector
  78129. * @returns a new Vector2
  78130. */
  78131. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78132. /**
  78133. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78134. * @param left defines 1st vector
  78135. * @param right defines 2nd vector
  78136. * @returns a new Vector2
  78137. */
  78138. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78139. /**
  78140. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78141. * @param vector defines the vector to transform
  78142. * @param transformation defines the matrix to apply
  78143. * @returns a new Vector2
  78144. */
  78145. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78146. /**
  78147. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78148. * @param vector defines the vector to transform
  78149. * @param transformation defines the matrix to apply
  78150. * @param result defines the target vector
  78151. */
  78152. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78153. /**
  78154. * Determines if a given vector is included in a triangle
  78155. * @param p defines the vector to test
  78156. * @param p0 defines 1st triangle point
  78157. * @param p1 defines 2nd triangle point
  78158. * @param p2 defines 3rd triangle point
  78159. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78160. */
  78161. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78162. /**
  78163. * Gets the distance between the vectors "value1" and "value2"
  78164. * @param value1 defines first vector
  78165. * @param value2 defines second vector
  78166. * @returns the distance between vectors
  78167. */
  78168. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78169. /**
  78170. * Returns the squared distance between the vectors "value1" and "value2"
  78171. * @param value1 defines first vector
  78172. * @param value2 defines second vector
  78173. * @returns the squared distance between vectors
  78174. */
  78175. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78176. /**
  78177. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78178. * @param value1 defines first vector
  78179. * @param value2 defines second vector
  78180. * @returns a new Vector2
  78181. */
  78182. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78183. /**
  78184. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78185. * @param p defines the middle point
  78186. * @param segA defines one point of the segment
  78187. * @param segB defines the other point of the segment
  78188. * @returns the shortest distance
  78189. */
  78190. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78191. }
  78192. /**
  78193. * Class used to store (x,y,z) vector representation
  78194. * A Vector3 is the main object used in 3D geometry
  78195. * It can represent etiher the coordinates of a point the space, either a direction
  78196. * Reminder: js uses a left handed forward facing system
  78197. */
  78198. export class Vector3 {
  78199. /**
  78200. * Defines the first coordinates (on X axis)
  78201. */
  78202. x: number;
  78203. /**
  78204. * Defines the second coordinates (on Y axis)
  78205. */
  78206. y: number;
  78207. /**
  78208. * Defines the third coordinates (on Z axis)
  78209. */
  78210. z: number;
  78211. private static _UpReadOnly;
  78212. private static _ZeroReadOnly;
  78213. /**
  78214. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78215. * @param x defines the first coordinates (on X axis)
  78216. * @param y defines the second coordinates (on Y axis)
  78217. * @param z defines the third coordinates (on Z axis)
  78218. */
  78219. constructor(
  78220. /**
  78221. * Defines the first coordinates (on X axis)
  78222. */
  78223. x?: number,
  78224. /**
  78225. * Defines the second coordinates (on Y axis)
  78226. */
  78227. y?: number,
  78228. /**
  78229. * Defines the third coordinates (on Z axis)
  78230. */
  78231. z?: number);
  78232. /**
  78233. * Creates a string representation of the Vector3
  78234. * @returns a string with the Vector3 coordinates.
  78235. */
  78236. toString(): string;
  78237. /**
  78238. * Gets the class name
  78239. * @returns the string "Vector3"
  78240. */
  78241. getClassName(): string;
  78242. /**
  78243. * Creates the Vector3 hash code
  78244. * @returns a number which tends to be unique between Vector3 instances
  78245. */
  78246. getHashCode(): number;
  78247. /**
  78248. * Creates an array containing three elements : the coordinates of the Vector3
  78249. * @returns a new array of numbers
  78250. */
  78251. asArray(): number[];
  78252. /**
  78253. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78254. * @param array defines the destination array
  78255. * @param index defines the offset in the destination array
  78256. * @returns the current Vector3
  78257. */
  78258. toArray(array: FloatArray, index?: number): Vector3;
  78259. /**
  78260. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78261. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78262. */
  78263. toQuaternion(): Quaternion;
  78264. /**
  78265. * Adds the given vector to the current Vector3
  78266. * @param otherVector defines the second operand
  78267. * @returns the current updated Vector3
  78268. */
  78269. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78270. /**
  78271. * Adds the given coordinates to the current Vector3
  78272. * @param x defines the x coordinate of the operand
  78273. * @param y defines the y coordinate of the operand
  78274. * @param z defines the z coordinate of the operand
  78275. * @returns the current updated Vector3
  78276. */
  78277. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78278. /**
  78279. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78280. * @param otherVector defines the second operand
  78281. * @returns the resulting Vector3
  78282. */
  78283. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78284. /**
  78285. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78286. * @param otherVector defines the second operand
  78287. * @param result defines the Vector3 object where to store the result
  78288. * @returns the current Vector3
  78289. */
  78290. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78291. /**
  78292. * Subtract the given vector from the current Vector3
  78293. * @param otherVector defines the second operand
  78294. * @returns the current updated Vector3
  78295. */
  78296. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78297. /**
  78298. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78299. * @param otherVector defines the second operand
  78300. * @returns the resulting Vector3
  78301. */
  78302. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78303. /**
  78304. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78305. * @param otherVector defines the second operand
  78306. * @param result defines the Vector3 object where to store the result
  78307. * @returns the current Vector3
  78308. */
  78309. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78310. /**
  78311. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78312. * @param x defines the x coordinate of the operand
  78313. * @param y defines the y coordinate of the operand
  78314. * @param z defines the z coordinate of the operand
  78315. * @returns the resulting Vector3
  78316. */
  78317. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78318. /**
  78319. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78320. * @param x defines the x coordinate of the operand
  78321. * @param y defines the y coordinate of the operand
  78322. * @param z defines the z coordinate of the operand
  78323. * @param result defines the Vector3 object where to store the result
  78324. * @returns the current Vector3
  78325. */
  78326. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78327. /**
  78328. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78329. * @returns a new Vector3
  78330. */
  78331. negate(): Vector3;
  78332. /**
  78333. * Negate this vector in place
  78334. * @returns this
  78335. */
  78336. negateInPlace(): Vector3;
  78337. /**
  78338. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78339. * @param result defines the Vector3 object where to store the result
  78340. * @returns the current Vector3
  78341. */
  78342. negateToRef(result: Vector3): Vector3;
  78343. /**
  78344. * Multiplies the Vector3 coordinates by the float "scale"
  78345. * @param scale defines the multiplier factor
  78346. * @returns the current updated Vector3
  78347. */
  78348. scaleInPlace(scale: number): Vector3;
  78349. /**
  78350. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78351. * @param scale defines the multiplier factor
  78352. * @returns a new Vector3
  78353. */
  78354. scale(scale: number): Vector3;
  78355. /**
  78356. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78357. * @param scale defines the multiplier factor
  78358. * @param result defines the Vector3 object where to store the result
  78359. * @returns the current Vector3
  78360. */
  78361. scaleToRef(scale: number, result: Vector3): Vector3;
  78362. /**
  78363. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78364. * @param scale defines the scale factor
  78365. * @param result defines the Vector3 object where to store the result
  78366. * @returns the unmodified current Vector3
  78367. */
  78368. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78369. /**
  78370. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78371. * @param origin defines the origin of the projection ray
  78372. * @param plane defines the plane to project to
  78373. * @returns the projected vector3
  78374. */
  78375. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78376. /**
  78377. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78378. * @param origin defines the origin of the projection ray
  78379. * @param plane defines the plane to project to
  78380. * @param result defines the Vector3 where to store the result
  78381. */
  78382. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78383. /**
  78384. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78385. * @param otherVector defines the second operand
  78386. * @returns true if both vectors are equals
  78387. */
  78388. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78389. /**
  78390. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78391. * @param otherVector defines the second operand
  78392. * @param epsilon defines the minimal distance to define values as equals
  78393. * @returns true if both vectors are distant less than epsilon
  78394. */
  78395. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78396. /**
  78397. * Returns true if the current Vector3 coordinates equals the given floats
  78398. * @param x defines the x coordinate of the operand
  78399. * @param y defines the y coordinate of the operand
  78400. * @param z defines the z coordinate of the operand
  78401. * @returns true if both vectors are equals
  78402. */
  78403. equalsToFloats(x: number, y: number, z: number): boolean;
  78404. /**
  78405. * Multiplies the current Vector3 coordinates by the given ones
  78406. * @param otherVector defines the second operand
  78407. * @returns the current updated Vector3
  78408. */
  78409. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78410. /**
  78411. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78412. * @param otherVector defines the second operand
  78413. * @returns the new Vector3
  78414. */
  78415. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78416. /**
  78417. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78418. * @param otherVector defines the second operand
  78419. * @param result defines the Vector3 object where to store the result
  78420. * @returns the current Vector3
  78421. */
  78422. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78423. /**
  78424. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78425. * @param x defines the x coordinate of the operand
  78426. * @param y defines the y coordinate of the operand
  78427. * @param z defines the z coordinate of the operand
  78428. * @returns the new Vector3
  78429. */
  78430. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78431. /**
  78432. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78433. * @param otherVector defines the second operand
  78434. * @returns the new Vector3
  78435. */
  78436. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78437. /**
  78438. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78439. * @param otherVector defines the second operand
  78440. * @param result defines the Vector3 object where to store the result
  78441. * @returns the current Vector3
  78442. */
  78443. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78444. /**
  78445. * Divides the current Vector3 coordinates by the given ones.
  78446. * @param otherVector defines the second operand
  78447. * @returns the current updated Vector3
  78448. */
  78449. divideInPlace(otherVector: Vector3): Vector3;
  78450. /**
  78451. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78452. * @param other defines the second operand
  78453. * @returns the current updated Vector3
  78454. */
  78455. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78456. /**
  78457. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78458. * @param other defines the second operand
  78459. * @returns the current updated Vector3
  78460. */
  78461. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78462. /**
  78463. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78464. * @param x defines the x coordinate of the operand
  78465. * @param y defines the y coordinate of the operand
  78466. * @param z defines the z coordinate of the operand
  78467. * @returns the current updated Vector3
  78468. */
  78469. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78470. /**
  78471. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78472. * @param x defines the x coordinate of the operand
  78473. * @param y defines the y coordinate of the operand
  78474. * @param z defines the z coordinate of the operand
  78475. * @returns the current updated Vector3
  78476. */
  78477. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78478. /**
  78479. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78480. * Check if is non uniform within a certain amount of decimal places to account for this
  78481. * @param epsilon the amount the values can differ
  78482. * @returns if the the vector is non uniform to a certain number of decimal places
  78483. */
  78484. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78485. /**
  78486. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78487. */
  78488. get isNonUniform(): boolean;
  78489. /**
  78490. * Gets a new Vector3 from current Vector3 floored values
  78491. * @returns a new Vector3
  78492. */
  78493. floor(): Vector3;
  78494. /**
  78495. * Gets a new Vector3 from current Vector3 floored values
  78496. * @returns a new Vector3
  78497. */
  78498. fract(): Vector3;
  78499. /**
  78500. * Gets the length of the Vector3
  78501. * @returns the length of the Vector3
  78502. */
  78503. length(): number;
  78504. /**
  78505. * Gets the squared length of the Vector3
  78506. * @returns squared length of the Vector3
  78507. */
  78508. lengthSquared(): number;
  78509. /**
  78510. * Normalize the current Vector3.
  78511. * Please note that this is an in place operation.
  78512. * @returns the current updated Vector3
  78513. */
  78514. normalize(): Vector3;
  78515. /**
  78516. * Reorders the x y z properties of the vector in place
  78517. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78518. * @returns the current updated vector
  78519. */
  78520. reorderInPlace(order: string): this;
  78521. /**
  78522. * Rotates the vector around 0,0,0 by a quaternion
  78523. * @param quaternion the rotation quaternion
  78524. * @param result vector to store the result
  78525. * @returns the resulting vector
  78526. */
  78527. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78528. /**
  78529. * Rotates a vector around a given point
  78530. * @param quaternion the rotation quaternion
  78531. * @param point the point to rotate around
  78532. * @param result vector to store the result
  78533. * @returns the resulting vector
  78534. */
  78535. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78536. /**
  78537. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78538. * The cross product is then orthogonal to both current and "other"
  78539. * @param other defines the right operand
  78540. * @returns the cross product
  78541. */
  78542. cross(other: Vector3): Vector3;
  78543. /**
  78544. * Normalize the current Vector3 with the given input length.
  78545. * Please note that this is an in place operation.
  78546. * @param len the length of the vector
  78547. * @returns the current updated Vector3
  78548. */
  78549. normalizeFromLength(len: number): Vector3;
  78550. /**
  78551. * Normalize the current Vector3 to a new vector
  78552. * @returns the new Vector3
  78553. */
  78554. normalizeToNew(): Vector3;
  78555. /**
  78556. * Normalize the current Vector3 to the reference
  78557. * @param reference define the Vector3 to update
  78558. * @returns the updated Vector3
  78559. */
  78560. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78561. /**
  78562. * Creates a new Vector3 copied from the current Vector3
  78563. * @returns the new Vector3
  78564. */
  78565. clone(): Vector3;
  78566. /**
  78567. * Copies the given vector coordinates to the current Vector3 ones
  78568. * @param source defines the source Vector3
  78569. * @returns the current updated Vector3
  78570. */
  78571. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78572. /**
  78573. * Copies the given floats to the current Vector3 coordinates
  78574. * @param x defines the x coordinate of the operand
  78575. * @param y defines the y coordinate of the operand
  78576. * @param z defines the z coordinate of the operand
  78577. * @returns the current updated Vector3
  78578. */
  78579. copyFromFloats(x: number, y: number, z: number): Vector3;
  78580. /**
  78581. * Copies the given floats to the current Vector3 coordinates
  78582. * @param x defines the x coordinate of the operand
  78583. * @param y defines the y coordinate of the operand
  78584. * @param z defines the z coordinate of the operand
  78585. * @returns the current updated Vector3
  78586. */
  78587. set(x: number, y: number, z: number): Vector3;
  78588. /**
  78589. * Copies the given float to the current Vector3 coordinates
  78590. * @param v defines the x, y and z coordinates of the operand
  78591. * @returns the current updated Vector3
  78592. */
  78593. setAll(v: number): Vector3;
  78594. /**
  78595. * Get the clip factor between two vectors
  78596. * @param vector0 defines the first operand
  78597. * @param vector1 defines the second operand
  78598. * @param axis defines the axis to use
  78599. * @param size defines the size along the axis
  78600. * @returns the clip factor
  78601. */
  78602. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78603. /**
  78604. * Get angle between two vectors
  78605. * @param vector0 angle between vector0 and vector1
  78606. * @param vector1 angle between vector0 and vector1
  78607. * @param normal direction of the normal
  78608. * @return the angle between vector0 and vector1
  78609. */
  78610. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78611. /**
  78612. * Returns a new Vector3 set from the index "offset" of the given array
  78613. * @param array defines the source array
  78614. * @param offset defines the offset in the source array
  78615. * @returns the new Vector3
  78616. */
  78617. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78618. /**
  78619. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78620. * @param array defines the source array
  78621. * @param offset defines the offset in the source array
  78622. * @returns the new Vector3
  78623. * @deprecated Please use FromArray instead.
  78624. */
  78625. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78626. /**
  78627. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78628. * @param array defines the source array
  78629. * @param offset defines the offset in the source array
  78630. * @param result defines the Vector3 where to store the result
  78631. */
  78632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78633. /**
  78634. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78635. * @param array defines the source array
  78636. * @param offset defines the offset in the source array
  78637. * @param result defines the Vector3 where to store the result
  78638. * @deprecated Please use FromArrayToRef instead.
  78639. */
  78640. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78641. /**
  78642. * Sets the given vector "result" with the given floats.
  78643. * @param x defines the x coordinate of the source
  78644. * @param y defines the y coordinate of the source
  78645. * @param z defines the z coordinate of the source
  78646. * @param result defines the Vector3 where to store the result
  78647. */
  78648. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78649. /**
  78650. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78651. * @returns a new empty Vector3
  78652. */
  78653. static Zero(): Vector3;
  78654. /**
  78655. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78656. * @returns a new unit Vector3
  78657. */
  78658. static One(): Vector3;
  78659. /**
  78660. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78661. * @returns a new up Vector3
  78662. */
  78663. static Up(): Vector3;
  78664. /**
  78665. * Gets a up Vector3 that must not be updated
  78666. */
  78667. static get UpReadOnly(): DeepImmutable<Vector3>;
  78668. /**
  78669. * Gets a zero Vector3 that must not be updated
  78670. */
  78671. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78672. /**
  78673. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78674. * @returns a new down Vector3
  78675. */
  78676. static Down(): Vector3;
  78677. /**
  78678. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78679. * @param rightHandedSystem is the scene right-handed (negative z)
  78680. * @returns a new forward Vector3
  78681. */
  78682. static Forward(rightHandedSystem?: boolean): Vector3;
  78683. /**
  78684. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78685. * @param rightHandedSystem is the scene right-handed (negative-z)
  78686. * @returns a new forward Vector3
  78687. */
  78688. static Backward(rightHandedSystem?: boolean): Vector3;
  78689. /**
  78690. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78691. * @returns a new right Vector3
  78692. */
  78693. static Right(): Vector3;
  78694. /**
  78695. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78696. * @returns a new left Vector3
  78697. */
  78698. static Left(): Vector3;
  78699. /**
  78700. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78702. * @param vector defines the Vector3 to transform
  78703. * @param transformation defines the transformation matrix
  78704. * @returns the transformed Vector3
  78705. */
  78706. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78707. /**
  78708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78709. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78710. * @param vector defines the Vector3 to transform
  78711. * @param transformation defines the transformation matrix
  78712. * @param result defines the Vector3 where to store the result
  78713. */
  78714. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78715. /**
  78716. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78717. * This method computes tranformed coordinates only, not transformed direction vectors
  78718. * @param x define the x coordinate of the source vector
  78719. * @param y define the y coordinate of the source vector
  78720. * @param z define the z coordinate of the source vector
  78721. * @param transformation defines the transformation matrix
  78722. * @param result defines the Vector3 where to store the result
  78723. */
  78724. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78725. /**
  78726. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78728. * @param vector defines the Vector3 to transform
  78729. * @param transformation defines the transformation matrix
  78730. * @returns the new Vector3
  78731. */
  78732. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78733. /**
  78734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78736. * @param vector defines the Vector3 to transform
  78737. * @param transformation defines the transformation matrix
  78738. * @param result defines the Vector3 where to store the result
  78739. */
  78740. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78741. /**
  78742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78743. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78744. * @param x define the x coordinate of the source vector
  78745. * @param y define the y coordinate of the source vector
  78746. * @param z define the z coordinate of the source vector
  78747. * @param transformation defines the transformation matrix
  78748. * @param result defines the Vector3 where to store the result
  78749. */
  78750. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78751. /**
  78752. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78753. * @param value1 defines the first control point
  78754. * @param value2 defines the second control point
  78755. * @param value3 defines the third control point
  78756. * @param value4 defines the fourth control point
  78757. * @param amount defines the amount on the spline to use
  78758. * @returns the new Vector3
  78759. */
  78760. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78761. /**
  78762. * 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"
  78763. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78764. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78765. * @param value defines the current value
  78766. * @param min defines the lower range value
  78767. * @param max defines the upper range value
  78768. * @returns the new Vector3
  78769. */
  78770. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78771. /**
  78772. * 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"
  78773. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78774. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78775. * @param value defines the current value
  78776. * @param min defines the lower range value
  78777. * @param max defines the upper range value
  78778. * @param result defines the Vector3 where to store the result
  78779. */
  78780. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78781. /**
  78782. * Checks if a given vector is inside a specific range
  78783. * @param v defines the vector to test
  78784. * @param min defines the minimum range
  78785. * @param max defines the maximum range
  78786. */
  78787. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78788. /**
  78789. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  78790. * @param value1 defines the first control point
  78791. * @param tangent1 defines the first tangent vector
  78792. * @param value2 defines the second control point
  78793. * @param tangent2 defines the second tangent vector
  78794. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  78795. * @returns the new Vector3
  78796. */
  78797. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  78798. /**
  78799. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  78800. * @param start defines the start value
  78801. * @param end defines the end value
  78802. * @param amount max defines amount between both (between 0 and 1)
  78803. * @returns the new Vector3
  78804. */
  78805. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  78806. /**
  78807. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  78808. * @param start defines the start value
  78809. * @param end defines the end value
  78810. * @param amount max defines amount between both (between 0 and 1)
  78811. * @param result defines the Vector3 where to store the result
  78812. */
  78813. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  78814. /**
  78815. * Returns the dot product (float) between the vectors "left" and "right"
  78816. * @param left defines the left operand
  78817. * @param right defines the right operand
  78818. * @returns the dot product
  78819. */
  78820. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  78821. /**
  78822. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  78823. * The cross product is then orthogonal to both "left" and "right"
  78824. * @param left defines the left operand
  78825. * @param right defines the right operand
  78826. * @returns the cross product
  78827. */
  78828. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78829. /**
  78830. * Sets the given vector "result" with the cross product of "left" and "right"
  78831. * The cross product is then orthogonal to both "left" and "right"
  78832. * @param left defines the left operand
  78833. * @param right defines the right operand
  78834. * @param result defines the Vector3 where to store the result
  78835. */
  78836. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  78837. /**
  78838. * Returns a new Vector3 as the normalization of the given vector
  78839. * @param vector defines the Vector3 to normalize
  78840. * @returns the new Vector3
  78841. */
  78842. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  78843. /**
  78844. * Sets the given vector "result" with the normalization of the given first vector
  78845. * @param vector defines the Vector3 to normalize
  78846. * @param result defines the Vector3 where to store the result
  78847. */
  78848. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  78849. /**
  78850. * Project a Vector3 onto screen space
  78851. * @param vector defines the Vector3 to project
  78852. * @param world defines the world matrix to use
  78853. * @param transform defines the transform (view x projection) matrix to use
  78854. * @param viewport defines the screen viewport to use
  78855. * @returns the new Vector3
  78856. */
  78857. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  78858. /** @hidden */
  78859. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  78860. /**
  78861. * Unproject from screen space to object space
  78862. * @param source defines the screen space Vector3 to use
  78863. * @param viewportWidth defines the current width of the viewport
  78864. * @param viewportHeight defines the current height of the viewport
  78865. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78866. * @param transform defines the transform (view x projection) matrix to use
  78867. * @returns the new Vector3
  78868. */
  78869. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  78870. /**
  78871. * Unproject from screen space to object space
  78872. * @param source defines the screen space Vector3 to use
  78873. * @param viewportWidth defines the current width of the viewport
  78874. * @param viewportHeight defines the current height of the viewport
  78875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78876. * @param view defines the view matrix to use
  78877. * @param projection defines the projection matrix to use
  78878. * @returns the new Vector3
  78879. */
  78880. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  78881. /**
  78882. * Unproject from screen space to object space
  78883. * @param source defines the screen space Vector3 to use
  78884. * @param viewportWidth defines the current width of the viewport
  78885. * @param viewportHeight defines the current height of the viewport
  78886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78887. * @param view defines the view matrix to use
  78888. * @param projection defines the projection matrix to use
  78889. * @param result defines the Vector3 where to store the result
  78890. */
  78891. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78892. /**
  78893. * Unproject from screen space to object space
  78894. * @param sourceX defines the screen space x coordinate to use
  78895. * @param sourceY defines the screen space y coordinate to use
  78896. * @param sourceZ defines the screen space z coordinate to use
  78897. * @param viewportWidth defines the current width of the viewport
  78898. * @param viewportHeight defines the current height of the viewport
  78899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78900. * @param view defines the view matrix to use
  78901. * @param projection defines the projection matrix to use
  78902. * @param result defines the Vector3 where to store the result
  78903. */
  78904. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78905. /**
  78906. * Gets the minimal coordinate values between two Vector3
  78907. * @param left defines the first operand
  78908. * @param right defines the second operand
  78909. * @returns the new Vector3
  78910. */
  78911. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78912. /**
  78913. * Gets the maximal coordinate values between two Vector3
  78914. * @param left defines the first operand
  78915. * @param right defines the second operand
  78916. * @returns the new Vector3
  78917. */
  78918. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78919. /**
  78920. * Returns the distance between the vectors "value1" and "value2"
  78921. * @param value1 defines the first operand
  78922. * @param value2 defines the second operand
  78923. * @returns the distance
  78924. */
  78925. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78926. /**
  78927. * Returns the squared distance between the vectors "value1" and "value2"
  78928. * @param value1 defines the first operand
  78929. * @param value2 defines the second operand
  78930. * @returns the squared distance
  78931. */
  78932. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78933. /**
  78934. * Returns a new Vector3 located at the center between "value1" and "value2"
  78935. * @param value1 defines the first operand
  78936. * @param value2 defines the second operand
  78937. * @returns the new Vector3
  78938. */
  78939. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  78940. /**
  78941. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  78942. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  78943. * to something in order to rotate it from its local system to the given target system
  78944. * Note: axis1, axis2 and axis3 are normalized during this operation
  78945. * @param axis1 defines the first axis
  78946. * @param axis2 defines the second axis
  78947. * @param axis3 defines the third axis
  78948. * @returns a new Vector3
  78949. */
  78950. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  78951. /**
  78952. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  78953. * @param axis1 defines the first axis
  78954. * @param axis2 defines the second axis
  78955. * @param axis3 defines the third axis
  78956. * @param ref defines the Vector3 where to store the result
  78957. */
  78958. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  78959. }
  78960. /**
  78961. * Vector4 class created for EulerAngle class conversion to Quaternion
  78962. */
  78963. export class Vector4 {
  78964. /** x value of the vector */
  78965. x: number;
  78966. /** y value of the vector */
  78967. y: number;
  78968. /** z value of the vector */
  78969. z: number;
  78970. /** w value of the vector */
  78971. w: number;
  78972. /**
  78973. * Creates a Vector4 object from the given floats.
  78974. * @param x x value of the vector
  78975. * @param y y value of the vector
  78976. * @param z z value of the vector
  78977. * @param w w value of the vector
  78978. */
  78979. constructor(
  78980. /** x value of the vector */
  78981. x: number,
  78982. /** y value of the vector */
  78983. y: number,
  78984. /** z value of the vector */
  78985. z: number,
  78986. /** w value of the vector */
  78987. w: number);
  78988. /**
  78989. * Returns the string with the Vector4 coordinates.
  78990. * @returns a string containing all the vector values
  78991. */
  78992. toString(): string;
  78993. /**
  78994. * Returns the string "Vector4".
  78995. * @returns "Vector4"
  78996. */
  78997. getClassName(): string;
  78998. /**
  78999. * Returns the Vector4 hash code.
  79000. * @returns a unique hash code
  79001. */
  79002. getHashCode(): number;
  79003. /**
  79004. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79005. * @returns the resulting array
  79006. */
  79007. asArray(): number[];
  79008. /**
  79009. * Populates the given array from the given index with the Vector4 coordinates.
  79010. * @param array array to populate
  79011. * @param index index of the array to start at (default: 0)
  79012. * @returns the Vector4.
  79013. */
  79014. toArray(array: FloatArray, index?: number): Vector4;
  79015. /**
  79016. * Adds the given vector to the current Vector4.
  79017. * @param otherVector the vector to add
  79018. * @returns the updated Vector4.
  79019. */
  79020. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79021. /**
  79022. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79023. * @param otherVector the vector to add
  79024. * @returns the resulting vector
  79025. */
  79026. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79027. /**
  79028. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79029. * @param otherVector the vector to add
  79030. * @param result the vector to store the result
  79031. * @returns the current Vector4.
  79032. */
  79033. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79034. /**
  79035. * Subtract in place the given vector from the current Vector4.
  79036. * @param otherVector the vector to subtract
  79037. * @returns the updated Vector4.
  79038. */
  79039. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79040. /**
  79041. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79042. * @param otherVector the vector to add
  79043. * @returns the new vector with the result
  79044. */
  79045. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79046. /**
  79047. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79048. * @param otherVector the vector to subtract
  79049. * @param result the vector to store the result
  79050. * @returns the current Vector4.
  79051. */
  79052. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79053. /**
  79054. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79055. */
  79056. /**
  79057. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79058. * @param x value to subtract
  79059. * @param y value to subtract
  79060. * @param z value to subtract
  79061. * @param w value to subtract
  79062. * @returns new vector containing the result
  79063. */
  79064. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79065. /**
  79066. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79067. * @param x value to subtract
  79068. * @param y value to subtract
  79069. * @param z value to subtract
  79070. * @param w value to subtract
  79071. * @param result the vector to store the result in
  79072. * @returns the current Vector4.
  79073. */
  79074. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79075. /**
  79076. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79077. * @returns a new vector with the negated values
  79078. */
  79079. negate(): Vector4;
  79080. /**
  79081. * Negate this vector in place
  79082. * @returns this
  79083. */
  79084. negateInPlace(): Vector4;
  79085. /**
  79086. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79087. * @param result defines the Vector3 object where to store the result
  79088. * @returns the current Vector4
  79089. */
  79090. negateToRef(result: Vector4): Vector4;
  79091. /**
  79092. * Multiplies the current Vector4 coordinates by scale (float).
  79093. * @param scale the number to scale with
  79094. * @returns the updated Vector4.
  79095. */
  79096. scaleInPlace(scale: number): Vector4;
  79097. /**
  79098. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79099. * @param scale the number to scale with
  79100. * @returns a new vector with the result
  79101. */
  79102. scale(scale: number): Vector4;
  79103. /**
  79104. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79105. * @param scale the number to scale with
  79106. * @param result a vector to store the result in
  79107. * @returns the current Vector4.
  79108. */
  79109. scaleToRef(scale: number, result: Vector4): Vector4;
  79110. /**
  79111. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79112. * @param scale defines the scale factor
  79113. * @param result defines the Vector4 object where to store the result
  79114. * @returns the unmodified current Vector4
  79115. */
  79116. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79117. /**
  79118. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79119. * @param otherVector the vector to compare against
  79120. * @returns true if they are equal
  79121. */
  79122. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79123. /**
  79124. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79125. * @param otherVector vector to compare against
  79126. * @param epsilon (Default: very small number)
  79127. * @returns true if they are equal
  79128. */
  79129. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79130. /**
  79131. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79132. * @param x x value to compare against
  79133. * @param y y value to compare against
  79134. * @param z z value to compare against
  79135. * @param w w value to compare against
  79136. * @returns true if equal
  79137. */
  79138. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79139. /**
  79140. * Multiplies in place the current Vector4 by the given one.
  79141. * @param otherVector vector to multiple with
  79142. * @returns the updated Vector4.
  79143. */
  79144. multiplyInPlace(otherVector: Vector4): Vector4;
  79145. /**
  79146. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79147. * @param otherVector vector to multiple with
  79148. * @returns resulting new vector
  79149. */
  79150. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79151. /**
  79152. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79153. * @param otherVector vector to multiple with
  79154. * @param result vector to store the result
  79155. * @returns the current Vector4.
  79156. */
  79157. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79158. /**
  79159. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79160. * @param x x value multiply with
  79161. * @param y y value multiply with
  79162. * @param z z value multiply with
  79163. * @param w w value multiply with
  79164. * @returns resulting new vector
  79165. */
  79166. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79167. /**
  79168. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79169. * @param otherVector vector to devide with
  79170. * @returns resulting new vector
  79171. */
  79172. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79173. /**
  79174. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79175. * @param otherVector vector to devide with
  79176. * @param result vector to store the result
  79177. * @returns the current Vector4.
  79178. */
  79179. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79180. /**
  79181. * Divides the current Vector3 coordinates by the given ones.
  79182. * @param otherVector vector to devide with
  79183. * @returns the updated Vector3.
  79184. */
  79185. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79186. /**
  79187. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79188. * @param other defines the second operand
  79189. * @returns the current updated Vector4
  79190. */
  79191. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79192. /**
  79193. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79194. * @param other defines the second operand
  79195. * @returns the current updated Vector4
  79196. */
  79197. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79198. /**
  79199. * Gets a new Vector4 from current Vector4 floored values
  79200. * @returns a new Vector4
  79201. */
  79202. floor(): Vector4;
  79203. /**
  79204. * Gets a new Vector4 from current Vector3 floored values
  79205. * @returns a new Vector4
  79206. */
  79207. fract(): Vector4;
  79208. /**
  79209. * Returns the Vector4 length (float).
  79210. * @returns the length
  79211. */
  79212. length(): number;
  79213. /**
  79214. * Returns the Vector4 squared length (float).
  79215. * @returns the length squared
  79216. */
  79217. lengthSquared(): number;
  79218. /**
  79219. * Normalizes in place the Vector4.
  79220. * @returns the updated Vector4.
  79221. */
  79222. normalize(): Vector4;
  79223. /**
  79224. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79225. * @returns this converted to a new vector3
  79226. */
  79227. toVector3(): Vector3;
  79228. /**
  79229. * Returns a new Vector4 copied from the current one.
  79230. * @returns the new cloned vector
  79231. */
  79232. clone(): Vector4;
  79233. /**
  79234. * Updates the current Vector4 with the given one coordinates.
  79235. * @param source the source vector to copy from
  79236. * @returns the updated Vector4.
  79237. */
  79238. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79239. /**
  79240. * Updates the current Vector4 coordinates with the given floats.
  79241. * @param x float to copy from
  79242. * @param y float to copy from
  79243. * @param z float to copy from
  79244. * @param w float to copy from
  79245. * @returns the updated Vector4.
  79246. */
  79247. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79248. /**
  79249. * Updates the current Vector4 coordinates with the given floats.
  79250. * @param x float to set from
  79251. * @param y float to set from
  79252. * @param z float to set from
  79253. * @param w float to set from
  79254. * @returns the updated Vector4.
  79255. */
  79256. set(x: number, y: number, z: number, w: number): Vector4;
  79257. /**
  79258. * Copies the given float to the current Vector3 coordinates
  79259. * @param v defines the x, y, z and w coordinates of the operand
  79260. * @returns the current updated Vector3
  79261. */
  79262. setAll(v: number): Vector4;
  79263. /**
  79264. * Returns a new Vector4 set from the starting index of the given array.
  79265. * @param array the array to pull values from
  79266. * @param offset the offset into the array to start at
  79267. * @returns the new vector
  79268. */
  79269. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79270. /**
  79271. * Updates the given vector "result" from the starting index of the given array.
  79272. * @param array the array to pull values from
  79273. * @param offset the offset into the array to start at
  79274. * @param result the vector to store the result in
  79275. */
  79276. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79277. /**
  79278. * Updates the given vector "result" from the starting index of the given Float32Array.
  79279. * @param array the array to pull values from
  79280. * @param offset the offset into the array to start at
  79281. * @param result the vector to store the result in
  79282. */
  79283. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79284. /**
  79285. * Updates the given vector "result" coordinates from the given floats.
  79286. * @param x float to set from
  79287. * @param y float to set from
  79288. * @param z float to set from
  79289. * @param w float to set from
  79290. * @param result the vector to the floats in
  79291. */
  79292. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79293. /**
  79294. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79295. * @returns the new vector
  79296. */
  79297. static Zero(): Vector4;
  79298. /**
  79299. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79300. * @returns the new vector
  79301. */
  79302. static One(): Vector4;
  79303. /**
  79304. * Returns a new normalized Vector4 from the given one.
  79305. * @param vector the vector to normalize
  79306. * @returns the vector
  79307. */
  79308. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79309. /**
  79310. * Updates the given vector "result" from the normalization of the given one.
  79311. * @param vector the vector to normalize
  79312. * @param result the vector to store the result in
  79313. */
  79314. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79315. /**
  79316. * Returns a vector with the minimum values from the left and right vectors
  79317. * @param left left vector to minimize
  79318. * @param right right vector to minimize
  79319. * @returns a new vector with the minimum of the left and right vector values
  79320. */
  79321. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79322. /**
  79323. * Returns a vector with the maximum values from the left and right vectors
  79324. * @param left left vector to maximize
  79325. * @param right right vector to maximize
  79326. * @returns a new vector with the maximum of the left and right vector values
  79327. */
  79328. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79329. /**
  79330. * Returns the distance (float) between the vectors "value1" and "value2".
  79331. * @param value1 value to calulate the distance between
  79332. * @param value2 value to calulate the distance between
  79333. * @return the distance between the two vectors
  79334. */
  79335. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79336. /**
  79337. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79338. * @param value1 value to calulate the distance between
  79339. * @param value2 value to calulate the distance between
  79340. * @return the distance between the two vectors squared
  79341. */
  79342. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79343. /**
  79344. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79345. * @param value1 value to calulate the center between
  79346. * @param value2 value to calulate the center between
  79347. * @return the center between the two vectors
  79348. */
  79349. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79350. /**
  79351. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79352. * This methods computes transformed normalized direction vectors only.
  79353. * @param vector the vector to transform
  79354. * @param transformation the transformation matrix to apply
  79355. * @returns the new vector
  79356. */
  79357. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79358. /**
  79359. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79360. * This methods computes transformed normalized direction vectors only.
  79361. * @param vector the vector to transform
  79362. * @param transformation the transformation matrix to apply
  79363. * @param result the vector to store the result in
  79364. */
  79365. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79366. /**
  79367. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79368. * This methods computes transformed normalized direction vectors only.
  79369. * @param x value to transform
  79370. * @param y value to transform
  79371. * @param z value to transform
  79372. * @param w value to transform
  79373. * @param transformation the transformation matrix to apply
  79374. * @param result the vector to store the results in
  79375. */
  79376. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79377. /**
  79378. * Creates a new Vector4 from a Vector3
  79379. * @param source defines the source data
  79380. * @param w defines the 4th component (default is 0)
  79381. * @returns a new Vector4
  79382. */
  79383. static FromVector3(source: Vector3, w?: number): Vector4;
  79384. }
  79385. /**
  79386. * Class used to store quaternion data
  79387. * @see https://en.wikipedia.org/wiki/Quaternion
  79388. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79389. */
  79390. export class Quaternion {
  79391. /** defines the first component (0 by default) */
  79392. x: number;
  79393. /** defines the second component (0 by default) */
  79394. y: number;
  79395. /** defines the third component (0 by default) */
  79396. z: number;
  79397. /** defines the fourth component (1.0 by default) */
  79398. w: number;
  79399. /**
  79400. * Creates a new Quaternion from the given floats
  79401. * @param x defines the first component (0 by default)
  79402. * @param y defines the second component (0 by default)
  79403. * @param z defines the third component (0 by default)
  79404. * @param w defines the fourth component (1.0 by default)
  79405. */
  79406. constructor(
  79407. /** defines the first component (0 by default) */
  79408. x?: number,
  79409. /** defines the second component (0 by default) */
  79410. y?: number,
  79411. /** defines the third component (0 by default) */
  79412. z?: number,
  79413. /** defines the fourth component (1.0 by default) */
  79414. w?: number);
  79415. /**
  79416. * Gets a string representation for the current quaternion
  79417. * @returns a string with the Quaternion coordinates
  79418. */
  79419. toString(): string;
  79420. /**
  79421. * Gets the class name of the quaternion
  79422. * @returns the string "Quaternion"
  79423. */
  79424. getClassName(): string;
  79425. /**
  79426. * Gets a hash code for this quaternion
  79427. * @returns the quaternion hash code
  79428. */
  79429. getHashCode(): number;
  79430. /**
  79431. * Copy the quaternion to an array
  79432. * @returns a new array populated with 4 elements from the quaternion coordinates
  79433. */
  79434. asArray(): number[];
  79435. /**
  79436. * Check if two quaternions are equals
  79437. * @param otherQuaternion defines the second operand
  79438. * @return true if the current quaternion and the given one coordinates are strictly equals
  79439. */
  79440. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79441. /**
  79442. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79443. * @param otherQuaternion defines the other quaternion
  79444. * @param epsilon defines the minimal distance to consider equality
  79445. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79446. */
  79447. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79448. /**
  79449. * Clone the current quaternion
  79450. * @returns a new quaternion copied from the current one
  79451. */
  79452. clone(): Quaternion;
  79453. /**
  79454. * Copy a quaternion to the current one
  79455. * @param other defines the other quaternion
  79456. * @returns the updated current quaternion
  79457. */
  79458. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79459. /**
  79460. * Updates the current quaternion with the given float coordinates
  79461. * @param x defines the x coordinate
  79462. * @param y defines the y coordinate
  79463. * @param z defines the z coordinate
  79464. * @param w defines the w coordinate
  79465. * @returns the updated current quaternion
  79466. */
  79467. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79468. /**
  79469. * Updates the current quaternion from the given float coordinates
  79470. * @param x defines the x coordinate
  79471. * @param y defines the y coordinate
  79472. * @param z defines the z coordinate
  79473. * @param w defines the w coordinate
  79474. * @returns the updated current quaternion
  79475. */
  79476. set(x: number, y: number, z: number, w: number): Quaternion;
  79477. /**
  79478. * Adds two quaternions
  79479. * @param other defines the second operand
  79480. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79481. */
  79482. add(other: DeepImmutable<Quaternion>): Quaternion;
  79483. /**
  79484. * Add a quaternion to the current one
  79485. * @param other defines the quaternion to add
  79486. * @returns the current quaternion
  79487. */
  79488. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79489. /**
  79490. * Subtract two quaternions
  79491. * @param other defines the second operand
  79492. * @returns a new quaternion as the subtraction result of the given one from the current one
  79493. */
  79494. subtract(other: Quaternion): Quaternion;
  79495. /**
  79496. * Multiplies the current quaternion by a scale factor
  79497. * @param value defines the scale factor
  79498. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79499. */
  79500. scale(value: number): Quaternion;
  79501. /**
  79502. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79503. * @param scale defines the scale factor
  79504. * @param result defines the Quaternion object where to store the result
  79505. * @returns the unmodified current quaternion
  79506. */
  79507. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79508. /**
  79509. * Multiplies in place the current quaternion by a scale factor
  79510. * @param value defines the scale factor
  79511. * @returns the current modified quaternion
  79512. */
  79513. scaleInPlace(value: number): Quaternion;
  79514. /**
  79515. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79516. * @param scale defines the scale factor
  79517. * @param result defines the Quaternion object where to store the result
  79518. * @returns the unmodified current quaternion
  79519. */
  79520. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79521. /**
  79522. * Multiplies two quaternions
  79523. * @param q1 defines the second operand
  79524. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79525. */
  79526. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79527. /**
  79528. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79529. * @param q1 defines the second operand
  79530. * @param result defines the target quaternion
  79531. * @returns the current quaternion
  79532. */
  79533. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79534. /**
  79535. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79536. * @param q1 defines the second operand
  79537. * @returns the currentupdated quaternion
  79538. */
  79539. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79540. /**
  79541. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79542. * @param ref defines the target quaternion
  79543. * @returns the current quaternion
  79544. */
  79545. conjugateToRef(ref: Quaternion): Quaternion;
  79546. /**
  79547. * Conjugates in place (1-q) the current quaternion
  79548. * @returns the current updated quaternion
  79549. */
  79550. conjugateInPlace(): Quaternion;
  79551. /**
  79552. * Conjugates in place (1-q) the current quaternion
  79553. * @returns a new quaternion
  79554. */
  79555. conjugate(): Quaternion;
  79556. /**
  79557. * Gets length of current quaternion
  79558. * @returns the quaternion length (float)
  79559. */
  79560. length(): number;
  79561. /**
  79562. * Normalize in place the current quaternion
  79563. * @returns the current updated quaternion
  79564. */
  79565. normalize(): Quaternion;
  79566. /**
  79567. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79568. * @param order is a reserved parameter and is ignore for now
  79569. * @returns a new Vector3 containing the Euler angles
  79570. */
  79571. toEulerAngles(order?: string): Vector3;
  79572. /**
  79573. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79574. * @param result defines the vector which will be filled with the Euler angles
  79575. * @param order is a reserved parameter and is ignore for now
  79576. * @returns the current unchanged quaternion
  79577. */
  79578. toEulerAnglesToRef(result: Vector3): Quaternion;
  79579. /**
  79580. * Updates the given rotation matrix with the current quaternion values
  79581. * @param result defines the target matrix
  79582. * @returns the current unchanged quaternion
  79583. */
  79584. toRotationMatrix(result: Matrix): Quaternion;
  79585. /**
  79586. * Updates the current quaternion from the given rotation matrix values
  79587. * @param matrix defines the source matrix
  79588. * @returns the current updated quaternion
  79589. */
  79590. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79591. /**
  79592. * Creates a new quaternion from a rotation matrix
  79593. * @param matrix defines the source matrix
  79594. * @returns a new quaternion created from the given rotation matrix values
  79595. */
  79596. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79597. /**
  79598. * Updates the given quaternion with the given rotation matrix values
  79599. * @param matrix defines the source matrix
  79600. * @param result defines the target quaternion
  79601. */
  79602. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79603. /**
  79604. * Returns the dot product (float) between the quaternions "left" and "right"
  79605. * @param left defines the left operand
  79606. * @param right defines the right operand
  79607. * @returns the dot product
  79608. */
  79609. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79610. /**
  79611. * Checks if the two quaternions are close to each other
  79612. * @param quat0 defines the first quaternion to check
  79613. * @param quat1 defines the second quaternion to check
  79614. * @returns true if the two quaternions are close to each other
  79615. */
  79616. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79617. /**
  79618. * Creates an empty quaternion
  79619. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79620. */
  79621. static Zero(): Quaternion;
  79622. /**
  79623. * Inverse a given quaternion
  79624. * @param q defines the source quaternion
  79625. * @returns a new quaternion as the inverted current quaternion
  79626. */
  79627. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79628. /**
  79629. * Inverse a given quaternion
  79630. * @param q defines the source quaternion
  79631. * @param result the quaternion the result will be stored in
  79632. * @returns the result quaternion
  79633. */
  79634. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79635. /**
  79636. * Creates an identity quaternion
  79637. * @returns the identity quaternion
  79638. */
  79639. static Identity(): Quaternion;
  79640. /**
  79641. * Gets a boolean indicating if the given quaternion is identity
  79642. * @param quaternion defines the quaternion to check
  79643. * @returns true if the quaternion is identity
  79644. */
  79645. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79646. /**
  79647. * Creates a quaternion from a rotation around an axis
  79648. * @param axis defines the axis to use
  79649. * @param angle defines the angle to use
  79650. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79651. */
  79652. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79653. /**
  79654. * Creates a rotation around an axis and stores it into the given quaternion
  79655. * @param axis defines the axis to use
  79656. * @param angle defines the angle to use
  79657. * @param result defines the target quaternion
  79658. * @returns the target quaternion
  79659. */
  79660. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79661. /**
  79662. * Creates a new quaternion from data stored into an array
  79663. * @param array defines the data source
  79664. * @param offset defines the offset in the source array where the data starts
  79665. * @returns a new quaternion
  79666. */
  79667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79668. /**
  79669. * Updates the given quaternion "result" from the starting index of the given array.
  79670. * @param array the array to pull values from
  79671. * @param offset the offset into the array to start at
  79672. * @param result the quaternion to store the result in
  79673. */
  79674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79675. /**
  79676. * Create a quaternion from Euler rotation angles
  79677. * @param x Pitch
  79678. * @param y Yaw
  79679. * @param z Roll
  79680. * @returns the new Quaternion
  79681. */
  79682. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79683. /**
  79684. * Updates a quaternion from Euler rotation angles
  79685. * @param x Pitch
  79686. * @param y Yaw
  79687. * @param z Roll
  79688. * @param result the quaternion to store the result
  79689. * @returns the updated quaternion
  79690. */
  79691. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79692. /**
  79693. * Create a quaternion from Euler rotation vector
  79694. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79695. * @returns the new Quaternion
  79696. */
  79697. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79698. /**
  79699. * Updates a quaternion from Euler rotation vector
  79700. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79701. * @param result the quaternion to store the result
  79702. * @returns the updated quaternion
  79703. */
  79704. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79705. /**
  79706. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79707. * @param yaw defines the rotation around Y axis
  79708. * @param pitch defines the rotation around X axis
  79709. * @param roll defines the rotation around Z axis
  79710. * @returns the new quaternion
  79711. */
  79712. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79713. /**
  79714. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79715. * @param yaw defines the rotation around Y axis
  79716. * @param pitch defines the rotation around X axis
  79717. * @param roll defines the rotation around Z axis
  79718. * @param result defines the target quaternion
  79719. */
  79720. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79721. /**
  79722. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79723. * @param alpha defines the rotation around first axis
  79724. * @param beta defines the rotation around second axis
  79725. * @param gamma defines the rotation around third axis
  79726. * @returns the new quaternion
  79727. */
  79728. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79729. /**
  79730. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79731. * @param alpha defines the rotation around first axis
  79732. * @param beta defines the rotation around second axis
  79733. * @param gamma defines the rotation around third axis
  79734. * @param result defines the target quaternion
  79735. */
  79736. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79737. /**
  79738. * 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)
  79739. * @param axis1 defines the first axis
  79740. * @param axis2 defines the second axis
  79741. * @param axis3 defines the third axis
  79742. * @returns the new quaternion
  79743. */
  79744. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79745. /**
  79746. * 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
  79747. * @param axis1 defines the first axis
  79748. * @param axis2 defines the second axis
  79749. * @param axis3 defines the third axis
  79750. * @param ref defines the target quaternion
  79751. */
  79752. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79753. /**
  79754. * Interpolates between two quaternions
  79755. * @param left defines first quaternion
  79756. * @param right defines second quaternion
  79757. * @param amount defines the gradient to use
  79758. * @returns the new interpolated quaternion
  79759. */
  79760. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79761. /**
  79762. * Interpolates between two quaternions and stores it into a target quaternion
  79763. * @param left defines first quaternion
  79764. * @param right defines second quaternion
  79765. * @param amount defines the gradient to use
  79766. * @param result defines the target quaternion
  79767. */
  79768. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79769. /**
  79770. * Interpolate between two quaternions using Hermite interpolation
  79771. * @param value1 defines first quaternion
  79772. * @param tangent1 defines the incoming tangent
  79773. * @param value2 defines second quaternion
  79774. * @param tangent2 defines the outgoing tangent
  79775. * @param amount defines the target quaternion
  79776. * @returns the new interpolated quaternion
  79777. */
  79778. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79779. }
  79780. /**
  79781. * Class used to store matrix data (4x4)
  79782. */
  79783. export class Matrix {
  79784. private static _updateFlagSeed;
  79785. private static _identityReadOnly;
  79786. private _isIdentity;
  79787. private _isIdentityDirty;
  79788. private _isIdentity3x2;
  79789. private _isIdentity3x2Dirty;
  79790. /**
  79791. * Gets the update flag of the matrix which is an unique number for the matrix.
  79792. * It will be incremented every time the matrix data change.
  79793. * You can use it to speed the comparison between two versions of the same matrix.
  79794. */
  79795. updateFlag: number;
  79796. private readonly _m;
  79797. /**
  79798. * Gets the internal data of the matrix
  79799. */
  79800. get m(): DeepImmutable<Float32Array>;
  79801. /** @hidden */
  79802. _markAsUpdated(): void;
  79803. /** @hidden */
  79804. private _updateIdentityStatus;
  79805. /**
  79806. * Creates an empty matrix (filled with zeros)
  79807. */
  79808. constructor();
  79809. /**
  79810. * Check if the current matrix is identity
  79811. * @returns true is the matrix is the identity matrix
  79812. */
  79813. isIdentity(): boolean;
  79814. /**
  79815. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  79816. * @returns true is the matrix is the identity matrix
  79817. */
  79818. isIdentityAs3x2(): boolean;
  79819. /**
  79820. * Gets the determinant of the matrix
  79821. * @returns the matrix determinant
  79822. */
  79823. determinant(): number;
  79824. /**
  79825. * Returns the matrix as a Float32Array
  79826. * @returns the matrix underlying array
  79827. */
  79828. toArray(): DeepImmutable<Float32Array>;
  79829. /**
  79830. * Returns the matrix as a Float32Array
  79831. * @returns the matrix underlying array.
  79832. */
  79833. asArray(): DeepImmutable<Float32Array>;
  79834. /**
  79835. * Inverts the current matrix in place
  79836. * @returns the current inverted matrix
  79837. */
  79838. invert(): Matrix;
  79839. /**
  79840. * Sets all the matrix elements to zero
  79841. * @returns the current matrix
  79842. */
  79843. reset(): Matrix;
  79844. /**
  79845. * Adds the current matrix with a second one
  79846. * @param other defines the matrix to add
  79847. * @returns a new matrix as the addition of the current matrix and the given one
  79848. */
  79849. add(other: DeepImmutable<Matrix>): Matrix;
  79850. /**
  79851. * Sets the given matrix "result" to the addition of the current matrix and the given one
  79852. * @param other defines the matrix to add
  79853. * @param result defines the target matrix
  79854. * @returns the current matrix
  79855. */
  79856. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79857. /**
  79858. * Adds in place the given matrix to the current matrix
  79859. * @param other defines the second operand
  79860. * @returns the current updated matrix
  79861. */
  79862. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  79863. /**
  79864. * Sets the given matrix to the current inverted Matrix
  79865. * @param other defines the target matrix
  79866. * @returns the unmodified current matrix
  79867. */
  79868. invertToRef(other: Matrix): Matrix;
  79869. /**
  79870. * add a value at the specified position in the current Matrix
  79871. * @param index the index of the value within the matrix. between 0 and 15.
  79872. * @param value the value to be added
  79873. * @returns the current updated matrix
  79874. */
  79875. addAtIndex(index: number, value: number): Matrix;
  79876. /**
  79877. * mutiply the specified position in the current Matrix by a value
  79878. * @param index the index of the value within the matrix. between 0 and 15.
  79879. * @param value the value to be added
  79880. * @returns the current updated matrix
  79881. */
  79882. multiplyAtIndex(index: number, value: number): Matrix;
  79883. /**
  79884. * Inserts the translation vector (using 3 floats) in the current matrix
  79885. * @param x defines the 1st component of the translation
  79886. * @param y defines the 2nd component of the translation
  79887. * @param z defines the 3rd component of the translation
  79888. * @returns the current updated matrix
  79889. */
  79890. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79891. /**
  79892. * Adds the translation vector (using 3 floats) in the current matrix
  79893. * @param x defines the 1st component of the translation
  79894. * @param y defines the 2nd component of the translation
  79895. * @param z defines the 3rd component of the translation
  79896. * @returns the current updated matrix
  79897. */
  79898. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79899. /**
  79900. * Inserts the translation vector in the current matrix
  79901. * @param vector3 defines the translation to insert
  79902. * @returns the current updated matrix
  79903. */
  79904. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  79905. /**
  79906. * Gets the translation value of the current matrix
  79907. * @returns a new Vector3 as the extracted translation from the matrix
  79908. */
  79909. getTranslation(): Vector3;
  79910. /**
  79911. * Fill a Vector3 with the extracted translation from the matrix
  79912. * @param result defines the Vector3 where to store the translation
  79913. * @returns the current matrix
  79914. */
  79915. getTranslationToRef(result: Vector3): Matrix;
  79916. /**
  79917. * Remove rotation and scaling part from the matrix
  79918. * @returns the updated matrix
  79919. */
  79920. removeRotationAndScaling(): Matrix;
  79921. /**
  79922. * Multiply two matrices
  79923. * @param other defines the second operand
  79924. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  79925. */
  79926. multiply(other: DeepImmutable<Matrix>): Matrix;
  79927. /**
  79928. * Copy the current matrix from the given one
  79929. * @param other defines the source matrix
  79930. * @returns the current updated matrix
  79931. */
  79932. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  79933. /**
  79934. * Populates the given array from the starting index with the current matrix values
  79935. * @param array defines the target array
  79936. * @param offset defines the offset in the target array where to start storing values
  79937. * @returns the current matrix
  79938. */
  79939. copyToArray(array: Float32Array, offset?: number): Matrix;
  79940. /**
  79941. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  79942. * @param other defines the second operand
  79943. * @param result defines the matrix where to store the multiplication
  79944. * @returns the current matrix
  79945. */
  79946. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79947. /**
  79948. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  79949. * @param other defines the second operand
  79950. * @param result defines the array where to store the multiplication
  79951. * @param offset defines the offset in the target array where to start storing values
  79952. * @returns the current matrix
  79953. */
  79954. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  79955. /**
  79956. * Check equality between this matrix and a second one
  79957. * @param value defines the second matrix to compare
  79958. * @returns true is the current matrix and the given one values are strictly equal
  79959. */
  79960. equals(value: DeepImmutable<Matrix>): boolean;
  79961. /**
  79962. * Clone the current matrix
  79963. * @returns a new matrix from the current matrix
  79964. */
  79965. clone(): Matrix;
  79966. /**
  79967. * Returns the name of the current matrix class
  79968. * @returns the string "Matrix"
  79969. */
  79970. getClassName(): string;
  79971. /**
  79972. * Gets the hash code of the current matrix
  79973. * @returns the hash code
  79974. */
  79975. getHashCode(): number;
  79976. /**
  79977. * Decomposes the current Matrix into a translation, rotation and scaling components
  79978. * @param scale defines the scale vector3 given as a reference to update
  79979. * @param rotation defines the rotation quaternion given as a reference to update
  79980. * @param translation defines the translation vector3 given as a reference to update
  79981. * @returns true if operation was successful
  79982. */
  79983. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  79984. /**
  79985. * Gets specific row of the matrix
  79986. * @param index defines the number of the row to get
  79987. * @returns the index-th row of the current matrix as a new Vector4
  79988. */
  79989. getRow(index: number): Nullable<Vector4>;
  79990. /**
  79991. * Sets the index-th row of the current matrix to the vector4 values
  79992. * @param index defines the number of the row to set
  79993. * @param row defines the target vector4
  79994. * @returns the updated current matrix
  79995. */
  79996. setRow(index: number, row: Vector4): Matrix;
  79997. /**
  79998. * Compute the transpose of the matrix
  79999. * @returns the new transposed matrix
  80000. */
  80001. transpose(): Matrix;
  80002. /**
  80003. * Compute the transpose of the matrix and store it in a given matrix
  80004. * @param result defines the target matrix
  80005. * @returns the current matrix
  80006. */
  80007. transposeToRef(result: Matrix): Matrix;
  80008. /**
  80009. * Sets the index-th row of the current matrix with the given 4 x float values
  80010. * @param index defines the row index
  80011. * @param x defines the x component to set
  80012. * @param y defines the y component to set
  80013. * @param z defines the z component to set
  80014. * @param w defines the w component to set
  80015. * @returns the updated current matrix
  80016. */
  80017. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80018. /**
  80019. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80020. * @param scale defines the scale factor
  80021. * @returns a new matrix
  80022. */
  80023. scale(scale: number): Matrix;
  80024. /**
  80025. * Scale the current matrix values by a factor to a given result matrix
  80026. * @param scale defines the scale factor
  80027. * @param result defines the matrix to store the result
  80028. * @returns the current matrix
  80029. */
  80030. scaleToRef(scale: number, result: Matrix): Matrix;
  80031. /**
  80032. * Scale the current matrix values by a factor and add the result to a given matrix
  80033. * @param scale defines the scale factor
  80034. * @param result defines the Matrix to store the result
  80035. * @returns the current matrix
  80036. */
  80037. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80038. /**
  80039. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80040. * @param ref matrix to store the result
  80041. */
  80042. toNormalMatrix(ref: Matrix): void;
  80043. /**
  80044. * Gets only rotation part of the current matrix
  80045. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80046. */
  80047. getRotationMatrix(): Matrix;
  80048. /**
  80049. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80050. * @param result defines the target matrix to store data to
  80051. * @returns the current matrix
  80052. */
  80053. getRotationMatrixToRef(result: Matrix): Matrix;
  80054. /**
  80055. * Toggles model matrix from being right handed to left handed in place and vice versa
  80056. */
  80057. toggleModelMatrixHandInPlace(): void;
  80058. /**
  80059. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80060. */
  80061. toggleProjectionMatrixHandInPlace(): void;
  80062. /**
  80063. * Creates a matrix from an array
  80064. * @param array defines the source array
  80065. * @param offset defines an offset in the source array
  80066. * @returns a new Matrix set from the starting index of the given array
  80067. */
  80068. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80069. /**
  80070. * Copy the content of an array into a given matrix
  80071. * @param array defines the source array
  80072. * @param offset defines an offset in the source array
  80073. * @param result defines the target matrix
  80074. */
  80075. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80076. /**
  80077. * Stores an array into a matrix after having multiplied each component by a given factor
  80078. * @param array defines the source array
  80079. * @param offset defines the offset in the source array
  80080. * @param scale defines the scaling factor
  80081. * @param result defines the target matrix
  80082. */
  80083. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80084. /**
  80085. * Gets an identity matrix that must not be updated
  80086. */
  80087. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80088. /**
  80089. * Stores a list of values (16) inside a given matrix
  80090. * @param initialM11 defines 1st value of 1st row
  80091. * @param initialM12 defines 2nd value of 1st row
  80092. * @param initialM13 defines 3rd value of 1st row
  80093. * @param initialM14 defines 4th value of 1st row
  80094. * @param initialM21 defines 1st value of 2nd row
  80095. * @param initialM22 defines 2nd value of 2nd row
  80096. * @param initialM23 defines 3rd value of 2nd row
  80097. * @param initialM24 defines 4th value of 2nd row
  80098. * @param initialM31 defines 1st value of 3rd row
  80099. * @param initialM32 defines 2nd value of 3rd row
  80100. * @param initialM33 defines 3rd value of 3rd row
  80101. * @param initialM34 defines 4th value of 3rd row
  80102. * @param initialM41 defines 1st value of 4th row
  80103. * @param initialM42 defines 2nd value of 4th row
  80104. * @param initialM43 defines 3rd value of 4th row
  80105. * @param initialM44 defines 4th value of 4th row
  80106. * @param result defines the target matrix
  80107. */
  80108. 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;
  80109. /**
  80110. * Creates new matrix from a list of values (16)
  80111. * @param initialM11 defines 1st value of 1st row
  80112. * @param initialM12 defines 2nd value of 1st row
  80113. * @param initialM13 defines 3rd value of 1st row
  80114. * @param initialM14 defines 4th value of 1st row
  80115. * @param initialM21 defines 1st value of 2nd row
  80116. * @param initialM22 defines 2nd value of 2nd row
  80117. * @param initialM23 defines 3rd value of 2nd row
  80118. * @param initialM24 defines 4th value of 2nd row
  80119. * @param initialM31 defines 1st value of 3rd row
  80120. * @param initialM32 defines 2nd value of 3rd row
  80121. * @param initialM33 defines 3rd value of 3rd row
  80122. * @param initialM34 defines 4th value of 3rd row
  80123. * @param initialM41 defines 1st value of 4th row
  80124. * @param initialM42 defines 2nd value of 4th row
  80125. * @param initialM43 defines 3rd value of 4th row
  80126. * @param initialM44 defines 4th value of 4th row
  80127. * @returns the new matrix
  80128. */
  80129. 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;
  80130. /**
  80131. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80132. * @param scale defines the scale vector3
  80133. * @param rotation defines the rotation quaternion
  80134. * @param translation defines the translation vector3
  80135. * @returns a new matrix
  80136. */
  80137. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80138. /**
  80139. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80140. * @param scale defines the scale vector3
  80141. * @param rotation defines the rotation quaternion
  80142. * @param translation defines the translation vector3
  80143. * @param result defines the target matrix
  80144. */
  80145. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80146. /**
  80147. * Creates a new identity matrix
  80148. * @returns a new identity matrix
  80149. */
  80150. static Identity(): Matrix;
  80151. /**
  80152. * Creates a new identity matrix and stores the result in a given matrix
  80153. * @param result defines the target matrix
  80154. */
  80155. static IdentityToRef(result: Matrix): void;
  80156. /**
  80157. * Creates a new zero matrix
  80158. * @returns a new zero matrix
  80159. */
  80160. static Zero(): Matrix;
  80161. /**
  80162. * Creates a new rotation matrix for "angle" radians around the X axis
  80163. * @param angle defines the angle (in radians) to use
  80164. * @return the new matrix
  80165. */
  80166. static RotationX(angle: number): Matrix;
  80167. /**
  80168. * Creates a new matrix as the invert of a given matrix
  80169. * @param source defines the source matrix
  80170. * @returns the new matrix
  80171. */
  80172. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80173. /**
  80174. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80175. * @param angle defines the angle (in radians) to use
  80176. * @param result defines the target matrix
  80177. */
  80178. static RotationXToRef(angle: number, result: Matrix): void;
  80179. /**
  80180. * Creates a new rotation matrix for "angle" radians around the Y axis
  80181. * @param angle defines the angle (in radians) to use
  80182. * @return the new matrix
  80183. */
  80184. static RotationY(angle: number): Matrix;
  80185. /**
  80186. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80187. * @param angle defines the angle (in radians) to use
  80188. * @param result defines the target matrix
  80189. */
  80190. static RotationYToRef(angle: number, result: Matrix): void;
  80191. /**
  80192. * Creates a new rotation matrix for "angle" radians around the Z axis
  80193. * @param angle defines the angle (in radians) to use
  80194. * @return the new matrix
  80195. */
  80196. static RotationZ(angle: number): Matrix;
  80197. /**
  80198. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80199. * @param angle defines the angle (in radians) to use
  80200. * @param result defines the target matrix
  80201. */
  80202. static RotationZToRef(angle: number, result: Matrix): void;
  80203. /**
  80204. * Creates a new rotation matrix for "angle" radians around the given axis
  80205. * @param axis defines the axis to use
  80206. * @param angle defines the angle (in radians) to use
  80207. * @return the new matrix
  80208. */
  80209. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80210. /**
  80211. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80212. * @param axis defines the axis to use
  80213. * @param angle defines the angle (in radians) to use
  80214. * @param result defines the target matrix
  80215. */
  80216. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80217. /**
  80218. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80219. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80220. * @param from defines the vector to align
  80221. * @param to defines the vector to align to
  80222. * @param result defines the target matrix
  80223. */
  80224. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80225. /**
  80226. * Creates a rotation matrix
  80227. * @param yaw defines the yaw angle in radians (Y axis)
  80228. * @param pitch defines the pitch angle in radians (X axis)
  80229. * @param roll defines the roll angle in radians (X axis)
  80230. * @returns the new rotation matrix
  80231. */
  80232. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80233. /**
  80234. * Creates a rotation matrix and stores it in a given matrix
  80235. * @param yaw defines the yaw angle in radians (Y axis)
  80236. * @param pitch defines the pitch angle in radians (X axis)
  80237. * @param roll defines the roll angle in radians (X axis)
  80238. * @param result defines the target matrix
  80239. */
  80240. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80241. /**
  80242. * Creates a scaling matrix
  80243. * @param x defines the scale factor on X axis
  80244. * @param y defines the scale factor on Y axis
  80245. * @param z defines the scale factor on Z axis
  80246. * @returns the new matrix
  80247. */
  80248. static Scaling(x: number, y: number, z: number): Matrix;
  80249. /**
  80250. * Creates a scaling matrix and stores it in a given matrix
  80251. * @param x defines the scale factor on X axis
  80252. * @param y defines the scale factor on Y axis
  80253. * @param z defines the scale factor on Z axis
  80254. * @param result defines the target matrix
  80255. */
  80256. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80257. /**
  80258. * Creates a translation matrix
  80259. * @param x defines the translation on X axis
  80260. * @param y defines the translation on Y axis
  80261. * @param z defines the translationon Z axis
  80262. * @returns the new matrix
  80263. */
  80264. static Translation(x: number, y: number, z: number): Matrix;
  80265. /**
  80266. * Creates a translation matrix and stores it in a given matrix
  80267. * @param x defines the translation on X axis
  80268. * @param y defines the translation on Y axis
  80269. * @param z defines the translationon Z axis
  80270. * @param result defines the target matrix
  80271. */
  80272. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80273. /**
  80274. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80275. * @param startValue defines the start value
  80276. * @param endValue defines the end value
  80277. * @param gradient defines the gradient factor
  80278. * @returns the new matrix
  80279. */
  80280. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80281. /**
  80282. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80283. * @param startValue defines the start value
  80284. * @param endValue defines the end value
  80285. * @param gradient defines the gradient factor
  80286. * @param result defines the Matrix object where to store data
  80287. */
  80288. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80289. /**
  80290. * Builds a new matrix whose values are computed by:
  80291. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80292. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80293. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80294. * @param startValue defines the first matrix
  80295. * @param endValue defines the second matrix
  80296. * @param gradient defines the gradient between the two matrices
  80297. * @returns the new matrix
  80298. */
  80299. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80300. /**
  80301. * Update a matrix to values which are computed by:
  80302. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80303. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80304. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80305. * @param startValue defines the first matrix
  80306. * @param endValue defines the second matrix
  80307. * @param gradient defines the gradient between the two matrices
  80308. * @param result defines the target matrix
  80309. */
  80310. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80311. /**
  80312. * 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"
  80313. * This function works in left handed mode
  80314. * @param eye defines the final position of the entity
  80315. * @param target defines where the entity should look at
  80316. * @param up defines the up vector for the entity
  80317. * @returns the new matrix
  80318. */
  80319. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80320. /**
  80321. * 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".
  80322. * This function works in left handed mode
  80323. * @param eye defines the final position of the entity
  80324. * @param target defines where the entity should look at
  80325. * @param up defines the up vector for the entity
  80326. * @param result defines the target matrix
  80327. */
  80328. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80329. /**
  80330. * 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"
  80331. * This function works in right handed mode
  80332. * @param eye defines the final position of the entity
  80333. * @param target defines where the entity should look at
  80334. * @param up defines the up vector for the entity
  80335. * @returns the new matrix
  80336. */
  80337. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80338. /**
  80339. * 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".
  80340. * This function works in right handed mode
  80341. * @param eye defines the final position of the entity
  80342. * @param target defines where the entity should look at
  80343. * @param up defines the up vector for the entity
  80344. * @param result defines the target matrix
  80345. */
  80346. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80347. /**
  80348. * Create a left-handed orthographic projection matrix
  80349. * @param width defines the viewport width
  80350. * @param height defines the viewport height
  80351. * @param znear defines the near clip plane
  80352. * @param zfar defines the far clip plane
  80353. * @returns a new matrix as a left-handed orthographic projection matrix
  80354. */
  80355. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80356. /**
  80357. * Store a left-handed orthographic projection to a given matrix
  80358. * @param width defines the viewport width
  80359. * @param height defines the viewport height
  80360. * @param znear defines the near clip plane
  80361. * @param zfar defines the far clip plane
  80362. * @param result defines the target matrix
  80363. */
  80364. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80365. /**
  80366. * Create a left-handed orthographic projection matrix
  80367. * @param left defines the viewport left coordinate
  80368. * @param right defines the viewport right coordinate
  80369. * @param bottom defines the viewport bottom coordinate
  80370. * @param top defines the viewport top coordinate
  80371. * @param znear defines the near clip plane
  80372. * @param zfar defines the far clip plane
  80373. * @returns a new matrix as a left-handed orthographic projection matrix
  80374. */
  80375. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80376. /**
  80377. * Stores a left-handed orthographic projection into a given matrix
  80378. * @param left defines the viewport left coordinate
  80379. * @param right defines the viewport right coordinate
  80380. * @param bottom defines the viewport bottom coordinate
  80381. * @param top defines the viewport top coordinate
  80382. * @param znear defines the near clip plane
  80383. * @param zfar defines the far clip plane
  80384. * @param result defines the target matrix
  80385. */
  80386. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80387. /**
  80388. * Creates a right-handed orthographic projection matrix
  80389. * @param left defines the viewport left coordinate
  80390. * @param right defines the viewport right coordinate
  80391. * @param bottom defines the viewport bottom coordinate
  80392. * @param top defines the viewport top coordinate
  80393. * @param znear defines the near clip plane
  80394. * @param zfar defines the far clip plane
  80395. * @returns a new matrix as a right-handed orthographic projection matrix
  80396. */
  80397. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80398. /**
  80399. * Stores a right-handed orthographic projection into a given matrix
  80400. * @param left defines the viewport left coordinate
  80401. * @param right defines the viewport right coordinate
  80402. * @param bottom defines the viewport bottom coordinate
  80403. * @param top defines the viewport top coordinate
  80404. * @param znear defines the near clip plane
  80405. * @param zfar defines the far clip plane
  80406. * @param result defines the target matrix
  80407. */
  80408. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80409. /**
  80410. * Creates a left-handed perspective projection matrix
  80411. * @param width defines the viewport width
  80412. * @param height defines the viewport height
  80413. * @param znear defines the near clip plane
  80414. * @param zfar defines the far clip plane
  80415. * @returns a new matrix as a left-handed perspective projection matrix
  80416. */
  80417. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80418. /**
  80419. * Creates a left-handed perspective projection matrix
  80420. * @param fov defines the horizontal field of view
  80421. * @param aspect defines the aspect ratio
  80422. * @param znear defines the near clip plane
  80423. * @param zfar defines the far clip plane
  80424. * @returns a new matrix as a left-handed perspective projection matrix
  80425. */
  80426. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80427. /**
  80428. * Stores a left-handed perspective projection into a given matrix
  80429. * @param fov defines the horizontal field of view
  80430. * @param aspect defines the aspect ratio
  80431. * @param znear defines the near clip plane
  80432. * @param zfar defines the far clip plane
  80433. * @param result defines the target matrix
  80434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80435. */
  80436. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80437. /**
  80438. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80439. * @param fov defines the horizontal field of view
  80440. * @param aspect defines the aspect ratio
  80441. * @param znear defines the near clip plane
  80442. * @param zfar not used as infinity is used as far clip
  80443. * @param result defines the target matrix
  80444. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80445. */
  80446. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80447. /**
  80448. * Creates a right-handed perspective projection matrix
  80449. * @param fov defines the horizontal field of view
  80450. * @param aspect defines the aspect ratio
  80451. * @param znear defines the near clip plane
  80452. * @param zfar defines the far clip plane
  80453. * @returns a new matrix as a right-handed perspective projection matrix
  80454. */
  80455. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80456. /**
  80457. * Stores a right-handed perspective projection into a given matrix
  80458. * @param fov defines the horizontal field of view
  80459. * @param aspect defines the aspect ratio
  80460. * @param znear defines the near clip plane
  80461. * @param zfar defines the far clip plane
  80462. * @param result defines the target matrix
  80463. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80464. */
  80465. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80466. /**
  80467. * Stores a right-handed perspective projection into a given matrix
  80468. * @param fov defines the horizontal field of view
  80469. * @param aspect defines the aspect ratio
  80470. * @param znear defines the near clip plane
  80471. * @param zfar not used as infinity is used as far clip
  80472. * @param result defines the target matrix
  80473. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80474. */
  80475. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80476. /**
  80477. * Stores a perspective projection for WebVR info a given matrix
  80478. * @param fov defines the field of view
  80479. * @param znear defines the near clip plane
  80480. * @param zfar defines the far clip plane
  80481. * @param result defines the target matrix
  80482. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80483. */
  80484. static PerspectiveFovWebVRToRef(fov: {
  80485. upDegrees: number;
  80486. downDegrees: number;
  80487. leftDegrees: number;
  80488. rightDegrees: number;
  80489. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80490. /**
  80491. * Computes a complete transformation matrix
  80492. * @param viewport defines the viewport to use
  80493. * @param world defines the world matrix
  80494. * @param view defines the view matrix
  80495. * @param projection defines the projection matrix
  80496. * @param zmin defines the near clip plane
  80497. * @param zmax defines the far clip plane
  80498. * @returns the transformation matrix
  80499. */
  80500. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80501. /**
  80502. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80503. * @param matrix defines the matrix to use
  80504. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80505. */
  80506. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80507. /**
  80508. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80509. * @param matrix defines the matrix to use
  80510. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80511. */
  80512. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80513. /**
  80514. * Compute the transpose of a given matrix
  80515. * @param matrix defines the matrix to transpose
  80516. * @returns the new matrix
  80517. */
  80518. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80519. /**
  80520. * Compute the transpose of a matrix and store it in a target matrix
  80521. * @param matrix defines the matrix to transpose
  80522. * @param result defines the target matrix
  80523. */
  80524. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80525. /**
  80526. * Computes a reflection matrix from a plane
  80527. * @param plane defines the reflection plane
  80528. * @returns a new matrix
  80529. */
  80530. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80531. /**
  80532. * Computes a reflection matrix from a plane
  80533. * @param plane defines the reflection plane
  80534. * @param result defines the target matrix
  80535. */
  80536. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80537. /**
  80538. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80539. * @param xaxis defines the value of the 1st axis
  80540. * @param yaxis defines the value of the 2nd axis
  80541. * @param zaxis defines the value of the 3rd axis
  80542. * @param result defines the target matrix
  80543. */
  80544. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80545. /**
  80546. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80547. * @param quat defines the quaternion to use
  80548. * @param result defines the target matrix
  80549. */
  80550. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80551. }
  80552. /**
  80553. * @hidden
  80554. */
  80555. export class TmpVectors {
  80556. static Vector2: Vector2[];
  80557. static Vector3: Vector3[];
  80558. static Vector4: Vector4[];
  80559. static Quaternion: Quaternion[];
  80560. static Matrix: Matrix[];
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. /**
  80565. * Defines potential orientation for back face culling
  80566. */
  80567. export enum Orientation {
  80568. /**
  80569. * Clockwise
  80570. */
  80571. CW = 0,
  80572. /** Counter clockwise */
  80573. CCW = 1
  80574. }
  80575. /** Class used to represent a Bezier curve */
  80576. export class BezierCurve {
  80577. /**
  80578. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80579. * @param t defines the time
  80580. * @param x1 defines the left coordinate on X axis
  80581. * @param y1 defines the left coordinate on Y axis
  80582. * @param x2 defines the right coordinate on X axis
  80583. * @param y2 defines the right coordinate on Y axis
  80584. * @returns the interpolated value
  80585. */
  80586. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80587. }
  80588. /**
  80589. * Defines angle representation
  80590. */
  80591. export class Angle {
  80592. private _radians;
  80593. /**
  80594. * Creates an Angle object of "radians" radians (float).
  80595. * @param radians the angle in radians
  80596. */
  80597. constructor(radians: number);
  80598. /**
  80599. * Get value in degrees
  80600. * @returns the Angle value in degrees (float)
  80601. */
  80602. degrees(): number;
  80603. /**
  80604. * Get value in radians
  80605. * @returns the Angle value in radians (float)
  80606. */
  80607. radians(): number;
  80608. /**
  80609. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80610. * @param a defines first vector
  80611. * @param b defines second vector
  80612. * @returns a new Angle
  80613. */
  80614. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80615. /**
  80616. * Gets a new Angle object from the given float in radians
  80617. * @param radians defines the angle value in radians
  80618. * @returns a new Angle
  80619. */
  80620. static FromRadians(radians: number): Angle;
  80621. /**
  80622. * Gets a new Angle object from the given float in degrees
  80623. * @param degrees defines the angle value in degrees
  80624. * @returns a new Angle
  80625. */
  80626. static FromDegrees(degrees: number): Angle;
  80627. }
  80628. /**
  80629. * This represents an arc in a 2d space.
  80630. */
  80631. export class Arc2 {
  80632. /** Defines the start point of the arc */
  80633. startPoint: Vector2;
  80634. /** Defines the mid point of the arc */
  80635. midPoint: Vector2;
  80636. /** Defines the end point of the arc */
  80637. endPoint: Vector2;
  80638. /**
  80639. * Defines the center point of the arc.
  80640. */
  80641. centerPoint: Vector2;
  80642. /**
  80643. * Defines the radius of the arc.
  80644. */
  80645. radius: number;
  80646. /**
  80647. * Defines the angle of the arc (from mid point to end point).
  80648. */
  80649. angle: Angle;
  80650. /**
  80651. * Defines the start angle of the arc (from start point to middle point).
  80652. */
  80653. startAngle: Angle;
  80654. /**
  80655. * Defines the orientation of the arc (clock wise/counter clock wise).
  80656. */
  80657. orientation: Orientation;
  80658. /**
  80659. * Creates an Arc object from the three given points : start, middle and end.
  80660. * @param startPoint Defines the start point of the arc
  80661. * @param midPoint Defines the midlle point of the arc
  80662. * @param endPoint Defines the end point of the arc
  80663. */
  80664. constructor(
  80665. /** Defines the start point of the arc */
  80666. startPoint: Vector2,
  80667. /** Defines the mid point of the arc */
  80668. midPoint: Vector2,
  80669. /** Defines the end point of the arc */
  80670. endPoint: Vector2);
  80671. }
  80672. /**
  80673. * Represents a 2D path made up of multiple 2D points
  80674. */
  80675. export class Path2 {
  80676. private _points;
  80677. private _length;
  80678. /**
  80679. * If the path start and end point are the same
  80680. */
  80681. closed: boolean;
  80682. /**
  80683. * Creates a Path2 object from the starting 2D coordinates x and y.
  80684. * @param x the starting points x value
  80685. * @param y the starting points y value
  80686. */
  80687. constructor(x: number, y: number);
  80688. /**
  80689. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80690. * @param x the added points x value
  80691. * @param y the added points y value
  80692. * @returns the updated Path2.
  80693. */
  80694. addLineTo(x: number, y: number): Path2;
  80695. /**
  80696. * 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.
  80697. * @param midX middle point x value
  80698. * @param midY middle point y value
  80699. * @param endX end point x value
  80700. * @param endY end point y value
  80701. * @param numberOfSegments (default: 36)
  80702. * @returns the updated Path2.
  80703. */
  80704. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80705. /**
  80706. * Closes the Path2.
  80707. * @returns the Path2.
  80708. */
  80709. close(): Path2;
  80710. /**
  80711. * Gets the sum of the distance between each sequential point in the path
  80712. * @returns the Path2 total length (float).
  80713. */
  80714. length(): number;
  80715. /**
  80716. * Gets the points which construct the path
  80717. * @returns the Path2 internal array of points.
  80718. */
  80719. getPoints(): Vector2[];
  80720. /**
  80721. * Retreives the point at the distance aways from the starting point
  80722. * @param normalizedLengthPosition the length along the path to retreive the point from
  80723. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80724. */
  80725. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80726. /**
  80727. * Creates a new path starting from an x and y position
  80728. * @param x starting x value
  80729. * @param y starting y value
  80730. * @returns a new Path2 starting at the coordinates (x, y).
  80731. */
  80732. static StartingAt(x: number, y: number): Path2;
  80733. }
  80734. /**
  80735. * Represents a 3D path made up of multiple 3D points
  80736. */
  80737. export class Path3D {
  80738. /**
  80739. * an array of Vector3, the curve axis of the Path3D
  80740. */
  80741. path: Vector3[];
  80742. private _curve;
  80743. private _distances;
  80744. private _tangents;
  80745. private _normals;
  80746. private _binormals;
  80747. private _raw;
  80748. private _alignTangentsWithPath;
  80749. private readonly _pointAtData;
  80750. /**
  80751. * new Path3D(path, normal, raw)
  80752. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80753. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80754. * @param path an array of Vector3, the curve axis of the Path3D
  80755. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80756. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80757. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80758. */
  80759. constructor(
  80760. /**
  80761. * an array of Vector3, the curve axis of the Path3D
  80762. */
  80763. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80764. /**
  80765. * Returns the Path3D array of successive Vector3 designing its curve.
  80766. * @returns the Path3D array of successive Vector3 designing its curve.
  80767. */
  80768. getCurve(): Vector3[];
  80769. /**
  80770. * Returns the Path3D array of successive Vector3 designing its curve.
  80771. * @returns the Path3D array of successive Vector3 designing its curve.
  80772. */
  80773. getPoints(): Vector3[];
  80774. /**
  80775. * @returns the computed length (float) of the path.
  80776. */
  80777. length(): number;
  80778. /**
  80779. * Returns an array populated with tangent vectors on each Path3D curve point.
  80780. * @returns an array populated with tangent vectors on each Path3D curve point.
  80781. */
  80782. getTangents(): Vector3[];
  80783. /**
  80784. * Returns an array populated with normal vectors on each Path3D curve point.
  80785. * @returns an array populated with normal vectors on each Path3D curve point.
  80786. */
  80787. getNormals(): Vector3[];
  80788. /**
  80789. * Returns an array populated with binormal vectors on each Path3D curve point.
  80790. * @returns an array populated with binormal vectors on each Path3D curve point.
  80791. */
  80792. getBinormals(): Vector3[];
  80793. /**
  80794. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  80795. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  80796. */
  80797. getDistances(): number[];
  80798. /**
  80799. * Returns an interpolated point along this path
  80800. * @param position the position of the point along this path, from 0.0 to 1.0
  80801. * @returns a new Vector3 as the point
  80802. */
  80803. getPointAt(position: number): Vector3;
  80804. /**
  80805. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80806. * @param position the position of the point along this path, from 0.0 to 1.0
  80807. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  80808. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  80809. */
  80810. getTangentAt(position: number, interpolated?: boolean): Vector3;
  80811. /**
  80812. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80813. * @param position the position of the point along this path, from 0.0 to 1.0
  80814. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  80815. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  80816. */
  80817. getNormalAt(position: number, interpolated?: boolean): Vector3;
  80818. /**
  80819. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  80820. * @param position the position of the point along this path, from 0.0 to 1.0
  80821. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  80822. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  80823. */
  80824. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  80825. /**
  80826. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  80827. * @param position the position of the point along this path, from 0.0 to 1.0
  80828. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  80829. */
  80830. getDistanceAt(position: number): number;
  80831. /**
  80832. * Returns the array index of the previous point of an interpolated point along this path
  80833. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80834. * @returns the array index
  80835. */
  80836. getPreviousPointIndexAt(position: number): number;
  80837. /**
  80838. * 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)
  80839. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80840. * @returns the sub position
  80841. */
  80842. getSubPositionAt(position: number): number;
  80843. /**
  80844. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  80845. * @param target the vector of which to get the closest position to
  80846. * @returns the position of the closest virtual point on this path to the target vector
  80847. */
  80848. getClosestPositionTo(target: Vector3): number;
  80849. /**
  80850. * Returns a sub path (slice) of this path
  80851. * @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
  80852. * @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
  80853. * @returns a sub path (slice) of this path
  80854. */
  80855. slice(start?: number, end?: number): Path3D;
  80856. /**
  80857. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  80858. * @param path path which all values are copied into the curves points
  80859. * @param firstNormal which should be projected onto the curve
  80860. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  80861. * @returns the same object updated.
  80862. */
  80863. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  80864. private _compute;
  80865. private _getFirstNonNullVector;
  80866. private _getLastNonNullVector;
  80867. private _normalVector;
  80868. /**
  80869. * Updates the point at data for an interpolated point along this curve
  80870. * @param position the position of the point along this curve, from 0.0 to 1.0
  80871. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  80872. * @returns the (updated) point at data
  80873. */
  80874. private _updatePointAtData;
  80875. /**
  80876. * Updates the point at data from the specified parameters
  80877. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  80878. * @param point the interpolated point
  80879. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  80880. */
  80881. private _setPointAtData;
  80882. /**
  80883. * Updates the point at interpolation matrix for the tangents, normals and binormals
  80884. */
  80885. private _updateInterpolationMatrix;
  80886. }
  80887. /**
  80888. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80889. * A Curve3 is designed from a series of successive Vector3.
  80890. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  80891. */
  80892. export class Curve3 {
  80893. private _points;
  80894. private _length;
  80895. /**
  80896. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  80897. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  80898. * @param v1 (Vector3) the control point
  80899. * @param v2 (Vector3) the end point of the Quadratic Bezier
  80900. * @param nbPoints (integer) the wanted number of points in the curve
  80901. * @returns the created Curve3
  80902. */
  80903. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80904. /**
  80905. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  80906. * @param v0 (Vector3) the origin point of the Cubic Bezier
  80907. * @param v1 (Vector3) the first control point
  80908. * @param v2 (Vector3) the second control point
  80909. * @param v3 (Vector3) the end point of the Cubic Bezier
  80910. * @param nbPoints (integer) the wanted number of points in the curve
  80911. * @returns the created Curve3
  80912. */
  80913. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80914. /**
  80915. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  80916. * @param p1 (Vector3) the origin point of the Hermite Spline
  80917. * @param t1 (Vector3) the tangent vector at the origin point
  80918. * @param p2 (Vector3) the end point of the Hermite Spline
  80919. * @param t2 (Vector3) the tangent vector at the end point
  80920. * @param nbPoints (integer) the wanted number of points in the curve
  80921. * @returns the created Curve3
  80922. */
  80923. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80924. /**
  80925. * Returns a Curve3 object along a CatmullRom Spline curve :
  80926. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  80927. * @param nbPoints (integer) the wanted number of points between each curve control points
  80928. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  80929. * @returns the created Curve3
  80930. */
  80931. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  80932. /**
  80933. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80934. * A Curve3 is designed from a series of successive Vector3.
  80935. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  80936. * @param points points which make up the curve
  80937. */
  80938. constructor(points: Vector3[]);
  80939. /**
  80940. * @returns the Curve3 stored array of successive Vector3
  80941. */
  80942. getPoints(): Vector3[];
  80943. /**
  80944. * @returns the computed length (float) of the curve.
  80945. */
  80946. length(): number;
  80947. /**
  80948. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  80949. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  80950. * curveA and curveB keep unchanged.
  80951. * @param curve the curve to continue from this curve
  80952. * @returns the newly constructed curve
  80953. */
  80954. continue(curve: DeepImmutable<Curve3>): Curve3;
  80955. private _computeLength;
  80956. }
  80957. }
  80958. declare module BABYLON {
  80959. /**
  80960. * This represents the main contract an easing function should follow.
  80961. * Easing functions are used throughout the animation system.
  80962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80963. */
  80964. export interface IEasingFunction {
  80965. /**
  80966. * Given an input gradient between 0 and 1, this returns the corrseponding value
  80967. * of the easing function.
  80968. * The link below provides some of the most common examples of easing functions.
  80969. * @see https://easings.net/
  80970. * @param gradient Defines the value between 0 and 1 we want the easing value for
  80971. * @returns the corresponding value on the curve defined by the easing function
  80972. */
  80973. ease(gradient: number): number;
  80974. }
  80975. /**
  80976. * Base class used for every default easing function.
  80977. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80978. */
  80979. export class EasingFunction implements IEasingFunction {
  80980. /**
  80981. * Interpolation follows the mathematical formula associated with the easing function.
  80982. */
  80983. static readonly EASINGMODE_EASEIN: number;
  80984. /**
  80985. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  80986. */
  80987. static readonly EASINGMODE_EASEOUT: number;
  80988. /**
  80989. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  80990. */
  80991. static readonly EASINGMODE_EASEINOUT: number;
  80992. private _easingMode;
  80993. /**
  80994. * Sets the easing mode of the current function.
  80995. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  80996. */
  80997. setEasingMode(easingMode: number): void;
  80998. /**
  80999. * Gets the current easing mode.
  81000. * @returns the easing mode
  81001. */
  81002. getEasingMode(): number;
  81003. /**
  81004. * @hidden
  81005. */
  81006. easeInCore(gradient: number): number;
  81007. /**
  81008. * Given an input gradient between 0 and 1, this returns the corresponding value
  81009. * of the easing function.
  81010. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81011. * @returns the corresponding value on the curve defined by the easing function
  81012. */
  81013. ease(gradient: number): number;
  81014. }
  81015. /**
  81016. * Easing function with a circle shape (see link below).
  81017. * @see https://easings.net/#easeInCirc
  81018. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81019. */
  81020. export class CircleEase extends EasingFunction implements IEasingFunction {
  81021. /** @hidden */
  81022. easeInCore(gradient: number): number;
  81023. }
  81024. /**
  81025. * Easing function with a ease back shape (see link below).
  81026. * @see https://easings.net/#easeInBack
  81027. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81028. */
  81029. export class BackEase extends EasingFunction implements IEasingFunction {
  81030. /** Defines the amplitude of the function */
  81031. amplitude: number;
  81032. /**
  81033. * Instantiates a back ease easing
  81034. * @see https://easings.net/#easeInBack
  81035. * @param amplitude Defines the amplitude of the function
  81036. */
  81037. constructor(
  81038. /** Defines the amplitude of the function */
  81039. amplitude?: number);
  81040. /** @hidden */
  81041. easeInCore(gradient: number): number;
  81042. }
  81043. /**
  81044. * Easing function with a bouncing shape (see link below).
  81045. * @see https://easings.net/#easeInBounce
  81046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81047. */
  81048. export class BounceEase extends EasingFunction implements IEasingFunction {
  81049. /** Defines the number of bounces */
  81050. bounces: number;
  81051. /** Defines the amplitude of the bounce */
  81052. bounciness: number;
  81053. /**
  81054. * Instantiates a bounce easing
  81055. * @see https://easings.net/#easeInBounce
  81056. * @param bounces Defines the number of bounces
  81057. * @param bounciness Defines the amplitude of the bounce
  81058. */
  81059. constructor(
  81060. /** Defines the number of bounces */
  81061. bounces?: number,
  81062. /** Defines the amplitude of the bounce */
  81063. bounciness?: number);
  81064. /** @hidden */
  81065. easeInCore(gradient: number): number;
  81066. }
  81067. /**
  81068. * Easing function with a power of 3 shape (see link below).
  81069. * @see https://easings.net/#easeInCubic
  81070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81071. */
  81072. export class CubicEase extends EasingFunction implements IEasingFunction {
  81073. /** @hidden */
  81074. easeInCore(gradient: number): number;
  81075. }
  81076. /**
  81077. * Easing function with an elastic shape (see link below).
  81078. * @see https://easings.net/#easeInElastic
  81079. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81080. */
  81081. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81082. /** Defines the number of oscillations*/
  81083. oscillations: number;
  81084. /** Defines the amplitude of the oscillations*/
  81085. springiness: number;
  81086. /**
  81087. * Instantiates an elastic easing function
  81088. * @see https://easings.net/#easeInElastic
  81089. * @param oscillations Defines the number of oscillations
  81090. * @param springiness Defines the amplitude of the oscillations
  81091. */
  81092. constructor(
  81093. /** Defines the number of oscillations*/
  81094. oscillations?: number,
  81095. /** Defines the amplitude of the oscillations*/
  81096. springiness?: number);
  81097. /** @hidden */
  81098. easeInCore(gradient: number): number;
  81099. }
  81100. /**
  81101. * Easing function with an exponential shape (see link below).
  81102. * @see https://easings.net/#easeInExpo
  81103. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81104. */
  81105. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81106. /** Defines the exponent of the function */
  81107. exponent: number;
  81108. /**
  81109. * Instantiates an exponential easing function
  81110. * @see https://easings.net/#easeInExpo
  81111. * @param exponent Defines the exponent of the function
  81112. */
  81113. constructor(
  81114. /** Defines the exponent of the function */
  81115. exponent?: number);
  81116. /** @hidden */
  81117. easeInCore(gradient: number): number;
  81118. }
  81119. /**
  81120. * Easing function with a power shape (see link below).
  81121. * @see https://easings.net/#easeInQuad
  81122. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81123. */
  81124. export class PowerEase extends EasingFunction implements IEasingFunction {
  81125. /** Defines the power of the function */
  81126. power: number;
  81127. /**
  81128. * Instantiates an power base easing function
  81129. * @see https://easings.net/#easeInQuad
  81130. * @param power Defines the power of the function
  81131. */
  81132. constructor(
  81133. /** Defines the power of the function */
  81134. power?: number);
  81135. /** @hidden */
  81136. easeInCore(gradient: number): number;
  81137. }
  81138. /**
  81139. * Easing function with a power of 2 shape (see link below).
  81140. * @see https://easings.net/#easeInQuad
  81141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81142. */
  81143. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81144. /** @hidden */
  81145. easeInCore(gradient: number): number;
  81146. }
  81147. /**
  81148. * Easing function with a power of 4 shape (see link below).
  81149. * @see https://easings.net/#easeInQuart
  81150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81151. */
  81152. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81153. /** @hidden */
  81154. easeInCore(gradient: number): number;
  81155. }
  81156. /**
  81157. * Easing function with a power of 5 shape (see link below).
  81158. * @see https://easings.net/#easeInQuint
  81159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81160. */
  81161. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81162. /** @hidden */
  81163. easeInCore(gradient: number): number;
  81164. }
  81165. /**
  81166. * Easing function with a sin shape (see link below).
  81167. * @see https://easings.net/#easeInSine
  81168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81169. */
  81170. export class SineEase extends EasingFunction implements IEasingFunction {
  81171. /** @hidden */
  81172. easeInCore(gradient: number): number;
  81173. }
  81174. /**
  81175. * Easing function with a bezier shape (see link below).
  81176. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81178. */
  81179. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81180. /** Defines the x component of the start tangent in the bezier curve */
  81181. x1: number;
  81182. /** Defines the y component of the start tangent in the bezier curve */
  81183. y1: number;
  81184. /** Defines the x component of the end tangent in the bezier curve */
  81185. x2: number;
  81186. /** Defines the y component of the end tangent in the bezier curve */
  81187. y2: number;
  81188. /**
  81189. * Instantiates a bezier function
  81190. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81191. * @param x1 Defines the x component of the start tangent in the bezier curve
  81192. * @param y1 Defines the y component of the start tangent in the bezier curve
  81193. * @param x2 Defines the x component of the end tangent in the bezier curve
  81194. * @param y2 Defines the y component of the end tangent in the bezier curve
  81195. */
  81196. constructor(
  81197. /** Defines the x component of the start tangent in the bezier curve */
  81198. x1?: number,
  81199. /** Defines the y component of the start tangent in the bezier curve */
  81200. y1?: number,
  81201. /** Defines the x component of the end tangent in the bezier curve */
  81202. x2?: number,
  81203. /** Defines the y component of the end tangent in the bezier curve */
  81204. y2?: number);
  81205. /** @hidden */
  81206. easeInCore(gradient: number): number;
  81207. }
  81208. }
  81209. declare module BABYLON {
  81210. /**
  81211. * Class used to hold a RBG color
  81212. */
  81213. export class Color3 {
  81214. /**
  81215. * Defines the red component (between 0 and 1, default is 0)
  81216. */
  81217. r: number;
  81218. /**
  81219. * Defines the green component (between 0 and 1, default is 0)
  81220. */
  81221. g: number;
  81222. /**
  81223. * Defines the blue component (between 0 and 1, default is 0)
  81224. */
  81225. b: number;
  81226. /**
  81227. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81228. * @param r defines the red component (between 0 and 1, default is 0)
  81229. * @param g defines the green component (between 0 and 1, default is 0)
  81230. * @param b defines the blue component (between 0 and 1, default is 0)
  81231. */
  81232. constructor(
  81233. /**
  81234. * Defines the red component (between 0 and 1, default is 0)
  81235. */
  81236. r?: number,
  81237. /**
  81238. * Defines the green component (between 0 and 1, default is 0)
  81239. */
  81240. g?: number,
  81241. /**
  81242. * Defines the blue component (between 0 and 1, default is 0)
  81243. */
  81244. b?: number);
  81245. /**
  81246. * Creates a string with the Color3 current values
  81247. * @returns the string representation of the Color3 object
  81248. */
  81249. toString(): string;
  81250. /**
  81251. * Returns the string "Color3"
  81252. * @returns "Color3"
  81253. */
  81254. getClassName(): string;
  81255. /**
  81256. * Compute the Color3 hash code
  81257. * @returns an unique number that can be used to hash Color3 objects
  81258. */
  81259. getHashCode(): number;
  81260. /**
  81261. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81262. * @param array defines the array where to store the r,g,b components
  81263. * @param index defines an optional index in the target array to define where to start storing values
  81264. * @returns the current Color3 object
  81265. */
  81266. toArray(array: FloatArray, index?: number): Color3;
  81267. /**
  81268. * Returns a new Color4 object from the current Color3 and the given alpha
  81269. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81270. * @returns a new Color4 object
  81271. */
  81272. toColor4(alpha?: number): Color4;
  81273. /**
  81274. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81275. * @returns the new array
  81276. */
  81277. asArray(): number[];
  81278. /**
  81279. * Returns the luminance value
  81280. * @returns a float value
  81281. */
  81282. toLuminance(): number;
  81283. /**
  81284. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81285. * @param otherColor defines the second operand
  81286. * @returns the new Color3 object
  81287. */
  81288. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81289. /**
  81290. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81291. * @param otherColor defines the second operand
  81292. * @param result defines the Color3 object where to store the result
  81293. * @returns the current Color3
  81294. */
  81295. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81296. /**
  81297. * Determines equality between Color3 objects
  81298. * @param otherColor defines the second operand
  81299. * @returns true if the rgb values are equal to the given ones
  81300. */
  81301. equals(otherColor: DeepImmutable<Color3>): boolean;
  81302. /**
  81303. * Determines equality between the current Color3 object and a set of r,b,g values
  81304. * @param r defines the red component to check
  81305. * @param g defines the green component to check
  81306. * @param b defines the blue component to check
  81307. * @returns true if the rgb values are equal to the given ones
  81308. */
  81309. equalsFloats(r: number, g: number, b: number): boolean;
  81310. /**
  81311. * Multiplies in place each rgb value by scale
  81312. * @param scale defines the scaling factor
  81313. * @returns the updated Color3
  81314. */
  81315. scale(scale: number): Color3;
  81316. /**
  81317. * Multiplies the rgb values by scale and stores the result into "result"
  81318. * @param scale defines the scaling factor
  81319. * @param result defines the Color3 object where to store the result
  81320. * @returns the unmodified current Color3
  81321. */
  81322. scaleToRef(scale: number, result: Color3): Color3;
  81323. /**
  81324. * Scale the current Color3 values by a factor and add the result to a given Color3
  81325. * @param scale defines the scale factor
  81326. * @param result defines color to store the result into
  81327. * @returns the unmodified current Color3
  81328. */
  81329. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81330. /**
  81331. * Clamps the rgb values by the min and max values and stores the result into "result"
  81332. * @param min defines minimum clamping value (default is 0)
  81333. * @param max defines maximum clamping value (default is 1)
  81334. * @param result defines color to store the result into
  81335. * @returns the original Color3
  81336. */
  81337. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81338. /**
  81339. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81340. * @param otherColor defines the second operand
  81341. * @returns the new Color3
  81342. */
  81343. add(otherColor: DeepImmutable<Color3>): Color3;
  81344. /**
  81345. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81346. * @param otherColor defines the second operand
  81347. * @param result defines Color3 object to store the result into
  81348. * @returns the unmodified current Color3
  81349. */
  81350. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81351. /**
  81352. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81353. * @param otherColor defines the second operand
  81354. * @returns the new Color3
  81355. */
  81356. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81357. /**
  81358. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81359. * @param otherColor defines the second operand
  81360. * @param result defines Color3 object to store the result into
  81361. * @returns the unmodified current Color3
  81362. */
  81363. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81364. /**
  81365. * Copy the current object
  81366. * @returns a new Color3 copied the current one
  81367. */
  81368. clone(): Color3;
  81369. /**
  81370. * Copies the rgb values from the source in the current Color3
  81371. * @param source defines the source Color3 object
  81372. * @returns the updated Color3 object
  81373. */
  81374. copyFrom(source: DeepImmutable<Color3>): Color3;
  81375. /**
  81376. * Updates the Color3 rgb values from the given floats
  81377. * @param r defines the red component to read from
  81378. * @param g defines the green component to read from
  81379. * @param b defines the blue component to read from
  81380. * @returns the current Color3 object
  81381. */
  81382. copyFromFloats(r: number, g: number, b: number): Color3;
  81383. /**
  81384. * Updates the Color3 rgb values from the given floats
  81385. * @param r defines the red component to read from
  81386. * @param g defines the green component to read from
  81387. * @param b defines the blue component to read from
  81388. * @returns the current Color3 object
  81389. */
  81390. set(r: number, g: number, b: number): Color3;
  81391. /**
  81392. * Compute the Color3 hexadecimal code as a string
  81393. * @returns a string containing the hexadecimal representation of the Color3 object
  81394. */
  81395. toHexString(): string;
  81396. /**
  81397. * Computes a new Color3 converted from the current one to linear space
  81398. * @returns a new Color3 object
  81399. */
  81400. toLinearSpace(): Color3;
  81401. /**
  81402. * Converts current color in rgb space to HSV values
  81403. * @returns a new color3 representing the HSV values
  81404. */
  81405. toHSV(): Color3;
  81406. /**
  81407. * Converts current color in rgb space to HSV values
  81408. * @param result defines the Color3 where to store the HSV values
  81409. */
  81410. toHSVToRef(result: Color3): void;
  81411. /**
  81412. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81413. * @param convertedColor defines the Color3 object where to store the linear space version
  81414. * @returns the unmodified Color3
  81415. */
  81416. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81417. /**
  81418. * Computes a new Color3 converted from the current one to gamma space
  81419. * @returns a new Color3 object
  81420. */
  81421. toGammaSpace(): Color3;
  81422. /**
  81423. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81424. * @param convertedColor defines the Color3 object where to store the gamma space version
  81425. * @returns the unmodified Color3
  81426. */
  81427. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81428. private static _BlackReadOnly;
  81429. /**
  81430. * Convert Hue, saturation and value to a Color3 (RGB)
  81431. * @param hue defines the hue
  81432. * @param saturation defines the saturation
  81433. * @param value defines the value
  81434. * @param result defines the Color3 where to store the RGB values
  81435. */
  81436. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81437. /**
  81438. * Creates a new Color3 from the string containing valid hexadecimal values
  81439. * @param hex defines a string containing valid hexadecimal values
  81440. * @returns a new Color3 object
  81441. */
  81442. static FromHexString(hex: string): Color3;
  81443. /**
  81444. * Creates a new Color3 from the starting index of the given array
  81445. * @param array defines the source array
  81446. * @param offset defines an offset in the source array
  81447. * @returns a new Color3 object
  81448. */
  81449. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81450. /**
  81451. * Creates a new Color3 from integer values (< 256)
  81452. * @param r defines the red component to read from (value between 0 and 255)
  81453. * @param g defines the green component to read from (value between 0 and 255)
  81454. * @param b defines the blue component to read from (value between 0 and 255)
  81455. * @returns a new Color3 object
  81456. */
  81457. static FromInts(r: number, g: number, b: number): Color3;
  81458. /**
  81459. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81460. * @param start defines the start Color3 value
  81461. * @param end defines the end Color3 value
  81462. * @param amount defines the gradient value between start and end
  81463. * @returns a new Color3 object
  81464. */
  81465. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81466. /**
  81467. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81468. * @param left defines the start value
  81469. * @param right defines the end value
  81470. * @param amount defines the gradient factor
  81471. * @param result defines the Color3 object where to store the result
  81472. */
  81473. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81474. /**
  81475. * Returns a Color3 value containing a red color
  81476. * @returns a new Color3 object
  81477. */
  81478. static Red(): Color3;
  81479. /**
  81480. * Returns a Color3 value containing a green color
  81481. * @returns a new Color3 object
  81482. */
  81483. static Green(): Color3;
  81484. /**
  81485. * Returns a Color3 value containing a blue color
  81486. * @returns a new Color3 object
  81487. */
  81488. static Blue(): Color3;
  81489. /**
  81490. * Returns a Color3 value containing a black color
  81491. * @returns a new Color3 object
  81492. */
  81493. static Black(): Color3;
  81494. /**
  81495. * Gets a Color3 value containing a black color that must not be updated
  81496. */
  81497. static get BlackReadOnly(): DeepImmutable<Color3>;
  81498. /**
  81499. * Returns a Color3 value containing a white color
  81500. * @returns a new Color3 object
  81501. */
  81502. static White(): Color3;
  81503. /**
  81504. * Returns a Color3 value containing a purple color
  81505. * @returns a new Color3 object
  81506. */
  81507. static Purple(): Color3;
  81508. /**
  81509. * Returns a Color3 value containing a magenta color
  81510. * @returns a new Color3 object
  81511. */
  81512. static Magenta(): Color3;
  81513. /**
  81514. * Returns a Color3 value containing a yellow color
  81515. * @returns a new Color3 object
  81516. */
  81517. static Yellow(): Color3;
  81518. /**
  81519. * Returns a Color3 value containing a gray color
  81520. * @returns a new Color3 object
  81521. */
  81522. static Gray(): Color3;
  81523. /**
  81524. * Returns a Color3 value containing a teal color
  81525. * @returns a new Color3 object
  81526. */
  81527. static Teal(): Color3;
  81528. /**
  81529. * Returns a Color3 value containing a random color
  81530. * @returns a new Color3 object
  81531. */
  81532. static Random(): Color3;
  81533. }
  81534. /**
  81535. * Class used to hold a RBGA color
  81536. */
  81537. export class Color4 {
  81538. /**
  81539. * Defines the red component (between 0 and 1, default is 0)
  81540. */
  81541. r: number;
  81542. /**
  81543. * Defines the green component (between 0 and 1, default is 0)
  81544. */
  81545. g: number;
  81546. /**
  81547. * Defines the blue component (between 0 and 1, default is 0)
  81548. */
  81549. b: number;
  81550. /**
  81551. * Defines the alpha component (between 0 and 1, default is 1)
  81552. */
  81553. a: number;
  81554. /**
  81555. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81556. * @param r defines the red component (between 0 and 1, default is 0)
  81557. * @param g defines the green component (between 0 and 1, default is 0)
  81558. * @param b defines the blue component (between 0 and 1, default is 0)
  81559. * @param a defines the alpha component (between 0 and 1, default is 1)
  81560. */
  81561. constructor(
  81562. /**
  81563. * Defines the red component (between 0 and 1, default is 0)
  81564. */
  81565. r?: number,
  81566. /**
  81567. * Defines the green component (between 0 and 1, default is 0)
  81568. */
  81569. g?: number,
  81570. /**
  81571. * Defines the blue component (between 0 and 1, default is 0)
  81572. */
  81573. b?: number,
  81574. /**
  81575. * Defines the alpha component (between 0 and 1, default is 1)
  81576. */
  81577. a?: number);
  81578. /**
  81579. * Adds in place the given Color4 values to the current Color4 object
  81580. * @param right defines the second operand
  81581. * @returns the current updated Color4 object
  81582. */
  81583. addInPlace(right: DeepImmutable<Color4>): Color4;
  81584. /**
  81585. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81586. * @returns the new array
  81587. */
  81588. asArray(): number[];
  81589. /**
  81590. * Stores from the starting index in the given array the Color4 successive values
  81591. * @param array defines the array where to store the r,g,b components
  81592. * @param index defines an optional index in the target array to define where to start storing values
  81593. * @returns the current Color4 object
  81594. */
  81595. toArray(array: number[], index?: number): Color4;
  81596. /**
  81597. * Determines equality between Color4 objects
  81598. * @param otherColor defines the second operand
  81599. * @returns true if the rgba values are equal to the given ones
  81600. */
  81601. equals(otherColor: DeepImmutable<Color4>): boolean;
  81602. /**
  81603. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81604. * @param right defines the second operand
  81605. * @returns a new Color4 object
  81606. */
  81607. add(right: DeepImmutable<Color4>): Color4;
  81608. /**
  81609. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81610. * @param right defines the second operand
  81611. * @returns a new Color4 object
  81612. */
  81613. subtract(right: DeepImmutable<Color4>): Color4;
  81614. /**
  81615. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81616. * @param right defines the second operand
  81617. * @param result defines the Color4 object where to store the result
  81618. * @returns the current Color4 object
  81619. */
  81620. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81621. /**
  81622. * Creates a new Color4 with the current Color4 values multiplied by scale
  81623. * @param scale defines the scaling factor to apply
  81624. * @returns a new Color4 object
  81625. */
  81626. scale(scale: number): Color4;
  81627. /**
  81628. * Multiplies the current Color4 values by scale and stores the result in "result"
  81629. * @param scale defines the scaling factor to apply
  81630. * @param result defines the Color4 object where to store the result
  81631. * @returns the current unmodified Color4
  81632. */
  81633. scaleToRef(scale: number, result: Color4): Color4;
  81634. /**
  81635. * Scale the current Color4 values by a factor and add the result to a given Color4
  81636. * @param scale defines the scale factor
  81637. * @param result defines the Color4 object where to store the result
  81638. * @returns the unmodified current Color4
  81639. */
  81640. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81641. /**
  81642. * Clamps the rgb values by the min and max values and stores the result into "result"
  81643. * @param min defines minimum clamping value (default is 0)
  81644. * @param max defines maximum clamping value (default is 1)
  81645. * @param result defines color to store the result into.
  81646. * @returns the cuurent Color4
  81647. */
  81648. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81649. /**
  81650. * Multipy an Color4 value by another and return a new Color4 object
  81651. * @param color defines the Color4 value to multiply by
  81652. * @returns a new Color4 object
  81653. */
  81654. multiply(color: Color4): Color4;
  81655. /**
  81656. * Multipy a Color4 value by another and push the result in a reference value
  81657. * @param color defines the Color4 value to multiply by
  81658. * @param result defines the Color4 to fill the result in
  81659. * @returns the result Color4
  81660. */
  81661. multiplyToRef(color: Color4, result: Color4): Color4;
  81662. /**
  81663. * Creates a string with the Color4 current values
  81664. * @returns the string representation of the Color4 object
  81665. */
  81666. toString(): string;
  81667. /**
  81668. * Returns the string "Color4"
  81669. * @returns "Color4"
  81670. */
  81671. getClassName(): string;
  81672. /**
  81673. * Compute the Color4 hash code
  81674. * @returns an unique number that can be used to hash Color4 objects
  81675. */
  81676. getHashCode(): number;
  81677. /**
  81678. * Creates a new Color4 copied from the current one
  81679. * @returns a new Color4 object
  81680. */
  81681. clone(): Color4;
  81682. /**
  81683. * Copies the given Color4 values into the current one
  81684. * @param source defines the source Color4 object
  81685. * @returns the current updated Color4 object
  81686. */
  81687. copyFrom(source: Color4): Color4;
  81688. /**
  81689. * Copies the given float values into the current one
  81690. * @param r defines the red component to read from
  81691. * @param g defines the green component to read from
  81692. * @param b defines the blue component to read from
  81693. * @param a defines the alpha component to read from
  81694. * @returns the current updated Color4 object
  81695. */
  81696. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81697. /**
  81698. * Copies the given float values into the current one
  81699. * @param r defines the red component to read from
  81700. * @param g defines the green component to read from
  81701. * @param b defines the blue component to read from
  81702. * @param a defines the alpha component to read from
  81703. * @returns the current updated Color4 object
  81704. */
  81705. set(r: number, g: number, b: number, a: number): Color4;
  81706. /**
  81707. * Compute the Color4 hexadecimal code as a string
  81708. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81709. * @returns a string containing the hexadecimal representation of the Color4 object
  81710. */
  81711. toHexString(returnAsColor3?: boolean): string;
  81712. /**
  81713. * Computes a new Color4 converted from the current one to linear space
  81714. * @returns a new Color4 object
  81715. */
  81716. toLinearSpace(): Color4;
  81717. /**
  81718. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81719. * @param convertedColor defines the Color4 object where to store the linear space version
  81720. * @returns the unmodified Color4
  81721. */
  81722. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81723. /**
  81724. * Computes a new Color4 converted from the current one to gamma space
  81725. * @returns a new Color4 object
  81726. */
  81727. toGammaSpace(): Color4;
  81728. /**
  81729. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81730. * @param convertedColor defines the Color4 object where to store the gamma space version
  81731. * @returns the unmodified Color4
  81732. */
  81733. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81734. /**
  81735. * Creates a new Color4 from the string containing valid hexadecimal values
  81736. * @param hex defines a string containing valid hexadecimal values
  81737. * @returns a new Color4 object
  81738. */
  81739. static FromHexString(hex: string): Color4;
  81740. /**
  81741. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81742. * @param left defines the start value
  81743. * @param right defines the end value
  81744. * @param amount defines the gradient factor
  81745. * @returns a new Color4 object
  81746. */
  81747. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81748. /**
  81749. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81750. * @param left defines the start value
  81751. * @param right defines the end value
  81752. * @param amount defines the gradient factor
  81753. * @param result defines the Color4 object where to store data
  81754. */
  81755. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81756. /**
  81757. * Creates a new Color4 from a Color3 and an alpha value
  81758. * @param color3 defines the source Color3 to read from
  81759. * @param alpha defines the alpha component (1.0 by default)
  81760. * @returns a new Color4 object
  81761. */
  81762. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81763. /**
  81764. * Creates a new Color4 from the starting index element of the given array
  81765. * @param array defines the source array to read from
  81766. * @param offset defines the offset in the source array
  81767. * @returns a new Color4 object
  81768. */
  81769. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81770. /**
  81771. * Creates a new Color3 from integer values (< 256)
  81772. * @param r defines the red component to read from (value between 0 and 255)
  81773. * @param g defines the green component to read from (value between 0 and 255)
  81774. * @param b defines the blue component to read from (value between 0 and 255)
  81775. * @param a defines the alpha component to read from (value between 0 and 255)
  81776. * @returns a new Color3 object
  81777. */
  81778. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81779. /**
  81780. * Check the content of a given array and convert it to an array containing RGBA data
  81781. * If the original array was already containing count * 4 values then it is returned directly
  81782. * @param colors defines the array to check
  81783. * @param count defines the number of RGBA data to expect
  81784. * @returns an array containing count * 4 values (RGBA)
  81785. */
  81786. static CheckColors4(colors: number[], count: number): number[];
  81787. }
  81788. /**
  81789. * @hidden
  81790. */
  81791. export class TmpColors {
  81792. static Color3: Color3[];
  81793. static Color4: Color4[];
  81794. }
  81795. }
  81796. declare module BABYLON {
  81797. /**
  81798. * Defines an interface which represents an animation key frame
  81799. */
  81800. export interface IAnimationKey {
  81801. /**
  81802. * Frame of the key frame
  81803. */
  81804. frame: number;
  81805. /**
  81806. * Value at the specifies key frame
  81807. */
  81808. value: any;
  81809. /**
  81810. * The input tangent for the cubic hermite spline
  81811. */
  81812. inTangent?: any;
  81813. /**
  81814. * The output tangent for the cubic hermite spline
  81815. */
  81816. outTangent?: any;
  81817. /**
  81818. * The animation interpolation type
  81819. */
  81820. interpolation?: AnimationKeyInterpolation;
  81821. }
  81822. /**
  81823. * Enum for the animation key frame interpolation type
  81824. */
  81825. export enum AnimationKeyInterpolation {
  81826. /**
  81827. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  81828. */
  81829. STEP = 1
  81830. }
  81831. }
  81832. declare module BABYLON {
  81833. /**
  81834. * Represents the range of an animation
  81835. */
  81836. export class AnimationRange {
  81837. /**The name of the animation range**/
  81838. name: string;
  81839. /**The starting frame of the animation */
  81840. from: number;
  81841. /**The ending frame of the animation*/
  81842. to: number;
  81843. /**
  81844. * Initializes the range of an animation
  81845. * @param name The name of the animation range
  81846. * @param from The starting frame of the animation
  81847. * @param to The ending frame of the animation
  81848. */
  81849. constructor(
  81850. /**The name of the animation range**/
  81851. name: string,
  81852. /**The starting frame of the animation */
  81853. from: number,
  81854. /**The ending frame of the animation*/
  81855. to: number);
  81856. /**
  81857. * Makes a copy of the animation range
  81858. * @returns A copy of the animation range
  81859. */
  81860. clone(): AnimationRange;
  81861. }
  81862. }
  81863. declare module BABYLON {
  81864. /**
  81865. * Composed of a frame, and an action function
  81866. */
  81867. export class AnimationEvent {
  81868. /** The frame for which the event is triggered **/
  81869. frame: number;
  81870. /** The event to perform when triggered **/
  81871. action: (currentFrame: number) => void;
  81872. /** Specifies if the event should be triggered only once**/
  81873. onlyOnce?: boolean | undefined;
  81874. /**
  81875. * Specifies if the animation event is done
  81876. */
  81877. isDone: boolean;
  81878. /**
  81879. * Initializes the animation event
  81880. * @param frame The frame for which the event is triggered
  81881. * @param action The event to perform when triggered
  81882. * @param onlyOnce Specifies if the event should be triggered only once
  81883. */
  81884. constructor(
  81885. /** The frame for which the event is triggered **/
  81886. frame: number,
  81887. /** The event to perform when triggered **/
  81888. action: (currentFrame: number) => void,
  81889. /** Specifies if the event should be triggered only once**/
  81890. onlyOnce?: boolean | undefined);
  81891. /** @hidden */
  81892. _clone(): AnimationEvent;
  81893. }
  81894. }
  81895. declare module BABYLON {
  81896. /**
  81897. * Interface used to define a behavior
  81898. */
  81899. export interface Behavior<T> {
  81900. /** gets or sets behavior's name */
  81901. name: string;
  81902. /**
  81903. * Function called when the behavior needs to be initialized (after attaching it to a target)
  81904. */
  81905. init(): void;
  81906. /**
  81907. * Called when the behavior is attached to a target
  81908. * @param target defines the target where the behavior is attached to
  81909. */
  81910. attach(target: T): void;
  81911. /**
  81912. * Called when the behavior is detached from its target
  81913. */
  81914. detach(): void;
  81915. }
  81916. /**
  81917. * Interface implemented by classes supporting behaviors
  81918. */
  81919. export interface IBehaviorAware<T> {
  81920. /**
  81921. * Attach a behavior
  81922. * @param behavior defines the behavior to attach
  81923. * @returns the current host
  81924. */
  81925. addBehavior(behavior: Behavior<T>): T;
  81926. /**
  81927. * Remove a behavior from the current object
  81928. * @param behavior defines the behavior to detach
  81929. * @returns the current host
  81930. */
  81931. removeBehavior(behavior: Behavior<T>): T;
  81932. /**
  81933. * Gets a behavior using its name to search
  81934. * @param name defines the name to search
  81935. * @returns the behavior or null if not found
  81936. */
  81937. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  81938. }
  81939. }
  81940. declare module BABYLON {
  81941. /**
  81942. * Defines an array and its length.
  81943. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  81944. */
  81945. export interface ISmartArrayLike<T> {
  81946. /**
  81947. * The data of the array.
  81948. */
  81949. data: Array<T>;
  81950. /**
  81951. * The active length of the array.
  81952. */
  81953. length: number;
  81954. }
  81955. /**
  81956. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  81957. */
  81958. export class SmartArray<T> implements ISmartArrayLike<T> {
  81959. /**
  81960. * The full set of data from the array.
  81961. */
  81962. data: Array<T>;
  81963. /**
  81964. * The active length of the array.
  81965. */
  81966. length: number;
  81967. protected _id: number;
  81968. /**
  81969. * Instantiates a Smart Array.
  81970. * @param capacity defines the default capacity of the array.
  81971. */
  81972. constructor(capacity: number);
  81973. /**
  81974. * Pushes a value at the end of the active data.
  81975. * @param value defines the object to push in the array.
  81976. */
  81977. push(value: T): void;
  81978. /**
  81979. * Iterates over the active data and apply the lambda to them.
  81980. * @param func defines the action to apply on each value.
  81981. */
  81982. forEach(func: (content: T) => void): void;
  81983. /**
  81984. * Sorts the full sets of data.
  81985. * @param compareFn defines the comparison function to apply.
  81986. */
  81987. sort(compareFn: (a: T, b: T) => number): void;
  81988. /**
  81989. * Resets the active data to an empty array.
  81990. */
  81991. reset(): void;
  81992. /**
  81993. * Releases all the data from the array as well as the array.
  81994. */
  81995. dispose(): void;
  81996. /**
  81997. * Concats the active data with a given array.
  81998. * @param array defines the data to concatenate with.
  81999. */
  82000. concat(array: any): void;
  82001. /**
  82002. * Returns the position of a value in the active data.
  82003. * @param value defines the value to find the index for
  82004. * @returns the index if found in the active data otherwise -1
  82005. */
  82006. indexOf(value: T): number;
  82007. /**
  82008. * Returns whether an element is part of the active data.
  82009. * @param value defines the value to look for
  82010. * @returns true if found in the active data otherwise false
  82011. */
  82012. contains(value: T): boolean;
  82013. private static _GlobalId;
  82014. }
  82015. /**
  82016. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82017. * The data in this array can only be present once
  82018. */
  82019. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82020. private _duplicateId;
  82021. /**
  82022. * Pushes a value at the end of the active data.
  82023. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82024. * @param value defines the object to push in the array.
  82025. */
  82026. push(value: T): void;
  82027. /**
  82028. * Pushes a value at the end of the active data.
  82029. * If the data is already present, it won t be added again
  82030. * @param value defines the object to push in the array.
  82031. * @returns true if added false if it was already present
  82032. */
  82033. pushNoDuplicate(value: T): boolean;
  82034. /**
  82035. * Resets the active data to an empty array.
  82036. */
  82037. reset(): void;
  82038. /**
  82039. * Concats the active data with a given array.
  82040. * This ensures no dupplicate will be present in the result.
  82041. * @param array defines the data to concatenate with.
  82042. */
  82043. concatWithNoDuplicate(array: any): void;
  82044. }
  82045. }
  82046. declare module BABYLON {
  82047. /**
  82048. * @ignore
  82049. * This is a list of all the different input types that are available in the application.
  82050. * Fo instance: ArcRotateCameraGamepadInput...
  82051. */
  82052. export var CameraInputTypes: {};
  82053. /**
  82054. * This is the contract to implement in order to create a new input class.
  82055. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82056. */
  82057. export interface ICameraInput<TCamera extends Camera> {
  82058. /**
  82059. * Defines the camera the input is attached to.
  82060. */
  82061. camera: Nullable<TCamera>;
  82062. /**
  82063. * Gets the class name of the current intput.
  82064. * @returns the class name
  82065. */
  82066. getClassName(): string;
  82067. /**
  82068. * Get the friendly name associated with the input class.
  82069. * @returns the input friendly name
  82070. */
  82071. getSimpleName(): string;
  82072. /**
  82073. * Attach the input controls to a specific dom element to get the input from.
  82074. * @param element Defines the element the controls should be listened from
  82075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82076. */
  82077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82078. /**
  82079. * Detach the current controls from the specified dom element.
  82080. * @param element Defines the element to stop listening the inputs from
  82081. */
  82082. detachControl(element: Nullable<HTMLElement>): void;
  82083. /**
  82084. * Update the current camera state depending on the inputs that have been used this frame.
  82085. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82086. */
  82087. checkInputs?: () => void;
  82088. }
  82089. /**
  82090. * Represents a map of input types to input instance or input index to input instance.
  82091. */
  82092. export interface CameraInputsMap<TCamera extends Camera> {
  82093. /**
  82094. * Accessor to the input by input type.
  82095. */
  82096. [name: string]: ICameraInput<TCamera>;
  82097. /**
  82098. * Accessor to the input by input index.
  82099. */
  82100. [idx: number]: ICameraInput<TCamera>;
  82101. }
  82102. /**
  82103. * This represents the input manager used within a camera.
  82104. * It helps dealing with all the different kind of input attached to a camera.
  82105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82106. */
  82107. export class CameraInputsManager<TCamera extends Camera> {
  82108. /**
  82109. * Defines the list of inputs attahed to the camera.
  82110. */
  82111. attached: CameraInputsMap<TCamera>;
  82112. /**
  82113. * Defines the dom element the camera is collecting inputs from.
  82114. * This is null if the controls have not been attached.
  82115. */
  82116. attachedElement: Nullable<HTMLElement>;
  82117. /**
  82118. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82119. */
  82120. noPreventDefault: boolean;
  82121. /**
  82122. * Defined the camera the input manager belongs to.
  82123. */
  82124. camera: TCamera;
  82125. /**
  82126. * Update the current camera state depending on the inputs that have been used this frame.
  82127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82128. */
  82129. checkInputs: () => void;
  82130. /**
  82131. * Instantiate a new Camera Input Manager.
  82132. * @param camera Defines the camera the input manager blongs to
  82133. */
  82134. constructor(camera: TCamera);
  82135. /**
  82136. * Add an input method to a camera
  82137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82138. * @param input camera input method
  82139. */
  82140. add(input: ICameraInput<TCamera>): void;
  82141. /**
  82142. * Remove a specific input method from a camera
  82143. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82144. * @param inputToRemove camera input method
  82145. */
  82146. remove(inputToRemove: ICameraInput<TCamera>): void;
  82147. /**
  82148. * Remove a specific input type from a camera
  82149. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82150. * @param inputType the type of the input to remove
  82151. */
  82152. removeByType(inputType: string): void;
  82153. private _addCheckInputs;
  82154. /**
  82155. * Attach the input controls to the currently attached dom element to listen the events from.
  82156. * @param input Defines the input to attach
  82157. */
  82158. attachInput(input: ICameraInput<TCamera>): void;
  82159. /**
  82160. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82161. * @param element Defines the dom element to collect the events from
  82162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82163. */
  82164. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82165. /**
  82166. * Detach the current manager inputs controls from a specific dom element.
  82167. * @param element Defines the dom element to collect the events from
  82168. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82169. */
  82170. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82171. /**
  82172. * Rebuild the dynamic inputCheck function from the current list of
  82173. * defined inputs in the manager.
  82174. */
  82175. rebuildInputCheck(): void;
  82176. /**
  82177. * Remove all attached input methods from a camera
  82178. */
  82179. clear(): void;
  82180. /**
  82181. * Serialize the current input manager attached to a camera.
  82182. * This ensures than once parsed,
  82183. * the input associated to the camera will be identical to the current ones
  82184. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82185. */
  82186. serialize(serializedCamera: any): void;
  82187. /**
  82188. * Parses an input manager serialized JSON to restore the previous list of inputs
  82189. * and states associated to a camera.
  82190. * @param parsedCamera Defines the JSON to parse
  82191. */
  82192. parse(parsedCamera: any): void;
  82193. }
  82194. }
  82195. declare module BABYLON {
  82196. /**
  82197. * Class used to store data that will be store in GPU memory
  82198. */
  82199. export class Buffer {
  82200. private _engine;
  82201. private _buffer;
  82202. /** @hidden */
  82203. _data: Nullable<DataArray>;
  82204. private _updatable;
  82205. private _instanced;
  82206. private _divisor;
  82207. /**
  82208. * Gets the byte stride.
  82209. */
  82210. readonly byteStride: number;
  82211. /**
  82212. * Constructor
  82213. * @param engine the engine
  82214. * @param data the data to use for this buffer
  82215. * @param updatable whether the data is updatable
  82216. * @param stride the stride (optional)
  82217. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82218. * @param instanced whether the buffer is instanced (optional)
  82219. * @param useBytes set to true if the stride in in bytes (optional)
  82220. * @param divisor sets an optional divisor for instances (1 by default)
  82221. */
  82222. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82223. /**
  82224. * Create a new VertexBuffer based on the current buffer
  82225. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82226. * @param offset defines offset in the buffer (0 by default)
  82227. * @param size defines the size in floats of attributes (position is 3 for instance)
  82228. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82229. * @param instanced defines if the vertex buffer contains indexed data
  82230. * @param useBytes defines if the offset and stride are in bytes *
  82231. * @param divisor sets an optional divisor for instances (1 by default)
  82232. * @returns the new vertex buffer
  82233. */
  82234. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82235. /**
  82236. * Gets a boolean indicating if the Buffer is updatable?
  82237. * @returns true if the buffer is updatable
  82238. */
  82239. isUpdatable(): boolean;
  82240. /**
  82241. * Gets current buffer's data
  82242. * @returns a DataArray or null
  82243. */
  82244. getData(): Nullable<DataArray>;
  82245. /**
  82246. * Gets underlying native buffer
  82247. * @returns underlying native buffer
  82248. */
  82249. getBuffer(): Nullable<DataBuffer>;
  82250. /**
  82251. * Gets the stride in float32 units (i.e. byte stride / 4).
  82252. * May not be an integer if the byte stride is not divisible by 4.
  82253. * @returns the stride in float32 units
  82254. * @deprecated Please use byteStride instead.
  82255. */
  82256. getStrideSize(): number;
  82257. /**
  82258. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82259. * @param data defines the data to store
  82260. */
  82261. create(data?: Nullable<DataArray>): void;
  82262. /** @hidden */
  82263. _rebuild(): void;
  82264. /**
  82265. * Update current buffer data
  82266. * @param data defines the data to store
  82267. */
  82268. update(data: DataArray): void;
  82269. /**
  82270. * Updates the data directly.
  82271. * @param data the new data
  82272. * @param offset the new offset
  82273. * @param vertexCount the vertex count (optional)
  82274. * @param useBytes set to true if the offset is in bytes
  82275. */
  82276. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82277. /**
  82278. * Release all resources
  82279. */
  82280. dispose(): void;
  82281. }
  82282. /**
  82283. * Specialized buffer used to store vertex data
  82284. */
  82285. export class VertexBuffer {
  82286. /** @hidden */
  82287. _buffer: Buffer;
  82288. private _kind;
  82289. private _size;
  82290. private _ownsBuffer;
  82291. private _instanced;
  82292. private _instanceDivisor;
  82293. /**
  82294. * The byte type.
  82295. */
  82296. static readonly BYTE: number;
  82297. /**
  82298. * The unsigned byte type.
  82299. */
  82300. static readonly UNSIGNED_BYTE: number;
  82301. /**
  82302. * The short type.
  82303. */
  82304. static readonly SHORT: number;
  82305. /**
  82306. * The unsigned short type.
  82307. */
  82308. static readonly UNSIGNED_SHORT: number;
  82309. /**
  82310. * The integer type.
  82311. */
  82312. static readonly INT: number;
  82313. /**
  82314. * The unsigned integer type.
  82315. */
  82316. static readonly UNSIGNED_INT: number;
  82317. /**
  82318. * The float type.
  82319. */
  82320. static readonly FLOAT: number;
  82321. /**
  82322. * Gets or sets the instance divisor when in instanced mode
  82323. */
  82324. get instanceDivisor(): number;
  82325. set instanceDivisor(value: number);
  82326. /**
  82327. * Gets the byte stride.
  82328. */
  82329. readonly byteStride: number;
  82330. /**
  82331. * Gets the byte offset.
  82332. */
  82333. readonly byteOffset: number;
  82334. /**
  82335. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82336. */
  82337. readonly normalized: boolean;
  82338. /**
  82339. * Gets the data type of each component in the array.
  82340. */
  82341. readonly type: number;
  82342. /**
  82343. * Constructor
  82344. * @param engine the engine
  82345. * @param data the data to use for this vertex buffer
  82346. * @param kind the vertex buffer kind
  82347. * @param updatable whether the data is updatable
  82348. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82349. * @param stride the stride (optional)
  82350. * @param instanced whether the buffer is instanced (optional)
  82351. * @param offset the offset of the data (optional)
  82352. * @param size the number of components (optional)
  82353. * @param type the type of the component (optional)
  82354. * @param normalized whether the data contains normalized data (optional)
  82355. * @param useBytes set to true if stride and offset are in bytes (optional)
  82356. * @param divisor defines the instance divisor to use (1 by default)
  82357. */
  82358. 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);
  82359. /** @hidden */
  82360. _rebuild(): void;
  82361. /**
  82362. * Returns the kind of the VertexBuffer (string)
  82363. * @returns a string
  82364. */
  82365. getKind(): string;
  82366. /**
  82367. * Gets a boolean indicating if the VertexBuffer is updatable?
  82368. * @returns true if the buffer is updatable
  82369. */
  82370. isUpdatable(): boolean;
  82371. /**
  82372. * Gets current buffer's data
  82373. * @returns a DataArray or null
  82374. */
  82375. getData(): Nullable<DataArray>;
  82376. /**
  82377. * Gets underlying native buffer
  82378. * @returns underlying native buffer
  82379. */
  82380. getBuffer(): Nullable<DataBuffer>;
  82381. /**
  82382. * Gets the stride in float32 units (i.e. byte stride / 4).
  82383. * May not be an integer if the byte stride is not divisible by 4.
  82384. * @returns the stride in float32 units
  82385. * @deprecated Please use byteStride instead.
  82386. */
  82387. getStrideSize(): number;
  82388. /**
  82389. * Returns the offset as a multiple of the type byte length.
  82390. * @returns the offset in bytes
  82391. * @deprecated Please use byteOffset instead.
  82392. */
  82393. getOffset(): number;
  82394. /**
  82395. * Returns the number of components per vertex attribute (integer)
  82396. * @returns the size in float
  82397. */
  82398. getSize(): number;
  82399. /**
  82400. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82401. * @returns true if this buffer is instanced
  82402. */
  82403. getIsInstanced(): boolean;
  82404. /**
  82405. * Returns the instancing divisor, zero for non-instanced (integer).
  82406. * @returns a number
  82407. */
  82408. getInstanceDivisor(): number;
  82409. /**
  82410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82411. * @param data defines the data to store
  82412. */
  82413. create(data?: DataArray): void;
  82414. /**
  82415. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82416. * This function will create a new buffer if the current one is not updatable
  82417. * @param data defines the data to store
  82418. */
  82419. update(data: DataArray): void;
  82420. /**
  82421. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82422. * Returns the directly updated WebGLBuffer.
  82423. * @param data the new data
  82424. * @param offset the new offset
  82425. * @param useBytes set to true if the offset is in bytes
  82426. */
  82427. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82428. /**
  82429. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82430. */
  82431. dispose(): void;
  82432. /**
  82433. * Enumerates each value of this vertex buffer as numbers.
  82434. * @param count the number of values to enumerate
  82435. * @param callback the callback function called for each value
  82436. */
  82437. forEach(count: number, callback: (value: number, index: number) => void): void;
  82438. /**
  82439. * Positions
  82440. */
  82441. static readonly PositionKind: string;
  82442. /**
  82443. * Normals
  82444. */
  82445. static readonly NormalKind: string;
  82446. /**
  82447. * Tangents
  82448. */
  82449. static readonly TangentKind: string;
  82450. /**
  82451. * Texture coordinates
  82452. */
  82453. static readonly UVKind: string;
  82454. /**
  82455. * Texture coordinates 2
  82456. */
  82457. static readonly UV2Kind: string;
  82458. /**
  82459. * Texture coordinates 3
  82460. */
  82461. static readonly UV3Kind: string;
  82462. /**
  82463. * Texture coordinates 4
  82464. */
  82465. static readonly UV4Kind: string;
  82466. /**
  82467. * Texture coordinates 5
  82468. */
  82469. static readonly UV5Kind: string;
  82470. /**
  82471. * Texture coordinates 6
  82472. */
  82473. static readonly UV6Kind: string;
  82474. /**
  82475. * Colors
  82476. */
  82477. static readonly ColorKind: string;
  82478. /**
  82479. * Matrix indices (for bones)
  82480. */
  82481. static readonly MatricesIndicesKind: string;
  82482. /**
  82483. * Matrix weights (for bones)
  82484. */
  82485. static readonly MatricesWeightsKind: string;
  82486. /**
  82487. * Additional matrix indices (for bones)
  82488. */
  82489. static readonly MatricesIndicesExtraKind: string;
  82490. /**
  82491. * Additional matrix weights (for bones)
  82492. */
  82493. static readonly MatricesWeightsExtraKind: string;
  82494. /**
  82495. * Deduces the stride given a kind.
  82496. * @param kind The kind string to deduce
  82497. * @returns The deduced stride
  82498. */
  82499. static DeduceStride(kind: string): number;
  82500. /**
  82501. * Gets the byte length of the given type.
  82502. * @param type the type
  82503. * @returns the number of bytes
  82504. */
  82505. static GetTypeByteLength(type: number): number;
  82506. /**
  82507. * Enumerates each value of the given parameters as numbers.
  82508. * @param data the data to enumerate
  82509. * @param byteOffset the byte offset of the data
  82510. * @param byteStride the byte stride of the data
  82511. * @param componentCount the number of components per element
  82512. * @param componentType the type of the component
  82513. * @param count the number of values to enumerate
  82514. * @param normalized whether the data is normalized
  82515. * @param callback the callback function called for each value
  82516. */
  82517. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82518. private static _GetFloatValue;
  82519. }
  82520. }
  82521. declare module BABYLON {
  82522. /**
  82523. * @hidden
  82524. */
  82525. export class IntersectionInfo {
  82526. bu: Nullable<number>;
  82527. bv: Nullable<number>;
  82528. distance: number;
  82529. faceId: number;
  82530. subMeshId: number;
  82531. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82532. }
  82533. }
  82534. declare module BABYLON {
  82535. /**
  82536. * Class used to store bounding sphere information
  82537. */
  82538. export class BoundingSphere {
  82539. /**
  82540. * Gets the center of the bounding sphere in local space
  82541. */
  82542. readonly center: Vector3;
  82543. /**
  82544. * Radius of the bounding sphere in local space
  82545. */
  82546. radius: number;
  82547. /**
  82548. * Gets the center of the bounding sphere in world space
  82549. */
  82550. readonly centerWorld: Vector3;
  82551. /**
  82552. * Radius of the bounding sphere in world space
  82553. */
  82554. radiusWorld: number;
  82555. /**
  82556. * Gets the minimum vector in local space
  82557. */
  82558. readonly minimum: Vector3;
  82559. /**
  82560. * Gets the maximum vector in local space
  82561. */
  82562. readonly maximum: Vector3;
  82563. private _worldMatrix;
  82564. private static readonly TmpVector3;
  82565. /**
  82566. * Creates a new bounding sphere
  82567. * @param min defines the minimum vector (in local space)
  82568. * @param max defines the maximum vector (in local space)
  82569. * @param worldMatrix defines the new world matrix
  82570. */
  82571. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82572. /**
  82573. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82574. * @param min defines the new minimum vector (in local space)
  82575. * @param max defines the new maximum vector (in local space)
  82576. * @param worldMatrix defines the new world matrix
  82577. */
  82578. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82579. /**
  82580. * Scale the current bounding sphere by applying a scale factor
  82581. * @param factor defines the scale factor to apply
  82582. * @returns the current bounding box
  82583. */
  82584. scale(factor: number): BoundingSphere;
  82585. /**
  82586. * Gets the world matrix of the bounding box
  82587. * @returns a matrix
  82588. */
  82589. getWorldMatrix(): DeepImmutable<Matrix>;
  82590. /** @hidden */
  82591. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82592. /**
  82593. * Tests if the bounding sphere is intersecting the frustum planes
  82594. * @param frustumPlanes defines the frustum planes to test
  82595. * @returns true if there is an intersection
  82596. */
  82597. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82598. /**
  82599. * Tests if the bounding sphere center is in between the frustum planes.
  82600. * Used for optimistic fast inclusion.
  82601. * @param frustumPlanes defines the frustum planes to test
  82602. * @returns true if the sphere center is in between the frustum planes
  82603. */
  82604. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82605. /**
  82606. * Tests if a point is inside the bounding sphere
  82607. * @param point defines the point to test
  82608. * @returns true if the point is inside the bounding sphere
  82609. */
  82610. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82611. /**
  82612. * Checks if two sphere intersct
  82613. * @param sphere0 sphere 0
  82614. * @param sphere1 sphere 1
  82615. * @returns true if the speres intersect
  82616. */
  82617. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82618. }
  82619. }
  82620. declare module BABYLON {
  82621. /**
  82622. * Class used to store bounding box information
  82623. */
  82624. export class BoundingBox implements ICullable {
  82625. /**
  82626. * Gets the 8 vectors representing the bounding box in local space
  82627. */
  82628. readonly vectors: Vector3[];
  82629. /**
  82630. * Gets the center of the bounding box in local space
  82631. */
  82632. readonly center: Vector3;
  82633. /**
  82634. * Gets the center of the bounding box in world space
  82635. */
  82636. readonly centerWorld: Vector3;
  82637. /**
  82638. * Gets the extend size in local space
  82639. */
  82640. readonly extendSize: Vector3;
  82641. /**
  82642. * Gets the extend size in world space
  82643. */
  82644. readonly extendSizeWorld: Vector3;
  82645. /**
  82646. * Gets the OBB (object bounding box) directions
  82647. */
  82648. readonly directions: Vector3[];
  82649. /**
  82650. * Gets the 8 vectors representing the bounding box in world space
  82651. */
  82652. readonly vectorsWorld: Vector3[];
  82653. /**
  82654. * Gets the minimum vector in world space
  82655. */
  82656. readonly minimumWorld: Vector3;
  82657. /**
  82658. * Gets the maximum vector in world space
  82659. */
  82660. readonly maximumWorld: Vector3;
  82661. /**
  82662. * Gets the minimum vector in local space
  82663. */
  82664. readonly minimum: Vector3;
  82665. /**
  82666. * Gets the maximum vector in local space
  82667. */
  82668. readonly maximum: Vector3;
  82669. private _worldMatrix;
  82670. private static readonly TmpVector3;
  82671. /**
  82672. * @hidden
  82673. */
  82674. _tag: number;
  82675. /**
  82676. * Creates a new bounding box
  82677. * @param min defines the minimum vector (in local space)
  82678. * @param max defines the maximum vector (in local space)
  82679. * @param worldMatrix defines the new world matrix
  82680. */
  82681. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82682. /**
  82683. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82684. * @param min defines the new minimum vector (in local space)
  82685. * @param max defines the new maximum vector (in local space)
  82686. * @param worldMatrix defines the new world matrix
  82687. */
  82688. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82689. /**
  82690. * Scale the current bounding box by applying a scale factor
  82691. * @param factor defines the scale factor to apply
  82692. * @returns the current bounding box
  82693. */
  82694. scale(factor: number): BoundingBox;
  82695. /**
  82696. * Gets the world matrix of the bounding box
  82697. * @returns a matrix
  82698. */
  82699. getWorldMatrix(): DeepImmutable<Matrix>;
  82700. /** @hidden */
  82701. _update(world: DeepImmutable<Matrix>): void;
  82702. /**
  82703. * Tests if the bounding box is intersecting the frustum planes
  82704. * @param frustumPlanes defines the frustum planes to test
  82705. * @returns true if there is an intersection
  82706. */
  82707. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82708. /**
  82709. * Tests if the bounding box is entirely inside the frustum planes
  82710. * @param frustumPlanes defines the frustum planes to test
  82711. * @returns true if there is an inclusion
  82712. */
  82713. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82714. /**
  82715. * Tests if a point is inside the bounding box
  82716. * @param point defines the point to test
  82717. * @returns true if the point is inside the bounding box
  82718. */
  82719. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82720. /**
  82721. * Tests if the bounding box intersects with a bounding sphere
  82722. * @param sphere defines the sphere to test
  82723. * @returns true if there is an intersection
  82724. */
  82725. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82726. /**
  82727. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82728. * @param min defines the min vector to use
  82729. * @param max defines the max vector to use
  82730. * @returns true if there is an intersection
  82731. */
  82732. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82733. /**
  82734. * Tests if two bounding boxes are intersections
  82735. * @param box0 defines the first box to test
  82736. * @param box1 defines the second box to test
  82737. * @returns true if there is an intersection
  82738. */
  82739. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82740. /**
  82741. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82742. * @param minPoint defines the minimum vector of the bounding box
  82743. * @param maxPoint defines the maximum vector of the bounding box
  82744. * @param sphereCenter defines the sphere center
  82745. * @param sphereRadius defines the sphere radius
  82746. * @returns true if there is an intersection
  82747. */
  82748. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82749. /**
  82750. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82751. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82752. * @param frustumPlanes defines the frustum planes to test
  82753. * @return true if there is an inclusion
  82754. */
  82755. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82756. /**
  82757. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82758. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82759. * @param frustumPlanes defines the frustum planes to test
  82760. * @return true if there is an intersection
  82761. */
  82762. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82763. }
  82764. }
  82765. declare module BABYLON {
  82766. /** @hidden */
  82767. export class Collider {
  82768. /** Define if a collision was found */
  82769. collisionFound: boolean;
  82770. /**
  82771. * Define last intersection point in local space
  82772. */
  82773. intersectionPoint: Vector3;
  82774. /**
  82775. * Define last collided mesh
  82776. */
  82777. collidedMesh: Nullable<AbstractMesh>;
  82778. private _collisionPoint;
  82779. private _planeIntersectionPoint;
  82780. private _tempVector;
  82781. private _tempVector2;
  82782. private _tempVector3;
  82783. private _tempVector4;
  82784. private _edge;
  82785. private _baseToVertex;
  82786. private _destinationPoint;
  82787. private _slidePlaneNormal;
  82788. private _displacementVector;
  82789. /** @hidden */
  82790. _radius: Vector3;
  82791. /** @hidden */
  82792. _retry: number;
  82793. private _velocity;
  82794. private _basePoint;
  82795. private _epsilon;
  82796. /** @hidden */
  82797. _velocityWorldLength: number;
  82798. /** @hidden */
  82799. _basePointWorld: Vector3;
  82800. private _velocityWorld;
  82801. private _normalizedVelocity;
  82802. /** @hidden */
  82803. _initialVelocity: Vector3;
  82804. /** @hidden */
  82805. _initialPosition: Vector3;
  82806. private _nearestDistance;
  82807. private _collisionMask;
  82808. get collisionMask(): number;
  82809. set collisionMask(mask: number);
  82810. /**
  82811. * Gets the plane normal used to compute the sliding response (in local space)
  82812. */
  82813. get slidePlaneNormal(): Vector3;
  82814. /** @hidden */
  82815. _initialize(source: Vector3, dir: Vector3, e: number): void;
  82816. /** @hidden */
  82817. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  82818. /** @hidden */
  82819. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  82820. /** @hidden */
  82821. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82822. /** @hidden */
  82823. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82824. /** @hidden */
  82825. _getResponse(pos: Vector3, vel: Vector3): void;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /**
  82830. * Interface for cullable objects
  82831. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  82832. */
  82833. export interface ICullable {
  82834. /**
  82835. * Checks if the object or part of the object is in the frustum
  82836. * @param frustumPlanes Camera near/planes
  82837. * @returns true if the object is in frustum otherwise false
  82838. */
  82839. isInFrustum(frustumPlanes: Plane[]): boolean;
  82840. /**
  82841. * Checks if a cullable object (mesh...) is in the camera frustum
  82842. * Unlike isInFrustum this cheks the full bounding box
  82843. * @param frustumPlanes Camera near/planes
  82844. * @returns true if the object is in frustum otherwise false
  82845. */
  82846. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82847. }
  82848. /**
  82849. * Info for a bounding data of a mesh
  82850. */
  82851. export class BoundingInfo implements ICullable {
  82852. /**
  82853. * Bounding box for the mesh
  82854. */
  82855. readonly boundingBox: BoundingBox;
  82856. /**
  82857. * Bounding sphere for the mesh
  82858. */
  82859. readonly boundingSphere: BoundingSphere;
  82860. private _isLocked;
  82861. private static readonly TmpVector3;
  82862. /**
  82863. * Constructs bounding info
  82864. * @param minimum min vector of the bounding box/sphere
  82865. * @param maximum max vector of the bounding box/sphere
  82866. * @param worldMatrix defines the new world matrix
  82867. */
  82868. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82869. /**
  82870. * Recreates the entire bounding info from scratch as if we call the constructor in place
  82871. * @param min defines the new minimum vector (in local space)
  82872. * @param max defines the new maximum vector (in local space)
  82873. * @param worldMatrix defines the new world matrix
  82874. */
  82875. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82876. /**
  82877. * min vector of the bounding box/sphere
  82878. */
  82879. get minimum(): Vector3;
  82880. /**
  82881. * max vector of the bounding box/sphere
  82882. */
  82883. get maximum(): Vector3;
  82884. /**
  82885. * If the info is locked and won't be updated to avoid perf overhead
  82886. */
  82887. get isLocked(): boolean;
  82888. set isLocked(value: boolean);
  82889. /**
  82890. * Updates the bounding sphere and box
  82891. * @param world world matrix to be used to update
  82892. */
  82893. update(world: DeepImmutable<Matrix>): void;
  82894. /**
  82895. * Recreate the bounding info to be centered around a specific point given a specific extend.
  82896. * @param center New center of the bounding info
  82897. * @param extend New extend of the bounding info
  82898. * @returns the current bounding info
  82899. */
  82900. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  82901. /**
  82902. * Scale the current bounding info by applying a scale factor
  82903. * @param factor defines the scale factor to apply
  82904. * @returns the current bounding info
  82905. */
  82906. scale(factor: number): BoundingInfo;
  82907. /**
  82908. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  82909. * @param frustumPlanes defines the frustum to test
  82910. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  82911. * @returns true if the bounding info is in the frustum planes
  82912. */
  82913. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  82914. /**
  82915. * Gets the world distance between the min and max points of the bounding box
  82916. */
  82917. get diagonalLength(): number;
  82918. /**
  82919. * Checks if a cullable object (mesh...) is in the camera frustum
  82920. * Unlike isInFrustum this cheks the full bounding box
  82921. * @param frustumPlanes Camera near/planes
  82922. * @returns true if the object is in frustum otherwise false
  82923. */
  82924. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82925. /** @hidden */
  82926. _checkCollision(collider: Collider): boolean;
  82927. /**
  82928. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  82929. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82930. * @param point the point to check intersection with
  82931. * @returns if the point intersects
  82932. */
  82933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82934. /**
  82935. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  82936. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82937. * @param boundingInfo the bounding info to check intersection with
  82938. * @param precise if the intersection should be done using OBB
  82939. * @returns if the bounding info intersects
  82940. */
  82941. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  82942. }
  82943. }
  82944. declare module BABYLON {
  82945. /**
  82946. * Extracts minimum and maximum values from a list of indexed positions
  82947. * @param positions defines the positions to use
  82948. * @param indices defines the indices to the positions
  82949. * @param indexStart defines the start index
  82950. * @param indexCount defines the end index
  82951. * @param bias defines bias value to add to the result
  82952. * @return minimum and maximum values
  82953. */
  82954. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  82955. minimum: Vector3;
  82956. maximum: Vector3;
  82957. };
  82958. /**
  82959. * Extracts minimum and maximum values from a list of positions
  82960. * @param positions defines the positions to use
  82961. * @param start defines the start index in the positions array
  82962. * @param count defines the number of positions to handle
  82963. * @param bias defines bias value to add to the result
  82964. * @param stride defines the stride size to use (distance between two positions in the positions array)
  82965. * @return minimum and maximum values
  82966. */
  82967. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  82968. minimum: Vector3;
  82969. maximum: Vector3;
  82970. };
  82971. }
  82972. declare module BABYLON {
  82973. /** @hidden */
  82974. export class WebGLDataBuffer extends DataBuffer {
  82975. private _buffer;
  82976. constructor(resource: WebGLBuffer);
  82977. get underlyingResource(): any;
  82978. }
  82979. }
  82980. declare module BABYLON {
  82981. /** @hidden */
  82982. export class WebGLPipelineContext implements IPipelineContext {
  82983. engine: ThinEngine;
  82984. program: Nullable<WebGLProgram>;
  82985. context?: WebGLRenderingContext;
  82986. vertexShader?: WebGLShader;
  82987. fragmentShader?: WebGLShader;
  82988. isParallelCompiled: boolean;
  82989. onCompiled?: () => void;
  82990. transformFeedback?: WebGLTransformFeedback | null;
  82991. vertexCompilationError: Nullable<string>;
  82992. fragmentCompilationError: Nullable<string>;
  82993. programLinkError: Nullable<string>;
  82994. programValidationError: Nullable<string>;
  82995. get isAsync(): boolean;
  82996. get isReady(): boolean;
  82997. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  82998. _getVertexShaderCode(): string | null;
  82999. _getFragmentShaderCode(): string | null;
  83000. }
  83001. }
  83002. declare module BABYLON {
  83003. interface ThinEngine {
  83004. /**
  83005. * Create an uniform buffer
  83006. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83007. * @param elements defines the content of the uniform buffer
  83008. * @returns the webGL uniform buffer
  83009. */
  83010. createUniformBuffer(elements: FloatArray): DataBuffer;
  83011. /**
  83012. * Create a dynamic uniform buffer
  83013. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83014. * @param elements defines the content of the uniform buffer
  83015. * @returns the webGL uniform buffer
  83016. */
  83017. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83018. /**
  83019. * Update an existing uniform buffer
  83020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83021. * @param uniformBuffer defines the target uniform buffer
  83022. * @param elements defines the content to update
  83023. * @param offset defines the offset in the uniform buffer where update should start
  83024. * @param count defines the size of the data to update
  83025. */
  83026. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83027. /**
  83028. * Bind an uniform buffer to the current webGL context
  83029. * @param buffer defines the buffer to bind
  83030. */
  83031. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83032. /**
  83033. * Bind a buffer to the current webGL context at a given location
  83034. * @param buffer defines the buffer to bind
  83035. * @param location defines the index where to bind the buffer
  83036. */
  83037. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83038. /**
  83039. * Bind a specific block at a given index in a specific shader program
  83040. * @param pipelineContext defines the pipeline context to use
  83041. * @param blockName defines the block name
  83042. * @param index defines the index where to bind the block
  83043. */
  83044. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83045. }
  83046. }
  83047. declare module BABYLON {
  83048. /**
  83049. * Uniform buffer objects.
  83050. *
  83051. * Handles blocks of uniform on the GPU.
  83052. *
  83053. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83054. *
  83055. * For more information, please refer to :
  83056. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83057. */
  83058. export class UniformBuffer {
  83059. private _engine;
  83060. private _buffer;
  83061. private _data;
  83062. private _bufferData;
  83063. private _dynamic?;
  83064. private _uniformLocations;
  83065. private _uniformSizes;
  83066. private _uniformLocationPointer;
  83067. private _needSync;
  83068. private _noUBO;
  83069. private _currentEffect;
  83070. /** @hidden */
  83071. _alreadyBound: boolean;
  83072. private static _MAX_UNIFORM_SIZE;
  83073. private static _tempBuffer;
  83074. /**
  83075. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83076. * This is dynamic to allow compat with webgl 1 and 2.
  83077. * You will need to pass the name of the uniform as well as the value.
  83078. */
  83079. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83080. /**
  83081. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83082. * This is dynamic to allow compat with webgl 1 and 2.
  83083. * You will need to pass the name of the uniform as well as the value.
  83084. */
  83085. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83086. /**
  83087. * Lambda to Update a single float in a uniform buffer.
  83088. * This is dynamic to allow compat with webgl 1 and 2.
  83089. * You will need to pass the name of the uniform as well as the value.
  83090. */
  83091. updateFloat: (name: string, x: number) => void;
  83092. /**
  83093. * Lambda to Update a vec2 of float in a uniform buffer.
  83094. * This is dynamic to allow compat with webgl 1 and 2.
  83095. * You will need to pass the name of the uniform as well as the value.
  83096. */
  83097. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83098. /**
  83099. * Lambda to Update a vec3 of float in a uniform buffer.
  83100. * This is dynamic to allow compat with webgl 1 and 2.
  83101. * You will need to pass the name of the uniform as well as the value.
  83102. */
  83103. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83104. /**
  83105. * Lambda to Update a vec4 of float in a uniform buffer.
  83106. * This is dynamic to allow compat with webgl 1 and 2.
  83107. * You will need to pass the name of the uniform as well as the value.
  83108. */
  83109. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83110. /**
  83111. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83112. * This is dynamic to allow compat with webgl 1 and 2.
  83113. * You will need to pass the name of the uniform as well as the value.
  83114. */
  83115. updateMatrix: (name: string, mat: Matrix) => void;
  83116. /**
  83117. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83118. * This is dynamic to allow compat with webgl 1 and 2.
  83119. * You will need to pass the name of the uniform as well as the value.
  83120. */
  83121. updateVector3: (name: string, vector: Vector3) => void;
  83122. /**
  83123. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83124. * This is dynamic to allow compat with webgl 1 and 2.
  83125. * You will need to pass the name of the uniform as well as the value.
  83126. */
  83127. updateVector4: (name: string, vector: Vector4) => void;
  83128. /**
  83129. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83130. * This is dynamic to allow compat with webgl 1 and 2.
  83131. * You will need to pass the name of the uniform as well as the value.
  83132. */
  83133. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83134. /**
  83135. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83136. * This is dynamic to allow compat with webgl 1 and 2.
  83137. * You will need to pass the name of the uniform as well as the value.
  83138. */
  83139. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83140. /**
  83141. * Instantiates a new Uniform buffer objects.
  83142. *
  83143. * Handles blocks of uniform on the GPU.
  83144. *
  83145. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83146. *
  83147. * For more information, please refer to :
  83148. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83149. * @param engine Define the engine the buffer is associated with
  83150. * @param data Define the data contained in the buffer
  83151. * @param dynamic Define if the buffer is updatable
  83152. */
  83153. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83154. /**
  83155. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83156. * or just falling back on setUniformXXX calls.
  83157. */
  83158. get useUbo(): boolean;
  83159. /**
  83160. * Indicates if the WebGL underlying uniform buffer is in sync
  83161. * with the javascript cache data.
  83162. */
  83163. get isSync(): boolean;
  83164. /**
  83165. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83166. * Also, a dynamic UniformBuffer will disable cache verification and always
  83167. * update the underlying WebGL uniform buffer to the GPU.
  83168. * @returns if Dynamic, otherwise false
  83169. */
  83170. isDynamic(): boolean;
  83171. /**
  83172. * The data cache on JS side.
  83173. * @returns the underlying data as a float array
  83174. */
  83175. getData(): Float32Array;
  83176. /**
  83177. * The underlying WebGL Uniform buffer.
  83178. * @returns the webgl buffer
  83179. */
  83180. getBuffer(): Nullable<DataBuffer>;
  83181. /**
  83182. * std140 layout specifies how to align data within an UBO structure.
  83183. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83184. * for specs.
  83185. */
  83186. private _fillAlignment;
  83187. /**
  83188. * Adds an uniform in the buffer.
  83189. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83190. * for the layout to be correct !
  83191. * @param name Name of the uniform, as used in the uniform block in the shader.
  83192. * @param size Data size, or data directly.
  83193. */
  83194. addUniform(name: string, size: number | number[]): void;
  83195. /**
  83196. * Adds a Matrix 4x4 to the uniform buffer.
  83197. * @param name Name of the uniform, as used in the uniform block in the shader.
  83198. * @param mat A 4x4 matrix.
  83199. */
  83200. addMatrix(name: string, mat: Matrix): void;
  83201. /**
  83202. * Adds a vec2 to the uniform buffer.
  83203. * @param name Name of the uniform, as used in the uniform block in the shader.
  83204. * @param x Define the x component value of the vec2
  83205. * @param y Define the y component value of the vec2
  83206. */
  83207. addFloat2(name: string, x: number, y: number): void;
  83208. /**
  83209. * Adds a vec3 to the uniform buffer.
  83210. * @param name Name of the uniform, as used in the uniform block in the shader.
  83211. * @param x Define the x component value of the vec3
  83212. * @param y Define the y component value of the vec3
  83213. * @param z Define the z component value of the vec3
  83214. */
  83215. addFloat3(name: string, x: number, y: number, z: number): void;
  83216. /**
  83217. * Adds a vec3 to the uniform buffer.
  83218. * @param name Name of the uniform, as used in the uniform block in the shader.
  83219. * @param color Define the vec3 from a Color
  83220. */
  83221. addColor3(name: string, color: Color3): void;
  83222. /**
  83223. * Adds a vec4 to the uniform buffer.
  83224. * @param name Name of the uniform, as used in the uniform block in the shader.
  83225. * @param color Define the rgb components from a Color
  83226. * @param alpha Define the a component of the vec4
  83227. */
  83228. addColor4(name: string, color: Color3, alpha: number): void;
  83229. /**
  83230. * Adds a vec3 to the uniform buffer.
  83231. * @param name Name of the uniform, as used in the uniform block in the shader.
  83232. * @param vector Define the vec3 components from a Vector
  83233. */
  83234. addVector3(name: string, vector: Vector3): void;
  83235. /**
  83236. * Adds a Matrix 3x3 to the uniform buffer.
  83237. * @param name Name of the uniform, as used in the uniform block in the shader.
  83238. */
  83239. addMatrix3x3(name: string): void;
  83240. /**
  83241. * Adds a Matrix 2x2 to the uniform buffer.
  83242. * @param name Name of the uniform, as used in the uniform block in the shader.
  83243. */
  83244. addMatrix2x2(name: string): void;
  83245. /**
  83246. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83247. */
  83248. create(): void;
  83249. /** @hidden */
  83250. _rebuild(): void;
  83251. /**
  83252. * Updates the WebGL Uniform Buffer on the GPU.
  83253. * If the `dynamic` flag is set to true, no cache comparison is done.
  83254. * Otherwise, the buffer will be updated only if the cache differs.
  83255. */
  83256. update(): void;
  83257. /**
  83258. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83259. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83260. * @param data Define the flattened data
  83261. * @param size Define the size of the data.
  83262. */
  83263. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83264. private _valueCache;
  83265. private _cacheMatrix;
  83266. private _updateMatrix3x3ForUniform;
  83267. private _updateMatrix3x3ForEffect;
  83268. private _updateMatrix2x2ForEffect;
  83269. private _updateMatrix2x2ForUniform;
  83270. private _updateFloatForEffect;
  83271. private _updateFloatForUniform;
  83272. private _updateFloat2ForEffect;
  83273. private _updateFloat2ForUniform;
  83274. private _updateFloat3ForEffect;
  83275. private _updateFloat3ForUniform;
  83276. private _updateFloat4ForEffect;
  83277. private _updateFloat4ForUniform;
  83278. private _updateMatrixForEffect;
  83279. private _updateMatrixForUniform;
  83280. private _updateVector3ForEffect;
  83281. private _updateVector3ForUniform;
  83282. private _updateVector4ForEffect;
  83283. private _updateVector4ForUniform;
  83284. private _updateColor3ForEffect;
  83285. private _updateColor3ForUniform;
  83286. private _updateColor4ForEffect;
  83287. private _updateColor4ForUniform;
  83288. /**
  83289. * Sets a sampler uniform on the effect.
  83290. * @param name Define the name of the sampler.
  83291. * @param texture Define the texture to set in the sampler
  83292. */
  83293. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83294. /**
  83295. * Directly updates the value of the uniform in the cache AND on the GPU.
  83296. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83297. * @param data Define the flattened data
  83298. */
  83299. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83300. /**
  83301. * Binds this uniform buffer to an effect.
  83302. * @param effect Define the effect to bind the buffer to
  83303. * @param name Name of the uniform block in the shader.
  83304. */
  83305. bindToEffect(effect: Effect, name: string): void;
  83306. /**
  83307. * Disposes the uniform buffer.
  83308. */
  83309. dispose(): void;
  83310. }
  83311. }
  83312. declare module BABYLON {
  83313. /**
  83314. * Enum that determines the text-wrapping mode to use.
  83315. */
  83316. export enum InspectableType {
  83317. /**
  83318. * Checkbox for booleans
  83319. */
  83320. Checkbox = 0,
  83321. /**
  83322. * Sliders for numbers
  83323. */
  83324. Slider = 1,
  83325. /**
  83326. * Vector3
  83327. */
  83328. Vector3 = 2,
  83329. /**
  83330. * Quaternions
  83331. */
  83332. Quaternion = 3,
  83333. /**
  83334. * Color3
  83335. */
  83336. Color3 = 4,
  83337. /**
  83338. * String
  83339. */
  83340. String = 5
  83341. }
  83342. /**
  83343. * Interface used to define custom inspectable properties.
  83344. * This interface is used by the inspector to display custom property grids
  83345. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83346. */
  83347. export interface IInspectable {
  83348. /**
  83349. * Gets the label to display
  83350. */
  83351. label: string;
  83352. /**
  83353. * Gets the name of the property to edit
  83354. */
  83355. propertyName: string;
  83356. /**
  83357. * Gets the type of the editor to use
  83358. */
  83359. type: InspectableType;
  83360. /**
  83361. * Gets the minimum value of the property when using in "slider" mode
  83362. */
  83363. min?: number;
  83364. /**
  83365. * Gets the maximum value of the property when using in "slider" mode
  83366. */
  83367. max?: number;
  83368. /**
  83369. * Gets the setp to use when using in "slider" mode
  83370. */
  83371. step?: number;
  83372. }
  83373. }
  83374. declare module BABYLON {
  83375. /**
  83376. * Class used to provide helper for timing
  83377. */
  83378. export class TimingTools {
  83379. /**
  83380. * Polyfill for setImmediate
  83381. * @param action defines the action to execute after the current execution block
  83382. */
  83383. static SetImmediate(action: () => void): void;
  83384. }
  83385. }
  83386. declare module BABYLON {
  83387. /**
  83388. * Class used to enable instatition of objects by class name
  83389. */
  83390. export class InstantiationTools {
  83391. /**
  83392. * Use this object to register external classes like custom textures or material
  83393. * to allow the laoders to instantiate them
  83394. */
  83395. static RegisteredExternalClasses: {
  83396. [key: string]: Object;
  83397. };
  83398. /**
  83399. * Tries to instantiate a new object from a given class name
  83400. * @param className defines the class name to instantiate
  83401. * @returns the new object or null if the system was not able to do the instantiation
  83402. */
  83403. static Instantiate(className: string): any;
  83404. }
  83405. }
  83406. declare module BABYLON {
  83407. /**
  83408. * Define options used to create a depth texture
  83409. */
  83410. export class DepthTextureCreationOptions {
  83411. /** Specifies whether or not a stencil should be allocated in the texture */
  83412. generateStencil?: boolean;
  83413. /** Specifies whether or not bilinear filtering is enable on the texture */
  83414. bilinearFiltering?: boolean;
  83415. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83416. comparisonFunction?: number;
  83417. /** Specifies if the created texture is a cube texture */
  83418. isCube?: boolean;
  83419. }
  83420. }
  83421. declare module BABYLON {
  83422. interface ThinEngine {
  83423. /**
  83424. * Creates a depth stencil cube texture.
  83425. * This is only available in WebGL 2.
  83426. * @param size The size of face edge in the cube texture.
  83427. * @param options The options defining the cube texture.
  83428. * @returns The cube texture
  83429. */
  83430. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83431. /**
  83432. * Creates a cube texture
  83433. * @param rootUrl defines the url where the files to load is located
  83434. * @param scene defines the current scene
  83435. * @param files defines the list of files to load (1 per face)
  83436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83437. * @param onLoad defines an optional callback raised when the texture is loaded
  83438. * @param onError defines an optional callback raised if there is an issue to load the texture
  83439. * @param format defines the format of the data
  83440. * @param forcedExtension defines the extension to use to pick the right loader
  83441. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83442. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83443. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83444. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83445. * @returns the cube texture as an InternalTexture
  83446. */
  83447. 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;
  83448. /**
  83449. * Creates a cube texture
  83450. * @param rootUrl defines the url where the files to load is located
  83451. * @param scene defines the current scene
  83452. * @param files defines the list of files to load (1 per face)
  83453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83454. * @param onLoad defines an optional callback raised when the texture is loaded
  83455. * @param onError defines an optional callback raised if there is an issue to load the texture
  83456. * @param format defines the format of the data
  83457. * @param forcedExtension defines the extension to use to pick the right loader
  83458. * @returns the cube texture as an InternalTexture
  83459. */
  83460. 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;
  83461. /**
  83462. * Creates a cube texture
  83463. * @param rootUrl defines the url where the files to load is located
  83464. * @param scene defines the current scene
  83465. * @param files defines the list of files to load (1 per face)
  83466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83467. * @param onLoad defines an optional callback raised when the texture is loaded
  83468. * @param onError defines an optional callback raised if there is an issue to load the texture
  83469. * @param format defines the format of the data
  83470. * @param forcedExtension defines the extension to use to pick the right loader
  83471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83474. * @returns the cube texture as an InternalTexture
  83475. */
  83476. 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;
  83477. /** @hidden */
  83478. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83479. /** @hidden */
  83480. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83481. /** @hidden */
  83482. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83483. /** @hidden */
  83484. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83485. /**
  83486. * @hidden
  83487. */
  83488. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83489. }
  83490. }
  83491. declare module BABYLON {
  83492. /**
  83493. * Class for creating a cube texture
  83494. */
  83495. export class CubeTexture extends BaseTexture {
  83496. private _delayedOnLoad;
  83497. /**
  83498. * Observable triggered once the texture has been loaded.
  83499. */
  83500. onLoadObservable: Observable<CubeTexture>;
  83501. /**
  83502. * The url of the texture
  83503. */
  83504. url: string;
  83505. /**
  83506. * Gets or sets the center of the bounding box associated with the cube texture.
  83507. * It must define where the camera used to render the texture was set
  83508. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83509. */
  83510. boundingBoxPosition: Vector3;
  83511. private _boundingBoxSize;
  83512. /**
  83513. * Gets or sets the size of the bounding box associated with the cube texture
  83514. * When defined, the cubemap will switch to local mode
  83515. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83516. * @example https://www.babylonjs-playground.com/#RNASML
  83517. */
  83518. set boundingBoxSize(value: Vector3);
  83519. /**
  83520. * Returns the bounding box size
  83521. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83522. */
  83523. get boundingBoxSize(): Vector3;
  83524. protected _rotationY: number;
  83525. /**
  83526. * Sets texture matrix rotation angle around Y axis in radians.
  83527. */
  83528. set rotationY(value: number);
  83529. /**
  83530. * Gets texture matrix rotation angle around Y axis radians.
  83531. */
  83532. get rotationY(): number;
  83533. /**
  83534. * Are mip maps generated for this texture or not.
  83535. */
  83536. get noMipmap(): boolean;
  83537. private _noMipmap;
  83538. private _files;
  83539. protected _forcedExtension: Nullable<string>;
  83540. private _extensions;
  83541. private _textureMatrix;
  83542. private _format;
  83543. private _createPolynomials;
  83544. /** @hidden */
  83545. _prefiltered: boolean;
  83546. /**
  83547. * Creates a cube texture from an array of image urls
  83548. * @param files defines an array of image urls
  83549. * @param scene defines the hosting scene
  83550. * @param noMipmap specifies if mip maps are not used
  83551. * @returns a cube texture
  83552. */
  83553. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83554. /**
  83555. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83556. * @param url defines the url of the prefiltered texture
  83557. * @param scene defines the scene the texture is attached to
  83558. * @param forcedExtension defines the extension of the file if different from the url
  83559. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83560. * @return the prefiltered texture
  83561. */
  83562. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83563. /**
  83564. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83565. * as prefiltered data.
  83566. * @param rootUrl defines the url of the texture or the root name of the six images
  83567. * @param scene defines the scene the texture is attached to
  83568. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83569. * @param noMipmap defines if mipmaps should be created or not
  83570. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83571. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83572. * @param onError defines a callback triggered in case of error during load
  83573. * @param format defines the internal format to use for the texture once loaded
  83574. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83575. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83576. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83579. * @return the cube texture
  83580. */
  83581. constructor(rootUrl: string, scene: Scene, 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);
  83582. /**
  83583. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83584. */
  83585. get isPrefiltered(): boolean;
  83586. /**
  83587. * Get the current class name of the texture useful for serialization or dynamic coding.
  83588. * @returns "CubeTexture"
  83589. */
  83590. getClassName(): string;
  83591. /**
  83592. * Update the url (and optional buffer) of this texture if url was null during construction.
  83593. * @param url the url of the texture
  83594. * @param forcedExtension defines the extension to use
  83595. * @param onLoad callback called when the texture is loaded (defaults to null)
  83596. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83597. */
  83598. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83599. /**
  83600. * Delays loading of the cube texture
  83601. * @param forcedExtension defines the extension to use
  83602. */
  83603. delayLoad(forcedExtension?: string): void;
  83604. /**
  83605. * Returns the reflection texture matrix
  83606. * @returns the reflection texture matrix
  83607. */
  83608. getReflectionTextureMatrix(): Matrix;
  83609. /**
  83610. * Sets the reflection texture matrix
  83611. * @param value Reflection texture matrix
  83612. */
  83613. setReflectionTextureMatrix(value: Matrix): void;
  83614. /**
  83615. * Parses text to create a cube texture
  83616. * @param parsedTexture define the serialized text to read from
  83617. * @param scene defines the hosting scene
  83618. * @param rootUrl defines the root url of the cube texture
  83619. * @returns a cube texture
  83620. */
  83621. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83622. /**
  83623. * Makes a clone, or deep copy, of the cube texture
  83624. * @returns a new cube texture
  83625. */
  83626. clone(): CubeTexture;
  83627. }
  83628. }
  83629. declare module BABYLON {
  83630. /**
  83631. * Manages the defines for the Material
  83632. */
  83633. export class MaterialDefines {
  83634. /** @hidden */
  83635. protected _keys: string[];
  83636. private _isDirty;
  83637. /** @hidden */
  83638. _renderId: number;
  83639. /** @hidden */
  83640. _areLightsDirty: boolean;
  83641. /** @hidden */
  83642. _areLightsDisposed: boolean;
  83643. /** @hidden */
  83644. _areAttributesDirty: boolean;
  83645. /** @hidden */
  83646. _areTexturesDirty: boolean;
  83647. /** @hidden */
  83648. _areFresnelDirty: boolean;
  83649. /** @hidden */
  83650. _areMiscDirty: boolean;
  83651. /** @hidden */
  83652. _areImageProcessingDirty: boolean;
  83653. /** @hidden */
  83654. _normals: boolean;
  83655. /** @hidden */
  83656. _uvs: boolean;
  83657. /** @hidden */
  83658. _needNormals: boolean;
  83659. /** @hidden */
  83660. _needUVs: boolean;
  83661. [id: string]: any;
  83662. /**
  83663. * Specifies if the material needs to be re-calculated
  83664. */
  83665. get isDirty(): boolean;
  83666. /**
  83667. * Marks the material to indicate that it has been re-calculated
  83668. */
  83669. markAsProcessed(): void;
  83670. /**
  83671. * Marks the material to indicate that it needs to be re-calculated
  83672. */
  83673. markAsUnprocessed(): void;
  83674. /**
  83675. * Marks the material to indicate all of its defines need to be re-calculated
  83676. */
  83677. markAllAsDirty(): void;
  83678. /**
  83679. * Marks the material to indicate that image processing needs to be re-calculated
  83680. */
  83681. markAsImageProcessingDirty(): void;
  83682. /**
  83683. * Marks the material to indicate the lights need to be re-calculated
  83684. * @param disposed Defines whether the light is dirty due to dispose or not
  83685. */
  83686. markAsLightDirty(disposed?: boolean): void;
  83687. /**
  83688. * Marks the attribute state as changed
  83689. */
  83690. markAsAttributesDirty(): void;
  83691. /**
  83692. * Marks the texture state as changed
  83693. */
  83694. markAsTexturesDirty(): void;
  83695. /**
  83696. * Marks the fresnel state as changed
  83697. */
  83698. markAsFresnelDirty(): void;
  83699. /**
  83700. * Marks the misc state as changed
  83701. */
  83702. markAsMiscDirty(): void;
  83703. /**
  83704. * Rebuilds the material defines
  83705. */
  83706. rebuild(): void;
  83707. /**
  83708. * Specifies if two material defines are equal
  83709. * @param other - A material define instance to compare to
  83710. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83711. */
  83712. isEqual(other: MaterialDefines): boolean;
  83713. /**
  83714. * Clones this instance's defines to another instance
  83715. * @param other - material defines to clone values to
  83716. */
  83717. cloneTo(other: MaterialDefines): void;
  83718. /**
  83719. * Resets the material define values
  83720. */
  83721. reset(): void;
  83722. /**
  83723. * Converts the material define values to a string
  83724. * @returns - String of material define information
  83725. */
  83726. toString(): string;
  83727. }
  83728. }
  83729. declare module BABYLON {
  83730. /**
  83731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83733. * 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;
  83734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83735. */
  83736. export class ColorCurves {
  83737. private _dirty;
  83738. private _tempColor;
  83739. private _globalCurve;
  83740. private _highlightsCurve;
  83741. private _midtonesCurve;
  83742. private _shadowsCurve;
  83743. private _positiveCurve;
  83744. private _negativeCurve;
  83745. private _globalHue;
  83746. private _globalDensity;
  83747. private _globalSaturation;
  83748. private _globalExposure;
  83749. /**
  83750. * Gets the global Hue value.
  83751. * 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).
  83752. */
  83753. get globalHue(): number;
  83754. /**
  83755. * Sets the global Hue value.
  83756. * 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).
  83757. */
  83758. set globalHue(value: number);
  83759. /**
  83760. * Gets the global Density value.
  83761. * 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.
  83762. * Values less than zero provide a filter of opposite hue.
  83763. */
  83764. get globalDensity(): number;
  83765. /**
  83766. * Sets the global Density value.
  83767. * 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.
  83768. * Values less than zero provide a filter of opposite hue.
  83769. */
  83770. set globalDensity(value: number);
  83771. /**
  83772. * Gets the global Saturation value.
  83773. * 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.
  83774. */
  83775. get globalSaturation(): number;
  83776. /**
  83777. * Sets the global Saturation value.
  83778. * 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.
  83779. */
  83780. set globalSaturation(value: number);
  83781. /**
  83782. * Gets the global Exposure value.
  83783. * 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.
  83784. */
  83785. get globalExposure(): number;
  83786. /**
  83787. * Sets the global Exposure value.
  83788. * 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.
  83789. */
  83790. set globalExposure(value: number);
  83791. private _highlightsHue;
  83792. private _highlightsDensity;
  83793. private _highlightsSaturation;
  83794. private _highlightsExposure;
  83795. /**
  83796. * Gets the highlights Hue value.
  83797. * 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).
  83798. */
  83799. get highlightsHue(): number;
  83800. /**
  83801. * Sets the highlights Hue value.
  83802. * 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).
  83803. */
  83804. set highlightsHue(value: number);
  83805. /**
  83806. * Gets the highlights Density value.
  83807. * 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.
  83808. * Values less than zero provide a filter of opposite hue.
  83809. */
  83810. get highlightsDensity(): number;
  83811. /**
  83812. * Sets the highlights Density value.
  83813. * 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.
  83814. * Values less than zero provide a filter of opposite hue.
  83815. */
  83816. set highlightsDensity(value: number);
  83817. /**
  83818. * Gets the highlights Saturation value.
  83819. * 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.
  83820. */
  83821. get highlightsSaturation(): number;
  83822. /**
  83823. * Sets the highlights Saturation value.
  83824. * 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.
  83825. */
  83826. set highlightsSaturation(value: number);
  83827. /**
  83828. * Gets the highlights Exposure value.
  83829. * 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.
  83830. */
  83831. get highlightsExposure(): number;
  83832. /**
  83833. * Sets the highlights Exposure value.
  83834. * 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.
  83835. */
  83836. set highlightsExposure(value: number);
  83837. private _midtonesHue;
  83838. private _midtonesDensity;
  83839. private _midtonesSaturation;
  83840. private _midtonesExposure;
  83841. /**
  83842. * Gets the midtones Hue value.
  83843. * 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).
  83844. */
  83845. get midtonesHue(): number;
  83846. /**
  83847. * Sets the midtones Hue value.
  83848. * 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).
  83849. */
  83850. set midtonesHue(value: number);
  83851. /**
  83852. * Gets the midtones Density value.
  83853. * 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.
  83854. * Values less than zero provide a filter of opposite hue.
  83855. */
  83856. get midtonesDensity(): number;
  83857. /**
  83858. * Sets the midtones Density value.
  83859. * 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.
  83860. * Values less than zero provide a filter of opposite hue.
  83861. */
  83862. set midtonesDensity(value: number);
  83863. /**
  83864. * Gets the midtones Saturation value.
  83865. * 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.
  83866. */
  83867. get midtonesSaturation(): number;
  83868. /**
  83869. * Sets the midtones Saturation value.
  83870. * 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.
  83871. */
  83872. set midtonesSaturation(value: number);
  83873. /**
  83874. * Gets the midtones Exposure value.
  83875. * 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.
  83876. */
  83877. get midtonesExposure(): number;
  83878. /**
  83879. * Sets the midtones Exposure value.
  83880. * 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.
  83881. */
  83882. set midtonesExposure(value: number);
  83883. private _shadowsHue;
  83884. private _shadowsDensity;
  83885. private _shadowsSaturation;
  83886. private _shadowsExposure;
  83887. /**
  83888. * Gets the shadows Hue value.
  83889. * 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).
  83890. */
  83891. get shadowsHue(): number;
  83892. /**
  83893. * Sets the shadows Hue value.
  83894. * 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).
  83895. */
  83896. set shadowsHue(value: number);
  83897. /**
  83898. * Gets the shadows Density value.
  83899. * 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.
  83900. * Values less than zero provide a filter of opposite hue.
  83901. */
  83902. get shadowsDensity(): number;
  83903. /**
  83904. * Sets the shadows Density value.
  83905. * 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.
  83906. * Values less than zero provide a filter of opposite hue.
  83907. */
  83908. set shadowsDensity(value: number);
  83909. /**
  83910. * Gets the shadows Saturation value.
  83911. * 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.
  83912. */
  83913. get shadowsSaturation(): number;
  83914. /**
  83915. * Sets the shadows Saturation value.
  83916. * 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.
  83917. */
  83918. set shadowsSaturation(value: number);
  83919. /**
  83920. * Gets the shadows Exposure value.
  83921. * 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.
  83922. */
  83923. get shadowsExposure(): number;
  83924. /**
  83925. * Sets the shadows Exposure value.
  83926. * 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.
  83927. */
  83928. set shadowsExposure(value: number);
  83929. /**
  83930. * Returns the class name
  83931. * @returns The class name
  83932. */
  83933. getClassName(): string;
  83934. /**
  83935. * Binds the color curves to the shader.
  83936. * @param colorCurves The color curve to bind
  83937. * @param effect The effect to bind to
  83938. * @param positiveUniform The positive uniform shader parameter
  83939. * @param neutralUniform The neutral uniform shader parameter
  83940. * @param negativeUniform The negative uniform shader parameter
  83941. */
  83942. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  83943. /**
  83944. * Prepare the list of uniforms associated with the ColorCurves effects.
  83945. * @param uniformsList The list of uniforms used in the effect
  83946. */
  83947. static PrepareUniforms(uniformsList: string[]): void;
  83948. /**
  83949. * Returns color grading data based on a hue, density, saturation and exposure value.
  83950. * @param filterHue The hue of the color filter.
  83951. * @param filterDensity The density of the color filter.
  83952. * @param saturation The saturation.
  83953. * @param exposure The exposure.
  83954. * @param result The result data container.
  83955. */
  83956. private getColorGradingDataToRef;
  83957. /**
  83958. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  83959. * @param value The input slider value in range [-100,100].
  83960. * @returns Adjusted value.
  83961. */
  83962. private static applyColorGradingSliderNonlinear;
  83963. /**
  83964. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  83965. * @param hue The hue (H) input.
  83966. * @param saturation The saturation (S) input.
  83967. * @param brightness The brightness (B) input.
  83968. * @result An RGBA color represented as Vector4.
  83969. */
  83970. private static fromHSBToRef;
  83971. /**
  83972. * Returns a value clamped between min and max
  83973. * @param value The value to clamp
  83974. * @param min The minimum of value
  83975. * @param max The maximum of value
  83976. * @returns The clamped value.
  83977. */
  83978. private static clamp;
  83979. /**
  83980. * Clones the current color curve instance.
  83981. * @return The cloned curves
  83982. */
  83983. clone(): ColorCurves;
  83984. /**
  83985. * Serializes the current color curve instance to a json representation.
  83986. * @return a JSON representation
  83987. */
  83988. serialize(): any;
  83989. /**
  83990. * Parses the color curve from a json representation.
  83991. * @param source the JSON source to parse
  83992. * @return The parsed curves
  83993. */
  83994. static Parse(source: any): ColorCurves;
  83995. }
  83996. }
  83997. declare module BABYLON {
  83998. /**
  83999. * Interface to follow in your material defines to integrate easily the
  84000. * Image proccessing functions.
  84001. * @hidden
  84002. */
  84003. export interface IImageProcessingConfigurationDefines {
  84004. IMAGEPROCESSING: boolean;
  84005. VIGNETTE: boolean;
  84006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84007. VIGNETTEBLENDMODEOPAQUE: boolean;
  84008. TONEMAPPING: boolean;
  84009. TONEMAPPING_ACES: boolean;
  84010. CONTRAST: boolean;
  84011. EXPOSURE: boolean;
  84012. COLORCURVES: boolean;
  84013. COLORGRADING: boolean;
  84014. COLORGRADING3D: boolean;
  84015. SAMPLER3DGREENDEPTH: boolean;
  84016. SAMPLER3DBGRMAP: boolean;
  84017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84018. }
  84019. /**
  84020. * @hidden
  84021. */
  84022. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84023. IMAGEPROCESSING: boolean;
  84024. VIGNETTE: boolean;
  84025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84026. VIGNETTEBLENDMODEOPAQUE: boolean;
  84027. TONEMAPPING: boolean;
  84028. TONEMAPPING_ACES: boolean;
  84029. CONTRAST: boolean;
  84030. COLORCURVES: boolean;
  84031. COLORGRADING: boolean;
  84032. COLORGRADING3D: boolean;
  84033. SAMPLER3DGREENDEPTH: boolean;
  84034. SAMPLER3DBGRMAP: boolean;
  84035. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84036. EXPOSURE: boolean;
  84037. constructor();
  84038. }
  84039. /**
  84040. * This groups together the common properties used for image processing either in direct forward pass
  84041. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84042. * or not.
  84043. */
  84044. export class ImageProcessingConfiguration {
  84045. /**
  84046. * Default tone mapping applied in BabylonJS.
  84047. */
  84048. static readonly TONEMAPPING_STANDARD: number;
  84049. /**
  84050. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84051. * to other engines rendering to increase portability.
  84052. */
  84053. static readonly TONEMAPPING_ACES: number;
  84054. /**
  84055. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84056. */
  84057. colorCurves: Nullable<ColorCurves>;
  84058. private _colorCurvesEnabled;
  84059. /**
  84060. * Gets wether the color curves effect is enabled.
  84061. */
  84062. get colorCurvesEnabled(): boolean;
  84063. /**
  84064. * Sets wether the color curves effect is enabled.
  84065. */
  84066. set colorCurvesEnabled(value: boolean);
  84067. private _colorGradingTexture;
  84068. /**
  84069. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84070. */
  84071. get colorGradingTexture(): Nullable<BaseTexture>;
  84072. /**
  84073. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84074. */
  84075. set colorGradingTexture(value: Nullable<BaseTexture>);
  84076. private _colorGradingEnabled;
  84077. /**
  84078. * Gets wether the color grading effect is enabled.
  84079. */
  84080. get colorGradingEnabled(): boolean;
  84081. /**
  84082. * Sets wether the color grading effect is enabled.
  84083. */
  84084. set colorGradingEnabled(value: boolean);
  84085. private _colorGradingWithGreenDepth;
  84086. /**
  84087. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84088. */
  84089. get colorGradingWithGreenDepth(): boolean;
  84090. /**
  84091. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84092. */
  84093. set colorGradingWithGreenDepth(value: boolean);
  84094. private _colorGradingBGR;
  84095. /**
  84096. * Gets wether the color grading texture contains BGR values.
  84097. */
  84098. get colorGradingBGR(): boolean;
  84099. /**
  84100. * Sets wether the color grading texture contains BGR values.
  84101. */
  84102. set colorGradingBGR(value: boolean);
  84103. /** @hidden */
  84104. _exposure: number;
  84105. /**
  84106. * Gets the Exposure used in the effect.
  84107. */
  84108. get exposure(): number;
  84109. /**
  84110. * Sets the Exposure used in the effect.
  84111. */
  84112. set exposure(value: number);
  84113. private _toneMappingEnabled;
  84114. /**
  84115. * Gets wether the tone mapping effect is enabled.
  84116. */
  84117. get toneMappingEnabled(): boolean;
  84118. /**
  84119. * Sets wether the tone mapping effect is enabled.
  84120. */
  84121. set toneMappingEnabled(value: boolean);
  84122. private _toneMappingType;
  84123. /**
  84124. * Gets the type of tone mapping effect.
  84125. */
  84126. get toneMappingType(): number;
  84127. /**
  84128. * Sets the type of tone mapping effect used in BabylonJS.
  84129. */
  84130. set toneMappingType(value: number);
  84131. protected _contrast: number;
  84132. /**
  84133. * Gets the contrast used in the effect.
  84134. */
  84135. get contrast(): number;
  84136. /**
  84137. * Sets the contrast used in the effect.
  84138. */
  84139. set contrast(value: number);
  84140. /**
  84141. * Vignette stretch size.
  84142. */
  84143. vignetteStretch: number;
  84144. /**
  84145. * Vignette centre X Offset.
  84146. */
  84147. vignetteCentreX: number;
  84148. /**
  84149. * Vignette centre Y Offset.
  84150. */
  84151. vignetteCentreY: number;
  84152. /**
  84153. * Vignette weight or intensity of the vignette effect.
  84154. */
  84155. vignetteWeight: number;
  84156. /**
  84157. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84158. * if vignetteEnabled is set to true.
  84159. */
  84160. vignetteColor: Color4;
  84161. /**
  84162. * Camera field of view used by the Vignette effect.
  84163. */
  84164. vignetteCameraFov: number;
  84165. private _vignetteBlendMode;
  84166. /**
  84167. * Gets the vignette blend mode allowing different kind of effect.
  84168. */
  84169. get vignetteBlendMode(): number;
  84170. /**
  84171. * Sets the vignette blend mode allowing different kind of effect.
  84172. */
  84173. set vignetteBlendMode(value: number);
  84174. private _vignetteEnabled;
  84175. /**
  84176. * Gets wether the vignette effect is enabled.
  84177. */
  84178. get vignetteEnabled(): boolean;
  84179. /**
  84180. * Sets wether the vignette effect is enabled.
  84181. */
  84182. set vignetteEnabled(value: boolean);
  84183. private _applyByPostProcess;
  84184. /**
  84185. * Gets wether the image processing is applied through a post process or not.
  84186. */
  84187. get applyByPostProcess(): boolean;
  84188. /**
  84189. * Sets wether the image processing is applied through a post process or not.
  84190. */
  84191. set applyByPostProcess(value: boolean);
  84192. private _isEnabled;
  84193. /**
  84194. * Gets wether the image processing is enabled or not.
  84195. */
  84196. get isEnabled(): boolean;
  84197. /**
  84198. * Sets wether the image processing is enabled or not.
  84199. */
  84200. set isEnabled(value: boolean);
  84201. /**
  84202. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84203. */
  84204. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84205. /**
  84206. * Method called each time the image processing information changes requires to recompile the effect.
  84207. */
  84208. protected _updateParameters(): void;
  84209. /**
  84210. * Gets the current class name.
  84211. * @return "ImageProcessingConfiguration"
  84212. */
  84213. getClassName(): string;
  84214. /**
  84215. * Prepare the list of uniforms associated with the Image Processing effects.
  84216. * @param uniforms The list of uniforms used in the effect
  84217. * @param defines the list of defines currently in use
  84218. */
  84219. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84220. /**
  84221. * Prepare the list of samplers associated with the Image Processing effects.
  84222. * @param samplersList The list of uniforms used in the effect
  84223. * @param defines the list of defines currently in use
  84224. */
  84225. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84226. /**
  84227. * Prepare the list of defines associated to the shader.
  84228. * @param defines the list of defines to complete
  84229. * @param forPostProcess Define if we are currently in post process mode or not
  84230. */
  84231. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84232. /**
  84233. * Returns true if all the image processing information are ready.
  84234. * @returns True if ready, otherwise, false
  84235. */
  84236. isReady(): boolean;
  84237. /**
  84238. * Binds the image processing to the shader.
  84239. * @param effect The effect to bind to
  84240. * @param overrideAspectRatio Override the aspect ratio of the effect
  84241. */
  84242. bind(effect: Effect, overrideAspectRatio?: number): void;
  84243. /**
  84244. * Clones the current image processing instance.
  84245. * @return The cloned image processing
  84246. */
  84247. clone(): ImageProcessingConfiguration;
  84248. /**
  84249. * Serializes the current image processing instance to a json representation.
  84250. * @return a JSON representation
  84251. */
  84252. serialize(): any;
  84253. /**
  84254. * Parses the image processing from a json representation.
  84255. * @param source the JSON source to parse
  84256. * @return The parsed image processing
  84257. */
  84258. static Parse(source: any): ImageProcessingConfiguration;
  84259. private static _VIGNETTEMODE_MULTIPLY;
  84260. private static _VIGNETTEMODE_OPAQUE;
  84261. /**
  84262. * Used to apply the vignette as a mix with the pixel color.
  84263. */
  84264. static get VIGNETTEMODE_MULTIPLY(): number;
  84265. /**
  84266. * Used to apply the vignette as a replacement of the pixel color.
  84267. */
  84268. static get VIGNETTEMODE_OPAQUE(): number;
  84269. }
  84270. }
  84271. declare module BABYLON {
  84272. /** @hidden */
  84273. export var postprocessVertexShader: {
  84274. name: string;
  84275. shader: string;
  84276. };
  84277. }
  84278. declare module BABYLON {
  84279. interface ThinEngine {
  84280. /**
  84281. * Creates a new render target texture
  84282. * @param size defines the size of the texture
  84283. * @param options defines the options used to create the texture
  84284. * @returns a new render target texture stored in an InternalTexture
  84285. */
  84286. createRenderTargetTexture(size: number | {
  84287. width: number;
  84288. height: number;
  84289. layers?: number;
  84290. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84291. /**
  84292. * Creates a depth stencil texture.
  84293. * This is only available in WebGL 2 or with the depth texture extension available.
  84294. * @param size The size of face edge in the texture.
  84295. * @param options The options defining the texture.
  84296. * @returns The texture
  84297. */
  84298. createDepthStencilTexture(size: number | {
  84299. width: number;
  84300. height: number;
  84301. layers?: number;
  84302. }, options: DepthTextureCreationOptions): InternalTexture;
  84303. /** @hidden */
  84304. _createDepthStencilTexture(size: number | {
  84305. width: number;
  84306. height: number;
  84307. layers?: number;
  84308. }, options: DepthTextureCreationOptions): InternalTexture;
  84309. }
  84310. }
  84311. declare module BABYLON {
  84312. /** Defines supported spaces */
  84313. export enum Space {
  84314. /** Local (object) space */
  84315. LOCAL = 0,
  84316. /** World space */
  84317. WORLD = 1,
  84318. /** Bone space */
  84319. BONE = 2
  84320. }
  84321. /** Defines the 3 main axes */
  84322. export class Axis {
  84323. /** X axis */
  84324. static X: Vector3;
  84325. /** Y axis */
  84326. static Y: Vector3;
  84327. /** Z axis */
  84328. static Z: Vector3;
  84329. }
  84330. }
  84331. declare module BABYLON {
  84332. /**
  84333. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84334. * This is the base of the follow, arc rotate cameras and Free camera
  84335. * @see http://doc.babylonjs.com/features/cameras
  84336. */
  84337. export class TargetCamera extends Camera {
  84338. private static _RigCamTransformMatrix;
  84339. private static _TargetTransformMatrix;
  84340. private static _TargetFocalPoint;
  84341. /**
  84342. * Define the current direction the camera is moving to
  84343. */
  84344. cameraDirection: Vector3;
  84345. /**
  84346. * Define the current rotation the camera is rotating to
  84347. */
  84348. cameraRotation: Vector2;
  84349. /**
  84350. * When set, the up vector of the camera will be updated by the rotation of the camera
  84351. */
  84352. updateUpVectorFromRotation: boolean;
  84353. private _tmpQuaternion;
  84354. /**
  84355. * Define the current rotation of the camera
  84356. */
  84357. rotation: Vector3;
  84358. /**
  84359. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84360. */
  84361. rotationQuaternion: Quaternion;
  84362. /**
  84363. * Define the current speed of the camera
  84364. */
  84365. speed: number;
  84366. /**
  84367. * Add constraint to the camera to prevent it to move freely in all directions and
  84368. * around all axis.
  84369. */
  84370. noRotationConstraint: boolean;
  84371. /**
  84372. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84373. * panning
  84374. */
  84375. invertRotation: boolean;
  84376. /**
  84377. * Speed multiplier for inverse camera panning
  84378. */
  84379. inverseRotationSpeed: number;
  84380. /**
  84381. * Define the current target of the camera as an object or a position.
  84382. */
  84383. lockedTarget: any;
  84384. /** @hidden */
  84385. _currentTarget: Vector3;
  84386. /** @hidden */
  84387. _initialFocalDistance: number;
  84388. /** @hidden */
  84389. _viewMatrix: Matrix;
  84390. /** @hidden */
  84391. _camMatrix: Matrix;
  84392. /** @hidden */
  84393. _cameraTransformMatrix: Matrix;
  84394. /** @hidden */
  84395. _cameraRotationMatrix: Matrix;
  84396. /** @hidden */
  84397. _referencePoint: Vector3;
  84398. /** @hidden */
  84399. _transformedReferencePoint: Vector3;
  84400. protected _globalCurrentTarget: Vector3;
  84401. protected _globalCurrentUpVector: Vector3;
  84402. /** @hidden */
  84403. _reset: () => void;
  84404. private _defaultUp;
  84405. /**
  84406. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84407. * This is the base of the follow, arc rotate cameras and Free camera
  84408. * @see http://doc.babylonjs.com/features/cameras
  84409. * @param name Defines the name of the camera in the scene
  84410. * @param position Defines the start position of the camera in the scene
  84411. * @param scene Defines the scene the camera belongs to
  84412. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84413. */
  84414. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84415. /**
  84416. * Gets the position in front of the camera at a given distance.
  84417. * @param distance The distance from the camera we want the position to be
  84418. * @returns the position
  84419. */
  84420. getFrontPosition(distance: number): Vector3;
  84421. /** @hidden */
  84422. _getLockedTargetPosition(): Nullable<Vector3>;
  84423. private _storedPosition;
  84424. private _storedRotation;
  84425. private _storedRotationQuaternion;
  84426. /**
  84427. * Store current camera state of the camera (fov, position, rotation, etc..)
  84428. * @returns the camera
  84429. */
  84430. storeState(): Camera;
  84431. /**
  84432. * Restored camera state. You must call storeState() first
  84433. * @returns whether it was successful or not
  84434. * @hidden
  84435. */
  84436. _restoreStateValues(): boolean;
  84437. /** @hidden */
  84438. _initCache(): void;
  84439. /** @hidden */
  84440. _updateCache(ignoreParentClass?: boolean): void;
  84441. /** @hidden */
  84442. _isSynchronizedViewMatrix(): boolean;
  84443. /** @hidden */
  84444. _computeLocalCameraSpeed(): number;
  84445. /**
  84446. * Defines the target the camera should look at.
  84447. * @param target Defines the new target as a Vector or a mesh
  84448. */
  84449. setTarget(target: Vector3): void;
  84450. /**
  84451. * Return the current target position of the camera. This value is expressed in local space.
  84452. * @returns the target position
  84453. */
  84454. getTarget(): Vector3;
  84455. /** @hidden */
  84456. _decideIfNeedsToMove(): boolean;
  84457. /** @hidden */
  84458. _updatePosition(): void;
  84459. /** @hidden */
  84460. _checkInputs(): void;
  84461. protected _updateCameraRotationMatrix(): void;
  84462. /**
  84463. * 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)
  84464. * @returns the current camera
  84465. */
  84466. private _rotateUpVectorWithCameraRotationMatrix;
  84467. private _cachedRotationZ;
  84468. private _cachedQuaternionRotationZ;
  84469. /** @hidden */
  84470. _getViewMatrix(): Matrix;
  84471. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84472. /**
  84473. * @hidden
  84474. */
  84475. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84476. /**
  84477. * @hidden
  84478. */
  84479. _updateRigCameras(): void;
  84480. private _getRigCamPositionAndTarget;
  84481. /**
  84482. * Gets the current object class name.
  84483. * @return the class name
  84484. */
  84485. getClassName(): string;
  84486. }
  84487. }
  84488. declare module BABYLON {
  84489. /**
  84490. * Gather the list of keyboard event types as constants.
  84491. */
  84492. export class KeyboardEventTypes {
  84493. /**
  84494. * The keydown event is fired when a key becomes active (pressed).
  84495. */
  84496. static readonly KEYDOWN: number;
  84497. /**
  84498. * The keyup event is fired when a key has been released.
  84499. */
  84500. static readonly KEYUP: number;
  84501. }
  84502. /**
  84503. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84504. */
  84505. export class KeyboardInfo {
  84506. /**
  84507. * Defines the type of event (KeyboardEventTypes)
  84508. */
  84509. type: number;
  84510. /**
  84511. * Defines the related dom event
  84512. */
  84513. event: KeyboardEvent;
  84514. /**
  84515. * Instantiates a new keyboard info.
  84516. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84517. * @param type Defines the type of event (KeyboardEventTypes)
  84518. * @param event Defines the related dom event
  84519. */
  84520. constructor(
  84521. /**
  84522. * Defines the type of event (KeyboardEventTypes)
  84523. */
  84524. type: number,
  84525. /**
  84526. * Defines the related dom event
  84527. */
  84528. event: KeyboardEvent);
  84529. }
  84530. /**
  84531. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84532. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84533. */
  84534. export class KeyboardInfoPre extends KeyboardInfo {
  84535. /**
  84536. * Defines the type of event (KeyboardEventTypes)
  84537. */
  84538. type: number;
  84539. /**
  84540. * Defines the related dom event
  84541. */
  84542. event: KeyboardEvent;
  84543. /**
  84544. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84545. */
  84546. skipOnPointerObservable: boolean;
  84547. /**
  84548. * Instantiates a new keyboard pre info.
  84549. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84550. * @param type Defines the type of event (KeyboardEventTypes)
  84551. * @param event Defines the related dom event
  84552. */
  84553. constructor(
  84554. /**
  84555. * Defines the type of event (KeyboardEventTypes)
  84556. */
  84557. type: number,
  84558. /**
  84559. * Defines the related dom event
  84560. */
  84561. event: KeyboardEvent);
  84562. }
  84563. }
  84564. declare module BABYLON {
  84565. /**
  84566. * Manage the keyboard inputs to control the movement of a free camera.
  84567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84568. */
  84569. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84570. /**
  84571. * Defines the camera the input is attached to.
  84572. */
  84573. camera: FreeCamera;
  84574. /**
  84575. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84576. */
  84577. keysUp: number[];
  84578. /**
  84579. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84580. */
  84581. keysUpward: number[];
  84582. /**
  84583. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84584. */
  84585. keysDown: number[];
  84586. /**
  84587. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84588. */
  84589. keysDownward: number[];
  84590. /**
  84591. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84592. */
  84593. keysLeft: number[];
  84594. /**
  84595. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84596. */
  84597. keysRight: number[];
  84598. private _keys;
  84599. private _onCanvasBlurObserver;
  84600. private _onKeyboardObserver;
  84601. private _engine;
  84602. private _scene;
  84603. /**
  84604. * Attach the input controls to a specific dom element to get the input from.
  84605. * @param element Defines the element the controls should be listened from
  84606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84607. */
  84608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84609. /**
  84610. * Detach the current controls from the specified dom element.
  84611. * @param element Defines the element to stop listening the inputs from
  84612. */
  84613. detachControl(element: Nullable<HTMLElement>): void;
  84614. /**
  84615. * Update the current camera state depending on the inputs that have been used this frame.
  84616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84617. */
  84618. checkInputs(): void;
  84619. /**
  84620. * Gets the class name of the current intput.
  84621. * @returns the class name
  84622. */
  84623. getClassName(): string;
  84624. /** @hidden */
  84625. _onLostFocus(): void;
  84626. /**
  84627. * Get the friendly name associated with the input class.
  84628. * @returns the input friendly name
  84629. */
  84630. getSimpleName(): string;
  84631. }
  84632. }
  84633. declare module BABYLON {
  84634. /**
  84635. * Interface describing all the common properties and methods a shadow light needs to implement.
  84636. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84637. * as well as binding the different shadow properties to the effects.
  84638. */
  84639. export interface IShadowLight extends Light {
  84640. /**
  84641. * The light id in the scene (used in scene.findLighById for instance)
  84642. */
  84643. id: string;
  84644. /**
  84645. * The position the shdow will be casted from.
  84646. */
  84647. position: Vector3;
  84648. /**
  84649. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84650. */
  84651. direction: Vector3;
  84652. /**
  84653. * The transformed position. Position of the light in world space taking parenting in account.
  84654. */
  84655. transformedPosition: Vector3;
  84656. /**
  84657. * The transformed direction. Direction of the light in world space taking parenting in account.
  84658. */
  84659. transformedDirection: Vector3;
  84660. /**
  84661. * The friendly name of the light in the scene.
  84662. */
  84663. name: string;
  84664. /**
  84665. * Defines the shadow projection clipping minimum z value.
  84666. */
  84667. shadowMinZ: number;
  84668. /**
  84669. * Defines the shadow projection clipping maximum z value.
  84670. */
  84671. shadowMaxZ: number;
  84672. /**
  84673. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84674. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84675. */
  84676. computeTransformedInformation(): boolean;
  84677. /**
  84678. * Gets the scene the light belongs to.
  84679. * @returns The scene
  84680. */
  84681. getScene(): Scene;
  84682. /**
  84683. * Callback defining a custom Projection Matrix Builder.
  84684. * This can be used to override the default projection matrix computation.
  84685. */
  84686. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84687. /**
  84688. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84689. * @param matrix The materix to updated with the projection information
  84690. * @param viewMatrix The transform matrix of the light
  84691. * @param renderList The list of mesh to render in the map
  84692. * @returns The current light
  84693. */
  84694. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84695. /**
  84696. * Gets the current depth scale used in ESM.
  84697. * @returns The scale
  84698. */
  84699. getDepthScale(): number;
  84700. /**
  84701. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84702. * @returns true if a cube texture needs to be use
  84703. */
  84704. needCube(): boolean;
  84705. /**
  84706. * Detects if the projection matrix requires to be recomputed this frame.
  84707. * @returns true if it requires to be recomputed otherwise, false.
  84708. */
  84709. needProjectionMatrixCompute(): boolean;
  84710. /**
  84711. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84712. */
  84713. forceProjectionMatrixCompute(): void;
  84714. /**
  84715. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84716. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84717. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84718. */
  84719. getShadowDirection(faceIndex?: number): Vector3;
  84720. /**
  84721. * Gets the minZ used for shadow according to both the scene and the light.
  84722. * @param activeCamera The camera we are returning the min for
  84723. * @returns the depth min z
  84724. */
  84725. getDepthMinZ(activeCamera: Camera): number;
  84726. /**
  84727. * Gets the maxZ used for shadow according to both the scene and the light.
  84728. * @param activeCamera The camera we are returning the max for
  84729. * @returns the depth max z
  84730. */
  84731. getDepthMaxZ(activeCamera: Camera): number;
  84732. }
  84733. /**
  84734. * Base implementation IShadowLight
  84735. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84736. */
  84737. export abstract class ShadowLight extends Light implements IShadowLight {
  84738. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84739. protected _position: Vector3;
  84740. protected _setPosition(value: Vector3): void;
  84741. /**
  84742. * Sets the position the shadow will be casted from. Also use as the light position for both
  84743. * point and spot lights.
  84744. */
  84745. get position(): Vector3;
  84746. /**
  84747. * Sets the position the shadow will be casted from. Also use as the light position for both
  84748. * point and spot lights.
  84749. */
  84750. set position(value: Vector3);
  84751. protected _direction: Vector3;
  84752. protected _setDirection(value: Vector3): void;
  84753. /**
  84754. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84755. * Also use as the light direction on spot and directional lights.
  84756. */
  84757. get direction(): Vector3;
  84758. /**
  84759. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84760. * Also use as the light direction on spot and directional lights.
  84761. */
  84762. set direction(value: Vector3);
  84763. protected _shadowMinZ: number;
  84764. /**
  84765. * Gets the shadow projection clipping minimum z value.
  84766. */
  84767. get shadowMinZ(): number;
  84768. /**
  84769. * Sets the shadow projection clipping minimum z value.
  84770. */
  84771. set shadowMinZ(value: number);
  84772. protected _shadowMaxZ: number;
  84773. /**
  84774. * Sets the shadow projection clipping maximum z value.
  84775. */
  84776. get shadowMaxZ(): number;
  84777. /**
  84778. * Gets the shadow projection clipping maximum z value.
  84779. */
  84780. set shadowMaxZ(value: number);
  84781. /**
  84782. * Callback defining a custom Projection Matrix Builder.
  84783. * This can be used to override the default projection matrix computation.
  84784. */
  84785. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84786. /**
  84787. * The transformed position. Position of the light in world space taking parenting in account.
  84788. */
  84789. transformedPosition: Vector3;
  84790. /**
  84791. * The transformed direction. Direction of the light in world space taking parenting in account.
  84792. */
  84793. transformedDirection: Vector3;
  84794. private _needProjectionMatrixCompute;
  84795. /**
  84796. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84797. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84798. */
  84799. computeTransformedInformation(): boolean;
  84800. /**
  84801. * Return the depth scale used for the shadow map.
  84802. * @returns the depth scale.
  84803. */
  84804. getDepthScale(): number;
  84805. /**
  84806. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84807. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84808. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84809. */
  84810. getShadowDirection(faceIndex?: number): Vector3;
  84811. /**
  84812. * Returns the ShadowLight absolute position in the World.
  84813. * @returns the position vector in world space
  84814. */
  84815. getAbsolutePosition(): Vector3;
  84816. /**
  84817. * Sets the ShadowLight direction toward the passed target.
  84818. * @param target The point to target in local space
  84819. * @returns the updated ShadowLight direction
  84820. */
  84821. setDirectionToTarget(target: Vector3): Vector3;
  84822. /**
  84823. * Returns the light rotation in euler definition.
  84824. * @returns the x y z rotation in local space.
  84825. */
  84826. getRotation(): Vector3;
  84827. /**
  84828. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84829. * @returns true if a cube texture needs to be use
  84830. */
  84831. needCube(): boolean;
  84832. /**
  84833. * Detects if the projection matrix requires to be recomputed this frame.
  84834. * @returns true if it requires to be recomputed otherwise, false.
  84835. */
  84836. needProjectionMatrixCompute(): boolean;
  84837. /**
  84838. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84839. */
  84840. forceProjectionMatrixCompute(): void;
  84841. /** @hidden */
  84842. _initCache(): void;
  84843. /** @hidden */
  84844. _isSynchronized(): boolean;
  84845. /**
  84846. * Computes the world matrix of the node
  84847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84848. * @returns the world matrix
  84849. */
  84850. computeWorldMatrix(force?: boolean): Matrix;
  84851. /**
  84852. * Gets the minZ used for shadow according to both the scene and the light.
  84853. * @param activeCamera The camera we are returning the min for
  84854. * @returns the depth min z
  84855. */
  84856. getDepthMinZ(activeCamera: Camera): number;
  84857. /**
  84858. * Gets the maxZ used for shadow according to both the scene and the light.
  84859. * @param activeCamera The camera we are returning the max for
  84860. * @returns the depth max z
  84861. */
  84862. getDepthMaxZ(activeCamera: Camera): number;
  84863. /**
  84864. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84865. * @param matrix The materix to updated with the projection information
  84866. * @param viewMatrix The transform matrix of the light
  84867. * @param renderList The list of mesh to render in the map
  84868. * @returns The current light
  84869. */
  84870. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84871. }
  84872. }
  84873. declare module BABYLON {
  84874. /**
  84875. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84876. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84877. */
  84878. export class EffectFallbacks implements IEffectFallbacks {
  84879. private _defines;
  84880. private _currentRank;
  84881. private _maxRank;
  84882. private _mesh;
  84883. /**
  84884. * Removes the fallback from the bound mesh.
  84885. */
  84886. unBindMesh(): void;
  84887. /**
  84888. * Adds a fallback on the specified property.
  84889. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84890. * @param define The name of the define in the shader
  84891. */
  84892. addFallback(rank: number, define: string): void;
  84893. /**
  84894. * Sets the mesh to use CPU skinning when needing to fallback.
  84895. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84896. * @param mesh The mesh to use the fallbacks.
  84897. */
  84898. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84899. /**
  84900. * Checks to see if more fallbacks are still availible.
  84901. */
  84902. get hasMoreFallbacks(): boolean;
  84903. /**
  84904. * Removes the defines that should be removed when falling back.
  84905. * @param currentDefines defines the current define statements for the shader.
  84906. * @param effect defines the current effect we try to compile
  84907. * @returns The resulting defines with defines of the current rank removed.
  84908. */
  84909. reduce(currentDefines: string, effect: Effect): string;
  84910. }
  84911. }
  84912. declare module BABYLON {
  84913. /**
  84914. * "Static Class" containing the most commonly used helper while dealing with material for
  84915. * rendering purpose.
  84916. *
  84917. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  84918. *
  84919. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  84920. */
  84921. export class MaterialHelper {
  84922. /**
  84923. * Bind the current view position to an effect.
  84924. * @param effect The effect to be bound
  84925. * @param scene The scene the eyes position is used from
  84926. * @param variableName name of the shader variable that will hold the eye position
  84927. */
  84928. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  84929. /**
  84930. * Helps preparing the defines values about the UVs in used in the effect.
  84931. * UVs are shared as much as we can accross channels in the shaders.
  84932. * @param texture The texture we are preparing the UVs for
  84933. * @param defines The defines to update
  84934. * @param key The channel key "diffuse", "specular"... used in the shader
  84935. */
  84936. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  84937. /**
  84938. * Binds a texture matrix value to its corrsponding uniform
  84939. * @param texture The texture to bind the matrix for
  84940. * @param uniformBuffer The uniform buffer receivin the data
  84941. * @param key The channel key "diffuse", "specular"... used in the shader
  84942. */
  84943. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  84944. /**
  84945. * Gets the current status of the fog (should it be enabled?)
  84946. * @param mesh defines the mesh to evaluate for fog support
  84947. * @param scene defines the hosting scene
  84948. * @returns true if fog must be enabled
  84949. */
  84950. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  84951. /**
  84952. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  84953. * @param mesh defines the current mesh
  84954. * @param scene defines the current scene
  84955. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  84956. * @param pointsCloud defines if point cloud rendering has to be turned on
  84957. * @param fogEnabled defines if fog has to be turned on
  84958. * @param alphaTest defines if alpha testing has to be turned on
  84959. * @param defines defines the current list of defines
  84960. */
  84961. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  84962. /**
  84963. * Helper used to prepare the list of defines associated with frame values for shader compilation
  84964. * @param scene defines the current scene
  84965. * @param engine defines the current engine
  84966. * @param defines specifies the list of active defines
  84967. * @param useInstances defines if instances have to be turned on
  84968. * @param useClipPlane defines if clip plane have to be turned on
  84969. */
  84970. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  84971. /**
  84972. * Prepares the defines for bones
  84973. * @param mesh The mesh containing the geometry data we will draw
  84974. * @param defines The defines to update
  84975. */
  84976. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  84977. /**
  84978. * Prepares the defines for morph targets
  84979. * @param mesh The mesh containing the geometry data we will draw
  84980. * @param defines The defines to update
  84981. */
  84982. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  84983. /**
  84984. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  84985. * @param mesh The mesh containing the geometry data we will draw
  84986. * @param defines The defines to update
  84987. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  84988. * @param useBones Precise whether bones should be used or not (override mesh info)
  84989. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  84990. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  84991. * @returns false if defines are considered not dirty and have not been checked
  84992. */
  84993. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  84994. /**
  84995. * Prepares the defines related to multiview
  84996. * @param scene The scene we are intending to draw
  84997. * @param defines The defines to update
  84998. */
  84999. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  85000. /**
  85001. * Prepares the defines related to the light information passed in parameter
  85002. * @param scene The scene we are intending to draw
  85003. * @param mesh The mesh the effect is compiling for
  85004. * @param light The light the effect is compiling for
  85005. * @param lightIndex The index of the light
  85006. * @param defines The defines to update
  85007. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85008. * @param state Defines the current state regarding what is needed (normals, etc...)
  85009. */
  85010. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85011. needNormals: boolean;
  85012. needRebuild: boolean;
  85013. shadowEnabled: boolean;
  85014. specularEnabled: boolean;
  85015. lightmapMode: boolean;
  85016. }): void;
  85017. /**
  85018. * Prepares the defines related to the light information passed in parameter
  85019. * @param scene The scene we are intending to draw
  85020. * @param mesh The mesh the effect is compiling for
  85021. * @param defines The defines to update
  85022. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85023. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85024. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85025. * @returns true if normals will be required for the rest of the effect
  85026. */
  85027. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85028. /**
  85029. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85030. * @param lightIndex defines the light index
  85031. * @param uniformsList The uniform list
  85032. * @param samplersList The sampler list
  85033. * @param projectedLightTexture defines if projected texture must be used
  85034. * @param uniformBuffersList defines an optional list of uniform buffers
  85035. */
  85036. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85037. /**
  85038. * Prepares the uniforms and samplers list to be used in the effect
  85039. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85040. * @param samplersList The sampler list
  85041. * @param defines The defines helping in the list generation
  85042. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85043. */
  85044. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85045. /**
  85046. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85047. * @param defines The defines to update while falling back
  85048. * @param fallbacks The authorized effect fallbacks
  85049. * @param maxSimultaneousLights The maximum number of lights allowed
  85050. * @param rank the current rank of the Effect
  85051. * @returns The newly affected rank
  85052. */
  85053. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85054. private static _TmpMorphInfluencers;
  85055. /**
  85056. * Prepares the list of attributes required for morph targets according to the effect defines.
  85057. * @param attribs The current list of supported attribs
  85058. * @param mesh The mesh to prepare the morph targets attributes for
  85059. * @param influencers The number of influencers
  85060. */
  85061. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85062. /**
  85063. * Prepares the list of attributes required for morph targets according to the effect defines.
  85064. * @param attribs The current list of supported attribs
  85065. * @param mesh The mesh to prepare the morph targets attributes for
  85066. * @param defines The current Defines of the effect
  85067. */
  85068. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85069. /**
  85070. * Prepares the list of attributes required for bones according to the effect defines.
  85071. * @param attribs The current list of supported attribs
  85072. * @param mesh The mesh to prepare the bones attributes for
  85073. * @param defines The current Defines of the effect
  85074. * @param fallbacks The current efffect fallback strategy
  85075. */
  85076. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85077. /**
  85078. * Check and prepare the list of attributes required for instances according to the effect defines.
  85079. * @param attribs The current list of supported attribs
  85080. * @param defines The current MaterialDefines of the effect
  85081. */
  85082. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85083. /**
  85084. * Add the list of attributes required for instances to the attribs array.
  85085. * @param attribs The current list of supported attribs
  85086. */
  85087. static PushAttributesForInstances(attribs: string[]): void;
  85088. /**
  85089. * Binds the light information to the effect.
  85090. * @param light The light containing the generator
  85091. * @param effect The effect we are binding the data to
  85092. * @param lightIndex The light index in the effect used to render
  85093. */
  85094. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85095. /**
  85096. * Binds the lights information from the scene to the effect for the given mesh.
  85097. * @param light Light to bind
  85098. * @param lightIndex Light index
  85099. * @param scene The scene where the light belongs to
  85100. * @param effect The effect we are binding the data to
  85101. * @param useSpecular Defines if specular is supported
  85102. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85103. */
  85104. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85105. /**
  85106. * Binds the lights information from the scene to the effect for the given mesh.
  85107. * @param scene The scene the lights belongs to
  85108. * @param mesh The mesh we are binding the information to render
  85109. * @param effect The effect we are binding the data to
  85110. * @param defines The generated defines for the effect
  85111. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85112. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85113. */
  85114. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85115. private static _tempFogColor;
  85116. /**
  85117. * Binds the fog information from the scene to the effect for the given mesh.
  85118. * @param scene The scene the lights belongs to
  85119. * @param mesh The mesh we are binding the information to render
  85120. * @param effect The effect we are binding the data to
  85121. * @param linearSpace Defines if the fog effect is applied in linear space
  85122. */
  85123. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85124. /**
  85125. * Binds the bones information from the mesh to the effect.
  85126. * @param mesh The mesh we are binding the information to render
  85127. * @param effect The effect we are binding the data to
  85128. */
  85129. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85130. /**
  85131. * Binds the morph targets information from the mesh to the effect.
  85132. * @param abstractMesh The mesh we are binding the information to render
  85133. * @param effect The effect we are binding the data to
  85134. */
  85135. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85136. /**
  85137. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85138. * @param defines The generated defines used in the effect
  85139. * @param effect The effect we are binding the data to
  85140. * @param scene The scene we are willing to render with logarithmic scale for
  85141. */
  85142. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85143. /**
  85144. * Binds the clip plane information from the scene to the effect.
  85145. * @param scene The scene the clip plane information are extracted from
  85146. * @param effect The effect we are binding the data to
  85147. */
  85148. static BindClipPlane(effect: Effect, scene: Scene): void;
  85149. }
  85150. }
  85151. declare module BABYLON {
  85152. /** @hidden */
  85153. export var packingFunctions: {
  85154. name: string;
  85155. shader: string;
  85156. };
  85157. }
  85158. declare module BABYLON {
  85159. /** @hidden */
  85160. export var shadowMapFragmentDeclaration: {
  85161. name: string;
  85162. shader: string;
  85163. };
  85164. }
  85165. declare module BABYLON {
  85166. /** @hidden */
  85167. export var clipPlaneFragmentDeclaration: {
  85168. name: string;
  85169. shader: string;
  85170. };
  85171. }
  85172. declare module BABYLON {
  85173. /** @hidden */
  85174. export var clipPlaneFragment: {
  85175. name: string;
  85176. shader: string;
  85177. };
  85178. }
  85179. declare module BABYLON {
  85180. /** @hidden */
  85181. export var shadowMapFragment: {
  85182. name: string;
  85183. shader: string;
  85184. };
  85185. }
  85186. declare module BABYLON {
  85187. /** @hidden */
  85188. export var shadowMapPixelShader: {
  85189. name: string;
  85190. shader: string;
  85191. };
  85192. }
  85193. declare module BABYLON {
  85194. /** @hidden */
  85195. export var bonesDeclaration: {
  85196. name: string;
  85197. shader: string;
  85198. };
  85199. }
  85200. declare module BABYLON {
  85201. /** @hidden */
  85202. export var morphTargetsVertexGlobalDeclaration: {
  85203. name: string;
  85204. shader: string;
  85205. };
  85206. }
  85207. declare module BABYLON {
  85208. /** @hidden */
  85209. export var morphTargetsVertexDeclaration: {
  85210. name: string;
  85211. shader: string;
  85212. };
  85213. }
  85214. declare module BABYLON {
  85215. /** @hidden */
  85216. export var instancesDeclaration: {
  85217. name: string;
  85218. shader: string;
  85219. };
  85220. }
  85221. declare module BABYLON {
  85222. /** @hidden */
  85223. export var helperFunctions: {
  85224. name: string;
  85225. shader: string;
  85226. };
  85227. }
  85228. declare module BABYLON {
  85229. /** @hidden */
  85230. export var shadowMapVertexDeclaration: {
  85231. name: string;
  85232. shader: string;
  85233. };
  85234. }
  85235. declare module BABYLON {
  85236. /** @hidden */
  85237. export var clipPlaneVertexDeclaration: {
  85238. name: string;
  85239. shader: string;
  85240. };
  85241. }
  85242. declare module BABYLON {
  85243. /** @hidden */
  85244. export var morphTargetsVertex: {
  85245. name: string;
  85246. shader: string;
  85247. };
  85248. }
  85249. declare module BABYLON {
  85250. /** @hidden */
  85251. export var instancesVertex: {
  85252. name: string;
  85253. shader: string;
  85254. };
  85255. }
  85256. declare module BABYLON {
  85257. /** @hidden */
  85258. export var bonesVertex: {
  85259. name: string;
  85260. shader: string;
  85261. };
  85262. }
  85263. declare module BABYLON {
  85264. /** @hidden */
  85265. export var shadowMapVertexNormalBias: {
  85266. name: string;
  85267. shader: string;
  85268. };
  85269. }
  85270. declare module BABYLON {
  85271. /** @hidden */
  85272. export var shadowMapVertexMetric: {
  85273. name: string;
  85274. shader: string;
  85275. };
  85276. }
  85277. declare module BABYLON {
  85278. /** @hidden */
  85279. export var clipPlaneVertex: {
  85280. name: string;
  85281. shader: string;
  85282. };
  85283. }
  85284. declare module BABYLON {
  85285. /** @hidden */
  85286. export var shadowMapVertexShader: {
  85287. name: string;
  85288. shader: string;
  85289. };
  85290. }
  85291. declare module BABYLON {
  85292. /** @hidden */
  85293. export var depthBoxBlurPixelShader: {
  85294. name: string;
  85295. shader: string;
  85296. };
  85297. }
  85298. declare module BABYLON {
  85299. /**
  85300. * Class representing a ray with position and direction
  85301. */
  85302. export class Ray {
  85303. /** origin point */
  85304. origin: Vector3;
  85305. /** direction */
  85306. direction: Vector3;
  85307. /** length of the ray */
  85308. length: number;
  85309. private static readonly TmpVector3;
  85310. private _tmpRay;
  85311. /**
  85312. * Creates a new ray
  85313. * @param origin origin point
  85314. * @param direction direction
  85315. * @param length length of the ray
  85316. */
  85317. constructor(
  85318. /** origin point */
  85319. origin: Vector3,
  85320. /** direction */
  85321. direction: Vector3,
  85322. /** length of the ray */
  85323. length?: number);
  85324. /**
  85325. * Checks if the ray intersects a box
  85326. * This does not account for the ray lenght by design to improve perfs.
  85327. * @param minimum bound of the box
  85328. * @param maximum bound of the box
  85329. * @param intersectionTreshold extra extend to be added to the box in all direction
  85330. * @returns if the box was hit
  85331. */
  85332. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85333. /**
  85334. * Checks if the ray intersects a box
  85335. * This does not account for the ray lenght by design to improve perfs.
  85336. * @param box the bounding box to check
  85337. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85338. * @returns if the box was hit
  85339. */
  85340. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85341. /**
  85342. * If the ray hits a sphere
  85343. * @param sphere the bounding sphere to check
  85344. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85345. * @returns true if it hits the sphere
  85346. */
  85347. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85348. /**
  85349. * If the ray hits a triange
  85350. * @param vertex0 triangle vertex
  85351. * @param vertex1 triangle vertex
  85352. * @param vertex2 triangle vertex
  85353. * @returns intersection information if hit
  85354. */
  85355. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85356. /**
  85357. * Checks if ray intersects a plane
  85358. * @param plane the plane to check
  85359. * @returns the distance away it was hit
  85360. */
  85361. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85362. /**
  85363. * Calculate the intercept of a ray on a given axis
  85364. * @param axis to check 'x' | 'y' | 'z'
  85365. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85366. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85367. */
  85368. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85369. /**
  85370. * Checks if ray intersects a mesh
  85371. * @param mesh the mesh to check
  85372. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85373. * @returns picking info of the intersecton
  85374. */
  85375. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85376. /**
  85377. * Checks if ray intersects a mesh
  85378. * @param meshes the meshes to check
  85379. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85380. * @param results array to store result in
  85381. * @returns Array of picking infos
  85382. */
  85383. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85384. private _comparePickingInfo;
  85385. private static smallnum;
  85386. private static rayl;
  85387. /**
  85388. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85389. * @param sega the first point of the segment to test the intersection against
  85390. * @param segb the second point of the segment to test the intersection against
  85391. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85392. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85393. */
  85394. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85395. /**
  85396. * Update the ray from viewport position
  85397. * @param x position
  85398. * @param y y position
  85399. * @param viewportWidth viewport width
  85400. * @param viewportHeight viewport height
  85401. * @param world world matrix
  85402. * @param view view matrix
  85403. * @param projection projection matrix
  85404. * @returns this ray updated
  85405. */
  85406. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85407. /**
  85408. * Creates a ray with origin and direction of 0,0,0
  85409. * @returns the new ray
  85410. */
  85411. static Zero(): Ray;
  85412. /**
  85413. * Creates a new ray from screen space and viewport
  85414. * @param x position
  85415. * @param y y position
  85416. * @param viewportWidth viewport width
  85417. * @param viewportHeight viewport height
  85418. * @param world world matrix
  85419. * @param view view matrix
  85420. * @param projection projection matrix
  85421. * @returns new ray
  85422. */
  85423. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85424. /**
  85425. * 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
  85426. * transformed to the given world matrix.
  85427. * @param origin The origin point
  85428. * @param end The end point
  85429. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85430. * @returns the new ray
  85431. */
  85432. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85433. /**
  85434. * Transforms a ray by a matrix
  85435. * @param ray ray to transform
  85436. * @param matrix matrix to apply
  85437. * @returns the resulting new ray
  85438. */
  85439. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85440. /**
  85441. * Transforms a ray by a matrix
  85442. * @param ray ray to transform
  85443. * @param matrix matrix to apply
  85444. * @param result ray to store result in
  85445. */
  85446. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85447. /**
  85448. * Unproject a ray from screen space to object space
  85449. * @param sourceX defines the screen space x coordinate to use
  85450. * @param sourceY defines the screen space y coordinate to use
  85451. * @param viewportWidth defines the current width of the viewport
  85452. * @param viewportHeight defines the current height of the viewport
  85453. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85454. * @param view defines the view matrix to use
  85455. * @param projection defines the projection matrix to use
  85456. */
  85457. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85458. }
  85459. /**
  85460. * Type used to define predicate used to select faces when a mesh intersection is detected
  85461. */
  85462. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85463. interface Scene {
  85464. /** @hidden */
  85465. _tempPickingRay: Nullable<Ray>;
  85466. /** @hidden */
  85467. _cachedRayForTransform: Ray;
  85468. /** @hidden */
  85469. _pickWithRayInverseMatrix: Matrix;
  85470. /** @hidden */
  85471. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85472. /** @hidden */
  85473. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85474. }
  85475. }
  85476. declare module BABYLON {
  85477. /**
  85478. * Groups all the scene component constants in one place to ease maintenance.
  85479. * @hidden
  85480. */
  85481. export class SceneComponentConstants {
  85482. static readonly NAME_EFFECTLAYER: string;
  85483. static readonly NAME_LAYER: string;
  85484. static readonly NAME_LENSFLARESYSTEM: string;
  85485. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85486. static readonly NAME_PARTICLESYSTEM: string;
  85487. static readonly NAME_GAMEPAD: string;
  85488. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85489. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85490. static readonly NAME_DEPTHRENDERER: string;
  85491. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85492. static readonly NAME_SPRITE: string;
  85493. static readonly NAME_OUTLINERENDERER: string;
  85494. static readonly NAME_PROCEDURALTEXTURE: string;
  85495. static readonly NAME_SHADOWGENERATOR: string;
  85496. static readonly NAME_OCTREE: string;
  85497. static readonly NAME_PHYSICSENGINE: string;
  85498. static readonly NAME_AUDIO: string;
  85499. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85500. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85501. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85502. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85503. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85504. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85505. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85506. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85507. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85508. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85509. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85510. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85511. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85512. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85513. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85514. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85515. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85516. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85517. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85518. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85519. static readonly STEP_AFTERRENDER_AUDIO: number;
  85520. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85521. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85522. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85523. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85524. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85525. static readonly STEP_POINTERMOVE_SPRITE: number;
  85526. static readonly STEP_POINTERDOWN_SPRITE: number;
  85527. static readonly STEP_POINTERUP_SPRITE: number;
  85528. }
  85529. /**
  85530. * This represents a scene component.
  85531. *
  85532. * This is used to decouple the dependency the scene is having on the different workloads like
  85533. * layers, post processes...
  85534. */
  85535. export interface ISceneComponent {
  85536. /**
  85537. * The name of the component. Each component must have a unique name.
  85538. */
  85539. name: string;
  85540. /**
  85541. * The scene the component belongs to.
  85542. */
  85543. scene: Scene;
  85544. /**
  85545. * Register the component to one instance of a scene.
  85546. */
  85547. register(): void;
  85548. /**
  85549. * Rebuilds the elements related to this component in case of
  85550. * context lost for instance.
  85551. */
  85552. rebuild(): void;
  85553. /**
  85554. * Disposes the component and the associated ressources.
  85555. */
  85556. dispose(): void;
  85557. }
  85558. /**
  85559. * This represents a SERIALIZABLE scene component.
  85560. *
  85561. * This extends Scene Component to add Serialization methods on top.
  85562. */
  85563. export interface ISceneSerializableComponent extends ISceneComponent {
  85564. /**
  85565. * Adds all the elements from the container to the scene
  85566. * @param container the container holding the elements
  85567. */
  85568. addFromContainer(container: AbstractScene): void;
  85569. /**
  85570. * Removes all the elements in the container from the scene
  85571. * @param container contains the elements to remove
  85572. * @param dispose if the removed element should be disposed (default: false)
  85573. */
  85574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85575. /**
  85576. * Serializes the component data to the specified json object
  85577. * @param serializationObject The object to serialize to
  85578. */
  85579. serialize(serializationObject: any): void;
  85580. }
  85581. /**
  85582. * Strong typing of a Mesh related stage step action
  85583. */
  85584. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85585. /**
  85586. * Strong typing of a Evaluate Sub Mesh related stage step action
  85587. */
  85588. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85589. /**
  85590. * Strong typing of a Active Mesh related stage step action
  85591. */
  85592. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85593. /**
  85594. * Strong typing of a Camera related stage step action
  85595. */
  85596. export type CameraStageAction = (camera: Camera) => void;
  85597. /**
  85598. * Strong typing of a Camera Frame buffer related stage step action
  85599. */
  85600. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85601. /**
  85602. * Strong typing of a Render Target related stage step action
  85603. */
  85604. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85605. /**
  85606. * Strong typing of a RenderingGroup related stage step action
  85607. */
  85608. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85609. /**
  85610. * Strong typing of a Mesh Render related stage step action
  85611. */
  85612. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85613. /**
  85614. * Strong typing of a simple stage step action
  85615. */
  85616. export type SimpleStageAction = () => void;
  85617. /**
  85618. * Strong typing of a render target action.
  85619. */
  85620. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85621. /**
  85622. * Strong typing of a pointer move action.
  85623. */
  85624. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85625. /**
  85626. * Strong typing of a pointer up/down action.
  85627. */
  85628. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85629. /**
  85630. * Representation of a stage in the scene (Basically a list of ordered steps)
  85631. * @hidden
  85632. */
  85633. export class Stage<T extends Function> extends Array<{
  85634. index: number;
  85635. component: ISceneComponent;
  85636. action: T;
  85637. }> {
  85638. /**
  85639. * Hide ctor from the rest of the world.
  85640. * @param items The items to add.
  85641. */
  85642. private constructor();
  85643. /**
  85644. * Creates a new Stage.
  85645. * @returns A new instance of a Stage
  85646. */
  85647. static Create<T extends Function>(): Stage<T>;
  85648. /**
  85649. * Registers a step in an ordered way in the targeted stage.
  85650. * @param index Defines the position to register the step in
  85651. * @param component Defines the component attached to the step
  85652. * @param action Defines the action to launch during the step
  85653. */
  85654. registerStep(index: number, component: ISceneComponent, action: T): void;
  85655. /**
  85656. * Clears all the steps from the stage.
  85657. */
  85658. clear(): void;
  85659. }
  85660. }
  85661. declare module BABYLON {
  85662. interface Scene {
  85663. /** @hidden */
  85664. _pointerOverSprite: Nullable<Sprite>;
  85665. /** @hidden */
  85666. _pickedDownSprite: Nullable<Sprite>;
  85667. /** @hidden */
  85668. _tempSpritePickingRay: Nullable<Ray>;
  85669. /**
  85670. * All of the sprite managers added to this scene
  85671. * @see http://doc.babylonjs.com/babylon101/sprites
  85672. */
  85673. spriteManagers: Array<ISpriteManager>;
  85674. /**
  85675. * An event triggered when sprites rendering is about to start
  85676. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85677. */
  85678. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85679. /**
  85680. * An event triggered when sprites rendering is done
  85681. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85682. */
  85683. onAfterSpritesRenderingObservable: Observable<Scene>;
  85684. /** @hidden */
  85685. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85686. /** Launch a ray to try to pick a sprite in the scene
  85687. * @param x position on screen
  85688. * @param y position on screen
  85689. * @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
  85690. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85691. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85692. * @returns a PickingInfo
  85693. */
  85694. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85695. /** Use the given ray to pick a sprite in the scene
  85696. * @param ray The ray (in world space) to use to pick meshes
  85697. * @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
  85698. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85699. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85700. * @returns a PickingInfo
  85701. */
  85702. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85703. /** @hidden */
  85704. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85705. /** Launch a ray to try to pick sprites in the scene
  85706. * @param x position on screen
  85707. * @param y position on screen
  85708. * @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
  85709. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85710. * @returns a PickingInfo array
  85711. */
  85712. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85713. /** Use the given ray to pick sprites in the scene
  85714. * @param ray The ray (in world space) to use to pick meshes
  85715. * @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
  85716. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85717. * @returns a PickingInfo array
  85718. */
  85719. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85720. /**
  85721. * Force the sprite under the pointer
  85722. * @param sprite defines the sprite to use
  85723. */
  85724. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85725. /**
  85726. * Gets the sprite under the pointer
  85727. * @returns a Sprite or null if no sprite is under the pointer
  85728. */
  85729. getPointerOverSprite(): Nullable<Sprite>;
  85730. }
  85731. /**
  85732. * Defines the sprite scene component responsible to manage sprites
  85733. * in a given scene.
  85734. */
  85735. export class SpriteSceneComponent implements ISceneComponent {
  85736. /**
  85737. * The component name helpfull to identify the component in the list of scene components.
  85738. */
  85739. readonly name: string;
  85740. /**
  85741. * The scene the component belongs to.
  85742. */
  85743. scene: Scene;
  85744. /** @hidden */
  85745. private _spritePredicate;
  85746. /**
  85747. * Creates a new instance of the component for the given scene
  85748. * @param scene Defines the scene to register the component in
  85749. */
  85750. constructor(scene: Scene);
  85751. /**
  85752. * Registers the component in a given scene
  85753. */
  85754. register(): void;
  85755. /**
  85756. * Rebuilds the elements related to this component in case of
  85757. * context lost for instance.
  85758. */
  85759. rebuild(): void;
  85760. /**
  85761. * Disposes the component and the associated ressources.
  85762. */
  85763. dispose(): void;
  85764. private _pickSpriteButKeepRay;
  85765. private _pointerMove;
  85766. private _pointerDown;
  85767. private _pointerUp;
  85768. }
  85769. }
  85770. declare module BABYLON {
  85771. /** @hidden */
  85772. export var fogFragmentDeclaration: {
  85773. name: string;
  85774. shader: string;
  85775. };
  85776. }
  85777. declare module BABYLON {
  85778. /** @hidden */
  85779. export var fogFragment: {
  85780. name: string;
  85781. shader: string;
  85782. };
  85783. }
  85784. declare module BABYLON {
  85785. /** @hidden */
  85786. export var spritesPixelShader: {
  85787. name: string;
  85788. shader: string;
  85789. };
  85790. }
  85791. declare module BABYLON {
  85792. /** @hidden */
  85793. export var fogVertexDeclaration: {
  85794. name: string;
  85795. shader: string;
  85796. };
  85797. }
  85798. declare module BABYLON {
  85799. /** @hidden */
  85800. export var spritesVertexShader: {
  85801. name: string;
  85802. shader: string;
  85803. };
  85804. }
  85805. declare module BABYLON {
  85806. /**
  85807. * Defines the minimum interface to fullfil in order to be a sprite manager.
  85808. */
  85809. export interface ISpriteManager extends IDisposable {
  85810. /**
  85811. * Restricts the camera to viewing objects with the same layerMask.
  85812. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  85813. */
  85814. layerMask: number;
  85815. /**
  85816. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  85817. */
  85818. isPickable: boolean;
  85819. /**
  85820. * Specifies the rendering group id for this mesh (0 by default)
  85821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  85822. */
  85823. renderingGroupId: number;
  85824. /**
  85825. * Defines the list of sprites managed by the manager.
  85826. */
  85827. sprites: Array<Sprite>;
  85828. /**
  85829. * Tests the intersection of a sprite with a specific ray.
  85830. * @param ray The ray we are sending to test the collision
  85831. * @param camera The camera space we are sending rays in
  85832. * @param predicate A predicate allowing excluding sprites from the list of object to test
  85833. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85834. * @returns picking info or null.
  85835. */
  85836. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85837. /**
  85838. * Intersects the sprites with a ray
  85839. * @param ray defines the ray to intersect with
  85840. * @param camera defines the current active camera
  85841. * @param predicate defines a predicate used to select candidate sprites
  85842. * @returns null if no hit or a PickingInfo array
  85843. */
  85844. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85845. /**
  85846. * Renders the list of sprites on screen.
  85847. */
  85848. render(): void;
  85849. }
  85850. /**
  85851. * Class used to manage multiple sprites on the same spritesheet
  85852. * @see http://doc.babylonjs.com/babylon101/sprites
  85853. */
  85854. export class SpriteManager implements ISpriteManager {
  85855. /** defines the manager's name */
  85856. name: string;
  85857. /** Gets the list of sprites */
  85858. sprites: Sprite[];
  85859. /** Gets or sets the rendering group id (0 by default) */
  85860. renderingGroupId: number;
  85861. /** Gets or sets camera layer mask */
  85862. layerMask: number;
  85863. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  85864. fogEnabled: boolean;
  85865. /** Gets or sets a boolean indicating if the sprites are pickable */
  85866. isPickable: boolean;
  85867. /** Defines the default width of a cell in the spritesheet */
  85868. cellWidth: number;
  85869. /** Defines the default height of a cell in the spritesheet */
  85870. cellHeight: number;
  85871. /** Associative array from JSON sprite data file */
  85872. private _cellData;
  85873. /** Array of sprite names from JSON sprite data file */
  85874. private _spriteMap;
  85875. /** True when packed cell data from JSON file is ready*/
  85876. private _packedAndReady;
  85877. private _textureContent;
  85878. /**
  85879. * An event triggered when the manager is disposed.
  85880. */
  85881. onDisposeObservable: Observable<SpriteManager>;
  85882. private _onDisposeObserver;
  85883. /**
  85884. * Callback called when the manager is disposed
  85885. */
  85886. set onDispose(callback: () => void);
  85887. private _capacity;
  85888. private _fromPacked;
  85889. private _spriteTexture;
  85890. private _epsilon;
  85891. private _scene;
  85892. private _vertexData;
  85893. private _buffer;
  85894. private _vertexBuffers;
  85895. private _indexBuffer;
  85896. private _effectBase;
  85897. private _effectFog;
  85898. /**
  85899. * Gets or sets the spritesheet texture
  85900. */
  85901. get texture(): Texture;
  85902. set texture(value: Texture);
  85903. private _blendMode;
  85904. /**
  85905. * Blend mode use to render the particle, it can be any of
  85906. * the static Constants.ALPHA_x properties provided in this class.
  85907. * Default value is Constants.ALPHA_COMBINE
  85908. */
  85909. get blendMode(): number;
  85910. set blendMode(blendMode: number);
  85911. /** Disables writing to the depth buffer when rendering the sprites.
  85912. * It can be handy to disable depth writing when using textures without alpha channel
  85913. * and setting some specific blend modes.
  85914. */
  85915. disableDepthWrite: boolean;
  85916. /**
  85917. * Creates a new sprite manager
  85918. * @param name defines the manager's name
  85919. * @param imgUrl defines the sprite sheet url
  85920. * @param capacity defines the maximum allowed number of sprites
  85921. * @param cellSize defines the size of a sprite cell
  85922. * @param scene defines the hosting scene
  85923. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  85924. * @param samplingMode defines the smapling mode to use with spritesheet
  85925. * @param fromPacked set to false; do not alter
  85926. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  85927. */
  85928. constructor(
  85929. /** defines the manager's name */
  85930. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  85931. private _makePacked;
  85932. private _appendSpriteVertex;
  85933. private _checkTextureAlpha;
  85934. /**
  85935. * Intersects the sprites with a ray
  85936. * @param ray defines the ray to intersect with
  85937. * @param camera defines the current active camera
  85938. * @param predicate defines a predicate used to select candidate sprites
  85939. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  85940. * @returns null if no hit or a PickingInfo
  85941. */
  85942. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85943. /**
  85944. * Intersects the sprites with a ray
  85945. * @param ray defines the ray to intersect with
  85946. * @param camera defines the current active camera
  85947. * @param predicate defines a predicate used to select candidate sprites
  85948. * @returns null if no hit or a PickingInfo array
  85949. */
  85950. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85951. /**
  85952. * Render all child sprites
  85953. */
  85954. render(): void;
  85955. /**
  85956. * Release associated resources
  85957. */
  85958. dispose(): void;
  85959. }
  85960. }
  85961. declare module BABYLON {
  85962. /** Interface used by value gradients (color, factor, ...) */
  85963. export interface IValueGradient {
  85964. /**
  85965. * Gets or sets the gradient value (between 0 and 1)
  85966. */
  85967. gradient: number;
  85968. }
  85969. /** Class used to store color4 gradient */
  85970. export class ColorGradient implements IValueGradient {
  85971. /**
  85972. * Gets or sets the gradient value (between 0 and 1)
  85973. */
  85974. gradient: number;
  85975. /**
  85976. * Gets or sets first associated color
  85977. */
  85978. color1: Color4;
  85979. /**
  85980. * Gets or sets second associated color
  85981. */
  85982. color2?: Color4 | undefined;
  85983. /**
  85984. * Creates a new color4 gradient
  85985. * @param gradient gets or sets the gradient value (between 0 and 1)
  85986. * @param color1 gets or sets first associated color
  85987. * @param color2 gets or sets first second color
  85988. */
  85989. constructor(
  85990. /**
  85991. * Gets or sets the gradient value (between 0 and 1)
  85992. */
  85993. gradient: number,
  85994. /**
  85995. * Gets or sets first associated color
  85996. */
  85997. color1: Color4,
  85998. /**
  85999. * Gets or sets second associated color
  86000. */
  86001. color2?: Color4 | undefined);
  86002. /**
  86003. * Will get a color picked randomly between color1 and color2.
  86004. * If color2 is undefined then color1 will be used
  86005. * @param result defines the target Color4 to store the result in
  86006. */
  86007. getColorToRef(result: Color4): void;
  86008. }
  86009. /** Class used to store color 3 gradient */
  86010. export class Color3Gradient implements IValueGradient {
  86011. /**
  86012. * Gets or sets the gradient value (between 0 and 1)
  86013. */
  86014. gradient: number;
  86015. /**
  86016. * Gets or sets the associated color
  86017. */
  86018. color: Color3;
  86019. /**
  86020. * Creates a new color3 gradient
  86021. * @param gradient gets or sets the gradient value (between 0 and 1)
  86022. * @param color gets or sets associated color
  86023. */
  86024. constructor(
  86025. /**
  86026. * Gets or sets the gradient value (between 0 and 1)
  86027. */
  86028. gradient: number,
  86029. /**
  86030. * Gets or sets the associated color
  86031. */
  86032. color: Color3);
  86033. }
  86034. /** Class used to store factor gradient */
  86035. export class FactorGradient implements IValueGradient {
  86036. /**
  86037. * Gets or sets the gradient value (between 0 and 1)
  86038. */
  86039. gradient: number;
  86040. /**
  86041. * Gets or sets first associated factor
  86042. */
  86043. factor1: number;
  86044. /**
  86045. * Gets or sets second associated factor
  86046. */
  86047. factor2?: number | undefined;
  86048. /**
  86049. * Creates a new factor gradient
  86050. * @param gradient gets or sets the gradient value (between 0 and 1)
  86051. * @param factor1 gets or sets first associated factor
  86052. * @param factor2 gets or sets second associated factor
  86053. */
  86054. constructor(
  86055. /**
  86056. * Gets or sets the gradient value (between 0 and 1)
  86057. */
  86058. gradient: number,
  86059. /**
  86060. * Gets or sets first associated factor
  86061. */
  86062. factor1: number,
  86063. /**
  86064. * Gets or sets second associated factor
  86065. */
  86066. factor2?: number | undefined);
  86067. /**
  86068. * Will get a number picked randomly between factor1 and factor2.
  86069. * If factor2 is undefined then factor1 will be used
  86070. * @returns the picked number
  86071. */
  86072. getFactor(): number;
  86073. }
  86074. /**
  86075. * Helper used to simplify some generic gradient tasks
  86076. */
  86077. export class GradientHelper {
  86078. /**
  86079. * Gets the current gradient from an array of IValueGradient
  86080. * @param ratio defines the current ratio to get
  86081. * @param gradients defines the array of IValueGradient
  86082. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86083. */
  86084. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86085. }
  86086. }
  86087. declare module BABYLON {
  86088. /**
  86089. * Interface for the size containing width and height
  86090. */
  86091. export interface ISize {
  86092. /**
  86093. * Width
  86094. */
  86095. width: number;
  86096. /**
  86097. * Heighht
  86098. */
  86099. height: number;
  86100. }
  86101. /**
  86102. * Size containing widht and height
  86103. */
  86104. export class Size implements ISize {
  86105. /**
  86106. * Width
  86107. */
  86108. width: number;
  86109. /**
  86110. * Height
  86111. */
  86112. height: number;
  86113. /**
  86114. * Creates a Size object from the given width and height (floats).
  86115. * @param width width of the new size
  86116. * @param height height of the new size
  86117. */
  86118. constructor(width: number, height: number);
  86119. /**
  86120. * Returns a string with the Size width and height
  86121. * @returns a string with the Size width and height
  86122. */
  86123. toString(): string;
  86124. /**
  86125. * "Size"
  86126. * @returns the string "Size"
  86127. */
  86128. getClassName(): string;
  86129. /**
  86130. * Returns the Size hash code.
  86131. * @returns a hash code for a unique width and height
  86132. */
  86133. getHashCode(): number;
  86134. /**
  86135. * Updates the current size from the given one.
  86136. * @param src the given size
  86137. */
  86138. copyFrom(src: Size): void;
  86139. /**
  86140. * Updates in place the current Size from the given floats.
  86141. * @param width width of the new size
  86142. * @param height height of the new size
  86143. * @returns the updated Size.
  86144. */
  86145. copyFromFloats(width: number, height: number): Size;
  86146. /**
  86147. * Updates in place the current Size from the given floats.
  86148. * @param width width to set
  86149. * @param height height to set
  86150. * @returns the updated Size.
  86151. */
  86152. set(width: number, height: number): Size;
  86153. /**
  86154. * Multiplies the width and height by numbers
  86155. * @param w factor to multiple the width by
  86156. * @param h factor to multiple the height by
  86157. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86158. */
  86159. multiplyByFloats(w: number, h: number): Size;
  86160. /**
  86161. * Clones the size
  86162. * @returns a new Size copied from the given one.
  86163. */
  86164. clone(): Size;
  86165. /**
  86166. * True if the current Size and the given one width and height are strictly equal.
  86167. * @param other the other size to compare against
  86168. * @returns True if the current Size and the given one width and height are strictly equal.
  86169. */
  86170. equals(other: Size): boolean;
  86171. /**
  86172. * The surface of the Size : width * height (float).
  86173. */
  86174. get surface(): number;
  86175. /**
  86176. * Create a new size of zero
  86177. * @returns a new Size set to (0.0, 0.0)
  86178. */
  86179. static Zero(): Size;
  86180. /**
  86181. * Sums the width and height of two sizes
  86182. * @param otherSize size to add to this size
  86183. * @returns a new Size set as the addition result of the current Size and the given one.
  86184. */
  86185. add(otherSize: Size): Size;
  86186. /**
  86187. * Subtracts the width and height of two
  86188. * @param otherSize size to subtract to this size
  86189. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86190. */
  86191. subtract(otherSize: Size): Size;
  86192. /**
  86193. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86194. * @param start starting size to lerp between
  86195. * @param end end size to lerp between
  86196. * @param amount amount to lerp between the start and end values
  86197. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86198. */
  86199. static Lerp(start: Size, end: Size, amount: number): Size;
  86200. }
  86201. }
  86202. declare module BABYLON {
  86203. interface ThinEngine {
  86204. /**
  86205. * Creates a dynamic texture
  86206. * @param width defines the width of the texture
  86207. * @param height defines the height of the texture
  86208. * @param generateMipMaps defines if the engine should generate the mip levels
  86209. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86210. * @returns the dynamic texture inside an InternalTexture
  86211. */
  86212. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86213. /**
  86214. * Update the content of a dynamic texture
  86215. * @param texture defines the texture to update
  86216. * @param canvas defines the canvas containing the source
  86217. * @param invertY defines if data must be stored with Y axis inverted
  86218. * @param premulAlpha defines if alpha is stored as premultiplied
  86219. * @param format defines the format of the data
  86220. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86221. */
  86222. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86223. }
  86224. }
  86225. declare module BABYLON {
  86226. /**
  86227. * Helper class used to generate a canvas to manipulate images
  86228. */
  86229. export class CanvasGenerator {
  86230. /**
  86231. * Create a new canvas (or offscreen canvas depending on the context)
  86232. * @param width defines the expected width
  86233. * @param height defines the expected height
  86234. * @return a new canvas or offscreen canvas
  86235. */
  86236. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86237. }
  86238. }
  86239. declare module BABYLON {
  86240. /**
  86241. * A class extending Texture allowing drawing on a texture
  86242. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86243. */
  86244. export class DynamicTexture extends Texture {
  86245. private _generateMipMaps;
  86246. private _canvas;
  86247. private _context;
  86248. private _engine;
  86249. /**
  86250. * Creates a DynamicTexture
  86251. * @param name defines the name of the texture
  86252. * @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
  86253. * @param scene defines the scene where you want the texture
  86254. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86255. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86256. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86257. */
  86258. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86259. /**
  86260. * Get the current class name of the texture useful for serialization or dynamic coding.
  86261. * @returns "DynamicTexture"
  86262. */
  86263. getClassName(): string;
  86264. /**
  86265. * Gets the current state of canRescale
  86266. */
  86267. get canRescale(): boolean;
  86268. private _recreate;
  86269. /**
  86270. * Scales the texture
  86271. * @param ratio the scale factor to apply to both width and height
  86272. */
  86273. scale(ratio: number): void;
  86274. /**
  86275. * Resizes the texture
  86276. * @param width the new width
  86277. * @param height the new height
  86278. */
  86279. scaleTo(width: number, height: number): void;
  86280. /**
  86281. * Gets the context of the canvas used by the texture
  86282. * @returns the canvas context of the dynamic texture
  86283. */
  86284. getContext(): CanvasRenderingContext2D;
  86285. /**
  86286. * Clears the texture
  86287. */
  86288. clear(): void;
  86289. /**
  86290. * Updates the texture
  86291. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86292. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86293. */
  86294. update(invertY?: boolean, premulAlpha?: boolean): void;
  86295. /**
  86296. * Draws text onto the texture
  86297. * @param text defines the text to be drawn
  86298. * @param x defines the placement of the text from the left
  86299. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86300. * @param font defines the font to be used with font-style, font-size, font-name
  86301. * @param color defines the color used for the text
  86302. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86303. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86304. * @param update defines whether texture is immediately update (default is true)
  86305. */
  86306. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86307. /**
  86308. * Clones the texture
  86309. * @returns the clone of the texture.
  86310. */
  86311. clone(): DynamicTexture;
  86312. /**
  86313. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86314. * @returns a serialized dynamic texture object
  86315. */
  86316. serialize(): any;
  86317. /** @hidden */
  86318. _rebuild(): void;
  86319. }
  86320. }
  86321. declare module BABYLON {
  86322. interface ThinEngine {
  86323. /**
  86324. * Creates a raw texture
  86325. * @param data defines the data to store in the texture
  86326. * @param width defines the width of the texture
  86327. * @param height defines the height of the texture
  86328. * @param format defines the format of the data
  86329. * @param generateMipMaps defines if the engine should generate the mip levels
  86330. * @param invertY defines if data must be stored with Y axis inverted
  86331. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86332. * @param compression defines the compression used (null by default)
  86333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86334. * @returns the raw texture inside an InternalTexture
  86335. */
  86336. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86337. /**
  86338. * Update a raw texture
  86339. * @param texture defines the texture to update
  86340. * @param data defines the data to store in the texture
  86341. * @param format defines the format of the data
  86342. * @param invertY defines if data must be stored with Y axis inverted
  86343. */
  86344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86345. /**
  86346. * Update a raw texture
  86347. * @param texture defines the texture to update
  86348. * @param data defines the data to store in the texture
  86349. * @param format defines the format of the data
  86350. * @param invertY defines if data must be stored with Y axis inverted
  86351. * @param compression defines the compression used (null by default)
  86352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86353. */
  86354. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86355. /**
  86356. * Creates a new raw cube texture
  86357. * @param data defines the array of data to use to create each face
  86358. * @param size defines the size of the textures
  86359. * @param format defines the format of the data
  86360. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86361. * @param generateMipMaps defines if the engine should generate the mip levels
  86362. * @param invertY defines if data must be stored with Y axis inverted
  86363. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86364. * @param compression defines the compression used (null by default)
  86365. * @returns the cube texture as an InternalTexture
  86366. */
  86367. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86368. /**
  86369. * Update a raw cube texture
  86370. * @param texture defines the texture to udpdate
  86371. * @param data defines the data to store
  86372. * @param format defines the data format
  86373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86374. * @param invertY defines if data must be stored with Y axis inverted
  86375. */
  86376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86377. /**
  86378. * Update a raw cube texture
  86379. * @param texture defines the texture to udpdate
  86380. * @param data defines the data to store
  86381. * @param format defines the data format
  86382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86383. * @param invertY defines if data must be stored with Y axis inverted
  86384. * @param compression defines the compression used (null by default)
  86385. */
  86386. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86387. /**
  86388. * Update a raw cube texture
  86389. * @param texture defines the texture to udpdate
  86390. * @param data defines the data to store
  86391. * @param format defines the data format
  86392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86393. * @param invertY defines if data must be stored with Y axis inverted
  86394. * @param compression defines the compression used (null by default)
  86395. * @param level defines which level of the texture to update
  86396. */
  86397. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86398. /**
  86399. * Creates a new raw cube texture from a specified url
  86400. * @param url defines the url where the data is located
  86401. * @param scene defines the current scene
  86402. * @param size defines the size of the textures
  86403. * @param format defines the format of the data
  86404. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86405. * @param noMipmap defines if the engine should avoid generating the mip levels
  86406. * @param callback defines a callback used to extract texture data from loaded data
  86407. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86408. * @param onLoad defines a callback called when texture is loaded
  86409. * @param onError defines a callback called if there is an error
  86410. * @returns the cube texture as an InternalTexture
  86411. */
  86412. createRawCubeTextureFromUrl(url: string, scene: 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;
  86413. /**
  86414. * Creates a new raw cube texture from a specified url
  86415. * @param url defines the url where the data is located
  86416. * @param scene defines the current scene
  86417. * @param size defines the size of the textures
  86418. * @param format defines the format of the data
  86419. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86420. * @param noMipmap defines if the engine should avoid generating the mip levels
  86421. * @param callback defines a callback used to extract texture data from loaded data
  86422. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86423. * @param onLoad defines a callback called when texture is loaded
  86424. * @param onError defines a callback called if there is an error
  86425. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86426. * @param invertY defines if data must be stored with Y axis inverted
  86427. * @returns the cube texture as an InternalTexture
  86428. */
  86429. createRawCubeTextureFromUrl(url: string, scene: 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;
  86430. /**
  86431. * Creates a new raw 3D texture
  86432. * @param data defines the data used to create the texture
  86433. * @param width defines the width of the texture
  86434. * @param height defines the height of the texture
  86435. * @param depth defines the depth of the texture
  86436. * @param format defines the format of the texture
  86437. * @param generateMipMaps defines if the engine must generate mip levels
  86438. * @param invertY defines if data must be stored with Y axis inverted
  86439. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86440. * @param compression defines the compressed used (can be null)
  86441. * @param textureType defines the compressed used (can be null)
  86442. * @returns a new raw 3D texture (stored in an InternalTexture)
  86443. */
  86444. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86445. /**
  86446. * Update a raw 3D texture
  86447. * @param texture defines the texture to update
  86448. * @param data defines the data to store
  86449. * @param format defines the data format
  86450. * @param invertY defines if data must be stored with Y axis inverted
  86451. */
  86452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86453. /**
  86454. * Update a raw 3D texture
  86455. * @param texture defines the texture to update
  86456. * @param data defines the data to store
  86457. * @param format defines the data format
  86458. * @param invertY defines if data must be stored with Y axis inverted
  86459. * @param compression defines the used compression (can be null)
  86460. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86461. */
  86462. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86463. /**
  86464. * Creates a new raw 2D array texture
  86465. * @param data defines the data used to create the texture
  86466. * @param width defines the width of the texture
  86467. * @param height defines the height of the texture
  86468. * @param depth defines the number of layers of the texture
  86469. * @param format defines the format of the texture
  86470. * @param generateMipMaps defines if the engine must generate mip levels
  86471. * @param invertY defines if data must be stored with Y axis inverted
  86472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86473. * @param compression defines the compressed used (can be null)
  86474. * @param textureType defines the compressed used (can be null)
  86475. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86476. */
  86477. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86478. /**
  86479. * Update a raw 2D array texture
  86480. * @param texture defines the texture to update
  86481. * @param data defines the data to store
  86482. * @param format defines the data format
  86483. * @param invertY defines if data must be stored with Y axis inverted
  86484. */
  86485. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86486. /**
  86487. * Update a raw 2D array texture
  86488. * @param texture defines the texture to update
  86489. * @param data defines the data to store
  86490. * @param format defines the data format
  86491. * @param invertY defines if data must be stored with Y axis inverted
  86492. * @param compression defines the used compression (can be null)
  86493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86494. */
  86495. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86496. }
  86497. }
  86498. declare module BABYLON {
  86499. /**
  86500. * Raw texture can help creating a texture directly from an array of data.
  86501. * This can be super useful if you either get the data from an uncompressed source or
  86502. * if you wish to create your texture pixel by pixel.
  86503. */
  86504. export class RawTexture extends Texture {
  86505. /**
  86506. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86507. */
  86508. format: number;
  86509. private _engine;
  86510. /**
  86511. * Instantiates a new RawTexture.
  86512. * Raw texture can help creating a texture directly from an array of data.
  86513. * This can be super useful if you either get the data from an uncompressed source or
  86514. * if you wish to create your texture pixel by pixel.
  86515. * @param data define the array of data to use to create the texture
  86516. * @param width define the width of the texture
  86517. * @param height define the height of the texture
  86518. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86519. * @param scene define the scene the texture belongs to
  86520. * @param generateMipMaps define whether mip maps should be generated or not
  86521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86523. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86524. */
  86525. constructor(data: ArrayBufferView, width: number, height: number,
  86526. /**
  86527. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86528. */
  86529. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86530. /**
  86531. * Updates the texture underlying data.
  86532. * @param data Define the new data of the texture
  86533. */
  86534. update(data: ArrayBufferView): void;
  86535. /**
  86536. * Creates a luminance texture from some data.
  86537. * @param data Define the texture data
  86538. * @param width Define the width of the texture
  86539. * @param height Define the height of the texture
  86540. * @param scene Define the scene the texture belongs to
  86541. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86542. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86543. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86544. * @returns the luminance texture
  86545. */
  86546. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86547. /**
  86548. * Creates a luminance alpha texture from some data.
  86549. * @param data Define the texture data
  86550. * @param width Define the width of the texture
  86551. * @param height Define the height of the texture
  86552. * @param scene Define the scene the texture belongs to
  86553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86556. * @returns the luminance alpha texture
  86557. */
  86558. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86559. /**
  86560. * Creates an alpha texture from some data.
  86561. * @param data Define the texture data
  86562. * @param width Define the width of the texture
  86563. * @param height Define the height of the texture
  86564. * @param scene Define the scene the texture belongs to
  86565. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86566. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86567. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86568. * @returns the alpha texture
  86569. */
  86570. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86571. /**
  86572. * Creates a RGB texture from some data.
  86573. * @param data Define the texture data
  86574. * @param width Define the width of the texture
  86575. * @param height Define the height of the texture
  86576. * @param scene Define the scene the texture belongs to
  86577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86580. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86581. * @returns the RGB alpha texture
  86582. */
  86583. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86584. /**
  86585. * Creates a RGBA texture from some data.
  86586. * @param data Define the texture data
  86587. * @param width Define the width of the texture
  86588. * @param height Define the height of the texture
  86589. * @param scene Define the scene the texture belongs to
  86590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86593. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86594. * @returns the RGBA texture
  86595. */
  86596. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86597. /**
  86598. * Creates a R texture from some data.
  86599. * @param data Define the texture data
  86600. * @param width Define the width of the texture
  86601. * @param height Define the height of the texture
  86602. * @param scene Define the scene the texture belongs to
  86603. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86604. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86605. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86606. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86607. * @returns the R texture
  86608. */
  86609. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86610. }
  86611. }
  86612. declare module BABYLON {
  86613. interface AbstractScene {
  86614. /**
  86615. * The list of procedural textures added to the scene
  86616. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86617. */
  86618. proceduralTextures: Array<ProceduralTexture>;
  86619. }
  86620. /**
  86621. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86622. * in a given scene.
  86623. */
  86624. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86625. /**
  86626. * The component name helpfull to identify the component in the list of scene components.
  86627. */
  86628. readonly name: string;
  86629. /**
  86630. * The scene the component belongs to.
  86631. */
  86632. scene: Scene;
  86633. /**
  86634. * Creates a new instance of the component for the given scene
  86635. * @param scene Defines the scene to register the component in
  86636. */
  86637. constructor(scene: Scene);
  86638. /**
  86639. * Registers the component in a given scene
  86640. */
  86641. register(): void;
  86642. /**
  86643. * Rebuilds the elements related to this component in case of
  86644. * context lost for instance.
  86645. */
  86646. rebuild(): void;
  86647. /**
  86648. * Disposes the component and the associated ressources.
  86649. */
  86650. dispose(): void;
  86651. private _beforeClear;
  86652. }
  86653. }
  86654. declare module BABYLON {
  86655. interface ThinEngine {
  86656. /**
  86657. * Creates a new render target cube texture
  86658. * @param size defines the size of the texture
  86659. * @param options defines the options used to create the texture
  86660. * @returns a new render target cube texture stored in an InternalTexture
  86661. */
  86662. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86663. }
  86664. }
  86665. declare module BABYLON {
  86666. /** @hidden */
  86667. export var proceduralVertexShader: {
  86668. name: string;
  86669. shader: string;
  86670. };
  86671. }
  86672. declare module BABYLON {
  86673. /**
  86674. * 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.
  86675. * This is the base class of any Procedural texture and contains most of the shareable code.
  86676. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86677. */
  86678. export class ProceduralTexture extends Texture {
  86679. isCube: boolean;
  86680. /**
  86681. * Define if the texture is enabled or not (disabled texture will not render)
  86682. */
  86683. isEnabled: boolean;
  86684. /**
  86685. * Define if the texture must be cleared before rendering (default is true)
  86686. */
  86687. autoClear: boolean;
  86688. /**
  86689. * Callback called when the texture is generated
  86690. */
  86691. onGenerated: () => void;
  86692. /**
  86693. * Event raised when the texture is generated
  86694. */
  86695. onGeneratedObservable: Observable<ProceduralTexture>;
  86696. /** @hidden */
  86697. _generateMipMaps: boolean;
  86698. /** @hidden **/
  86699. _effect: Effect;
  86700. /** @hidden */
  86701. _textures: {
  86702. [key: string]: Texture;
  86703. };
  86704. /** @hidden */
  86705. protected _fallbackTexture: Nullable<Texture>;
  86706. private _size;
  86707. private _currentRefreshId;
  86708. private _frameId;
  86709. private _refreshRate;
  86710. private _vertexBuffers;
  86711. private _indexBuffer;
  86712. private _uniforms;
  86713. private _samplers;
  86714. private _fragment;
  86715. private _floats;
  86716. private _ints;
  86717. private _floatsArrays;
  86718. private _colors3;
  86719. private _colors4;
  86720. private _vectors2;
  86721. private _vectors3;
  86722. private _matrices;
  86723. private _fallbackTextureUsed;
  86724. private _engine;
  86725. private _cachedDefines;
  86726. private _contentUpdateId;
  86727. private _contentData;
  86728. /**
  86729. * Instantiates a new procedural texture.
  86730. * 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.
  86731. * This is the base class of any Procedural texture and contains most of the shareable code.
  86732. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86733. * @param name Define the name of the texture
  86734. * @param size Define the size of the texture to create
  86735. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86736. * @param scene Define the scene the texture belongs to
  86737. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86738. * @param generateMipMaps Define if the texture should creates mip maps or not
  86739. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86740. */
  86741. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86742. /**
  86743. * The effect that is created when initializing the post process.
  86744. * @returns The created effect corresponding the the postprocess.
  86745. */
  86746. getEffect(): Effect;
  86747. /**
  86748. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86749. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86750. */
  86751. getContent(): Nullable<ArrayBufferView>;
  86752. private _createIndexBuffer;
  86753. /** @hidden */
  86754. _rebuild(): void;
  86755. /**
  86756. * Resets the texture in order to recreate its associated resources.
  86757. * This can be called in case of context loss
  86758. */
  86759. reset(): void;
  86760. protected _getDefines(): string;
  86761. /**
  86762. * Is the texture ready to be used ? (rendered at least once)
  86763. * @returns true if ready, otherwise, false.
  86764. */
  86765. isReady(): boolean;
  86766. /**
  86767. * Resets the refresh counter of the texture and start bak from scratch.
  86768. * Could be useful to regenerate the texture if it is setup to render only once.
  86769. */
  86770. resetRefreshCounter(): void;
  86771. /**
  86772. * Set the fragment shader to use in order to render the texture.
  86773. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86774. */
  86775. setFragment(fragment: any): void;
  86776. /**
  86777. * Define the refresh rate of the texture or the rendering frequency.
  86778. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86779. */
  86780. get refreshRate(): number;
  86781. set refreshRate(value: number);
  86782. /** @hidden */
  86783. _shouldRender(): boolean;
  86784. /**
  86785. * Get the size the texture is rendering at.
  86786. * @returns the size (texture is always squared)
  86787. */
  86788. getRenderSize(): number;
  86789. /**
  86790. * Resize the texture to new value.
  86791. * @param size Define the new size the texture should have
  86792. * @param generateMipMaps Define whether the new texture should create mip maps
  86793. */
  86794. resize(size: number, generateMipMaps: boolean): void;
  86795. private _checkUniform;
  86796. /**
  86797. * Set a texture in the shader program used to render.
  86798. * @param name Define the name of the uniform samplers as defined in the shader
  86799. * @param texture Define the texture to bind to this sampler
  86800. * @return the texture itself allowing "fluent" like uniform updates
  86801. */
  86802. setTexture(name: string, texture: Texture): ProceduralTexture;
  86803. /**
  86804. * Set a float in the shader.
  86805. * @param name Define the name of the uniform as defined in the shader
  86806. * @param value Define the value to give to the uniform
  86807. * @return the texture itself allowing "fluent" like uniform updates
  86808. */
  86809. setFloat(name: string, value: number): ProceduralTexture;
  86810. /**
  86811. * Set a int in the shader.
  86812. * @param name Define the name of the uniform as defined in the shader
  86813. * @param value Define the value to give to the uniform
  86814. * @return the texture itself allowing "fluent" like uniform updates
  86815. */
  86816. setInt(name: string, value: number): ProceduralTexture;
  86817. /**
  86818. * Set an array of floats in the shader.
  86819. * @param name Define the name of the uniform as defined in the shader
  86820. * @param value Define the value to give to the uniform
  86821. * @return the texture itself allowing "fluent" like uniform updates
  86822. */
  86823. setFloats(name: string, value: number[]): ProceduralTexture;
  86824. /**
  86825. * Set a vec3 in the shader from a Color3.
  86826. * @param name Define the name of the uniform as defined in the shader
  86827. * @param value Define the value to give to the uniform
  86828. * @return the texture itself allowing "fluent" like uniform updates
  86829. */
  86830. setColor3(name: string, value: Color3): ProceduralTexture;
  86831. /**
  86832. * Set a vec4 in the shader from a Color4.
  86833. * @param name Define the name of the uniform as defined in the shader
  86834. * @param value Define the value to give to the uniform
  86835. * @return the texture itself allowing "fluent" like uniform updates
  86836. */
  86837. setColor4(name: string, value: Color4): ProceduralTexture;
  86838. /**
  86839. * Set a vec2 in the shader from a Vector2.
  86840. * @param name Define the name of the uniform as defined in the shader
  86841. * @param value Define the value to give to the uniform
  86842. * @return the texture itself allowing "fluent" like uniform updates
  86843. */
  86844. setVector2(name: string, value: Vector2): ProceduralTexture;
  86845. /**
  86846. * Set a vec3 in the shader from a Vector3.
  86847. * @param name Define the name of the uniform as defined in the shader
  86848. * @param value Define the value to give to the uniform
  86849. * @return the texture itself allowing "fluent" like uniform updates
  86850. */
  86851. setVector3(name: string, value: Vector3): ProceduralTexture;
  86852. /**
  86853. * Set a mat4 in the shader from a MAtrix.
  86854. * @param name Define the name of the uniform as defined in the shader
  86855. * @param value Define the value to give to the uniform
  86856. * @return the texture itself allowing "fluent" like uniform updates
  86857. */
  86858. setMatrix(name: string, value: Matrix): ProceduralTexture;
  86859. /**
  86860. * Render the texture to its associated render target.
  86861. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  86862. */
  86863. render(useCameraPostProcess?: boolean): void;
  86864. /**
  86865. * Clone the texture.
  86866. * @returns the cloned texture
  86867. */
  86868. clone(): ProceduralTexture;
  86869. /**
  86870. * Dispose the texture and release its asoociated resources.
  86871. */
  86872. dispose(): void;
  86873. }
  86874. }
  86875. declare module BABYLON {
  86876. /**
  86877. * This represents the base class for particle system in Babylon.
  86878. * 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.
  86879. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86880. * @example https://doc.babylonjs.com/babylon101/particles
  86881. */
  86882. export class BaseParticleSystem {
  86883. /**
  86884. * Source color is added to the destination color without alpha affecting the result
  86885. */
  86886. static BLENDMODE_ONEONE: number;
  86887. /**
  86888. * Blend current color and particle color using particle’s alpha
  86889. */
  86890. static BLENDMODE_STANDARD: number;
  86891. /**
  86892. * Add current color and particle color multiplied by particle’s alpha
  86893. */
  86894. static BLENDMODE_ADD: number;
  86895. /**
  86896. * Multiply current color with particle color
  86897. */
  86898. static BLENDMODE_MULTIPLY: number;
  86899. /**
  86900. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86901. */
  86902. static BLENDMODE_MULTIPLYADD: number;
  86903. /**
  86904. * List of animations used by the particle system.
  86905. */
  86906. animations: Animation[];
  86907. /**
  86908. * Gets or sets the unique id of the particle system
  86909. */
  86910. uniqueId: number;
  86911. /**
  86912. * The id of the Particle system.
  86913. */
  86914. id: string;
  86915. /**
  86916. * The friendly name of the Particle system.
  86917. */
  86918. name: string;
  86919. /**
  86920. * Snippet ID if the particle system was created from the snippet server
  86921. */
  86922. snippetId: string;
  86923. /**
  86924. * The rendering group used by the Particle system to chose when to render.
  86925. */
  86926. renderingGroupId: number;
  86927. /**
  86928. * The emitter represents the Mesh or position we are attaching the particle system to.
  86929. */
  86930. emitter: Nullable<AbstractMesh | Vector3>;
  86931. /**
  86932. * The maximum number of particles to emit per frame
  86933. */
  86934. emitRate: number;
  86935. /**
  86936. * If you want to launch only a few particles at once, that can be done, as well.
  86937. */
  86938. manualEmitCount: number;
  86939. /**
  86940. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86941. */
  86942. updateSpeed: number;
  86943. /**
  86944. * The amount of time the particle system is running (depends of the overall update speed).
  86945. */
  86946. targetStopDuration: number;
  86947. /**
  86948. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86949. */
  86950. disposeOnStop: boolean;
  86951. /**
  86952. * Minimum power of emitting particles.
  86953. */
  86954. minEmitPower: number;
  86955. /**
  86956. * Maximum power of emitting particles.
  86957. */
  86958. maxEmitPower: number;
  86959. /**
  86960. * Minimum life time of emitting particles.
  86961. */
  86962. minLifeTime: number;
  86963. /**
  86964. * Maximum life time of emitting particles.
  86965. */
  86966. maxLifeTime: number;
  86967. /**
  86968. * Minimum Size of emitting particles.
  86969. */
  86970. minSize: number;
  86971. /**
  86972. * Maximum Size of emitting particles.
  86973. */
  86974. maxSize: number;
  86975. /**
  86976. * Minimum scale of emitting particles on X axis.
  86977. */
  86978. minScaleX: number;
  86979. /**
  86980. * Maximum scale of emitting particles on X axis.
  86981. */
  86982. maxScaleX: number;
  86983. /**
  86984. * Minimum scale of emitting particles on Y axis.
  86985. */
  86986. minScaleY: number;
  86987. /**
  86988. * Maximum scale of emitting particles on Y axis.
  86989. */
  86990. maxScaleY: number;
  86991. /**
  86992. * Gets or sets the minimal initial rotation in radians.
  86993. */
  86994. minInitialRotation: number;
  86995. /**
  86996. * Gets or sets the maximal initial rotation in radians.
  86997. */
  86998. maxInitialRotation: number;
  86999. /**
  87000. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87001. */
  87002. minAngularSpeed: number;
  87003. /**
  87004. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87005. */
  87006. maxAngularSpeed: number;
  87007. /**
  87008. * The texture used to render each particle. (this can be a spritesheet)
  87009. */
  87010. particleTexture: Nullable<Texture>;
  87011. /**
  87012. * The layer mask we are rendering the particles through.
  87013. */
  87014. layerMask: number;
  87015. /**
  87016. * This can help using your own shader to render the particle system.
  87017. * The according effect will be created
  87018. */
  87019. customShader: any;
  87020. /**
  87021. * By default particle system starts as soon as they are created. This prevents the
  87022. * automatic start to happen and let you decide when to start emitting particles.
  87023. */
  87024. preventAutoStart: boolean;
  87025. private _noiseTexture;
  87026. /**
  87027. * Gets or sets a texture used to add random noise to particle positions
  87028. */
  87029. get noiseTexture(): Nullable<ProceduralTexture>;
  87030. set noiseTexture(value: Nullable<ProceduralTexture>);
  87031. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87032. noiseStrength: Vector3;
  87033. /**
  87034. * Callback triggered when the particle animation is ending.
  87035. */
  87036. onAnimationEnd: Nullable<() => void>;
  87037. /**
  87038. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87039. */
  87040. blendMode: number;
  87041. /**
  87042. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87043. * to override the particles.
  87044. */
  87045. forceDepthWrite: boolean;
  87046. /** 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 */
  87047. preWarmCycles: number;
  87048. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87049. preWarmStepOffset: number;
  87050. /**
  87051. * 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)
  87052. */
  87053. spriteCellChangeSpeed: number;
  87054. /**
  87055. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87056. */
  87057. startSpriteCellID: number;
  87058. /**
  87059. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87060. */
  87061. endSpriteCellID: number;
  87062. /**
  87063. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87064. */
  87065. spriteCellWidth: number;
  87066. /**
  87067. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87068. */
  87069. spriteCellHeight: number;
  87070. /**
  87071. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87072. */
  87073. spriteRandomStartCell: boolean;
  87074. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87075. translationPivot: Vector2;
  87076. /** @hidden */
  87077. protected _isAnimationSheetEnabled: boolean;
  87078. /**
  87079. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87080. */
  87081. beginAnimationOnStart: boolean;
  87082. /**
  87083. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87084. */
  87085. beginAnimationFrom: number;
  87086. /**
  87087. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87088. */
  87089. beginAnimationTo: number;
  87090. /**
  87091. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87092. */
  87093. beginAnimationLoop: boolean;
  87094. /**
  87095. * Gets or sets a world offset applied to all particles
  87096. */
  87097. worldOffset: Vector3;
  87098. /**
  87099. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87100. */
  87101. get isAnimationSheetEnabled(): boolean;
  87102. set isAnimationSheetEnabled(value: boolean);
  87103. /**
  87104. * Get hosting scene
  87105. * @returns the scene
  87106. */
  87107. getScene(): Scene;
  87108. /**
  87109. * You can use gravity if you want to give an orientation to your particles.
  87110. */
  87111. gravity: Vector3;
  87112. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87113. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87114. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87115. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87116. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87117. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87118. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87119. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87120. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87121. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87122. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87123. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87124. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87125. /**
  87126. * Defines the delay in milliseconds before starting the system (0 by default)
  87127. */
  87128. startDelay: number;
  87129. /**
  87130. * Gets the current list of drag gradients.
  87131. * You must use addDragGradient and removeDragGradient to udpate this list
  87132. * @returns the list of drag gradients
  87133. */
  87134. getDragGradients(): Nullable<Array<FactorGradient>>;
  87135. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87136. limitVelocityDamping: number;
  87137. /**
  87138. * Gets the current list of limit velocity gradients.
  87139. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87140. * @returns the list of limit velocity gradients
  87141. */
  87142. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87143. /**
  87144. * Gets the current list of color gradients.
  87145. * You must use addColorGradient and removeColorGradient to udpate this list
  87146. * @returns the list of color gradients
  87147. */
  87148. getColorGradients(): Nullable<Array<ColorGradient>>;
  87149. /**
  87150. * Gets the current list of size gradients.
  87151. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87152. * @returns the list of size gradients
  87153. */
  87154. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87155. /**
  87156. * Gets the current list of color remap gradients.
  87157. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87158. * @returns the list of color remap gradients
  87159. */
  87160. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87161. /**
  87162. * Gets the current list of alpha remap gradients.
  87163. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87164. * @returns the list of alpha remap gradients
  87165. */
  87166. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87167. /**
  87168. * Gets the current list of life time gradients.
  87169. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87170. * @returns the list of life time gradients
  87171. */
  87172. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87173. /**
  87174. * Gets the current list of angular speed gradients.
  87175. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87176. * @returns the list of angular speed gradients
  87177. */
  87178. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87179. /**
  87180. * Gets the current list of velocity gradients.
  87181. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87182. * @returns the list of velocity gradients
  87183. */
  87184. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87185. /**
  87186. * Gets the current list of start size gradients.
  87187. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87188. * @returns the list of start size gradients
  87189. */
  87190. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87191. /**
  87192. * Gets the current list of emit rate gradients.
  87193. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87194. * @returns the list of emit rate gradients
  87195. */
  87196. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87197. /**
  87198. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87200. */
  87201. get direction1(): Vector3;
  87202. set direction1(value: Vector3);
  87203. /**
  87204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87206. */
  87207. get direction2(): Vector3;
  87208. set direction2(value: Vector3);
  87209. /**
  87210. * 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.
  87211. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87212. */
  87213. get minEmitBox(): Vector3;
  87214. set minEmitBox(value: Vector3);
  87215. /**
  87216. * 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.
  87217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87218. */
  87219. get maxEmitBox(): Vector3;
  87220. set maxEmitBox(value: Vector3);
  87221. /**
  87222. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87223. */
  87224. color1: Color4;
  87225. /**
  87226. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87227. */
  87228. color2: Color4;
  87229. /**
  87230. * Color the particle will have at the end of its lifetime
  87231. */
  87232. colorDead: Color4;
  87233. /**
  87234. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87235. */
  87236. textureMask: Color4;
  87237. /**
  87238. * The particle emitter type defines the emitter used by the particle system.
  87239. * It can be for example box, sphere, or cone...
  87240. */
  87241. particleEmitterType: IParticleEmitterType;
  87242. /** @hidden */
  87243. _isSubEmitter: boolean;
  87244. /**
  87245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87247. */
  87248. billboardMode: number;
  87249. protected _isBillboardBased: boolean;
  87250. /**
  87251. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87252. */
  87253. get isBillboardBased(): boolean;
  87254. set isBillboardBased(value: boolean);
  87255. /**
  87256. * The scene the particle system belongs to.
  87257. */
  87258. protected _scene: Scene;
  87259. /**
  87260. * Local cache of defines for image processing.
  87261. */
  87262. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87263. /**
  87264. * Default configuration related to image processing available in the standard Material.
  87265. */
  87266. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87267. /**
  87268. * Gets the image processing configuration used either in this material.
  87269. */
  87270. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87271. /**
  87272. * Sets the Default image processing configuration used either in the this material.
  87273. *
  87274. * If sets to null, the scene one is in use.
  87275. */
  87276. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87277. /**
  87278. * Attaches a new image processing configuration to the Standard Material.
  87279. * @param configuration
  87280. */
  87281. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87282. /** @hidden */
  87283. protected _reset(): void;
  87284. /** @hidden */
  87285. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87286. /**
  87287. * Instantiates a particle system.
  87288. * 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.
  87289. * @param name The name of the particle system
  87290. */
  87291. constructor(name: string);
  87292. /**
  87293. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87294. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87295. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87296. * @returns the emitter
  87297. */
  87298. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87299. /**
  87300. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87301. * @param radius The radius of the hemisphere to emit from
  87302. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87303. * @returns the emitter
  87304. */
  87305. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87306. /**
  87307. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87308. * @param radius The radius of the sphere to emit from
  87309. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87310. * @returns the emitter
  87311. */
  87312. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87313. /**
  87314. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87315. * @param radius The radius of the sphere to emit from
  87316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87318. * @returns the emitter
  87319. */
  87320. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87321. /**
  87322. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87323. * @param radius The radius of the emission cylinder
  87324. * @param height The height of the emission cylinder
  87325. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87326. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87327. * @returns the emitter
  87328. */
  87329. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87330. /**
  87331. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87332. * @param radius The radius of the cylinder to emit from
  87333. * @param height The height of the emission cylinder
  87334. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87335. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87336. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87337. * @returns the emitter
  87338. */
  87339. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87340. /**
  87341. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87342. * @param radius The radius of the cone to emit from
  87343. * @param angle The base angle of the cone
  87344. * @returns the emitter
  87345. */
  87346. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87347. /**
  87348. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87351. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87352. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87353. * @returns the emitter
  87354. */
  87355. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87356. }
  87357. }
  87358. declare module BABYLON {
  87359. /**
  87360. * Type of sub emitter
  87361. */
  87362. export enum SubEmitterType {
  87363. /**
  87364. * Attached to the particle over it's lifetime
  87365. */
  87366. ATTACHED = 0,
  87367. /**
  87368. * Created when the particle dies
  87369. */
  87370. END = 1
  87371. }
  87372. /**
  87373. * Sub emitter class used to emit particles from an existing particle
  87374. */
  87375. export class SubEmitter {
  87376. /**
  87377. * the particle system to be used by the sub emitter
  87378. */
  87379. particleSystem: ParticleSystem;
  87380. /**
  87381. * Type of the submitter (Default: END)
  87382. */
  87383. type: SubEmitterType;
  87384. /**
  87385. * 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)
  87386. * Note: This only is supported when using an emitter of type Mesh
  87387. */
  87388. inheritDirection: boolean;
  87389. /**
  87390. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87391. */
  87392. inheritedVelocityAmount: number;
  87393. /**
  87394. * Creates a sub emitter
  87395. * @param particleSystem the particle system to be used by the sub emitter
  87396. */
  87397. constructor(
  87398. /**
  87399. * the particle system to be used by the sub emitter
  87400. */
  87401. particleSystem: ParticleSystem);
  87402. /**
  87403. * Clones the sub emitter
  87404. * @returns the cloned sub emitter
  87405. */
  87406. clone(): SubEmitter;
  87407. /**
  87408. * Serialize current object to a JSON object
  87409. * @returns the serialized object
  87410. */
  87411. serialize(): any;
  87412. /** @hidden */
  87413. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87414. /**
  87415. * Creates a new SubEmitter from a serialized JSON version
  87416. * @param serializationObject defines the JSON object to read from
  87417. * @param scene defines the hosting scene
  87418. * @param rootUrl defines the rootUrl for data loading
  87419. * @returns a new SubEmitter
  87420. */
  87421. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87422. /** Release associated resources */
  87423. dispose(): void;
  87424. }
  87425. }
  87426. declare module BABYLON {
  87427. /** @hidden */
  87428. export var imageProcessingDeclaration: {
  87429. name: string;
  87430. shader: string;
  87431. };
  87432. }
  87433. declare module BABYLON {
  87434. /** @hidden */
  87435. export var imageProcessingFunctions: {
  87436. name: string;
  87437. shader: string;
  87438. };
  87439. }
  87440. declare module BABYLON {
  87441. /** @hidden */
  87442. export var particlesPixelShader: {
  87443. name: string;
  87444. shader: string;
  87445. };
  87446. }
  87447. declare module BABYLON {
  87448. /** @hidden */
  87449. export var particlesVertexShader: {
  87450. name: string;
  87451. shader: string;
  87452. };
  87453. }
  87454. declare module BABYLON {
  87455. /**
  87456. * This represents a particle system in Babylon.
  87457. * 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.
  87458. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87459. * @example https://doc.babylonjs.com/babylon101/particles
  87460. */
  87461. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87462. /**
  87463. * Billboard mode will only apply to Y axis
  87464. */
  87465. static readonly BILLBOARDMODE_Y: number;
  87466. /**
  87467. * Billboard mode will apply to all axes
  87468. */
  87469. static readonly BILLBOARDMODE_ALL: number;
  87470. /**
  87471. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87472. */
  87473. static readonly BILLBOARDMODE_STRETCHED: number;
  87474. /**
  87475. * This function can be defined to provide custom update for active particles.
  87476. * This function will be called instead of regular update (age, position, color, etc.).
  87477. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87478. */
  87479. updateFunction: (particles: Particle[]) => void;
  87480. private _emitterWorldMatrix;
  87481. /**
  87482. * This function can be defined to specify initial direction for every new particle.
  87483. * It by default use the emitterType defined function
  87484. */
  87485. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87486. /**
  87487. * This function can be defined to specify initial position for every new particle.
  87488. * It by default use the emitterType defined function
  87489. */
  87490. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87491. /**
  87492. * @hidden
  87493. */
  87494. _inheritedVelocityOffset: Vector3;
  87495. /**
  87496. * An event triggered when the system is disposed
  87497. */
  87498. onDisposeObservable: Observable<ParticleSystem>;
  87499. private _onDisposeObserver;
  87500. /**
  87501. * Sets a callback that will be triggered when the system is disposed
  87502. */
  87503. set onDispose(callback: () => void);
  87504. private _particles;
  87505. private _epsilon;
  87506. private _capacity;
  87507. private _stockParticles;
  87508. private _newPartsExcess;
  87509. private _vertexData;
  87510. private _vertexBuffer;
  87511. private _vertexBuffers;
  87512. private _spriteBuffer;
  87513. private _indexBuffer;
  87514. private _effect;
  87515. private _customEffect;
  87516. private _cachedDefines;
  87517. private _scaledColorStep;
  87518. private _colorDiff;
  87519. private _scaledDirection;
  87520. private _scaledGravity;
  87521. private _currentRenderId;
  87522. private _alive;
  87523. private _useInstancing;
  87524. private _started;
  87525. private _stopped;
  87526. private _actualFrame;
  87527. private _scaledUpdateSpeed;
  87528. private _vertexBufferSize;
  87529. /** @hidden */
  87530. _currentEmitRateGradient: Nullable<FactorGradient>;
  87531. /** @hidden */
  87532. _currentEmitRate1: number;
  87533. /** @hidden */
  87534. _currentEmitRate2: number;
  87535. /** @hidden */
  87536. _currentStartSizeGradient: Nullable<FactorGradient>;
  87537. /** @hidden */
  87538. _currentStartSize1: number;
  87539. /** @hidden */
  87540. _currentStartSize2: number;
  87541. private readonly _rawTextureWidth;
  87542. private _rampGradientsTexture;
  87543. private _useRampGradients;
  87544. /** Gets or sets a boolean indicating that ramp gradients must be used
  87545. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87546. */
  87547. get useRampGradients(): boolean;
  87548. set useRampGradients(value: boolean);
  87549. /**
  87550. * 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.
  87551. * 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: [])
  87552. */
  87553. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87554. private _subEmitters;
  87555. /**
  87556. * @hidden
  87557. * If the particle systems emitter should be disposed when the particle system is disposed
  87558. */
  87559. _disposeEmitterOnDispose: boolean;
  87560. /**
  87561. * The current active Sub-systems, this property is used by the root particle system only.
  87562. */
  87563. activeSubSystems: Array<ParticleSystem>;
  87564. /**
  87565. * Specifies if the particles are updated in emitter local space or world space
  87566. */
  87567. isLocal: boolean;
  87568. private _rootParticleSystem;
  87569. /**
  87570. * Gets the current list of active particles
  87571. */
  87572. get particles(): Particle[];
  87573. /**
  87574. * Gets the number of particles active at the same time.
  87575. * @returns The number of active particles.
  87576. */
  87577. getActiveCount(): number;
  87578. /**
  87579. * Returns the string "ParticleSystem"
  87580. * @returns a string containing the class name
  87581. */
  87582. getClassName(): string;
  87583. /**
  87584. * Gets a boolean indicating that the system is stopping
  87585. * @returns true if the system is currently stopping
  87586. */
  87587. isStopping(): boolean;
  87588. /**
  87589. * Instantiates a particle system.
  87590. * 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.
  87591. * @param name The name of the particle system
  87592. * @param capacity The max number of particles alive at the same time
  87593. * @param scene The scene the particle system belongs to
  87594. * @param customEffect a custom effect used to change the way particles are rendered by default
  87595. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87596. * @param epsilon Offset used to render the particles
  87597. */
  87598. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87599. private _addFactorGradient;
  87600. private _removeFactorGradient;
  87601. /**
  87602. * Adds a new life time gradient
  87603. * @param gradient defines the gradient to use (between 0 and 1)
  87604. * @param factor defines the life time factor to affect to the specified gradient
  87605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87606. * @returns the current particle system
  87607. */
  87608. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87609. /**
  87610. * Remove a specific life time gradient
  87611. * @param gradient defines the gradient to remove
  87612. * @returns the current particle system
  87613. */
  87614. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87615. /**
  87616. * Adds a new size gradient
  87617. * @param gradient defines the gradient to use (between 0 and 1)
  87618. * @param factor defines the size factor to affect to the specified gradient
  87619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87620. * @returns the current particle system
  87621. */
  87622. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87623. /**
  87624. * Remove a specific size gradient
  87625. * @param gradient defines the gradient to remove
  87626. * @returns the current particle system
  87627. */
  87628. removeSizeGradient(gradient: number): IParticleSystem;
  87629. /**
  87630. * Adds a new color remap gradient
  87631. * @param gradient defines the gradient to use (between 0 and 1)
  87632. * @param min defines the color remap minimal range
  87633. * @param max defines the color remap maximal range
  87634. * @returns the current particle system
  87635. */
  87636. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87637. /**
  87638. * Remove a specific color remap gradient
  87639. * @param gradient defines the gradient to remove
  87640. * @returns the current particle system
  87641. */
  87642. removeColorRemapGradient(gradient: number): IParticleSystem;
  87643. /**
  87644. * Adds a new alpha remap gradient
  87645. * @param gradient defines the gradient to use (between 0 and 1)
  87646. * @param min defines the alpha remap minimal range
  87647. * @param max defines the alpha remap maximal range
  87648. * @returns the current particle system
  87649. */
  87650. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87651. /**
  87652. * Remove a specific alpha remap gradient
  87653. * @param gradient defines the gradient to remove
  87654. * @returns the current particle system
  87655. */
  87656. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87657. /**
  87658. * Adds a new angular speed gradient
  87659. * @param gradient defines the gradient to use (between 0 and 1)
  87660. * @param factor defines the angular speed to affect to the specified gradient
  87661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87662. * @returns the current particle system
  87663. */
  87664. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87665. /**
  87666. * Remove a specific angular speed gradient
  87667. * @param gradient defines the gradient to remove
  87668. * @returns the current particle system
  87669. */
  87670. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87671. /**
  87672. * Adds a new velocity gradient
  87673. * @param gradient defines the gradient to use (between 0 and 1)
  87674. * @param factor defines the velocity to affect to the specified gradient
  87675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87676. * @returns the current particle system
  87677. */
  87678. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87679. /**
  87680. * Remove a specific velocity gradient
  87681. * @param gradient defines the gradient to remove
  87682. * @returns the current particle system
  87683. */
  87684. removeVelocityGradient(gradient: number): IParticleSystem;
  87685. /**
  87686. * Adds a new limit velocity gradient
  87687. * @param gradient defines the gradient to use (between 0 and 1)
  87688. * @param factor defines the limit velocity value to affect to the specified gradient
  87689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87690. * @returns the current particle system
  87691. */
  87692. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87693. /**
  87694. * Remove a specific limit velocity gradient
  87695. * @param gradient defines the gradient to remove
  87696. * @returns the current particle system
  87697. */
  87698. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87699. /**
  87700. * Adds a new drag gradient
  87701. * @param gradient defines the gradient to use (between 0 and 1)
  87702. * @param factor defines the drag value to affect to the specified gradient
  87703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87704. * @returns the current particle system
  87705. */
  87706. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87707. /**
  87708. * Remove a specific drag gradient
  87709. * @param gradient defines the gradient to remove
  87710. * @returns the current particle system
  87711. */
  87712. removeDragGradient(gradient: number): IParticleSystem;
  87713. /**
  87714. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87715. * @param gradient defines the gradient to use (between 0 and 1)
  87716. * @param factor defines the emit rate value to affect to the specified gradient
  87717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87718. * @returns the current particle system
  87719. */
  87720. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87721. /**
  87722. * Remove a specific emit rate gradient
  87723. * @param gradient defines the gradient to remove
  87724. * @returns the current particle system
  87725. */
  87726. removeEmitRateGradient(gradient: number): IParticleSystem;
  87727. /**
  87728. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87729. * @param gradient defines the gradient to use (between 0 and 1)
  87730. * @param factor defines the start size value to affect to the specified gradient
  87731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87732. * @returns the current particle system
  87733. */
  87734. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87735. /**
  87736. * Remove a specific start size gradient
  87737. * @param gradient defines the gradient to remove
  87738. * @returns the current particle system
  87739. */
  87740. removeStartSizeGradient(gradient: number): IParticleSystem;
  87741. private _createRampGradientTexture;
  87742. /**
  87743. * Gets the current list of ramp gradients.
  87744. * You must use addRampGradient and removeRampGradient to udpate this list
  87745. * @returns the list of ramp gradients
  87746. */
  87747. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87748. /** Force the system to rebuild all gradients that need to be resync */
  87749. forceRefreshGradients(): void;
  87750. private _syncRampGradientTexture;
  87751. /**
  87752. * Adds a new ramp gradient used to remap particle colors
  87753. * @param gradient defines the gradient to use (between 0 and 1)
  87754. * @param color defines the color to affect to the specified gradient
  87755. * @returns the current particle system
  87756. */
  87757. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87758. /**
  87759. * Remove a specific ramp gradient
  87760. * @param gradient defines the gradient to remove
  87761. * @returns the current particle system
  87762. */
  87763. removeRampGradient(gradient: number): ParticleSystem;
  87764. /**
  87765. * Adds a new color gradient
  87766. * @param gradient defines the gradient to use (between 0 and 1)
  87767. * @param color1 defines the color to affect to the specified gradient
  87768. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87769. * @returns this particle system
  87770. */
  87771. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87772. /**
  87773. * Remove a specific color gradient
  87774. * @param gradient defines the gradient to remove
  87775. * @returns this particle system
  87776. */
  87777. removeColorGradient(gradient: number): IParticleSystem;
  87778. private _fetchR;
  87779. protected _reset(): void;
  87780. private _resetEffect;
  87781. private _createVertexBuffers;
  87782. private _createIndexBuffer;
  87783. /**
  87784. * Gets the maximum number of particles active at the same time.
  87785. * @returns The max number of active particles.
  87786. */
  87787. getCapacity(): number;
  87788. /**
  87789. * Gets whether there are still active particles in the system.
  87790. * @returns True if it is alive, otherwise false.
  87791. */
  87792. isAlive(): boolean;
  87793. /**
  87794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87795. * @returns True if it has been started, otherwise false.
  87796. */
  87797. isStarted(): boolean;
  87798. private _prepareSubEmitterInternalArray;
  87799. /**
  87800. * Starts the particle system and begins to emit
  87801. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87802. */
  87803. start(delay?: number): void;
  87804. /**
  87805. * Stops the particle system.
  87806. * @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.
  87807. */
  87808. stop(stopSubEmitters?: boolean): void;
  87809. /**
  87810. * Remove all active particles
  87811. */
  87812. reset(): void;
  87813. /**
  87814. * @hidden (for internal use only)
  87815. */
  87816. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  87817. /**
  87818. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  87819. * Its lifetime will start back at 0.
  87820. */
  87821. recycleParticle: (particle: Particle) => void;
  87822. private _stopSubEmitters;
  87823. private _createParticle;
  87824. private _removeFromRoot;
  87825. private _emitFromParticle;
  87826. private _update;
  87827. /** @hidden */
  87828. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  87829. /** @hidden */
  87830. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  87831. /** @hidden */
  87832. private _getEffect;
  87833. /**
  87834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  87835. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  87836. */
  87837. animate(preWarmOnly?: boolean): void;
  87838. private _appendParticleVertices;
  87839. /**
  87840. * Rebuilds the particle system.
  87841. */
  87842. rebuild(): void;
  87843. /**
  87844. * Is this system ready to be used/rendered
  87845. * @return true if the system is ready
  87846. */
  87847. isReady(): boolean;
  87848. private _render;
  87849. /**
  87850. * Renders the particle system in its current state.
  87851. * @returns the current number of particles
  87852. */
  87853. render(): number;
  87854. /**
  87855. * Disposes the particle system and free the associated resources
  87856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87857. */
  87858. dispose(disposeTexture?: boolean): void;
  87859. /**
  87860. * Clones the particle system.
  87861. * @param name The name of the cloned object
  87862. * @param newEmitter The new emitter to use
  87863. * @returns the cloned particle system
  87864. */
  87865. clone(name: string, newEmitter: any): ParticleSystem;
  87866. /**
  87867. * Serializes the particle system to a JSON object
  87868. * @param serializeTexture defines if the texture must be serialized as well
  87869. * @returns the JSON object
  87870. */
  87871. serialize(serializeTexture?: boolean): any;
  87872. /** @hidden */
  87873. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  87874. /** @hidden */
  87875. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  87876. /**
  87877. * Parses a JSON object to create a particle system.
  87878. * @param parsedParticleSystem The JSON object to parse
  87879. * @param scene The scene to create the particle system in
  87880. * @param rootUrl The root url to use to load external dependencies like texture
  87881. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87882. * @returns the Parsed particle system
  87883. */
  87884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87885. }
  87886. }
  87887. declare module BABYLON {
  87888. /**
  87889. * A particle represents one of the element emitted by a particle system.
  87890. * This is mainly define by its coordinates, direction, velocity and age.
  87891. */
  87892. export class Particle {
  87893. /**
  87894. * The particle system the particle belongs to.
  87895. */
  87896. particleSystem: ParticleSystem;
  87897. private static _Count;
  87898. /**
  87899. * Unique ID of the particle
  87900. */
  87901. id: number;
  87902. /**
  87903. * The world position of the particle in the scene.
  87904. */
  87905. position: Vector3;
  87906. /**
  87907. * The world direction of the particle in the scene.
  87908. */
  87909. direction: Vector3;
  87910. /**
  87911. * The color of the particle.
  87912. */
  87913. color: Color4;
  87914. /**
  87915. * The color change of the particle per step.
  87916. */
  87917. colorStep: Color4;
  87918. /**
  87919. * Defines how long will the life of the particle be.
  87920. */
  87921. lifeTime: number;
  87922. /**
  87923. * The current age of the particle.
  87924. */
  87925. age: number;
  87926. /**
  87927. * The current size of the particle.
  87928. */
  87929. size: number;
  87930. /**
  87931. * The current scale of the particle.
  87932. */
  87933. scale: Vector2;
  87934. /**
  87935. * The current angle of the particle.
  87936. */
  87937. angle: number;
  87938. /**
  87939. * Defines how fast is the angle changing.
  87940. */
  87941. angularSpeed: number;
  87942. /**
  87943. * Defines the cell index used by the particle to be rendered from a sprite.
  87944. */
  87945. cellIndex: number;
  87946. /**
  87947. * The information required to support color remapping
  87948. */
  87949. remapData: Vector4;
  87950. /** @hidden */
  87951. _randomCellOffset?: number;
  87952. /** @hidden */
  87953. _initialDirection: Nullable<Vector3>;
  87954. /** @hidden */
  87955. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87956. /** @hidden */
  87957. _initialStartSpriteCellID: number;
  87958. /** @hidden */
  87959. _initialEndSpriteCellID: number;
  87960. /** @hidden */
  87961. _currentColorGradient: Nullable<ColorGradient>;
  87962. /** @hidden */
  87963. _currentColor1: Color4;
  87964. /** @hidden */
  87965. _currentColor2: Color4;
  87966. /** @hidden */
  87967. _currentSizeGradient: Nullable<FactorGradient>;
  87968. /** @hidden */
  87969. _currentSize1: number;
  87970. /** @hidden */
  87971. _currentSize2: number;
  87972. /** @hidden */
  87973. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87974. /** @hidden */
  87975. _currentAngularSpeed1: number;
  87976. /** @hidden */
  87977. _currentAngularSpeed2: number;
  87978. /** @hidden */
  87979. _currentVelocityGradient: Nullable<FactorGradient>;
  87980. /** @hidden */
  87981. _currentVelocity1: number;
  87982. /** @hidden */
  87983. _currentVelocity2: number;
  87984. /** @hidden */
  87985. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87986. /** @hidden */
  87987. _currentLimitVelocity1: number;
  87988. /** @hidden */
  87989. _currentLimitVelocity2: number;
  87990. /** @hidden */
  87991. _currentDragGradient: Nullable<FactorGradient>;
  87992. /** @hidden */
  87993. _currentDrag1: number;
  87994. /** @hidden */
  87995. _currentDrag2: number;
  87996. /** @hidden */
  87997. _randomNoiseCoordinates1: Vector3;
  87998. /** @hidden */
  87999. _randomNoiseCoordinates2: Vector3;
  88000. /** @hidden */
  88001. _localPosition?: Vector3;
  88002. /**
  88003. * Creates a new instance Particle
  88004. * @param particleSystem the particle system the particle belongs to
  88005. */
  88006. constructor(
  88007. /**
  88008. * The particle system the particle belongs to.
  88009. */
  88010. particleSystem: ParticleSystem);
  88011. private updateCellInfoFromSystem;
  88012. /**
  88013. * Defines how the sprite cell index is updated for the particle
  88014. */
  88015. updateCellIndex(): void;
  88016. /** @hidden */
  88017. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88018. /** @hidden */
  88019. _inheritParticleInfoToSubEmitters(): void;
  88020. /** @hidden */
  88021. _reset(): void;
  88022. /**
  88023. * Copy the properties of particle to another one.
  88024. * @param other the particle to copy the information to.
  88025. */
  88026. copyTo(other: Particle): void;
  88027. }
  88028. }
  88029. declare module BABYLON {
  88030. /**
  88031. * Particle emitter represents a volume emitting particles.
  88032. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88033. */
  88034. export interface IParticleEmitterType {
  88035. /**
  88036. * Called by the particle System when the direction is computed for the created particle.
  88037. * @param worldMatrix is the world matrix of the particle system
  88038. * @param directionToUpdate is the direction vector to update with the result
  88039. * @param particle is the particle we are computed the direction for
  88040. * @param isLocal defines if the direction should be set in local space
  88041. */
  88042. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88043. /**
  88044. * Called by the particle System when the position is computed for the created particle.
  88045. * @param worldMatrix is the world matrix of the particle system
  88046. * @param positionToUpdate is the position vector to update with the result
  88047. * @param particle is the particle we are computed the position for
  88048. * @param isLocal defines if the position should be set in local space
  88049. */
  88050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88051. /**
  88052. * Clones the current emitter and returns a copy of it
  88053. * @returns the new emitter
  88054. */
  88055. clone(): IParticleEmitterType;
  88056. /**
  88057. * Called by the GPUParticleSystem to setup the update shader
  88058. * @param effect defines the update shader
  88059. */
  88060. applyToShader(effect: Effect): void;
  88061. /**
  88062. * Returns a string to use to update the GPU particles update shader
  88063. * @returns the effect defines string
  88064. */
  88065. getEffectDefines(): string;
  88066. /**
  88067. * Returns a string representing the class name
  88068. * @returns a string containing the class name
  88069. */
  88070. getClassName(): string;
  88071. /**
  88072. * Serializes the particle system to a JSON object.
  88073. * @returns the JSON object
  88074. */
  88075. serialize(): any;
  88076. /**
  88077. * Parse properties from a JSON object
  88078. * @param serializationObject defines the JSON object
  88079. * @param scene defines the hosting scene
  88080. */
  88081. parse(serializationObject: any, scene: Scene): void;
  88082. }
  88083. }
  88084. declare module BABYLON {
  88085. /**
  88086. * Particle emitter emitting particles from the inside of a box.
  88087. * It emits the particles randomly between 2 given directions.
  88088. */
  88089. export class BoxParticleEmitter implements IParticleEmitterType {
  88090. /**
  88091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88092. */
  88093. direction1: Vector3;
  88094. /**
  88095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88096. */
  88097. direction2: Vector3;
  88098. /**
  88099. * 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.
  88100. */
  88101. minEmitBox: Vector3;
  88102. /**
  88103. * 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.
  88104. */
  88105. maxEmitBox: Vector3;
  88106. /**
  88107. * Creates a new instance BoxParticleEmitter
  88108. */
  88109. constructor();
  88110. /**
  88111. * Called by the particle System when the direction is computed for the created particle.
  88112. * @param worldMatrix is the world matrix of the particle system
  88113. * @param directionToUpdate is the direction vector to update with the result
  88114. * @param particle is the particle we are computed the direction for
  88115. * @param isLocal defines if the direction should be set in local space
  88116. */
  88117. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88118. /**
  88119. * Called by the particle System when the position is computed for the created particle.
  88120. * @param worldMatrix is the world matrix of the particle system
  88121. * @param positionToUpdate is the position vector to update with the result
  88122. * @param particle is the particle we are computed the position for
  88123. * @param isLocal defines if the position should be set in local space
  88124. */
  88125. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88126. /**
  88127. * Clones the current emitter and returns a copy of it
  88128. * @returns the new emitter
  88129. */
  88130. clone(): BoxParticleEmitter;
  88131. /**
  88132. * Called by the GPUParticleSystem to setup the update shader
  88133. * @param effect defines the update shader
  88134. */
  88135. applyToShader(effect: Effect): void;
  88136. /**
  88137. * Returns a string to use to update the GPU particles update shader
  88138. * @returns a string containng the defines string
  88139. */
  88140. getEffectDefines(): string;
  88141. /**
  88142. * Returns the string "BoxParticleEmitter"
  88143. * @returns a string containing the class name
  88144. */
  88145. getClassName(): string;
  88146. /**
  88147. * Serializes the particle system to a JSON object.
  88148. * @returns the JSON object
  88149. */
  88150. serialize(): any;
  88151. /**
  88152. * Parse properties from a JSON object
  88153. * @param serializationObject defines the JSON object
  88154. */
  88155. parse(serializationObject: any): void;
  88156. }
  88157. }
  88158. declare module BABYLON {
  88159. /**
  88160. * Particle emitter emitting particles from the inside of a cone.
  88161. * It emits the particles alongside the cone volume from the base to the particle.
  88162. * The emission direction might be randomized.
  88163. */
  88164. export class ConeParticleEmitter implements IParticleEmitterType {
  88165. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88166. directionRandomizer: number;
  88167. private _radius;
  88168. private _angle;
  88169. private _height;
  88170. /**
  88171. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88172. */
  88173. radiusRange: number;
  88174. /**
  88175. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88176. */
  88177. heightRange: number;
  88178. /**
  88179. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88180. */
  88181. emitFromSpawnPointOnly: boolean;
  88182. /**
  88183. * Gets or sets the radius of the emission cone
  88184. */
  88185. get radius(): number;
  88186. set radius(value: number);
  88187. /**
  88188. * Gets or sets the angle of the emission cone
  88189. */
  88190. get angle(): number;
  88191. set angle(value: number);
  88192. private _buildHeight;
  88193. /**
  88194. * Creates a new instance ConeParticleEmitter
  88195. * @param radius the radius of the emission cone (1 by default)
  88196. * @param angle the cone base angle (PI by default)
  88197. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88198. */
  88199. constructor(radius?: number, angle?: number,
  88200. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88201. directionRandomizer?: number);
  88202. /**
  88203. * Called by the particle System when the direction is computed for the created particle.
  88204. * @param worldMatrix is the world matrix of the particle system
  88205. * @param directionToUpdate is the direction vector to update with the result
  88206. * @param particle is the particle we are computed the direction for
  88207. * @param isLocal defines if the direction should be set in local space
  88208. */
  88209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88210. /**
  88211. * Called by the particle System when the position is computed for the created particle.
  88212. * @param worldMatrix is the world matrix of the particle system
  88213. * @param positionToUpdate is the position vector to update with the result
  88214. * @param particle is the particle we are computed the position for
  88215. * @param isLocal defines if the position should be set in local space
  88216. */
  88217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88218. /**
  88219. * Clones the current emitter and returns a copy of it
  88220. * @returns the new emitter
  88221. */
  88222. clone(): ConeParticleEmitter;
  88223. /**
  88224. * Called by the GPUParticleSystem to setup the update shader
  88225. * @param effect defines the update shader
  88226. */
  88227. applyToShader(effect: Effect): void;
  88228. /**
  88229. * Returns a string to use to update the GPU particles update shader
  88230. * @returns a string containng the defines string
  88231. */
  88232. getEffectDefines(): string;
  88233. /**
  88234. * Returns the string "ConeParticleEmitter"
  88235. * @returns a string containing the class name
  88236. */
  88237. getClassName(): string;
  88238. /**
  88239. * Serializes the particle system to a JSON object.
  88240. * @returns the JSON object
  88241. */
  88242. serialize(): any;
  88243. /**
  88244. * Parse properties from a JSON object
  88245. * @param serializationObject defines the JSON object
  88246. */
  88247. parse(serializationObject: any): void;
  88248. }
  88249. }
  88250. declare module BABYLON {
  88251. /**
  88252. * Particle emitter emitting particles from the inside of a cylinder.
  88253. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88254. */
  88255. export class CylinderParticleEmitter implements IParticleEmitterType {
  88256. /**
  88257. * The radius of the emission cylinder.
  88258. */
  88259. radius: number;
  88260. /**
  88261. * The height of the emission cylinder.
  88262. */
  88263. height: number;
  88264. /**
  88265. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88266. */
  88267. radiusRange: number;
  88268. /**
  88269. * How much to randomize the particle direction [0-1].
  88270. */
  88271. directionRandomizer: number;
  88272. /**
  88273. * Creates a new instance CylinderParticleEmitter
  88274. * @param radius the radius of the emission cylinder (1 by default)
  88275. * @param height the height of the emission cylinder (1 by default)
  88276. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88277. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88278. */
  88279. constructor(
  88280. /**
  88281. * The radius of the emission cylinder.
  88282. */
  88283. radius?: number,
  88284. /**
  88285. * The height of the emission cylinder.
  88286. */
  88287. height?: number,
  88288. /**
  88289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88290. */
  88291. radiusRange?: number,
  88292. /**
  88293. * How much to randomize the particle direction [0-1].
  88294. */
  88295. directionRandomizer?: number);
  88296. /**
  88297. * Called by the particle System when the direction is computed for the created particle.
  88298. * @param worldMatrix is the world matrix of the particle system
  88299. * @param directionToUpdate is the direction vector to update with the result
  88300. * @param particle is the particle we are computed the direction for
  88301. * @param isLocal defines if the direction should be set in local space
  88302. */
  88303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88304. /**
  88305. * Called by the particle System when the position is computed for the created particle.
  88306. * @param worldMatrix is the world matrix of the particle system
  88307. * @param positionToUpdate is the position vector to update with the result
  88308. * @param particle is the particle we are computed the position for
  88309. * @param isLocal defines if the position should be set in local space
  88310. */
  88311. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88312. /**
  88313. * Clones the current emitter and returns a copy of it
  88314. * @returns the new emitter
  88315. */
  88316. clone(): CylinderParticleEmitter;
  88317. /**
  88318. * Called by the GPUParticleSystem to setup the update shader
  88319. * @param effect defines the update shader
  88320. */
  88321. applyToShader(effect: Effect): void;
  88322. /**
  88323. * Returns a string to use to update the GPU particles update shader
  88324. * @returns a string containng the defines string
  88325. */
  88326. getEffectDefines(): string;
  88327. /**
  88328. * Returns the string "CylinderParticleEmitter"
  88329. * @returns a string containing the class name
  88330. */
  88331. getClassName(): string;
  88332. /**
  88333. * Serializes the particle system to a JSON object.
  88334. * @returns the JSON object
  88335. */
  88336. serialize(): any;
  88337. /**
  88338. * Parse properties from a JSON object
  88339. * @param serializationObject defines the JSON object
  88340. */
  88341. parse(serializationObject: any): void;
  88342. }
  88343. /**
  88344. * Particle emitter emitting particles from the inside of a cylinder.
  88345. * It emits the particles randomly between two vectors.
  88346. */
  88347. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88348. /**
  88349. * The min limit of the emission direction.
  88350. */
  88351. direction1: Vector3;
  88352. /**
  88353. * The max limit of the emission direction.
  88354. */
  88355. direction2: Vector3;
  88356. /**
  88357. * Creates a new instance CylinderDirectedParticleEmitter
  88358. * @param radius the radius of the emission cylinder (1 by default)
  88359. * @param height the height of the emission cylinder (1 by default)
  88360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88361. * @param direction1 the min limit of the emission direction (up vector by default)
  88362. * @param direction2 the max limit of the emission direction (up vector by default)
  88363. */
  88364. constructor(radius?: number, height?: number, radiusRange?: number,
  88365. /**
  88366. * The min limit of the emission direction.
  88367. */
  88368. direction1?: Vector3,
  88369. /**
  88370. * The max limit of the emission direction.
  88371. */
  88372. direction2?: Vector3);
  88373. /**
  88374. * Called by the particle System when the direction is computed for the created particle.
  88375. * @param worldMatrix is the world matrix of the particle system
  88376. * @param directionToUpdate is the direction vector to update with the result
  88377. * @param particle is the particle we are computed the direction for
  88378. */
  88379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88380. /**
  88381. * Clones the current emitter and returns a copy of it
  88382. * @returns the new emitter
  88383. */
  88384. clone(): CylinderDirectedParticleEmitter;
  88385. /**
  88386. * Called by the GPUParticleSystem to setup the update shader
  88387. * @param effect defines the update shader
  88388. */
  88389. applyToShader(effect: Effect): void;
  88390. /**
  88391. * Returns a string to use to update the GPU particles update shader
  88392. * @returns a string containng the defines string
  88393. */
  88394. getEffectDefines(): string;
  88395. /**
  88396. * Returns the string "CylinderDirectedParticleEmitter"
  88397. * @returns a string containing the class name
  88398. */
  88399. getClassName(): string;
  88400. /**
  88401. * Serializes the particle system to a JSON object.
  88402. * @returns the JSON object
  88403. */
  88404. serialize(): any;
  88405. /**
  88406. * Parse properties from a JSON object
  88407. * @param serializationObject defines the JSON object
  88408. */
  88409. parse(serializationObject: any): void;
  88410. }
  88411. }
  88412. declare module BABYLON {
  88413. /**
  88414. * Particle emitter emitting particles from the inside of a hemisphere.
  88415. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88416. */
  88417. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88418. /**
  88419. * The radius of the emission hemisphere.
  88420. */
  88421. radius: number;
  88422. /**
  88423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88424. */
  88425. radiusRange: number;
  88426. /**
  88427. * How much to randomize the particle direction [0-1].
  88428. */
  88429. directionRandomizer: number;
  88430. /**
  88431. * Creates a new instance HemisphericParticleEmitter
  88432. * @param radius the radius of the emission hemisphere (1 by default)
  88433. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88434. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88435. */
  88436. constructor(
  88437. /**
  88438. * The radius of the emission hemisphere.
  88439. */
  88440. radius?: number,
  88441. /**
  88442. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88443. */
  88444. radiusRange?: number,
  88445. /**
  88446. * How much to randomize the particle direction [0-1].
  88447. */
  88448. directionRandomizer?: number);
  88449. /**
  88450. * Called by the particle System when the direction is computed for the created particle.
  88451. * @param worldMatrix is the world matrix of the particle system
  88452. * @param directionToUpdate is the direction vector to update with the result
  88453. * @param particle is the particle we are computed the direction for
  88454. * @param isLocal defines if the direction should be set in local space
  88455. */
  88456. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88457. /**
  88458. * Called by the particle System when the position is computed for the created particle.
  88459. * @param worldMatrix is the world matrix of the particle system
  88460. * @param positionToUpdate is the position vector to update with the result
  88461. * @param particle is the particle we are computed the position for
  88462. * @param isLocal defines if the position should be set in local space
  88463. */
  88464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88465. /**
  88466. * Clones the current emitter and returns a copy of it
  88467. * @returns the new emitter
  88468. */
  88469. clone(): HemisphericParticleEmitter;
  88470. /**
  88471. * Called by the GPUParticleSystem to setup the update shader
  88472. * @param effect defines the update shader
  88473. */
  88474. applyToShader(effect: Effect): void;
  88475. /**
  88476. * Returns a string to use to update the GPU particles update shader
  88477. * @returns a string containng the defines string
  88478. */
  88479. getEffectDefines(): string;
  88480. /**
  88481. * Returns the string "HemisphericParticleEmitter"
  88482. * @returns a string containing the class name
  88483. */
  88484. getClassName(): string;
  88485. /**
  88486. * Serializes the particle system to a JSON object.
  88487. * @returns the JSON object
  88488. */
  88489. serialize(): any;
  88490. /**
  88491. * Parse properties from a JSON object
  88492. * @param serializationObject defines the JSON object
  88493. */
  88494. parse(serializationObject: any): void;
  88495. }
  88496. }
  88497. declare module BABYLON {
  88498. /**
  88499. * Particle emitter emitting particles from a point.
  88500. * It emits the particles randomly between 2 given directions.
  88501. */
  88502. export class PointParticleEmitter implements IParticleEmitterType {
  88503. /**
  88504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88505. */
  88506. direction1: Vector3;
  88507. /**
  88508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88509. */
  88510. direction2: Vector3;
  88511. /**
  88512. * Creates a new instance PointParticleEmitter
  88513. */
  88514. constructor();
  88515. /**
  88516. * Called by the particle System when the direction is computed for the created particle.
  88517. * @param worldMatrix is the world matrix of the particle system
  88518. * @param directionToUpdate is the direction vector to update with the result
  88519. * @param particle is the particle we are computed the direction for
  88520. * @param isLocal defines if the direction should be set in local space
  88521. */
  88522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88523. /**
  88524. * Called by the particle System when the position is computed for the created particle.
  88525. * @param worldMatrix is the world matrix of the particle system
  88526. * @param positionToUpdate is the position vector to update with the result
  88527. * @param particle is the particle we are computed the position for
  88528. * @param isLocal defines if the position should be set in local space
  88529. */
  88530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88531. /**
  88532. * Clones the current emitter and returns a copy of it
  88533. * @returns the new emitter
  88534. */
  88535. clone(): PointParticleEmitter;
  88536. /**
  88537. * Called by the GPUParticleSystem to setup the update shader
  88538. * @param effect defines the update shader
  88539. */
  88540. applyToShader(effect: Effect): void;
  88541. /**
  88542. * Returns a string to use to update the GPU particles update shader
  88543. * @returns a string containng the defines string
  88544. */
  88545. getEffectDefines(): string;
  88546. /**
  88547. * Returns the string "PointParticleEmitter"
  88548. * @returns a string containing the class name
  88549. */
  88550. getClassName(): string;
  88551. /**
  88552. * Serializes the particle system to a JSON object.
  88553. * @returns the JSON object
  88554. */
  88555. serialize(): any;
  88556. /**
  88557. * Parse properties from a JSON object
  88558. * @param serializationObject defines the JSON object
  88559. */
  88560. parse(serializationObject: any): void;
  88561. }
  88562. }
  88563. declare module BABYLON {
  88564. /**
  88565. * Particle emitter emitting particles from the inside of a sphere.
  88566. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88567. */
  88568. export class SphereParticleEmitter implements IParticleEmitterType {
  88569. /**
  88570. * The radius of the emission sphere.
  88571. */
  88572. radius: number;
  88573. /**
  88574. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88575. */
  88576. radiusRange: number;
  88577. /**
  88578. * How much to randomize the particle direction [0-1].
  88579. */
  88580. directionRandomizer: number;
  88581. /**
  88582. * Creates a new instance SphereParticleEmitter
  88583. * @param radius the radius of the emission sphere (1 by default)
  88584. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88586. */
  88587. constructor(
  88588. /**
  88589. * The radius of the emission sphere.
  88590. */
  88591. radius?: number,
  88592. /**
  88593. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88594. */
  88595. radiusRange?: number,
  88596. /**
  88597. * How much to randomize the particle direction [0-1].
  88598. */
  88599. directionRandomizer?: number);
  88600. /**
  88601. * Called by the particle System when the direction is computed for the created particle.
  88602. * @param worldMatrix is the world matrix of the particle system
  88603. * @param directionToUpdate is the direction vector to update with the result
  88604. * @param particle is the particle we are computed the direction for
  88605. * @param isLocal defines if the direction should be set in local space
  88606. */
  88607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88608. /**
  88609. * Called by the particle System when the position is computed for the created particle.
  88610. * @param worldMatrix is the world matrix of the particle system
  88611. * @param positionToUpdate is the position vector to update with the result
  88612. * @param particle is the particle we are computed the position for
  88613. * @param isLocal defines if the position should be set in local space
  88614. */
  88615. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88616. /**
  88617. * Clones the current emitter and returns a copy of it
  88618. * @returns the new emitter
  88619. */
  88620. clone(): SphereParticleEmitter;
  88621. /**
  88622. * Called by the GPUParticleSystem to setup the update shader
  88623. * @param effect defines the update shader
  88624. */
  88625. applyToShader(effect: Effect): void;
  88626. /**
  88627. * Returns a string to use to update the GPU particles update shader
  88628. * @returns a string containng the defines string
  88629. */
  88630. getEffectDefines(): string;
  88631. /**
  88632. * Returns the string "SphereParticleEmitter"
  88633. * @returns a string containing the class name
  88634. */
  88635. getClassName(): string;
  88636. /**
  88637. * Serializes the particle system to a JSON object.
  88638. * @returns the JSON object
  88639. */
  88640. serialize(): any;
  88641. /**
  88642. * Parse properties from a JSON object
  88643. * @param serializationObject defines the JSON object
  88644. */
  88645. parse(serializationObject: any): void;
  88646. }
  88647. /**
  88648. * Particle emitter emitting particles from the inside of a sphere.
  88649. * It emits the particles randomly between two vectors.
  88650. */
  88651. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88652. /**
  88653. * The min limit of the emission direction.
  88654. */
  88655. direction1: Vector3;
  88656. /**
  88657. * The max limit of the emission direction.
  88658. */
  88659. direction2: Vector3;
  88660. /**
  88661. * Creates a new instance SphereDirectedParticleEmitter
  88662. * @param radius the radius of the emission sphere (1 by default)
  88663. * @param direction1 the min limit of the emission direction (up vector by default)
  88664. * @param direction2 the max limit of the emission direction (up vector by default)
  88665. */
  88666. constructor(radius?: number,
  88667. /**
  88668. * The min limit of the emission direction.
  88669. */
  88670. direction1?: Vector3,
  88671. /**
  88672. * The max limit of the emission direction.
  88673. */
  88674. direction2?: Vector3);
  88675. /**
  88676. * Called by the particle System when the direction is computed for the created particle.
  88677. * @param worldMatrix is the world matrix of the particle system
  88678. * @param directionToUpdate is the direction vector to update with the result
  88679. * @param particle is the particle we are computed the direction for
  88680. */
  88681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88682. /**
  88683. * Clones the current emitter and returns a copy of it
  88684. * @returns the new emitter
  88685. */
  88686. clone(): SphereDirectedParticleEmitter;
  88687. /**
  88688. * Called by the GPUParticleSystem to setup the update shader
  88689. * @param effect defines the update shader
  88690. */
  88691. applyToShader(effect: Effect): void;
  88692. /**
  88693. * Returns a string to use to update the GPU particles update shader
  88694. * @returns a string containng the defines string
  88695. */
  88696. getEffectDefines(): string;
  88697. /**
  88698. * Returns the string "SphereDirectedParticleEmitter"
  88699. * @returns a string containing the class name
  88700. */
  88701. getClassName(): string;
  88702. /**
  88703. * Serializes the particle system to a JSON object.
  88704. * @returns the JSON object
  88705. */
  88706. serialize(): any;
  88707. /**
  88708. * Parse properties from a JSON object
  88709. * @param serializationObject defines the JSON object
  88710. */
  88711. parse(serializationObject: any): void;
  88712. }
  88713. }
  88714. declare module BABYLON {
  88715. /**
  88716. * Particle emitter emitting particles from a custom list of positions.
  88717. */
  88718. export class CustomParticleEmitter implements IParticleEmitterType {
  88719. /**
  88720. * Gets or sets the position generator that will create the inital position of each particle.
  88721. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88722. */
  88723. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88724. /**
  88725. * Gets or sets the destination generator that will create the final destination of each particle.
  88726. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88727. */
  88728. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88729. /**
  88730. * Creates a new instance CustomParticleEmitter
  88731. */
  88732. constructor();
  88733. /**
  88734. * Called by the particle System when the direction is computed for the created particle.
  88735. * @param worldMatrix is the world matrix of the particle system
  88736. * @param directionToUpdate is the direction vector to update with the result
  88737. * @param particle is the particle we are computed the direction for
  88738. * @param isLocal defines if the direction should be set in local space
  88739. */
  88740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88741. /**
  88742. * Called by the particle System when the position is computed for the created particle.
  88743. * @param worldMatrix is the world matrix of the particle system
  88744. * @param positionToUpdate is the position vector to update with the result
  88745. * @param particle is the particle we are computed the position for
  88746. * @param isLocal defines if the position should be set in local space
  88747. */
  88748. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88749. /**
  88750. * Clones the current emitter and returns a copy of it
  88751. * @returns the new emitter
  88752. */
  88753. clone(): CustomParticleEmitter;
  88754. /**
  88755. * Called by the GPUParticleSystem to setup the update shader
  88756. * @param effect defines the update shader
  88757. */
  88758. applyToShader(effect: Effect): void;
  88759. /**
  88760. * Returns a string to use to update the GPU particles update shader
  88761. * @returns a string containng the defines string
  88762. */
  88763. getEffectDefines(): string;
  88764. /**
  88765. * Returns the string "PointParticleEmitter"
  88766. * @returns a string containing the class name
  88767. */
  88768. getClassName(): string;
  88769. /**
  88770. * Serializes the particle system to a JSON object.
  88771. * @returns the JSON object
  88772. */
  88773. serialize(): any;
  88774. /**
  88775. * Parse properties from a JSON object
  88776. * @param serializationObject defines the JSON object
  88777. */
  88778. parse(serializationObject: any): void;
  88779. }
  88780. }
  88781. declare module BABYLON {
  88782. /**
  88783. * Particle emitter emitting particles from the inside of a box.
  88784. * It emits the particles randomly between 2 given directions.
  88785. */
  88786. export class MeshParticleEmitter implements IParticleEmitterType {
  88787. private _indices;
  88788. private _positions;
  88789. private _normals;
  88790. private _storedNormal;
  88791. private _mesh;
  88792. /**
  88793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88794. */
  88795. direction1: Vector3;
  88796. /**
  88797. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88798. */
  88799. direction2: Vector3;
  88800. /**
  88801. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  88802. */
  88803. useMeshNormalsForDirection: boolean;
  88804. /** Defines the mesh to use as source */
  88805. get mesh(): Nullable<AbstractMesh>;
  88806. set mesh(value: Nullable<AbstractMesh>);
  88807. /**
  88808. * Creates a new instance MeshParticleEmitter
  88809. * @param mesh defines the mesh to use as source
  88810. */
  88811. constructor(mesh?: Nullable<AbstractMesh>);
  88812. /**
  88813. * Called by the particle System when the direction is computed for the created particle.
  88814. * @param worldMatrix is the world matrix of the particle system
  88815. * @param directionToUpdate is the direction vector to update with the result
  88816. * @param particle is the particle we are computed the direction for
  88817. * @param isLocal defines if the direction should be set in local space
  88818. */
  88819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88820. /**
  88821. * Called by the particle System when the position is computed for the created particle.
  88822. * @param worldMatrix is the world matrix of the particle system
  88823. * @param positionToUpdate is the position vector to update with the result
  88824. * @param particle is the particle we are computed the position for
  88825. * @param isLocal defines if the position should be set in local space
  88826. */
  88827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88828. /**
  88829. * Clones the current emitter and returns a copy of it
  88830. * @returns the new emitter
  88831. */
  88832. clone(): MeshParticleEmitter;
  88833. /**
  88834. * Called by the GPUParticleSystem to setup the update shader
  88835. * @param effect defines the update shader
  88836. */
  88837. applyToShader(effect: Effect): void;
  88838. /**
  88839. * Returns a string to use to update the GPU particles update shader
  88840. * @returns a string containng the defines string
  88841. */
  88842. getEffectDefines(): string;
  88843. /**
  88844. * Returns the string "BoxParticleEmitter"
  88845. * @returns a string containing the class name
  88846. */
  88847. getClassName(): string;
  88848. /**
  88849. * Serializes the particle system to a JSON object.
  88850. * @returns the JSON object
  88851. */
  88852. serialize(): any;
  88853. /**
  88854. * Parse properties from a JSON object
  88855. * @param serializationObject defines the JSON object
  88856. * @param scene defines the hosting scene
  88857. */
  88858. parse(serializationObject: any, scene: Scene): void;
  88859. }
  88860. }
  88861. declare module BABYLON {
  88862. /**
  88863. * Interface representing a particle system in Babylon.js.
  88864. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  88865. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  88866. */
  88867. export interface IParticleSystem {
  88868. /**
  88869. * List of animations used by the particle system.
  88870. */
  88871. animations: Animation[];
  88872. /**
  88873. * The id of the Particle system.
  88874. */
  88875. id: string;
  88876. /**
  88877. * The name of the Particle system.
  88878. */
  88879. name: string;
  88880. /**
  88881. * The emitter represents the Mesh or position we are attaching the particle system to.
  88882. */
  88883. emitter: Nullable<AbstractMesh | Vector3>;
  88884. /**
  88885. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88886. */
  88887. isBillboardBased: boolean;
  88888. /**
  88889. * The rendering group used by the Particle system to chose when to render.
  88890. */
  88891. renderingGroupId: number;
  88892. /**
  88893. * The layer mask we are rendering the particles through.
  88894. */
  88895. layerMask: number;
  88896. /**
  88897. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88898. */
  88899. updateSpeed: number;
  88900. /**
  88901. * The amount of time the particle system is running (depends of the overall update speed).
  88902. */
  88903. targetStopDuration: number;
  88904. /**
  88905. * The texture used to render each particle. (this can be a spritesheet)
  88906. */
  88907. particleTexture: Nullable<Texture>;
  88908. /**
  88909. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  88910. */
  88911. blendMode: number;
  88912. /**
  88913. * Minimum life time of emitting particles.
  88914. */
  88915. minLifeTime: number;
  88916. /**
  88917. * Maximum life time of emitting particles.
  88918. */
  88919. maxLifeTime: number;
  88920. /**
  88921. * Minimum Size of emitting particles.
  88922. */
  88923. minSize: number;
  88924. /**
  88925. * Maximum Size of emitting particles.
  88926. */
  88927. maxSize: number;
  88928. /**
  88929. * Minimum scale of emitting particles on X axis.
  88930. */
  88931. minScaleX: number;
  88932. /**
  88933. * Maximum scale of emitting particles on X axis.
  88934. */
  88935. maxScaleX: number;
  88936. /**
  88937. * Minimum scale of emitting particles on Y axis.
  88938. */
  88939. minScaleY: number;
  88940. /**
  88941. * Maximum scale of emitting particles on Y axis.
  88942. */
  88943. maxScaleY: number;
  88944. /**
  88945. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88946. */
  88947. color1: Color4;
  88948. /**
  88949. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88950. */
  88951. color2: Color4;
  88952. /**
  88953. * Color the particle will have at the end of its lifetime.
  88954. */
  88955. colorDead: Color4;
  88956. /**
  88957. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  88958. */
  88959. emitRate: number;
  88960. /**
  88961. * You can use gravity if you want to give an orientation to your particles.
  88962. */
  88963. gravity: Vector3;
  88964. /**
  88965. * Minimum power of emitting particles.
  88966. */
  88967. minEmitPower: number;
  88968. /**
  88969. * Maximum power of emitting particles.
  88970. */
  88971. maxEmitPower: number;
  88972. /**
  88973. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88974. */
  88975. minAngularSpeed: number;
  88976. /**
  88977. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88978. */
  88979. maxAngularSpeed: number;
  88980. /**
  88981. * Gets or sets the minimal initial rotation in radians.
  88982. */
  88983. minInitialRotation: number;
  88984. /**
  88985. * Gets or sets the maximal initial rotation in radians.
  88986. */
  88987. maxInitialRotation: number;
  88988. /**
  88989. * The particle emitter type defines the emitter used by the particle system.
  88990. * It can be for example box, sphere, or cone...
  88991. */
  88992. particleEmitterType: Nullable<IParticleEmitterType>;
  88993. /**
  88994. * Defines the delay in milliseconds before starting the system (0 by default)
  88995. */
  88996. startDelay: number;
  88997. /**
  88998. * 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
  88999. */
  89000. preWarmCycles: number;
  89001. /**
  89002. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89003. */
  89004. preWarmStepOffset: number;
  89005. /**
  89006. * 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)
  89007. */
  89008. spriteCellChangeSpeed: number;
  89009. /**
  89010. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89011. */
  89012. startSpriteCellID: number;
  89013. /**
  89014. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89015. */
  89016. endSpriteCellID: number;
  89017. /**
  89018. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89019. */
  89020. spriteCellWidth: number;
  89021. /**
  89022. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89023. */
  89024. spriteCellHeight: number;
  89025. /**
  89026. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89027. */
  89028. spriteRandomStartCell: boolean;
  89029. /**
  89030. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89031. */
  89032. isAnimationSheetEnabled: boolean;
  89033. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89034. translationPivot: Vector2;
  89035. /**
  89036. * Gets or sets a texture used to add random noise to particle positions
  89037. */
  89038. noiseTexture: Nullable<BaseTexture>;
  89039. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89040. noiseStrength: Vector3;
  89041. /**
  89042. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89043. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89044. */
  89045. billboardMode: number;
  89046. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89047. limitVelocityDamping: number;
  89048. /**
  89049. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89050. */
  89051. beginAnimationOnStart: boolean;
  89052. /**
  89053. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89054. */
  89055. beginAnimationFrom: number;
  89056. /**
  89057. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89058. */
  89059. beginAnimationTo: number;
  89060. /**
  89061. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89062. */
  89063. beginAnimationLoop: boolean;
  89064. /**
  89065. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89066. */
  89067. disposeOnStop: boolean;
  89068. /**
  89069. * Specifies if the particles are updated in emitter local space or world space
  89070. */
  89071. isLocal: boolean;
  89072. /** Snippet ID if the particle system was created from the snippet server */
  89073. snippetId: string;
  89074. /**
  89075. * Gets the maximum number of particles active at the same time.
  89076. * @returns The max number of active particles.
  89077. */
  89078. getCapacity(): number;
  89079. /**
  89080. * Gets the number of particles active at the same time.
  89081. * @returns The number of active particles.
  89082. */
  89083. getActiveCount(): number;
  89084. /**
  89085. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89086. * @returns True if it has been started, otherwise false.
  89087. */
  89088. isStarted(): boolean;
  89089. /**
  89090. * Animates the particle system for this frame.
  89091. */
  89092. animate(): void;
  89093. /**
  89094. * Renders the particle system in its current state.
  89095. * @returns the current number of particles
  89096. */
  89097. render(): number;
  89098. /**
  89099. * Dispose the particle system and frees its associated resources.
  89100. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89101. */
  89102. dispose(disposeTexture?: boolean): void;
  89103. /**
  89104. * Clones the particle system.
  89105. * @param name The name of the cloned object
  89106. * @param newEmitter The new emitter to use
  89107. * @returns the cloned particle system
  89108. */
  89109. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89110. /**
  89111. * Serializes the particle system to a JSON object
  89112. * @param serializeTexture defines if the texture must be serialized as well
  89113. * @returns the JSON object
  89114. */
  89115. serialize(serializeTexture: boolean): any;
  89116. /**
  89117. * Rebuild the particle system
  89118. */
  89119. rebuild(): void;
  89120. /** Force the system to rebuild all gradients that need to be resync */
  89121. forceRefreshGradients(): void;
  89122. /**
  89123. * Starts the particle system and begins to emit
  89124. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89125. */
  89126. start(delay?: number): void;
  89127. /**
  89128. * Stops the particle system.
  89129. */
  89130. stop(): void;
  89131. /**
  89132. * Remove all active particles
  89133. */
  89134. reset(): void;
  89135. /**
  89136. * Gets a boolean indicating that the system is stopping
  89137. * @returns true if the system is currently stopping
  89138. */
  89139. isStopping(): boolean;
  89140. /**
  89141. * Is this system ready to be used/rendered
  89142. * @return true if the system is ready
  89143. */
  89144. isReady(): boolean;
  89145. /**
  89146. * Returns the string "ParticleSystem"
  89147. * @returns a string containing the class name
  89148. */
  89149. getClassName(): string;
  89150. /**
  89151. * Adds a new color gradient
  89152. * @param gradient defines the gradient to use (between 0 and 1)
  89153. * @param color1 defines the color to affect to the specified gradient
  89154. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89155. * @returns the current particle system
  89156. */
  89157. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89158. /**
  89159. * Remove a specific color gradient
  89160. * @param gradient defines the gradient to remove
  89161. * @returns the current particle system
  89162. */
  89163. removeColorGradient(gradient: number): IParticleSystem;
  89164. /**
  89165. * Adds a new size gradient
  89166. * @param gradient defines the gradient to use (between 0 and 1)
  89167. * @param factor defines the size factor to affect to the specified gradient
  89168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89169. * @returns the current particle system
  89170. */
  89171. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89172. /**
  89173. * Remove a specific size gradient
  89174. * @param gradient defines the gradient to remove
  89175. * @returns the current particle system
  89176. */
  89177. removeSizeGradient(gradient: number): IParticleSystem;
  89178. /**
  89179. * Gets the current list of color gradients.
  89180. * You must use addColorGradient and removeColorGradient to udpate this list
  89181. * @returns the list of color gradients
  89182. */
  89183. getColorGradients(): Nullable<Array<ColorGradient>>;
  89184. /**
  89185. * Gets the current list of size gradients.
  89186. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89187. * @returns the list of size gradients
  89188. */
  89189. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89190. /**
  89191. * Gets the current list of angular speed gradients.
  89192. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89193. * @returns the list of angular speed gradients
  89194. */
  89195. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89196. /**
  89197. * Adds a new angular speed gradient
  89198. * @param gradient defines the gradient to use (between 0 and 1)
  89199. * @param factor defines the angular speed to affect to the specified gradient
  89200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89201. * @returns the current particle system
  89202. */
  89203. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89204. /**
  89205. * Remove a specific angular speed gradient
  89206. * @param gradient defines the gradient to remove
  89207. * @returns the current particle system
  89208. */
  89209. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89210. /**
  89211. * Gets the current list of velocity gradients.
  89212. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89213. * @returns the list of velocity gradients
  89214. */
  89215. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89216. /**
  89217. * Adds a new velocity gradient
  89218. * @param gradient defines the gradient to use (between 0 and 1)
  89219. * @param factor defines the velocity to affect to the specified gradient
  89220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89221. * @returns the current particle system
  89222. */
  89223. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89224. /**
  89225. * Remove a specific velocity gradient
  89226. * @param gradient defines the gradient to remove
  89227. * @returns the current particle system
  89228. */
  89229. removeVelocityGradient(gradient: number): IParticleSystem;
  89230. /**
  89231. * Gets the current list of limit velocity gradients.
  89232. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89233. * @returns the list of limit velocity gradients
  89234. */
  89235. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89236. /**
  89237. * Adds a new limit velocity gradient
  89238. * @param gradient defines the gradient to use (between 0 and 1)
  89239. * @param factor defines the limit velocity to affect to the specified gradient
  89240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89241. * @returns the current particle system
  89242. */
  89243. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89244. /**
  89245. * Remove a specific limit velocity gradient
  89246. * @param gradient defines the gradient to remove
  89247. * @returns the current particle system
  89248. */
  89249. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89250. /**
  89251. * Adds a new drag gradient
  89252. * @param gradient defines the gradient to use (between 0 and 1)
  89253. * @param factor defines the drag to affect to the specified gradient
  89254. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89255. * @returns the current particle system
  89256. */
  89257. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89258. /**
  89259. * Remove a specific drag gradient
  89260. * @param gradient defines the gradient to remove
  89261. * @returns the current particle system
  89262. */
  89263. removeDragGradient(gradient: number): IParticleSystem;
  89264. /**
  89265. * Gets the current list of drag gradients.
  89266. * You must use addDragGradient and removeDragGradient to udpate this list
  89267. * @returns the list of drag gradients
  89268. */
  89269. getDragGradients(): Nullable<Array<FactorGradient>>;
  89270. /**
  89271. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89272. * @param gradient defines the gradient to use (between 0 and 1)
  89273. * @param factor defines the emit rate to affect to the specified gradient
  89274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89275. * @returns the current particle system
  89276. */
  89277. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89278. /**
  89279. * Remove a specific emit rate gradient
  89280. * @param gradient defines the gradient to remove
  89281. * @returns the current particle system
  89282. */
  89283. removeEmitRateGradient(gradient: number): IParticleSystem;
  89284. /**
  89285. * Gets the current list of emit rate gradients.
  89286. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89287. * @returns the list of emit rate gradients
  89288. */
  89289. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89290. /**
  89291. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89292. * @param gradient defines the gradient to use (between 0 and 1)
  89293. * @param factor defines the start size to affect to the specified gradient
  89294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89295. * @returns the current particle system
  89296. */
  89297. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89298. /**
  89299. * Remove a specific start size gradient
  89300. * @param gradient defines the gradient to remove
  89301. * @returns the current particle system
  89302. */
  89303. removeStartSizeGradient(gradient: number): IParticleSystem;
  89304. /**
  89305. * Gets the current list of start size gradients.
  89306. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89307. * @returns the list of start size gradients
  89308. */
  89309. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89310. /**
  89311. * Adds a new life time gradient
  89312. * @param gradient defines the gradient to use (between 0 and 1)
  89313. * @param factor defines the life time factor to affect to the specified gradient
  89314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89315. * @returns the current particle system
  89316. */
  89317. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89318. /**
  89319. * Remove a specific life time gradient
  89320. * @param gradient defines the gradient to remove
  89321. * @returns the current particle system
  89322. */
  89323. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89324. /**
  89325. * Gets the current list of life time gradients.
  89326. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89327. * @returns the list of life time gradients
  89328. */
  89329. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89330. /**
  89331. * Gets the current list of color gradients.
  89332. * You must use addColorGradient and removeColorGradient to udpate this list
  89333. * @returns the list of color gradients
  89334. */
  89335. getColorGradients(): Nullable<Array<ColorGradient>>;
  89336. /**
  89337. * Adds a new ramp gradient used to remap particle colors
  89338. * @param gradient defines the gradient to use (between 0 and 1)
  89339. * @param color defines the color to affect to the specified gradient
  89340. * @returns the current particle system
  89341. */
  89342. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89343. /**
  89344. * Gets the current list of ramp gradients.
  89345. * You must use addRampGradient and removeRampGradient to udpate this list
  89346. * @returns the list of ramp gradients
  89347. */
  89348. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89349. /** Gets or sets a boolean indicating that ramp gradients must be used
  89350. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89351. */
  89352. useRampGradients: boolean;
  89353. /**
  89354. * Adds a new color remap gradient
  89355. * @param gradient defines the gradient to use (between 0 and 1)
  89356. * @param min defines the color remap minimal range
  89357. * @param max defines the color remap maximal range
  89358. * @returns the current particle system
  89359. */
  89360. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89361. /**
  89362. * Gets the current list of color remap gradients.
  89363. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89364. * @returns the list of color remap gradients
  89365. */
  89366. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89367. /**
  89368. * Adds a new alpha remap gradient
  89369. * @param gradient defines the gradient to use (between 0 and 1)
  89370. * @param min defines the alpha remap minimal range
  89371. * @param max defines the alpha remap maximal range
  89372. * @returns the current particle system
  89373. */
  89374. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89375. /**
  89376. * Gets the current list of alpha remap gradients.
  89377. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89378. * @returns the list of alpha remap gradients
  89379. */
  89380. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89381. /**
  89382. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89385. * @returns the emitter
  89386. */
  89387. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89388. /**
  89389. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89390. * @param radius The radius of the hemisphere to emit from
  89391. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89392. * @returns the emitter
  89393. */
  89394. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89395. /**
  89396. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89397. * @param radius The radius of the sphere to emit from
  89398. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89399. * @returns the emitter
  89400. */
  89401. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89402. /**
  89403. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89404. * @param radius The radius of the sphere to emit from
  89405. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89406. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89407. * @returns the emitter
  89408. */
  89409. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89410. /**
  89411. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89412. * @param radius The radius of the emission cylinder
  89413. * @param height The height of the emission cylinder
  89414. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89415. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89416. * @returns the emitter
  89417. */
  89418. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89419. /**
  89420. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89421. * @param radius The radius of the cylinder to emit from
  89422. * @param height The height of the emission cylinder
  89423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89426. * @returns the emitter
  89427. */
  89428. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89429. /**
  89430. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89431. * @param radius The radius of the cone to emit from
  89432. * @param angle The base angle of the cone
  89433. * @returns the emitter
  89434. */
  89435. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89436. /**
  89437. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89440. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89441. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89442. * @returns the emitter
  89443. */
  89444. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89445. /**
  89446. * Get hosting scene
  89447. * @returns the scene
  89448. */
  89449. getScene(): Scene;
  89450. }
  89451. }
  89452. declare module BABYLON {
  89453. /**
  89454. * 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.
  89455. * @see https://doc.babylonjs.com/how_to/transformnode
  89456. */
  89457. export class TransformNode extends Node {
  89458. /**
  89459. * Object will not rotate to face the camera
  89460. */
  89461. static BILLBOARDMODE_NONE: number;
  89462. /**
  89463. * Object will rotate to face the camera but only on the x axis
  89464. */
  89465. static BILLBOARDMODE_X: number;
  89466. /**
  89467. * Object will rotate to face the camera but only on the y axis
  89468. */
  89469. static BILLBOARDMODE_Y: number;
  89470. /**
  89471. * Object will rotate to face the camera but only on the z axis
  89472. */
  89473. static BILLBOARDMODE_Z: number;
  89474. /**
  89475. * Object will rotate to face the camera
  89476. */
  89477. static BILLBOARDMODE_ALL: number;
  89478. /**
  89479. * Object will rotate to face the camera's position instead of orientation
  89480. */
  89481. static BILLBOARDMODE_USE_POSITION: number;
  89482. private _forward;
  89483. private _forwardInverted;
  89484. private _up;
  89485. private _right;
  89486. private _rightInverted;
  89487. private _position;
  89488. private _rotation;
  89489. private _rotationQuaternion;
  89490. protected _scaling: Vector3;
  89491. protected _isDirty: boolean;
  89492. private _transformToBoneReferal;
  89493. private _isAbsoluteSynced;
  89494. private _billboardMode;
  89495. /**
  89496. * Gets or sets the billboard mode. Default is 0.
  89497. *
  89498. * | Value | Type | Description |
  89499. * | --- | --- | --- |
  89500. * | 0 | BILLBOARDMODE_NONE | |
  89501. * | 1 | BILLBOARDMODE_X | |
  89502. * | 2 | BILLBOARDMODE_Y | |
  89503. * | 4 | BILLBOARDMODE_Z | |
  89504. * | 7 | BILLBOARDMODE_ALL | |
  89505. *
  89506. */
  89507. get billboardMode(): number;
  89508. set billboardMode(value: number);
  89509. private _preserveParentRotationForBillboard;
  89510. /**
  89511. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89512. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89513. */
  89514. get preserveParentRotationForBillboard(): boolean;
  89515. set preserveParentRotationForBillboard(value: boolean);
  89516. /**
  89517. * 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
  89518. */
  89519. scalingDeterminant: number;
  89520. private _infiniteDistance;
  89521. /**
  89522. * Gets or sets the distance of the object to max, often used by skybox
  89523. */
  89524. get infiniteDistance(): boolean;
  89525. set infiniteDistance(value: boolean);
  89526. /**
  89527. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89528. * By default the system will update normals to compensate
  89529. */
  89530. ignoreNonUniformScaling: boolean;
  89531. /**
  89532. * 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
  89533. */
  89534. reIntegrateRotationIntoRotationQuaternion: boolean;
  89535. /** @hidden */
  89536. _poseMatrix: Nullable<Matrix>;
  89537. /** @hidden */
  89538. _localMatrix: Matrix;
  89539. private _usePivotMatrix;
  89540. private _absolutePosition;
  89541. private _absoluteScaling;
  89542. private _absoluteRotationQuaternion;
  89543. private _pivotMatrix;
  89544. private _pivotMatrixInverse;
  89545. protected _postMultiplyPivotMatrix: boolean;
  89546. protected _isWorldMatrixFrozen: boolean;
  89547. /** @hidden */
  89548. _indexInSceneTransformNodesArray: number;
  89549. /**
  89550. * An event triggered after the world matrix is updated
  89551. */
  89552. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89553. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89554. /**
  89555. * Gets a string identifying the name of the class
  89556. * @returns "TransformNode" string
  89557. */
  89558. getClassName(): string;
  89559. /**
  89560. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89561. */
  89562. get position(): Vector3;
  89563. set position(newPosition: Vector3);
  89564. /**
  89565. * 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)).
  89566. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89567. */
  89568. get rotation(): Vector3;
  89569. set rotation(newRotation: Vector3);
  89570. /**
  89571. * 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)).
  89572. */
  89573. get scaling(): Vector3;
  89574. set scaling(newScaling: Vector3);
  89575. /**
  89576. * 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).
  89577. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89578. */
  89579. get rotationQuaternion(): Nullable<Quaternion>;
  89580. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89581. /**
  89582. * The forward direction of that transform in world space.
  89583. */
  89584. get forward(): Vector3;
  89585. /**
  89586. * The up direction of that transform in world space.
  89587. */
  89588. get up(): Vector3;
  89589. /**
  89590. * The right direction of that transform in world space.
  89591. */
  89592. get right(): Vector3;
  89593. /**
  89594. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89595. * @param matrix the matrix to copy the pose from
  89596. * @returns this TransformNode.
  89597. */
  89598. updatePoseMatrix(matrix: Matrix): TransformNode;
  89599. /**
  89600. * Returns the mesh Pose matrix.
  89601. * @returns the pose matrix
  89602. */
  89603. getPoseMatrix(): Matrix;
  89604. /** @hidden */
  89605. _isSynchronized(): boolean;
  89606. /** @hidden */
  89607. _initCache(): void;
  89608. /**
  89609. * Flag the transform node as dirty (Forcing it to update everything)
  89610. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89611. * @returns this transform node
  89612. */
  89613. markAsDirty(property: string): TransformNode;
  89614. /**
  89615. * Returns the current mesh absolute position.
  89616. * Returns a Vector3.
  89617. */
  89618. get absolutePosition(): Vector3;
  89619. /**
  89620. * Returns the current mesh absolute scaling.
  89621. * Returns a Vector3.
  89622. */
  89623. get absoluteScaling(): Vector3;
  89624. /**
  89625. * Returns the current mesh absolute rotation.
  89626. * Returns a Quaternion.
  89627. */
  89628. get absoluteRotationQuaternion(): Quaternion;
  89629. /**
  89630. * Sets a new matrix to apply before all other transformation
  89631. * @param matrix defines the transform matrix
  89632. * @returns the current TransformNode
  89633. */
  89634. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89635. /**
  89636. * Sets a new pivot matrix to the current node
  89637. * @param matrix defines the new pivot matrix to use
  89638. * @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
  89639. * @returns the current TransformNode
  89640. */
  89641. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89642. /**
  89643. * Returns the mesh pivot matrix.
  89644. * Default : Identity.
  89645. * @returns the matrix
  89646. */
  89647. getPivotMatrix(): Matrix;
  89648. /**
  89649. * Instantiate (when possible) or clone that node with its hierarchy
  89650. * @param newParent defines the new parent to use for the instance (or clone)
  89651. * @param options defines options to configure how copy is done
  89652. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89653. * @returns an instance (or a clone) of the current node with its hiearchy
  89654. */
  89655. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89656. doNotInstantiate: boolean;
  89657. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89658. /**
  89659. * Prevents the World matrix to be computed any longer
  89660. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89661. * @returns the TransformNode.
  89662. */
  89663. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89664. /**
  89665. * Allows back the World matrix computation.
  89666. * @returns the TransformNode.
  89667. */
  89668. unfreezeWorldMatrix(): this;
  89669. /**
  89670. * True if the World matrix has been frozen.
  89671. */
  89672. get isWorldMatrixFrozen(): boolean;
  89673. /**
  89674. * Retuns the mesh absolute position in the World.
  89675. * @returns a Vector3.
  89676. */
  89677. getAbsolutePosition(): Vector3;
  89678. /**
  89679. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89680. * @param absolutePosition the absolute position to set
  89681. * @returns the TransformNode.
  89682. */
  89683. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89684. /**
  89685. * Sets the mesh position in its local space.
  89686. * @param vector3 the position to set in localspace
  89687. * @returns the TransformNode.
  89688. */
  89689. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89690. /**
  89691. * Returns the mesh position in the local space from the current World matrix values.
  89692. * @returns a new Vector3.
  89693. */
  89694. getPositionExpressedInLocalSpace(): Vector3;
  89695. /**
  89696. * Translates the mesh along the passed Vector3 in its local space.
  89697. * @param vector3 the distance to translate in localspace
  89698. * @returns the TransformNode.
  89699. */
  89700. locallyTranslate(vector3: Vector3): TransformNode;
  89701. private static _lookAtVectorCache;
  89702. /**
  89703. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89704. * @param targetPoint the position (must be in same space as current mesh) to look at
  89705. * @param yawCor optional yaw (y-axis) correction in radians
  89706. * @param pitchCor optional pitch (x-axis) correction in radians
  89707. * @param rollCor optional roll (z-axis) correction in radians
  89708. * @param space the choosen space of the target
  89709. * @returns the TransformNode.
  89710. */
  89711. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89712. /**
  89713. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89714. * This Vector3 is expressed in the World space.
  89715. * @param localAxis axis to rotate
  89716. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89717. */
  89718. getDirection(localAxis: Vector3): Vector3;
  89719. /**
  89720. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89721. * localAxis is expressed in the mesh local space.
  89722. * result is computed in the Wordl space from the mesh World matrix.
  89723. * @param localAxis axis to rotate
  89724. * @param result the resulting transformnode
  89725. * @returns this TransformNode.
  89726. */
  89727. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89728. /**
  89729. * Sets this transform node rotation to the given local axis.
  89730. * @param localAxis the axis in local space
  89731. * @param yawCor optional yaw (y-axis) correction in radians
  89732. * @param pitchCor optional pitch (x-axis) correction in radians
  89733. * @param rollCor optional roll (z-axis) correction in radians
  89734. * @returns this TransformNode
  89735. */
  89736. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89737. /**
  89738. * Sets a new pivot point to the current node
  89739. * @param point defines the new pivot point to use
  89740. * @param space defines if the point is in world or local space (local by default)
  89741. * @returns the current TransformNode
  89742. */
  89743. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89744. /**
  89745. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89746. * @returns the pivot point
  89747. */
  89748. getPivotPoint(): Vector3;
  89749. /**
  89750. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89751. * @param result the vector3 to store the result
  89752. * @returns this TransformNode.
  89753. */
  89754. getPivotPointToRef(result: Vector3): TransformNode;
  89755. /**
  89756. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89757. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89758. */
  89759. getAbsolutePivotPoint(): Vector3;
  89760. /**
  89761. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89762. * @param result vector3 to store the result
  89763. * @returns this TransformNode.
  89764. */
  89765. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  89766. /**
  89767. * Defines the passed node as the parent of the current node.
  89768. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89769. * @see https://doc.babylonjs.com/how_to/parenting
  89770. * @param node the node ot set as the parent
  89771. * @returns this TransformNode.
  89772. */
  89773. setParent(node: Nullable<Node>): TransformNode;
  89774. private _nonUniformScaling;
  89775. /**
  89776. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89777. */
  89778. get nonUniformScaling(): boolean;
  89779. /** @hidden */
  89780. _updateNonUniformScalingState(value: boolean): boolean;
  89781. /**
  89782. * Attach the current TransformNode to another TransformNode associated with a bone
  89783. * @param bone Bone affecting the TransformNode
  89784. * @param affectedTransformNode TransformNode associated with the bone
  89785. * @returns this object
  89786. */
  89787. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  89788. /**
  89789. * Detach the transform node if its associated with a bone
  89790. * @returns this object
  89791. */
  89792. detachFromBone(): TransformNode;
  89793. private static _rotationAxisCache;
  89794. /**
  89795. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89796. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89797. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89798. * The passed axis is also normalized.
  89799. * @param axis the axis to rotate around
  89800. * @param amount the amount to rotate in radians
  89801. * @param space Space to rotate in (Default: local)
  89802. * @returns the TransformNode.
  89803. */
  89804. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89805. /**
  89806. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89807. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89808. * The passed axis is also normalized. .
  89809. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89810. * @param point the point to rotate around
  89811. * @param axis the axis to rotate around
  89812. * @param amount the amount to rotate in radians
  89813. * @returns the TransformNode
  89814. */
  89815. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  89816. /**
  89817. * Translates the mesh along the axis vector for the passed distance in the given space.
  89818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89819. * @param axis the axis to translate in
  89820. * @param distance the distance to translate
  89821. * @param space Space to rotate in (Default: local)
  89822. * @returns the TransformNode.
  89823. */
  89824. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89825. /**
  89826. * Adds a rotation step to the mesh current rotation.
  89827. * x, y, z are Euler angles expressed in radians.
  89828. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89829. * This means this rotation is made in the mesh local space only.
  89830. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89831. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89832. * ```javascript
  89833. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89834. * ```
  89835. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89836. * 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.
  89837. * @param x Rotation to add
  89838. * @param y Rotation to add
  89839. * @param z Rotation to add
  89840. * @returns the TransformNode.
  89841. */
  89842. addRotation(x: number, y: number, z: number): TransformNode;
  89843. /**
  89844. * @hidden
  89845. */
  89846. protected _getEffectiveParent(): Nullable<Node>;
  89847. /**
  89848. * Computes the world matrix of the node
  89849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89850. * @returns the world matrix
  89851. */
  89852. computeWorldMatrix(force?: boolean): Matrix;
  89853. /**
  89854. * Resets this nodeTransform's local matrix to Matrix.Identity().
  89855. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  89856. */
  89857. resetLocalMatrix(independentOfChildren?: boolean): void;
  89858. protected _afterComputeWorldMatrix(): void;
  89859. /**
  89860. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  89861. * @param func callback function to add
  89862. *
  89863. * @returns the TransformNode.
  89864. */
  89865. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89866. /**
  89867. * Removes a registered callback function.
  89868. * @param func callback function to remove
  89869. * @returns the TransformNode.
  89870. */
  89871. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89872. /**
  89873. * Gets the position of the current mesh in camera space
  89874. * @param camera defines the camera to use
  89875. * @returns a position
  89876. */
  89877. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  89878. /**
  89879. * Returns the distance from the mesh to the active camera
  89880. * @param camera defines the camera to use
  89881. * @returns the distance
  89882. */
  89883. getDistanceToCamera(camera?: Nullable<Camera>): number;
  89884. /**
  89885. * Clone the current transform node
  89886. * @param name Name of the new clone
  89887. * @param newParent New parent for the clone
  89888. * @param doNotCloneChildren Do not clone children hierarchy
  89889. * @returns the new transform node
  89890. */
  89891. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  89892. /**
  89893. * Serializes the objects information.
  89894. * @param currentSerializationObject defines the object to serialize in
  89895. * @returns the serialized object
  89896. */
  89897. serialize(currentSerializationObject?: any): any;
  89898. /**
  89899. * Returns a new TransformNode object parsed from the source provided.
  89900. * @param parsedTransformNode is the source.
  89901. * @param scene the scne the object belongs to
  89902. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  89903. * @returns a new TransformNode object parsed from the source provided.
  89904. */
  89905. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  89906. /**
  89907. * Get all child-transformNodes of this node
  89908. * @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
  89909. * @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
  89910. * @returns an array of TransformNode
  89911. */
  89912. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  89913. /**
  89914. * Releases resources associated with this transform node.
  89915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89917. */
  89918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89919. /**
  89920. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89921. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89922. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89923. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89924. * @returns the current mesh
  89925. */
  89926. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  89927. private _syncAbsoluteScalingAndRotation;
  89928. }
  89929. }
  89930. declare module BABYLON {
  89931. /**
  89932. * Class used to override all child animations of a given target
  89933. */
  89934. export class AnimationPropertiesOverride {
  89935. /**
  89936. * Gets or sets a value indicating if animation blending must be used
  89937. */
  89938. enableBlending: boolean;
  89939. /**
  89940. * Gets or sets the blending speed to use when enableBlending is true
  89941. */
  89942. blendingSpeed: number;
  89943. /**
  89944. * Gets or sets the default loop mode to use
  89945. */
  89946. loopMode: number;
  89947. }
  89948. }
  89949. declare module BABYLON {
  89950. /**
  89951. * Class used to store bone information
  89952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89953. */
  89954. export class Bone extends Node {
  89955. /**
  89956. * defines the bone name
  89957. */
  89958. name: string;
  89959. private static _tmpVecs;
  89960. private static _tmpQuat;
  89961. private static _tmpMats;
  89962. /**
  89963. * Gets the list of child bones
  89964. */
  89965. children: Bone[];
  89966. /** Gets the animations associated with this bone */
  89967. animations: Animation[];
  89968. /**
  89969. * Gets or sets bone length
  89970. */
  89971. length: number;
  89972. /**
  89973. * @hidden Internal only
  89974. * Set this value to map this bone to a different index in the transform matrices
  89975. * Set this value to -1 to exclude the bone from the transform matrices
  89976. */
  89977. _index: Nullable<number>;
  89978. private _skeleton;
  89979. private _localMatrix;
  89980. private _restPose;
  89981. private _baseMatrix;
  89982. private _absoluteTransform;
  89983. private _invertedAbsoluteTransform;
  89984. private _parent;
  89985. private _scalingDeterminant;
  89986. private _worldTransform;
  89987. private _localScaling;
  89988. private _localRotation;
  89989. private _localPosition;
  89990. private _needToDecompose;
  89991. private _needToCompose;
  89992. /** @hidden */
  89993. _linkedTransformNode: Nullable<TransformNode>;
  89994. /** @hidden */
  89995. _waitingTransformNodeId: Nullable<string>;
  89996. /** @hidden */
  89997. get _matrix(): Matrix;
  89998. /** @hidden */
  89999. set _matrix(value: Matrix);
  90000. /**
  90001. * Create a new bone
  90002. * @param name defines the bone name
  90003. * @param skeleton defines the parent skeleton
  90004. * @param parentBone defines the parent (can be null if the bone is the root)
  90005. * @param localMatrix defines the local matrix
  90006. * @param restPose defines the rest pose matrix
  90007. * @param baseMatrix defines the base matrix
  90008. * @param index defines index of the bone in the hiearchy
  90009. */
  90010. constructor(
  90011. /**
  90012. * defines the bone name
  90013. */
  90014. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90015. /**
  90016. * Gets the current object class name.
  90017. * @return the class name
  90018. */
  90019. getClassName(): string;
  90020. /**
  90021. * Gets the parent skeleton
  90022. * @returns a skeleton
  90023. */
  90024. getSkeleton(): Skeleton;
  90025. /**
  90026. * Gets parent bone
  90027. * @returns a bone or null if the bone is the root of the bone hierarchy
  90028. */
  90029. getParent(): Nullable<Bone>;
  90030. /**
  90031. * Returns an array containing the root bones
  90032. * @returns an array containing the root bones
  90033. */
  90034. getChildren(): Array<Bone>;
  90035. /**
  90036. * Gets the node index in matrix array generated for rendering
  90037. * @returns the node index
  90038. */
  90039. getIndex(): number;
  90040. /**
  90041. * Sets the parent bone
  90042. * @param parent defines the parent (can be null if the bone is the root)
  90043. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90044. */
  90045. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90046. /**
  90047. * Gets the local matrix
  90048. * @returns a matrix
  90049. */
  90050. getLocalMatrix(): Matrix;
  90051. /**
  90052. * Gets the base matrix (initial matrix which remains unchanged)
  90053. * @returns a matrix
  90054. */
  90055. getBaseMatrix(): Matrix;
  90056. /**
  90057. * Gets the rest pose matrix
  90058. * @returns a matrix
  90059. */
  90060. getRestPose(): Matrix;
  90061. /**
  90062. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90063. */
  90064. getWorldMatrix(): Matrix;
  90065. /**
  90066. * Sets the local matrix to rest pose matrix
  90067. */
  90068. returnToRest(): void;
  90069. /**
  90070. * Gets the inverse of the absolute transform matrix.
  90071. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90072. * @returns a matrix
  90073. */
  90074. getInvertedAbsoluteTransform(): Matrix;
  90075. /**
  90076. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90077. * @returns a matrix
  90078. */
  90079. getAbsoluteTransform(): Matrix;
  90080. /**
  90081. * Links with the given transform node.
  90082. * The local matrix of this bone is copied from the transform node every frame.
  90083. * @param transformNode defines the transform node to link to
  90084. */
  90085. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90086. /**
  90087. * Gets the node used to drive the bone's transformation
  90088. * @returns a transform node or null
  90089. */
  90090. getTransformNode(): Nullable<TransformNode>;
  90091. /** Gets or sets current position (in local space) */
  90092. get position(): Vector3;
  90093. set position(newPosition: Vector3);
  90094. /** Gets or sets current rotation (in local space) */
  90095. get rotation(): Vector3;
  90096. set rotation(newRotation: Vector3);
  90097. /** Gets or sets current rotation quaternion (in local space) */
  90098. get rotationQuaternion(): Quaternion;
  90099. set rotationQuaternion(newRotation: Quaternion);
  90100. /** Gets or sets current scaling (in local space) */
  90101. get scaling(): Vector3;
  90102. set scaling(newScaling: Vector3);
  90103. /**
  90104. * Gets the animation properties override
  90105. */
  90106. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90107. private _decompose;
  90108. private _compose;
  90109. /**
  90110. * Update the base and local matrices
  90111. * @param matrix defines the new base or local matrix
  90112. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90113. * @param updateLocalMatrix defines if the local matrix should be updated
  90114. */
  90115. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90116. /** @hidden */
  90117. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90118. /**
  90119. * Flag the bone as dirty (Forcing it to update everything)
  90120. */
  90121. markAsDirty(): void;
  90122. /** @hidden */
  90123. _markAsDirtyAndCompose(): void;
  90124. private _markAsDirtyAndDecompose;
  90125. /**
  90126. * Translate the bone in local or world space
  90127. * @param vec The amount to translate the bone
  90128. * @param space The space that the translation is in
  90129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90130. */
  90131. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90132. /**
  90133. * Set the postion of the bone in local or world space
  90134. * @param position The position to set the bone
  90135. * @param space The space that the position is in
  90136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90137. */
  90138. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90139. /**
  90140. * Set the absolute position of the bone (world space)
  90141. * @param position The position to set the bone
  90142. * @param mesh The mesh that this bone is attached to
  90143. */
  90144. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90145. /**
  90146. * Scale the bone on the x, y and z axes (in local space)
  90147. * @param x The amount to scale the bone on the x axis
  90148. * @param y The amount to scale the bone on the y axis
  90149. * @param z The amount to scale the bone on the z axis
  90150. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90151. */
  90152. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90153. /**
  90154. * Set the bone scaling in local space
  90155. * @param scale defines the scaling vector
  90156. */
  90157. setScale(scale: Vector3): void;
  90158. /**
  90159. * Gets the current scaling in local space
  90160. * @returns the current scaling vector
  90161. */
  90162. getScale(): Vector3;
  90163. /**
  90164. * Gets the current scaling in local space and stores it in a target vector
  90165. * @param result defines the target vector
  90166. */
  90167. getScaleToRef(result: Vector3): void;
  90168. /**
  90169. * Set the yaw, pitch, and roll of the bone in local or world space
  90170. * @param yaw The rotation of the bone on the y axis
  90171. * @param pitch The rotation of the bone on the x axis
  90172. * @param roll The rotation of the bone on the z axis
  90173. * @param space The space that the axes of rotation are in
  90174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90175. */
  90176. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90177. /**
  90178. * Add a rotation to the bone on an axis in local or world space
  90179. * @param axis The axis to rotate the bone on
  90180. * @param amount The amount to rotate the bone
  90181. * @param space The space that the axis is in
  90182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90183. */
  90184. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90185. /**
  90186. * Set the rotation of the bone to a particular axis angle in local or world space
  90187. * @param axis The axis to rotate the bone on
  90188. * @param angle The angle that the bone should be rotated to
  90189. * @param space The space that the axis is in
  90190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90191. */
  90192. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90193. /**
  90194. * Set the euler rotation of the bone in local of world space
  90195. * @param rotation The euler rotation that the bone should be set to
  90196. * @param space The space that the rotation is in
  90197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90198. */
  90199. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90200. /**
  90201. * Set the quaternion rotation of the bone in local of world space
  90202. * @param quat The quaternion rotation that the bone should be set to
  90203. * @param space The space that the rotation is in
  90204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90205. */
  90206. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90207. /**
  90208. * Set the rotation matrix of the bone in local of world space
  90209. * @param rotMat The rotation matrix that the bone should be set to
  90210. * @param space The space that the rotation is in
  90211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90212. */
  90213. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90214. private _rotateWithMatrix;
  90215. private _getNegativeRotationToRef;
  90216. /**
  90217. * Get the position of the bone in local or world space
  90218. * @param space The space that the returned position is in
  90219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90220. * @returns The position of the bone
  90221. */
  90222. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90223. /**
  90224. * Copy the position of the bone to a vector3 in local or world space
  90225. * @param space The space that the returned position is in
  90226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90227. * @param result The vector3 to copy the position to
  90228. */
  90229. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90230. /**
  90231. * Get the absolute position of the bone (world space)
  90232. * @param mesh The mesh that this bone is attached to
  90233. * @returns The absolute position of the bone
  90234. */
  90235. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90236. /**
  90237. * Copy the absolute position of the bone (world space) to the result param
  90238. * @param mesh The mesh that this bone is attached to
  90239. * @param result The vector3 to copy the absolute position to
  90240. */
  90241. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90242. /**
  90243. * Compute the absolute transforms of this bone and its children
  90244. */
  90245. computeAbsoluteTransforms(): void;
  90246. /**
  90247. * Get the world direction from an axis that is in the local space of the bone
  90248. * @param localAxis The local direction that is used to compute the world direction
  90249. * @param mesh The mesh that this bone is attached to
  90250. * @returns The world direction
  90251. */
  90252. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90253. /**
  90254. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90255. * @param localAxis The local direction that is used to compute the world direction
  90256. * @param mesh The mesh that this bone is attached to
  90257. * @param result The vector3 that the world direction will be copied to
  90258. */
  90259. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90260. /**
  90261. * Get the euler rotation of the bone in local or world space
  90262. * @param space The space that the rotation should be in
  90263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90264. * @returns The euler rotation
  90265. */
  90266. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90267. /**
  90268. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90269. * @param space The space that the rotation should be in
  90270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90271. * @param result The vector3 that the rotation should be copied to
  90272. */
  90273. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90274. /**
  90275. * Get the quaternion rotation of the bone in either local or world space
  90276. * @param space The space that the rotation should be in
  90277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90278. * @returns The quaternion rotation
  90279. */
  90280. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90281. /**
  90282. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90283. * @param space The space that the rotation should be in
  90284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90285. * @param result The quaternion that the rotation should be copied to
  90286. */
  90287. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90288. /**
  90289. * Get the rotation matrix of the bone in local or world space
  90290. * @param space The space that the rotation should be in
  90291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90292. * @returns The rotation matrix
  90293. */
  90294. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90295. /**
  90296. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90297. * @param space The space that the rotation should be in
  90298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90299. * @param result The quaternion that the rotation should be copied to
  90300. */
  90301. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90302. /**
  90303. * Get the world position of a point that is in the local space of the bone
  90304. * @param position The local position
  90305. * @param mesh The mesh that this bone is attached to
  90306. * @returns The world position
  90307. */
  90308. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90309. /**
  90310. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90311. * @param position The local position
  90312. * @param mesh The mesh that this bone is attached to
  90313. * @param result The vector3 that the world position should be copied to
  90314. */
  90315. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90316. /**
  90317. * Get the local position of a point that is in world space
  90318. * @param position The world position
  90319. * @param mesh The mesh that this bone is attached to
  90320. * @returns The local position
  90321. */
  90322. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90323. /**
  90324. * Get the local position of a point that is in world space and copy it to the result param
  90325. * @param position The world position
  90326. * @param mesh The mesh that this bone is attached to
  90327. * @param result The vector3 that the local position should be copied to
  90328. */
  90329. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90330. }
  90331. }
  90332. declare module BABYLON {
  90333. /**
  90334. * Defines a runtime animation
  90335. */
  90336. export class RuntimeAnimation {
  90337. private _events;
  90338. /**
  90339. * The current frame of the runtime animation
  90340. */
  90341. private _currentFrame;
  90342. /**
  90343. * The animation used by the runtime animation
  90344. */
  90345. private _animation;
  90346. /**
  90347. * The target of the runtime animation
  90348. */
  90349. private _target;
  90350. /**
  90351. * The initiating animatable
  90352. */
  90353. private _host;
  90354. /**
  90355. * The original value of the runtime animation
  90356. */
  90357. private _originalValue;
  90358. /**
  90359. * The original blend value of the runtime animation
  90360. */
  90361. private _originalBlendValue;
  90362. /**
  90363. * The offsets cache of the runtime animation
  90364. */
  90365. private _offsetsCache;
  90366. /**
  90367. * The high limits cache of the runtime animation
  90368. */
  90369. private _highLimitsCache;
  90370. /**
  90371. * Specifies if the runtime animation has been stopped
  90372. */
  90373. private _stopped;
  90374. /**
  90375. * The blending factor of the runtime animation
  90376. */
  90377. private _blendingFactor;
  90378. /**
  90379. * The BabylonJS scene
  90380. */
  90381. private _scene;
  90382. /**
  90383. * The current value of the runtime animation
  90384. */
  90385. private _currentValue;
  90386. /** @hidden */
  90387. _animationState: _IAnimationState;
  90388. /**
  90389. * The active target of the runtime animation
  90390. */
  90391. private _activeTargets;
  90392. private _currentActiveTarget;
  90393. private _directTarget;
  90394. /**
  90395. * The target path of the runtime animation
  90396. */
  90397. private _targetPath;
  90398. /**
  90399. * The weight of the runtime animation
  90400. */
  90401. private _weight;
  90402. /**
  90403. * The ratio offset of the runtime animation
  90404. */
  90405. private _ratioOffset;
  90406. /**
  90407. * The previous delay of the runtime animation
  90408. */
  90409. private _previousDelay;
  90410. /**
  90411. * The previous ratio of the runtime animation
  90412. */
  90413. private _previousRatio;
  90414. private _enableBlending;
  90415. private _keys;
  90416. private _minFrame;
  90417. private _maxFrame;
  90418. private _minValue;
  90419. private _maxValue;
  90420. private _targetIsArray;
  90421. /**
  90422. * Gets the current frame of the runtime animation
  90423. */
  90424. get currentFrame(): number;
  90425. /**
  90426. * Gets the weight of the runtime animation
  90427. */
  90428. get weight(): number;
  90429. /**
  90430. * Gets the current value of the runtime animation
  90431. */
  90432. get currentValue(): any;
  90433. /**
  90434. * Gets the target path of the runtime animation
  90435. */
  90436. get targetPath(): string;
  90437. /**
  90438. * Gets the actual target of the runtime animation
  90439. */
  90440. get target(): any;
  90441. /**
  90442. * Gets the additive state of the runtime animation
  90443. */
  90444. get isAdditive(): boolean;
  90445. /** @hidden */
  90446. _onLoop: () => void;
  90447. /**
  90448. * Create a new RuntimeAnimation object
  90449. * @param target defines the target of the animation
  90450. * @param animation defines the source animation object
  90451. * @param scene defines the hosting scene
  90452. * @param host defines the initiating Animatable
  90453. */
  90454. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90455. private _preparePath;
  90456. /**
  90457. * Gets the animation from the runtime animation
  90458. */
  90459. get animation(): Animation;
  90460. /**
  90461. * Resets the runtime animation to the beginning
  90462. * @param restoreOriginal defines whether to restore the target property to the original value
  90463. */
  90464. reset(restoreOriginal?: boolean): void;
  90465. /**
  90466. * Specifies if the runtime animation is stopped
  90467. * @returns Boolean specifying if the runtime animation is stopped
  90468. */
  90469. isStopped(): boolean;
  90470. /**
  90471. * Disposes of the runtime animation
  90472. */
  90473. dispose(): void;
  90474. /**
  90475. * Apply the interpolated value to the target
  90476. * @param currentValue defines the value computed by the animation
  90477. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90478. */
  90479. setValue(currentValue: any, weight: number): void;
  90480. private _getOriginalValues;
  90481. private _setValue;
  90482. /**
  90483. * Gets the loop pmode of the runtime animation
  90484. * @returns Loop Mode
  90485. */
  90486. private _getCorrectLoopMode;
  90487. /**
  90488. * Move the current animation to a given frame
  90489. * @param frame defines the frame to move to
  90490. */
  90491. goToFrame(frame: number): void;
  90492. /**
  90493. * @hidden Internal use only
  90494. */
  90495. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90496. /**
  90497. * Execute the current animation
  90498. * @param delay defines the delay to add to the current frame
  90499. * @param from defines the lower bound of the animation range
  90500. * @param to defines the upper bound of the animation range
  90501. * @param loop defines if the current animation must loop
  90502. * @param speedRatio defines the current speed ratio
  90503. * @param weight defines the weight of the animation (default is -1 so no weight)
  90504. * @param onLoop optional callback called when animation loops
  90505. * @returns a boolean indicating if the animation is running
  90506. */
  90507. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90508. }
  90509. }
  90510. declare module BABYLON {
  90511. /**
  90512. * Class used to store an actual running animation
  90513. */
  90514. export class Animatable {
  90515. /** defines the target object */
  90516. target: any;
  90517. /** defines the starting frame number (default is 0) */
  90518. fromFrame: number;
  90519. /** defines the ending frame number (default is 100) */
  90520. toFrame: number;
  90521. /** defines if the animation must loop (default is false) */
  90522. loopAnimation: boolean;
  90523. /** defines a callback to call when animation ends if it is not looping */
  90524. onAnimationEnd?: (() => void) | null | undefined;
  90525. /** defines a callback to call when animation loops */
  90526. onAnimationLoop?: (() => void) | null | undefined;
  90527. /** defines whether the animation should be evaluated additively */
  90528. isAdditive: boolean;
  90529. private _localDelayOffset;
  90530. private _pausedDelay;
  90531. private _runtimeAnimations;
  90532. private _paused;
  90533. private _scene;
  90534. private _speedRatio;
  90535. private _weight;
  90536. private _syncRoot;
  90537. /**
  90538. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90539. * This will only apply for non looping animation (default is true)
  90540. */
  90541. disposeOnEnd: boolean;
  90542. /**
  90543. * Gets a boolean indicating if the animation has started
  90544. */
  90545. animationStarted: boolean;
  90546. /**
  90547. * Observer raised when the animation ends
  90548. */
  90549. onAnimationEndObservable: Observable<Animatable>;
  90550. /**
  90551. * Observer raised when the animation loops
  90552. */
  90553. onAnimationLoopObservable: Observable<Animatable>;
  90554. /**
  90555. * Gets the root Animatable used to synchronize and normalize animations
  90556. */
  90557. get syncRoot(): Nullable<Animatable>;
  90558. /**
  90559. * Gets the current frame of the first RuntimeAnimation
  90560. * Used to synchronize Animatables
  90561. */
  90562. get masterFrame(): number;
  90563. /**
  90564. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90565. */
  90566. get weight(): number;
  90567. set weight(value: number);
  90568. /**
  90569. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90570. */
  90571. get speedRatio(): number;
  90572. set speedRatio(value: number);
  90573. /**
  90574. * Creates a new Animatable
  90575. * @param scene defines the hosting scene
  90576. * @param target defines the target object
  90577. * @param fromFrame defines the starting frame number (default is 0)
  90578. * @param toFrame defines the ending frame number (default is 100)
  90579. * @param loopAnimation defines if the animation must loop (default is false)
  90580. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90581. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90582. * @param animations defines a group of animation to add to the new Animatable
  90583. * @param onAnimationLoop defines a callback to call when animation loops
  90584. * @param isAdditive defines whether the animation should be evaluated additively
  90585. */
  90586. constructor(scene: Scene,
  90587. /** defines the target object */
  90588. target: any,
  90589. /** defines the starting frame number (default is 0) */
  90590. fromFrame?: number,
  90591. /** defines the ending frame number (default is 100) */
  90592. toFrame?: number,
  90593. /** defines if the animation must loop (default is false) */
  90594. loopAnimation?: boolean, speedRatio?: number,
  90595. /** defines a callback to call when animation ends if it is not looping */
  90596. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90597. /** defines a callback to call when animation loops */
  90598. onAnimationLoop?: (() => void) | null | undefined,
  90599. /** defines whether the animation should be evaluated additively */
  90600. isAdditive?: boolean);
  90601. /**
  90602. * Synchronize and normalize current Animatable with a source Animatable
  90603. * This is useful when using animation weights and when animations are not of the same length
  90604. * @param root defines the root Animatable to synchronize with
  90605. * @returns the current Animatable
  90606. */
  90607. syncWith(root: Animatable): Animatable;
  90608. /**
  90609. * Gets the list of runtime animations
  90610. * @returns an array of RuntimeAnimation
  90611. */
  90612. getAnimations(): RuntimeAnimation[];
  90613. /**
  90614. * Adds more animations to the current animatable
  90615. * @param target defines the target of the animations
  90616. * @param animations defines the new animations to add
  90617. */
  90618. appendAnimations(target: any, animations: Animation[]): void;
  90619. /**
  90620. * Gets the source animation for a specific property
  90621. * @param property defines the propertyu to look for
  90622. * @returns null or the source animation for the given property
  90623. */
  90624. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90625. /**
  90626. * Gets the runtime animation for a specific property
  90627. * @param property defines the propertyu to look for
  90628. * @returns null or the runtime animation for the given property
  90629. */
  90630. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90631. /**
  90632. * Resets the animatable to its original state
  90633. */
  90634. reset(): void;
  90635. /**
  90636. * Allows the animatable to blend with current running animations
  90637. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90638. * @param blendingSpeed defines the blending speed to use
  90639. */
  90640. enableBlending(blendingSpeed: number): void;
  90641. /**
  90642. * Disable animation blending
  90643. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90644. */
  90645. disableBlending(): void;
  90646. /**
  90647. * Jump directly to a given frame
  90648. * @param frame defines the frame to jump to
  90649. */
  90650. goToFrame(frame: number): void;
  90651. /**
  90652. * Pause the animation
  90653. */
  90654. pause(): void;
  90655. /**
  90656. * Restart the animation
  90657. */
  90658. restart(): void;
  90659. private _raiseOnAnimationEnd;
  90660. /**
  90661. * Stop and delete the current animation
  90662. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90663. * @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)
  90664. */
  90665. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90666. /**
  90667. * Wait asynchronously for the animation to end
  90668. * @returns a promise which will be fullfilled when the animation ends
  90669. */
  90670. waitAsync(): Promise<Animatable>;
  90671. /** @hidden */
  90672. _animate(delay: number): boolean;
  90673. }
  90674. interface Scene {
  90675. /** @hidden */
  90676. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90677. /** @hidden */
  90678. _processLateAnimationBindingsForMatrices(holder: {
  90679. totalWeight: number;
  90680. totalAdditiveWeight: number;
  90681. animations: RuntimeAnimation[];
  90682. additiveAnimations: RuntimeAnimation[];
  90683. originalValue: Matrix;
  90684. }): any;
  90685. /** @hidden */
  90686. _processLateAnimationBindingsForQuaternions(holder: {
  90687. totalWeight: number;
  90688. totalAdditiveWeight: number;
  90689. animations: RuntimeAnimation[];
  90690. additiveAnimations: RuntimeAnimation[];
  90691. originalValue: Quaternion;
  90692. }, refQuaternion: Quaternion): Quaternion;
  90693. /** @hidden */
  90694. _processLateAnimationBindings(): void;
  90695. /**
  90696. * Will start the animation sequence of a given target
  90697. * @param target defines the target
  90698. * @param from defines from which frame should animation start
  90699. * @param to defines until which frame should animation run.
  90700. * @param weight defines the weight to apply to the animation (1.0 by default)
  90701. * @param loop defines if the animation loops
  90702. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90703. * @param onAnimationEnd defines the function to be executed when the animation ends
  90704. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90705. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90706. * @param onAnimationLoop defines the callback to call when an animation loops
  90707. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90708. * @returns the animatable object created for this animation
  90709. */
  90710. 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;
  90711. /**
  90712. * Will start the animation sequence of a given target
  90713. * @param target defines the target
  90714. * @param from defines from which frame should animation start
  90715. * @param to defines until which frame should animation run.
  90716. * @param loop defines if the animation loops
  90717. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90718. * @param onAnimationEnd defines the function to be executed when the animation ends
  90719. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90720. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90721. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90722. * @param onAnimationLoop defines the callback to call when an animation loops
  90723. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90724. * @returns the animatable object created for this animation
  90725. */
  90726. 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;
  90727. /**
  90728. * Will start the animation sequence of a given target and its hierarchy
  90729. * @param target defines the target
  90730. * @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.
  90731. * @param from defines from which frame should animation start
  90732. * @param to defines until which frame should animation run.
  90733. * @param loop defines if the animation loops
  90734. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90735. * @param onAnimationEnd defines the function to be executed when the animation ends
  90736. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90737. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90738. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90739. * @param onAnimationLoop defines the callback to call when an animation loops
  90740. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90741. * @returns the list of created animatables
  90742. */
  90743. 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[];
  90744. /**
  90745. * Begin a new animation on a given node
  90746. * @param target defines the target where the animation will take place
  90747. * @param animations defines the list of animations to start
  90748. * @param from defines the initial value
  90749. * @param to defines the final value
  90750. * @param loop defines if you want animation to loop (off by default)
  90751. * @param speedRatio defines the speed ratio to apply to all animations
  90752. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90753. * @param onAnimationLoop defines the callback to call when an animation loops
  90754. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90755. * @returns the list of created animatables
  90756. */
  90757. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90758. /**
  90759. * Begin a new animation on a given node and its hierarchy
  90760. * @param target defines the root node where the animation will take place
  90761. * @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.
  90762. * @param animations defines the list of animations to start
  90763. * @param from defines the initial value
  90764. * @param to defines the final value
  90765. * @param loop defines if you want animation to loop (off by default)
  90766. * @param speedRatio defines the speed ratio to apply to all animations
  90767. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90768. * @param onAnimationLoop defines the callback to call when an animation loops
  90769. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90770. * @returns the list of animatables created for all nodes
  90771. */
  90772. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90773. /**
  90774. * Gets the animatable associated with a specific target
  90775. * @param target defines the target of the animatable
  90776. * @returns the required animatable if found
  90777. */
  90778. getAnimatableByTarget(target: any): Nullable<Animatable>;
  90779. /**
  90780. * Gets all animatables associated with a given target
  90781. * @param target defines the target to look animatables for
  90782. * @returns an array of Animatables
  90783. */
  90784. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  90785. /**
  90786. * Stops and removes all animations that have been applied to the scene
  90787. */
  90788. stopAllAnimations(): void;
  90789. /**
  90790. * Gets the current delta time used by animation engine
  90791. */
  90792. deltaTime: number;
  90793. }
  90794. interface Bone {
  90795. /**
  90796. * Copy an animation range from another bone
  90797. * @param source defines the source bone
  90798. * @param rangeName defines the range name to copy
  90799. * @param frameOffset defines the frame offset
  90800. * @param rescaleAsRequired defines if rescaling must be applied if required
  90801. * @param skelDimensionsRatio defines the scaling ratio
  90802. * @returns true if operation was successful
  90803. */
  90804. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  90805. }
  90806. }
  90807. declare module BABYLON {
  90808. /**
  90809. * Class used to handle skinning animations
  90810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90811. */
  90812. export class Skeleton implements IAnimatable {
  90813. /** defines the skeleton name */
  90814. name: string;
  90815. /** defines the skeleton Id */
  90816. id: string;
  90817. /**
  90818. * Defines the list of child bones
  90819. */
  90820. bones: Bone[];
  90821. /**
  90822. * Defines an estimate of the dimension of the skeleton at rest
  90823. */
  90824. dimensionsAtRest: Vector3;
  90825. /**
  90826. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  90827. */
  90828. needInitialSkinMatrix: boolean;
  90829. /**
  90830. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  90831. */
  90832. overrideMesh: Nullable<AbstractMesh>;
  90833. /**
  90834. * Gets the list of animations attached to this skeleton
  90835. */
  90836. animations: Array<Animation>;
  90837. private _scene;
  90838. private _isDirty;
  90839. private _transformMatrices;
  90840. private _transformMatrixTexture;
  90841. private _meshesWithPoseMatrix;
  90842. private _animatables;
  90843. private _identity;
  90844. private _synchronizedWithMesh;
  90845. private _ranges;
  90846. private _lastAbsoluteTransformsUpdateId;
  90847. private _canUseTextureForBones;
  90848. private _uniqueId;
  90849. /** @hidden */
  90850. _numBonesWithLinkedTransformNode: number;
  90851. /** @hidden */
  90852. _hasWaitingData: Nullable<boolean>;
  90853. /**
  90854. * Specifies if the skeleton should be serialized
  90855. */
  90856. doNotSerialize: boolean;
  90857. private _useTextureToStoreBoneMatrices;
  90858. /**
  90859. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  90860. * Please note that this option is not available if the hardware does not support it
  90861. */
  90862. get useTextureToStoreBoneMatrices(): boolean;
  90863. set useTextureToStoreBoneMatrices(value: boolean);
  90864. private _animationPropertiesOverride;
  90865. /**
  90866. * Gets or sets the animation properties override
  90867. */
  90868. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90869. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  90870. /**
  90871. * List of inspectable custom properties (used by the Inspector)
  90872. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90873. */
  90874. inspectableCustomProperties: IInspectable[];
  90875. /**
  90876. * An observable triggered before computing the skeleton's matrices
  90877. */
  90878. onBeforeComputeObservable: Observable<Skeleton>;
  90879. /**
  90880. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  90881. */
  90882. get isUsingTextureForMatrices(): boolean;
  90883. /**
  90884. * Gets the unique ID of this skeleton
  90885. */
  90886. get uniqueId(): number;
  90887. /**
  90888. * Creates a new skeleton
  90889. * @param name defines the skeleton name
  90890. * @param id defines the skeleton Id
  90891. * @param scene defines the hosting scene
  90892. */
  90893. constructor(
  90894. /** defines the skeleton name */
  90895. name: string,
  90896. /** defines the skeleton Id */
  90897. id: string, scene: Scene);
  90898. /**
  90899. * Gets the current object class name.
  90900. * @return the class name
  90901. */
  90902. getClassName(): string;
  90903. /**
  90904. * Returns an array containing the root bones
  90905. * @returns an array containing the root bones
  90906. */
  90907. getChildren(): Array<Bone>;
  90908. /**
  90909. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  90910. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90911. * @returns a Float32Array containing matrices data
  90912. */
  90913. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  90914. /**
  90915. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  90916. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90917. * @returns a raw texture containing the data
  90918. */
  90919. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  90920. /**
  90921. * Gets the current hosting scene
  90922. * @returns a scene object
  90923. */
  90924. getScene(): Scene;
  90925. /**
  90926. * Gets a string representing the current skeleton data
  90927. * @param fullDetails defines a boolean indicating if we want a verbose version
  90928. * @returns a string representing the current skeleton data
  90929. */
  90930. toString(fullDetails?: boolean): string;
  90931. /**
  90932. * Get bone's index searching by name
  90933. * @param name defines bone's name to search for
  90934. * @return the indice of the bone. Returns -1 if not found
  90935. */
  90936. getBoneIndexByName(name: string): number;
  90937. /**
  90938. * Creater a new animation range
  90939. * @param name defines the name of the range
  90940. * @param from defines the start key
  90941. * @param to defines the end key
  90942. */
  90943. createAnimationRange(name: string, from: number, to: number): void;
  90944. /**
  90945. * Delete a specific animation range
  90946. * @param name defines the name of the range
  90947. * @param deleteFrames defines if frames must be removed as well
  90948. */
  90949. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90950. /**
  90951. * Gets a specific animation range
  90952. * @param name defines the name of the range to look for
  90953. * @returns the requested animation range or null if not found
  90954. */
  90955. getAnimationRange(name: string): Nullable<AnimationRange>;
  90956. /**
  90957. * Gets the list of all animation ranges defined on this skeleton
  90958. * @returns an array
  90959. */
  90960. getAnimationRanges(): Nullable<AnimationRange>[];
  90961. /**
  90962. * Copy animation range from a source skeleton.
  90963. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  90964. * @param source defines the source skeleton
  90965. * @param name defines the name of the range to copy
  90966. * @param rescaleAsRequired defines if rescaling must be applied if required
  90967. * @returns true if operation was successful
  90968. */
  90969. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  90970. /**
  90971. * Forces the skeleton to go to rest pose
  90972. */
  90973. returnToRest(): void;
  90974. private _getHighestAnimationFrame;
  90975. /**
  90976. * Begin a specific animation range
  90977. * @param name defines the name of the range to start
  90978. * @param loop defines if looping must be turned on (false by default)
  90979. * @param speedRatio defines the speed ratio to apply (1 by default)
  90980. * @param onAnimationEnd defines a callback which will be called when animation will end
  90981. * @returns a new animatable
  90982. */
  90983. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90984. /**
  90985. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  90986. * @param skeleton defines the Skeleton containing the animation range to convert
  90987. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  90988. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  90989. * @returns the original skeleton
  90990. */
  90991. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  90992. /** @hidden */
  90993. _markAsDirty(): void;
  90994. /** @hidden */
  90995. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90996. /** @hidden */
  90997. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90998. private _computeTransformMatrices;
  90999. /**
  91000. * Build all resources required to render a skeleton
  91001. */
  91002. prepare(): void;
  91003. /**
  91004. * Gets the list of animatables currently running for this skeleton
  91005. * @returns an array of animatables
  91006. */
  91007. getAnimatables(): IAnimatable[];
  91008. /**
  91009. * Clone the current skeleton
  91010. * @param name defines the name of the new skeleton
  91011. * @param id defines the id of the new skeleton
  91012. * @returns the new skeleton
  91013. */
  91014. clone(name: string, id?: string): Skeleton;
  91015. /**
  91016. * Enable animation blending for this skeleton
  91017. * @param blendingSpeed defines the blending speed to apply
  91018. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91019. */
  91020. enableBlending(blendingSpeed?: number): void;
  91021. /**
  91022. * Releases all resources associated with the current skeleton
  91023. */
  91024. dispose(): void;
  91025. /**
  91026. * Serialize the skeleton in a JSON object
  91027. * @returns a JSON object
  91028. */
  91029. serialize(): any;
  91030. /**
  91031. * Creates a new skeleton from serialized data
  91032. * @param parsedSkeleton defines the serialized data
  91033. * @param scene defines the hosting scene
  91034. * @returns a new skeleton
  91035. */
  91036. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91037. /**
  91038. * Compute all node absolute transforms
  91039. * @param forceUpdate defines if computation must be done even if cache is up to date
  91040. */
  91041. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91042. /**
  91043. * Gets the root pose matrix
  91044. * @returns a matrix
  91045. */
  91046. getPoseMatrix(): Nullable<Matrix>;
  91047. /**
  91048. * Sorts bones per internal index
  91049. */
  91050. sortBones(): void;
  91051. private _sortBones;
  91052. }
  91053. }
  91054. declare module BABYLON {
  91055. /**
  91056. * Creates an instance based on a source mesh.
  91057. */
  91058. export class InstancedMesh extends AbstractMesh {
  91059. private _sourceMesh;
  91060. private _currentLOD;
  91061. /** @hidden */
  91062. _indexInSourceMeshInstanceArray: number;
  91063. constructor(name: string, source: Mesh);
  91064. /**
  91065. * Returns the string "InstancedMesh".
  91066. */
  91067. getClassName(): string;
  91068. /** Gets the list of lights affecting that mesh */
  91069. get lightSources(): Light[];
  91070. _resyncLightSources(): void;
  91071. _resyncLightSource(light: Light): void;
  91072. _removeLightSource(light: Light, dispose: boolean): void;
  91073. /**
  91074. * If the source mesh receives shadows
  91075. */
  91076. get receiveShadows(): boolean;
  91077. /**
  91078. * The material of the source mesh
  91079. */
  91080. get material(): Nullable<Material>;
  91081. /**
  91082. * Visibility of the source mesh
  91083. */
  91084. get visibility(): number;
  91085. /**
  91086. * Skeleton of the source mesh
  91087. */
  91088. get skeleton(): Nullable<Skeleton>;
  91089. /**
  91090. * Rendering ground id of the source mesh
  91091. */
  91092. get renderingGroupId(): number;
  91093. set renderingGroupId(value: number);
  91094. /**
  91095. * Returns the total number of vertices (integer).
  91096. */
  91097. getTotalVertices(): number;
  91098. /**
  91099. * Returns a positive integer : the total number of indices in this mesh geometry.
  91100. * @returns the numner of indices or zero if the mesh has no geometry.
  91101. */
  91102. getTotalIndices(): number;
  91103. /**
  91104. * The source mesh of the instance
  91105. */
  91106. get sourceMesh(): Mesh;
  91107. /**
  91108. * Is this node ready to be used/rendered
  91109. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91110. * @return {boolean} is it ready
  91111. */
  91112. isReady(completeCheck?: boolean): boolean;
  91113. /**
  91114. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91115. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91116. * @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.
  91117. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91118. */
  91119. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91120. /**
  91121. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91122. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91123. * The `data` are either a numeric array either a Float32Array.
  91124. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91125. * 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).
  91126. * Note that a new underlying VertexBuffer object is created each call.
  91127. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91128. *
  91129. * Possible `kind` values :
  91130. * - VertexBuffer.PositionKind
  91131. * - VertexBuffer.UVKind
  91132. * - VertexBuffer.UV2Kind
  91133. * - VertexBuffer.UV3Kind
  91134. * - VertexBuffer.UV4Kind
  91135. * - VertexBuffer.UV5Kind
  91136. * - VertexBuffer.UV6Kind
  91137. * - VertexBuffer.ColorKind
  91138. * - VertexBuffer.MatricesIndicesKind
  91139. * - VertexBuffer.MatricesIndicesExtraKind
  91140. * - VertexBuffer.MatricesWeightsKind
  91141. * - VertexBuffer.MatricesWeightsExtraKind
  91142. *
  91143. * Returns the Mesh.
  91144. */
  91145. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91146. /**
  91147. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91148. * If the mesh has no geometry, it is simply returned as it is.
  91149. * The `data` are either a numeric array either a Float32Array.
  91150. * No new underlying VertexBuffer object is created.
  91151. * 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.
  91152. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91153. *
  91154. * Possible `kind` values :
  91155. * - VertexBuffer.PositionKind
  91156. * - VertexBuffer.UVKind
  91157. * - VertexBuffer.UV2Kind
  91158. * - VertexBuffer.UV3Kind
  91159. * - VertexBuffer.UV4Kind
  91160. * - VertexBuffer.UV5Kind
  91161. * - VertexBuffer.UV6Kind
  91162. * - VertexBuffer.ColorKind
  91163. * - VertexBuffer.MatricesIndicesKind
  91164. * - VertexBuffer.MatricesIndicesExtraKind
  91165. * - VertexBuffer.MatricesWeightsKind
  91166. * - VertexBuffer.MatricesWeightsExtraKind
  91167. *
  91168. * Returns the Mesh.
  91169. */
  91170. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91171. /**
  91172. * Sets the mesh indices.
  91173. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91174. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91175. * This method creates a new index buffer each call.
  91176. * Returns the Mesh.
  91177. */
  91178. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91179. /**
  91180. * Boolean : True if the mesh owns the requested kind of data.
  91181. */
  91182. isVerticesDataPresent(kind: string): boolean;
  91183. /**
  91184. * Returns an array of indices (IndicesArray).
  91185. */
  91186. getIndices(): Nullable<IndicesArray>;
  91187. get _positions(): Nullable<Vector3[]>;
  91188. /**
  91189. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91190. * This means the mesh underlying bounding box and sphere are recomputed.
  91191. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91192. * @returns the current mesh
  91193. */
  91194. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91195. /** @hidden */
  91196. _preActivate(): InstancedMesh;
  91197. /** @hidden */
  91198. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91199. /** @hidden */
  91200. _postActivate(): void;
  91201. getWorldMatrix(): Matrix;
  91202. get isAnInstance(): boolean;
  91203. /**
  91204. * Returns the current associated LOD AbstractMesh.
  91205. */
  91206. getLOD(camera: Camera): AbstractMesh;
  91207. /** @hidden */
  91208. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91209. /** @hidden */
  91210. _syncSubMeshes(): InstancedMesh;
  91211. /** @hidden */
  91212. _generatePointsArray(): boolean;
  91213. /**
  91214. * Creates a new InstancedMesh from the current mesh.
  91215. * - name (string) : the cloned mesh name
  91216. * - newParent (optional Node) : the optional Node to parent the clone to.
  91217. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91218. *
  91219. * Returns the clone.
  91220. */
  91221. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91222. /**
  91223. * Disposes the InstancedMesh.
  91224. * Returns nothing.
  91225. */
  91226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91227. }
  91228. interface Mesh {
  91229. /**
  91230. * Register a custom buffer that will be instanced
  91231. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91232. * @param kind defines the buffer kind
  91233. * @param stride defines the stride in floats
  91234. */
  91235. registerInstancedBuffer(kind: string, stride: number): void;
  91236. /** @hidden */
  91237. _userInstancedBuffersStorage: {
  91238. data: {
  91239. [key: string]: Float32Array;
  91240. };
  91241. sizes: {
  91242. [key: string]: number;
  91243. };
  91244. vertexBuffers: {
  91245. [key: string]: Nullable<VertexBuffer>;
  91246. };
  91247. strides: {
  91248. [key: string]: number;
  91249. };
  91250. };
  91251. }
  91252. interface AbstractMesh {
  91253. /**
  91254. * Object used to store instanced buffers defined by user
  91255. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91256. */
  91257. instancedBuffers: {
  91258. [key: string]: any;
  91259. };
  91260. }
  91261. }
  91262. declare module BABYLON {
  91263. /**
  91264. * Defines the options associated with the creation of a shader material.
  91265. */
  91266. export interface IShaderMaterialOptions {
  91267. /**
  91268. * Does the material work in alpha blend mode
  91269. */
  91270. needAlphaBlending: boolean;
  91271. /**
  91272. * Does the material work in alpha test mode
  91273. */
  91274. needAlphaTesting: boolean;
  91275. /**
  91276. * The list of attribute names used in the shader
  91277. */
  91278. attributes: string[];
  91279. /**
  91280. * The list of unifrom names used in the shader
  91281. */
  91282. uniforms: string[];
  91283. /**
  91284. * The list of UBO names used in the shader
  91285. */
  91286. uniformBuffers: string[];
  91287. /**
  91288. * The list of sampler names used in the shader
  91289. */
  91290. samplers: string[];
  91291. /**
  91292. * The list of defines used in the shader
  91293. */
  91294. defines: string[];
  91295. }
  91296. /**
  91297. * 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.
  91298. *
  91299. * This returned material effects how the mesh will look based on the code in the shaders.
  91300. *
  91301. * @see http://doc.babylonjs.com/how_to/shader_material
  91302. */
  91303. export class ShaderMaterial extends Material {
  91304. private _shaderPath;
  91305. private _options;
  91306. private _textures;
  91307. private _textureArrays;
  91308. private _floats;
  91309. private _ints;
  91310. private _floatsArrays;
  91311. private _colors3;
  91312. private _colors3Arrays;
  91313. private _colors4;
  91314. private _colors4Arrays;
  91315. private _vectors2;
  91316. private _vectors3;
  91317. private _vectors4;
  91318. private _matrices;
  91319. private _matrixArrays;
  91320. private _matrices3x3;
  91321. private _matrices2x2;
  91322. private _vectors2Arrays;
  91323. private _vectors3Arrays;
  91324. private _vectors4Arrays;
  91325. private _cachedWorldViewMatrix;
  91326. private _cachedWorldViewProjectionMatrix;
  91327. private _renderId;
  91328. private _multiview;
  91329. private _cachedDefines;
  91330. /**
  91331. * Instantiate a new shader material.
  91332. * 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.
  91333. * This returned material effects how the mesh will look based on the code in the shaders.
  91334. * @see http://doc.babylonjs.com/how_to/shader_material
  91335. * @param name Define the name of the material in the scene
  91336. * @param scene Define the scene the material belongs to
  91337. * @param shaderPath Defines the route to the shader code in one of three ways:
  91338. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91339. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91340. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91341. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91342. * @param options Define the options used to create the shader
  91343. */
  91344. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91345. /**
  91346. * Gets the shader path used to define the shader code
  91347. * It can be modified to trigger a new compilation
  91348. */
  91349. get shaderPath(): any;
  91350. /**
  91351. * Sets the shader path used to define the shader code
  91352. * It can be modified to trigger a new compilation
  91353. */
  91354. set shaderPath(shaderPath: any);
  91355. /**
  91356. * Gets the options used to compile the shader.
  91357. * They can be modified to trigger a new compilation
  91358. */
  91359. get options(): IShaderMaterialOptions;
  91360. /**
  91361. * Gets the current class name of the material e.g. "ShaderMaterial"
  91362. * Mainly use in serialization.
  91363. * @returns the class name
  91364. */
  91365. getClassName(): string;
  91366. /**
  91367. * Specifies if the material will require alpha blending
  91368. * @returns a boolean specifying if alpha blending is needed
  91369. */
  91370. needAlphaBlending(): boolean;
  91371. /**
  91372. * Specifies if this material should be rendered in alpha test mode
  91373. * @returns a boolean specifying if an alpha test is needed.
  91374. */
  91375. needAlphaTesting(): boolean;
  91376. private _checkUniform;
  91377. /**
  91378. * Set a texture in the shader.
  91379. * @param name Define the name of the uniform samplers as defined in the shader
  91380. * @param texture Define the texture to bind to this sampler
  91381. * @return the material itself allowing "fluent" like uniform updates
  91382. */
  91383. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91384. /**
  91385. * Set a texture array in the shader.
  91386. * @param name Define the name of the uniform sampler array as defined in the shader
  91387. * @param textures Define the list of textures to bind to this sampler
  91388. * @return the material itself allowing "fluent" like uniform updates
  91389. */
  91390. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91391. /**
  91392. * Set a float in the shader.
  91393. * @param name Define the name of the uniform as defined in the shader
  91394. * @param value Define the value to give to the uniform
  91395. * @return the material itself allowing "fluent" like uniform updates
  91396. */
  91397. setFloat(name: string, value: number): ShaderMaterial;
  91398. /**
  91399. * Set a int in the shader.
  91400. * @param name Define the name of the uniform as defined in the shader
  91401. * @param value Define the value to give to the uniform
  91402. * @return the material itself allowing "fluent" like uniform updates
  91403. */
  91404. setInt(name: string, value: number): ShaderMaterial;
  91405. /**
  91406. * Set an array of floats in the shader.
  91407. * @param name Define the name of the uniform as defined in the shader
  91408. * @param value Define the value to give to the uniform
  91409. * @return the material itself allowing "fluent" like uniform updates
  91410. */
  91411. setFloats(name: string, value: number[]): ShaderMaterial;
  91412. /**
  91413. * Set a vec3 in the shader from a Color3.
  91414. * @param name Define the name of the uniform as defined in the shader
  91415. * @param value Define the value to give to the uniform
  91416. * @return the material itself allowing "fluent" like uniform updates
  91417. */
  91418. setColor3(name: string, value: Color3): ShaderMaterial;
  91419. /**
  91420. * Set a vec3 array in the shader from a Color3 array.
  91421. * @param name Define the name of the uniform as defined in the shader
  91422. * @param value Define the value to give to the uniform
  91423. * @return the material itself allowing "fluent" like uniform updates
  91424. */
  91425. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91426. /**
  91427. * Set a vec4 in the shader from a Color4.
  91428. * @param name Define the name of the uniform as defined in the shader
  91429. * @param value Define the value to give to the uniform
  91430. * @return the material itself allowing "fluent" like uniform updates
  91431. */
  91432. setColor4(name: string, value: Color4): ShaderMaterial;
  91433. /**
  91434. * Set a vec4 array in the shader from a Color4 array.
  91435. * @param name Define the name of the uniform as defined in the shader
  91436. * @param value Define the value to give to the uniform
  91437. * @return the material itself allowing "fluent" like uniform updates
  91438. */
  91439. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91440. /**
  91441. * Set a vec2 in the shader from a Vector2.
  91442. * @param name Define the name of the uniform as defined in the shader
  91443. * @param value Define the value to give to the uniform
  91444. * @return the material itself allowing "fluent" like uniform updates
  91445. */
  91446. setVector2(name: string, value: Vector2): ShaderMaterial;
  91447. /**
  91448. * Set a vec3 in the shader from a Vector3.
  91449. * @param name Define the name of the uniform as defined in the shader
  91450. * @param value Define the value to give to the uniform
  91451. * @return the material itself allowing "fluent" like uniform updates
  91452. */
  91453. setVector3(name: string, value: Vector3): ShaderMaterial;
  91454. /**
  91455. * Set a vec4 in the shader from a Vector4.
  91456. * @param name Define the name of the uniform as defined in the shader
  91457. * @param value Define the value to give to the uniform
  91458. * @return the material itself allowing "fluent" like uniform updates
  91459. */
  91460. setVector4(name: string, value: Vector4): ShaderMaterial;
  91461. /**
  91462. * Set a mat4 in the shader from a Matrix.
  91463. * @param name Define the name of the uniform as defined in the shader
  91464. * @param value Define the value to give to the uniform
  91465. * @return the material itself allowing "fluent" like uniform updates
  91466. */
  91467. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91468. /**
  91469. * Set a float32Array in the shader from a matrix array.
  91470. * @param name Define the name of the uniform as defined in the shader
  91471. * @param value Define the value to give to the uniform
  91472. * @return the material itself allowing "fluent" like uniform updates
  91473. */
  91474. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91475. /**
  91476. * Set a mat3 in the shader from a Float32Array.
  91477. * @param name Define the name of the uniform as defined in the shader
  91478. * @param value Define the value to give to the uniform
  91479. * @return the material itself allowing "fluent" like uniform updates
  91480. */
  91481. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91482. /**
  91483. * Set a mat2 in the shader from a Float32Array.
  91484. * @param name Define the name of the uniform as defined in the shader
  91485. * @param value Define the value to give to the uniform
  91486. * @return the material itself allowing "fluent" like uniform updates
  91487. */
  91488. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91489. /**
  91490. * Set a vec2 array in the shader from a number array.
  91491. * @param name Define the name of the uniform as defined in the shader
  91492. * @param value Define the value to give to the uniform
  91493. * @return the material itself allowing "fluent" like uniform updates
  91494. */
  91495. setArray2(name: string, value: number[]): ShaderMaterial;
  91496. /**
  91497. * Set a vec3 array in the shader from a number array.
  91498. * @param name Define the name of the uniform as defined in the shader
  91499. * @param value Define the value to give to the uniform
  91500. * @return the material itself allowing "fluent" like uniform updates
  91501. */
  91502. setArray3(name: string, value: number[]): ShaderMaterial;
  91503. /**
  91504. * Set a vec4 array in the shader from a number array.
  91505. * @param name Define the name of the uniform as defined in the shader
  91506. * @param value Define the value to give to the uniform
  91507. * @return the material itself allowing "fluent" like uniform updates
  91508. */
  91509. setArray4(name: string, value: number[]): ShaderMaterial;
  91510. private _checkCache;
  91511. /**
  91512. * Specifies that the submesh is ready to be used
  91513. * @param mesh defines the mesh to check
  91514. * @param subMesh defines which submesh to check
  91515. * @param useInstances specifies that instances should be used
  91516. * @returns a boolean indicating that the submesh is ready or not
  91517. */
  91518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91519. /**
  91520. * Checks if the material is ready to render the requested mesh
  91521. * @param mesh Define the mesh to render
  91522. * @param useInstances Define whether or not the material is used with instances
  91523. * @returns true if ready, otherwise false
  91524. */
  91525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91526. /**
  91527. * Binds the world matrix to the material
  91528. * @param world defines the world transformation matrix
  91529. * @param effectOverride - If provided, use this effect instead of internal effect
  91530. */
  91531. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91532. /**
  91533. * Binds the submesh to this material by preparing the effect and shader to draw
  91534. * @param world defines the world transformation matrix
  91535. * @param mesh defines the mesh containing the submesh
  91536. * @param subMesh defines the submesh to bind the material to
  91537. */
  91538. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91539. /**
  91540. * Binds the material to the mesh
  91541. * @param world defines the world transformation matrix
  91542. * @param mesh defines the mesh to bind the material to
  91543. * @param effectOverride - If provided, use this effect instead of internal effect
  91544. */
  91545. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91546. protected _afterBind(mesh?: Mesh): void;
  91547. /**
  91548. * Gets the active textures from the material
  91549. * @returns an array of textures
  91550. */
  91551. getActiveTextures(): BaseTexture[];
  91552. /**
  91553. * Specifies if the material uses a texture
  91554. * @param texture defines the texture to check against the material
  91555. * @returns a boolean specifying if the material uses the texture
  91556. */
  91557. hasTexture(texture: BaseTexture): boolean;
  91558. /**
  91559. * Makes a duplicate of the material, and gives it a new name
  91560. * @param name defines the new name for the duplicated material
  91561. * @returns the cloned material
  91562. */
  91563. clone(name: string): ShaderMaterial;
  91564. /**
  91565. * Disposes the material
  91566. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91567. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91568. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91569. */
  91570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91571. /**
  91572. * Serializes this material in a JSON representation
  91573. * @returns the serialized material object
  91574. */
  91575. serialize(): any;
  91576. /**
  91577. * Creates a shader material from parsed shader material data
  91578. * @param source defines the JSON represnetation of the material
  91579. * @param scene defines the hosting scene
  91580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91581. * @returns a new material
  91582. */
  91583. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91584. }
  91585. }
  91586. declare module BABYLON {
  91587. /** @hidden */
  91588. export var colorPixelShader: {
  91589. name: string;
  91590. shader: string;
  91591. };
  91592. }
  91593. declare module BABYLON {
  91594. /** @hidden */
  91595. export var colorVertexShader: {
  91596. name: string;
  91597. shader: string;
  91598. };
  91599. }
  91600. declare module BABYLON {
  91601. /**
  91602. * Line mesh
  91603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91604. */
  91605. export class LinesMesh extends Mesh {
  91606. /**
  91607. * If vertex color should be applied to the mesh
  91608. */
  91609. readonly useVertexColor?: boolean | undefined;
  91610. /**
  91611. * If vertex alpha should be applied to the mesh
  91612. */
  91613. readonly useVertexAlpha?: boolean | undefined;
  91614. /**
  91615. * Color of the line (Default: White)
  91616. */
  91617. color: Color3;
  91618. /**
  91619. * Alpha of the line (Default: 1)
  91620. */
  91621. alpha: number;
  91622. /**
  91623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91624. * This margin is expressed in world space coordinates, so its value may vary.
  91625. * Default value is 0.1
  91626. */
  91627. intersectionThreshold: number;
  91628. private _colorShader;
  91629. private color4;
  91630. /**
  91631. * Creates a new LinesMesh
  91632. * @param name defines the name
  91633. * @param scene defines the hosting scene
  91634. * @param parent defines the parent mesh if any
  91635. * @param source defines the optional source LinesMesh used to clone data from
  91636. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91637. * When false, achieved by calling a clone(), also passing False.
  91638. * This will make creation of children, recursive.
  91639. * @param useVertexColor defines if this LinesMesh supports vertex color
  91640. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91641. */
  91642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91643. /**
  91644. * If vertex color should be applied to the mesh
  91645. */
  91646. useVertexColor?: boolean | undefined,
  91647. /**
  91648. * If vertex alpha should be applied to the mesh
  91649. */
  91650. useVertexAlpha?: boolean | undefined);
  91651. private _addClipPlaneDefine;
  91652. private _removeClipPlaneDefine;
  91653. isReady(): boolean;
  91654. /**
  91655. * Returns the string "LineMesh"
  91656. */
  91657. getClassName(): string;
  91658. /**
  91659. * @hidden
  91660. */
  91661. get material(): Material;
  91662. /**
  91663. * @hidden
  91664. */
  91665. set material(value: Material);
  91666. /**
  91667. * @hidden
  91668. */
  91669. get checkCollisions(): boolean;
  91670. /** @hidden */
  91671. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91672. /** @hidden */
  91673. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91674. /**
  91675. * Disposes of the line mesh
  91676. * @param doNotRecurse If children should be disposed
  91677. */
  91678. dispose(doNotRecurse?: boolean): void;
  91679. /**
  91680. * Returns a new LineMesh object cloned from the current one.
  91681. */
  91682. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91683. /**
  91684. * Creates a new InstancedLinesMesh object from the mesh model.
  91685. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91686. * @param name defines the name of the new instance
  91687. * @returns a new InstancedLinesMesh
  91688. */
  91689. createInstance(name: string): InstancedLinesMesh;
  91690. }
  91691. /**
  91692. * Creates an instance based on a source LinesMesh
  91693. */
  91694. export class InstancedLinesMesh extends InstancedMesh {
  91695. /**
  91696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91697. * This margin is expressed in world space coordinates, so its value may vary.
  91698. * Initilized with the intersectionThreshold value of the source LinesMesh
  91699. */
  91700. intersectionThreshold: number;
  91701. constructor(name: string, source: LinesMesh);
  91702. /**
  91703. * Returns the string "InstancedLinesMesh".
  91704. */
  91705. getClassName(): string;
  91706. }
  91707. }
  91708. declare module BABYLON {
  91709. /** @hidden */
  91710. export var linePixelShader: {
  91711. name: string;
  91712. shader: string;
  91713. };
  91714. }
  91715. declare module BABYLON {
  91716. /** @hidden */
  91717. export var lineVertexShader: {
  91718. name: string;
  91719. shader: string;
  91720. };
  91721. }
  91722. declare module BABYLON {
  91723. interface AbstractMesh {
  91724. /**
  91725. * Gets the edgesRenderer associated with the mesh
  91726. */
  91727. edgesRenderer: Nullable<EdgesRenderer>;
  91728. }
  91729. interface LinesMesh {
  91730. /**
  91731. * Enables the edge rendering mode on the mesh.
  91732. * This mode makes the mesh edges visible
  91733. * @param epsilon defines the maximal distance between two angles to detect a face
  91734. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91735. * @returns the currentAbstractMesh
  91736. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91737. */
  91738. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91739. }
  91740. interface InstancedLinesMesh {
  91741. /**
  91742. * Enables the edge rendering mode on the mesh.
  91743. * This mode makes the mesh edges visible
  91744. * @param epsilon defines the maximal distance between two angles to detect a face
  91745. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91746. * @returns the current InstancedLinesMesh
  91747. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91748. */
  91749. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91750. }
  91751. /**
  91752. * Defines the minimum contract an Edges renderer should follow.
  91753. */
  91754. export interface IEdgesRenderer extends IDisposable {
  91755. /**
  91756. * Gets or sets a boolean indicating if the edgesRenderer is active
  91757. */
  91758. isEnabled: boolean;
  91759. /**
  91760. * Renders the edges of the attached mesh,
  91761. */
  91762. render(): void;
  91763. /**
  91764. * Checks wether or not the edges renderer is ready to render.
  91765. * @return true if ready, otherwise false.
  91766. */
  91767. isReady(): boolean;
  91768. }
  91769. /**
  91770. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91771. */
  91772. export class EdgesRenderer implements IEdgesRenderer {
  91773. /**
  91774. * Define the size of the edges with an orthographic camera
  91775. */
  91776. edgesWidthScalerForOrthographic: number;
  91777. /**
  91778. * Define the size of the edges with a perspective camera
  91779. */
  91780. edgesWidthScalerForPerspective: number;
  91781. protected _source: AbstractMesh;
  91782. protected _linesPositions: number[];
  91783. protected _linesNormals: number[];
  91784. protected _linesIndices: number[];
  91785. protected _epsilon: number;
  91786. protected _indicesCount: number;
  91787. protected _lineShader: ShaderMaterial;
  91788. protected _ib: DataBuffer;
  91789. protected _buffers: {
  91790. [key: string]: Nullable<VertexBuffer>;
  91791. };
  91792. protected _checkVerticesInsteadOfIndices: boolean;
  91793. private _meshRebuildObserver;
  91794. private _meshDisposeObserver;
  91795. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91796. isEnabled: boolean;
  91797. /**
  91798. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91799. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91800. * @param source Mesh used to create edges
  91801. * @param epsilon sum of angles in adjacency to check for edge
  91802. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91803. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91804. */
  91805. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91806. protected _prepareRessources(): void;
  91807. /** @hidden */
  91808. _rebuild(): void;
  91809. /**
  91810. * Releases the required resources for the edges renderer
  91811. */
  91812. dispose(): void;
  91813. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91814. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91815. /**
  91816. * Checks if the pair of p0 and p1 is en edge
  91817. * @param faceIndex
  91818. * @param edge
  91819. * @param faceNormals
  91820. * @param p0
  91821. * @param p1
  91822. * @private
  91823. */
  91824. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91825. /**
  91826. * push line into the position, normal and index buffer
  91827. * @protected
  91828. */
  91829. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91830. /**
  91831. * Generates lines edges from adjacencjes
  91832. * @private
  91833. */
  91834. _generateEdgesLines(): void;
  91835. /**
  91836. * Checks wether or not the edges renderer is ready to render.
  91837. * @return true if ready, otherwise false.
  91838. */
  91839. isReady(): boolean;
  91840. /**
  91841. * Renders the edges of the attached mesh,
  91842. */
  91843. render(): void;
  91844. }
  91845. /**
  91846. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91847. */
  91848. export class LineEdgesRenderer extends EdgesRenderer {
  91849. /**
  91850. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91851. * @param source LineMesh used to generate edges
  91852. * @param epsilon not important (specified angle for edge detection)
  91853. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91854. */
  91855. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91856. /**
  91857. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91858. */
  91859. _generateEdgesLines(): void;
  91860. }
  91861. }
  91862. declare module BABYLON {
  91863. /**
  91864. * This represents the object necessary to create a rendering group.
  91865. * This is exclusively used and created by the rendering manager.
  91866. * To modify the behavior, you use the available helpers in your scene or meshes.
  91867. * @hidden
  91868. */
  91869. export class RenderingGroup {
  91870. index: number;
  91871. private static _zeroVector;
  91872. private _scene;
  91873. private _opaqueSubMeshes;
  91874. private _transparentSubMeshes;
  91875. private _alphaTestSubMeshes;
  91876. private _depthOnlySubMeshes;
  91877. private _particleSystems;
  91878. private _spriteManagers;
  91879. private _opaqueSortCompareFn;
  91880. private _alphaTestSortCompareFn;
  91881. private _transparentSortCompareFn;
  91882. private _renderOpaque;
  91883. private _renderAlphaTest;
  91884. private _renderTransparent;
  91885. /** @hidden */
  91886. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91887. onBeforeTransparentRendering: () => void;
  91888. /**
  91889. * Set the opaque sort comparison function.
  91890. * If null the sub meshes will be render in the order they were created
  91891. */
  91892. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91893. /**
  91894. * Set the alpha test sort comparison function.
  91895. * If null the sub meshes will be render in the order they were created
  91896. */
  91897. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91898. /**
  91899. * Set the transparent sort comparison function.
  91900. * If null the sub meshes will be render in the order they were created
  91901. */
  91902. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91903. /**
  91904. * Creates a new rendering group.
  91905. * @param index The rendering group index
  91906. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91907. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91908. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91909. */
  91910. 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>);
  91911. /**
  91912. * Render all the sub meshes contained in the group.
  91913. * @param customRenderFunction Used to override the default render behaviour of the group.
  91914. * @returns true if rendered some submeshes.
  91915. */
  91916. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91917. /**
  91918. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91919. * @param subMeshes The submeshes to render
  91920. */
  91921. private renderOpaqueSorted;
  91922. /**
  91923. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91924. * @param subMeshes The submeshes to render
  91925. */
  91926. private renderAlphaTestSorted;
  91927. /**
  91928. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91929. * @param subMeshes The submeshes to render
  91930. */
  91931. private renderTransparentSorted;
  91932. /**
  91933. * Renders the submeshes in a specified order.
  91934. * @param subMeshes The submeshes to sort before render
  91935. * @param sortCompareFn The comparison function use to sort
  91936. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91937. * @param transparent Specifies to activate blending if true
  91938. */
  91939. private static renderSorted;
  91940. /**
  91941. * Renders the submeshes in the order they were dispatched (no sort applied).
  91942. * @param subMeshes The submeshes to render
  91943. */
  91944. private static renderUnsorted;
  91945. /**
  91946. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91947. * are rendered back to front if in the same alpha index.
  91948. *
  91949. * @param a The first submesh
  91950. * @param b The second submesh
  91951. * @returns The result of the comparison
  91952. */
  91953. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91954. /**
  91955. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91956. * are rendered back to front.
  91957. *
  91958. * @param a The first submesh
  91959. * @param b The second submesh
  91960. * @returns The result of the comparison
  91961. */
  91962. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91963. /**
  91964. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91965. * are rendered front to back (prevent overdraw).
  91966. *
  91967. * @param a The first submesh
  91968. * @param b The second submesh
  91969. * @returns The result of the comparison
  91970. */
  91971. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91972. /**
  91973. * Resets the different lists of submeshes to prepare a new frame.
  91974. */
  91975. prepare(): void;
  91976. dispose(): void;
  91977. /**
  91978. * Inserts the submesh in its correct queue depending on its material.
  91979. * @param subMesh The submesh to dispatch
  91980. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91981. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91982. */
  91983. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91984. dispatchSprites(spriteManager: ISpriteManager): void;
  91985. dispatchParticles(particleSystem: IParticleSystem): void;
  91986. private _renderParticles;
  91987. private _renderSprites;
  91988. }
  91989. }
  91990. declare module BABYLON {
  91991. /**
  91992. * Interface describing the different options available in the rendering manager
  91993. * regarding Auto Clear between groups.
  91994. */
  91995. export interface IRenderingManagerAutoClearSetup {
  91996. /**
  91997. * Defines whether or not autoclear is enable.
  91998. */
  91999. autoClear: boolean;
  92000. /**
  92001. * Defines whether or not to autoclear the depth buffer.
  92002. */
  92003. depth: boolean;
  92004. /**
  92005. * Defines whether or not to autoclear the stencil buffer.
  92006. */
  92007. stencil: boolean;
  92008. }
  92009. /**
  92010. * This class is used by the onRenderingGroupObservable
  92011. */
  92012. export class RenderingGroupInfo {
  92013. /**
  92014. * The Scene that being rendered
  92015. */
  92016. scene: Scene;
  92017. /**
  92018. * The camera currently used for the rendering pass
  92019. */
  92020. camera: Nullable<Camera>;
  92021. /**
  92022. * The ID of the renderingGroup being processed
  92023. */
  92024. renderingGroupId: number;
  92025. }
  92026. /**
  92027. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92028. * It is enable to manage the different groups as well as the different necessary sort functions.
  92029. * This should not be used directly aside of the few static configurations
  92030. */
  92031. export class RenderingManager {
  92032. /**
  92033. * The max id used for rendering groups (not included)
  92034. */
  92035. static MAX_RENDERINGGROUPS: number;
  92036. /**
  92037. * The min id used for rendering groups (included)
  92038. */
  92039. static MIN_RENDERINGGROUPS: number;
  92040. /**
  92041. * Used to globally prevent autoclearing scenes.
  92042. */
  92043. static AUTOCLEAR: boolean;
  92044. /**
  92045. * @hidden
  92046. */
  92047. _useSceneAutoClearSetup: boolean;
  92048. private _scene;
  92049. private _renderingGroups;
  92050. private _depthStencilBufferAlreadyCleaned;
  92051. private _autoClearDepthStencil;
  92052. private _customOpaqueSortCompareFn;
  92053. private _customAlphaTestSortCompareFn;
  92054. private _customTransparentSortCompareFn;
  92055. private _renderingGroupInfo;
  92056. /**
  92057. * Instantiates a new rendering group for a particular scene
  92058. * @param scene Defines the scene the groups belongs to
  92059. */
  92060. constructor(scene: Scene);
  92061. private _clearDepthStencilBuffer;
  92062. /**
  92063. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92064. * @hidden
  92065. */
  92066. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92067. /**
  92068. * Resets the different information of the group to prepare a new frame
  92069. * @hidden
  92070. */
  92071. reset(): void;
  92072. /**
  92073. * Dispose and release the group and its associated resources.
  92074. * @hidden
  92075. */
  92076. dispose(): void;
  92077. /**
  92078. * Clear the info related to rendering groups preventing retention points during dispose.
  92079. */
  92080. freeRenderingGroups(): void;
  92081. private _prepareRenderingGroup;
  92082. /**
  92083. * Add a sprite manager to the rendering manager in order to render it this frame.
  92084. * @param spriteManager Define the sprite manager to render
  92085. */
  92086. dispatchSprites(spriteManager: ISpriteManager): void;
  92087. /**
  92088. * Add a particle system to the rendering manager in order to render it this frame.
  92089. * @param particleSystem Define the particle system to render
  92090. */
  92091. dispatchParticles(particleSystem: IParticleSystem): void;
  92092. /**
  92093. * Add a submesh to the manager in order to render it this frame
  92094. * @param subMesh The submesh to dispatch
  92095. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92096. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92097. */
  92098. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92099. /**
  92100. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92101. * This allowed control for front to back rendering or reversly depending of the special needs.
  92102. *
  92103. * @param renderingGroupId The rendering group id corresponding to its index
  92104. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92105. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92106. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92107. */
  92108. 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;
  92109. /**
  92110. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92111. *
  92112. * @param renderingGroupId The rendering group id corresponding to its index
  92113. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92114. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92115. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92116. */
  92117. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92118. /**
  92119. * Gets the current auto clear configuration for one rendering group of the rendering
  92120. * manager.
  92121. * @param index the rendering group index to get the information for
  92122. * @returns The auto clear setup for the requested rendering group
  92123. */
  92124. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92125. }
  92126. }
  92127. declare module BABYLON {
  92128. /**
  92129. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92130. */
  92131. export interface ICustomShaderOptions {
  92132. /**
  92133. * Gets or sets the custom shader name to use
  92134. */
  92135. shaderName: string;
  92136. /**
  92137. * The list of attribute names used in the shader
  92138. */
  92139. attributes?: string[];
  92140. /**
  92141. * The list of unifrom names used in the shader
  92142. */
  92143. uniforms?: string[];
  92144. /**
  92145. * The list of sampler names used in the shader
  92146. */
  92147. samplers?: string[];
  92148. /**
  92149. * The list of defines used in the shader
  92150. */
  92151. defines?: string[];
  92152. }
  92153. /**
  92154. * Interface to implement to create a shadow generator compatible with BJS.
  92155. */
  92156. export interface IShadowGenerator {
  92157. /**
  92158. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92159. * @returns The render target texture if present otherwise, null
  92160. */
  92161. getShadowMap(): Nullable<RenderTargetTexture>;
  92162. /**
  92163. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92164. * @param subMesh The submesh we want to render in the shadow map
  92165. * @param useInstances Defines wether will draw in the map using instances
  92166. * @returns true if ready otherwise, false
  92167. */
  92168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  92169. /**
  92170. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92171. * @param defines Defines of the material we want to update
  92172. * @param lightIndex Index of the light in the enabled light list of the material
  92173. */
  92174. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92175. /**
  92176. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92177. * defined in the generator but impacting the effect).
  92178. * It implies the unifroms available on the materials are the standard BJS ones.
  92179. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92180. * @param effect The effect we are binfing the information for
  92181. */
  92182. bindShadowLight(lightIndex: string, effect: Effect): void;
  92183. /**
  92184. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92185. * (eq to shadow prjection matrix * light transform matrix)
  92186. * @returns The transform matrix used to create the shadow map
  92187. */
  92188. getTransformMatrix(): Matrix;
  92189. /**
  92190. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92191. * Cube and 2D textures for instance.
  92192. */
  92193. recreateShadowMap(): void;
  92194. /**
  92195. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92196. * @param onCompiled Callback triggered at the and of the effects compilation
  92197. * @param options Sets of optional options forcing the compilation with different modes
  92198. */
  92199. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92200. useInstances: boolean;
  92201. }>): void;
  92202. /**
  92203. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92204. * @param options Sets of optional options forcing the compilation with different modes
  92205. * @returns A promise that resolves when the compilation completes
  92206. */
  92207. forceCompilationAsync(options?: Partial<{
  92208. useInstances: boolean;
  92209. }>): Promise<void>;
  92210. /**
  92211. * Serializes the shadow generator setup to a json object.
  92212. * @returns The serialized JSON object
  92213. */
  92214. serialize(): any;
  92215. /**
  92216. * Disposes the Shadow map and related Textures and effects.
  92217. */
  92218. dispose(): void;
  92219. }
  92220. /**
  92221. * Default implementation IShadowGenerator.
  92222. * This is the main object responsible of generating shadows in the framework.
  92223. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92224. */
  92225. export class ShadowGenerator implements IShadowGenerator {
  92226. /**
  92227. * Name of the shadow generator class
  92228. */
  92229. static CLASSNAME: string;
  92230. /**
  92231. * Shadow generator mode None: no filtering applied.
  92232. */
  92233. static readonly FILTER_NONE: number;
  92234. /**
  92235. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92236. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92237. */
  92238. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92239. /**
  92240. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92241. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92242. */
  92243. static readonly FILTER_POISSONSAMPLING: number;
  92244. /**
  92245. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92246. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92247. */
  92248. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92249. /**
  92250. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92251. * edge artifacts on steep falloff.
  92252. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92253. */
  92254. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92255. /**
  92256. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92257. * edge artifacts on steep falloff.
  92258. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92259. */
  92260. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92261. /**
  92262. * Shadow generator mode PCF: Percentage Closer Filtering
  92263. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92264. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92265. */
  92266. static readonly FILTER_PCF: number;
  92267. /**
  92268. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92269. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92270. * Contact Hardening
  92271. */
  92272. static readonly FILTER_PCSS: number;
  92273. /**
  92274. * Reserved for PCF and PCSS
  92275. * Highest Quality.
  92276. *
  92277. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92278. *
  92279. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92280. */
  92281. static readonly QUALITY_HIGH: number;
  92282. /**
  92283. * Reserved for PCF and PCSS
  92284. * Good tradeoff for quality/perf cross devices
  92285. *
  92286. * Execute PCF on a 3*3 kernel.
  92287. *
  92288. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92289. */
  92290. static readonly QUALITY_MEDIUM: number;
  92291. /**
  92292. * Reserved for PCF and PCSS
  92293. * The lowest quality but the fastest.
  92294. *
  92295. * Execute PCF on a 1*1 kernel.
  92296. *
  92297. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92298. */
  92299. static readonly QUALITY_LOW: number;
  92300. /** Gets or sets the custom shader name to use */
  92301. customShaderOptions: ICustomShaderOptions;
  92302. /**
  92303. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92304. */
  92305. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92306. /**
  92307. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92308. */
  92309. onAfterShadowMapRenderObservable: Observable<Effect>;
  92310. /**
  92311. * Observable triggered before a mesh is rendered in the shadow map.
  92312. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92313. */
  92314. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92315. /**
  92316. * Observable triggered after a mesh is rendered in the shadow map.
  92317. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92318. */
  92319. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92320. protected _bias: number;
  92321. /**
  92322. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92323. */
  92324. get bias(): number;
  92325. /**
  92326. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92327. */
  92328. set bias(bias: number);
  92329. protected _normalBias: number;
  92330. /**
  92331. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92332. */
  92333. get normalBias(): number;
  92334. /**
  92335. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92336. */
  92337. set normalBias(normalBias: number);
  92338. protected _blurBoxOffset: number;
  92339. /**
  92340. * Gets the blur box offset: offset applied during the blur pass.
  92341. * Only useful if useKernelBlur = false
  92342. */
  92343. get blurBoxOffset(): number;
  92344. /**
  92345. * Sets the blur box offset: offset applied during the blur pass.
  92346. * Only useful if useKernelBlur = false
  92347. */
  92348. set blurBoxOffset(value: number);
  92349. protected _blurScale: number;
  92350. /**
  92351. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92352. * 2 means half of the size.
  92353. */
  92354. get blurScale(): number;
  92355. /**
  92356. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92357. * 2 means half of the size.
  92358. */
  92359. set blurScale(value: number);
  92360. protected _blurKernel: number;
  92361. /**
  92362. * Gets the blur kernel: kernel size of the blur pass.
  92363. * Only useful if useKernelBlur = true
  92364. */
  92365. get blurKernel(): number;
  92366. /**
  92367. * Sets the blur kernel: kernel size of the blur pass.
  92368. * Only useful if useKernelBlur = true
  92369. */
  92370. set blurKernel(value: number);
  92371. protected _useKernelBlur: boolean;
  92372. /**
  92373. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92374. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92375. */
  92376. get useKernelBlur(): boolean;
  92377. /**
  92378. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92379. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92380. */
  92381. set useKernelBlur(value: boolean);
  92382. protected _depthScale: number;
  92383. /**
  92384. * Gets the depth scale used in ESM mode.
  92385. */
  92386. get depthScale(): number;
  92387. /**
  92388. * Sets the depth scale used in ESM mode.
  92389. * This can override the scale stored on the light.
  92390. */
  92391. set depthScale(value: number);
  92392. protected _validateFilter(filter: number): number;
  92393. protected _filter: number;
  92394. /**
  92395. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92396. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92397. */
  92398. get filter(): number;
  92399. /**
  92400. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92401. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92402. */
  92403. set filter(value: number);
  92404. /**
  92405. * Gets if the current filter is set to Poisson Sampling.
  92406. */
  92407. get usePoissonSampling(): boolean;
  92408. /**
  92409. * Sets the current filter to Poisson Sampling.
  92410. */
  92411. set usePoissonSampling(value: boolean);
  92412. /**
  92413. * Gets if the current filter is set to ESM.
  92414. */
  92415. get useExponentialShadowMap(): boolean;
  92416. /**
  92417. * Sets the current filter is to ESM.
  92418. */
  92419. set useExponentialShadowMap(value: boolean);
  92420. /**
  92421. * Gets if the current filter is set to filtered ESM.
  92422. */
  92423. get useBlurExponentialShadowMap(): boolean;
  92424. /**
  92425. * Gets if the current filter is set to filtered ESM.
  92426. */
  92427. set useBlurExponentialShadowMap(value: boolean);
  92428. /**
  92429. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92430. * exponential to prevent steep falloff artifacts).
  92431. */
  92432. get useCloseExponentialShadowMap(): boolean;
  92433. /**
  92434. * Sets the current filter to "close ESM" (using the inverse of the
  92435. * exponential to prevent steep falloff artifacts).
  92436. */
  92437. set useCloseExponentialShadowMap(value: boolean);
  92438. /**
  92439. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92440. * exponential to prevent steep falloff artifacts).
  92441. */
  92442. get useBlurCloseExponentialShadowMap(): boolean;
  92443. /**
  92444. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92445. * exponential to prevent steep falloff artifacts).
  92446. */
  92447. set useBlurCloseExponentialShadowMap(value: boolean);
  92448. /**
  92449. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92450. */
  92451. get usePercentageCloserFiltering(): boolean;
  92452. /**
  92453. * Sets the current filter to "PCF" (percentage closer filtering).
  92454. */
  92455. set usePercentageCloserFiltering(value: boolean);
  92456. protected _filteringQuality: number;
  92457. /**
  92458. * Gets the PCF or PCSS Quality.
  92459. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92460. */
  92461. get filteringQuality(): number;
  92462. /**
  92463. * Sets the PCF or PCSS Quality.
  92464. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92465. */
  92466. set filteringQuality(filteringQuality: number);
  92467. /**
  92468. * Gets if the current filter is set to "PCSS" (contact hardening).
  92469. */
  92470. get useContactHardeningShadow(): boolean;
  92471. /**
  92472. * Sets the current filter to "PCSS" (contact hardening).
  92473. */
  92474. set useContactHardeningShadow(value: boolean);
  92475. protected _contactHardeningLightSizeUVRatio: number;
  92476. /**
  92477. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92478. * Using a ratio helps keeping shape stability independently of the map size.
  92479. *
  92480. * It does not account for the light projection as it was having too much
  92481. * instability during the light setup or during light position changes.
  92482. *
  92483. * Only valid if useContactHardeningShadow is true.
  92484. */
  92485. get contactHardeningLightSizeUVRatio(): number;
  92486. /**
  92487. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92488. * Using a ratio helps keeping shape stability independently of the map size.
  92489. *
  92490. * It does not account for the light projection as it was having too much
  92491. * instability during the light setup or during light position changes.
  92492. *
  92493. * Only valid if useContactHardeningShadow is true.
  92494. */
  92495. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92496. protected _darkness: number;
  92497. /** Gets or sets the actual darkness of a shadow */
  92498. get darkness(): number;
  92499. set darkness(value: number);
  92500. /**
  92501. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92502. * 0 means strongest and 1 would means no shadow.
  92503. * @returns the darkness.
  92504. */
  92505. getDarkness(): number;
  92506. /**
  92507. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92508. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92509. * @returns the shadow generator allowing fluent coding.
  92510. */
  92511. setDarkness(darkness: number): ShadowGenerator;
  92512. protected _transparencyShadow: boolean;
  92513. /** Gets or sets the ability to have transparent shadow */
  92514. get transparencyShadow(): boolean;
  92515. set transparencyShadow(value: boolean);
  92516. /**
  92517. * Sets the ability to have transparent shadow (boolean).
  92518. * @param transparent True if transparent else False
  92519. * @returns the shadow generator allowing fluent coding
  92520. */
  92521. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92522. protected _shadowMap: Nullable<RenderTargetTexture>;
  92523. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92524. /**
  92525. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92526. * @returns The render target texture if present otherwise, null
  92527. */
  92528. getShadowMap(): Nullable<RenderTargetTexture>;
  92529. /**
  92530. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92531. * @returns The render target texture if the shadow map is present otherwise, null
  92532. */
  92533. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92534. /**
  92535. * Gets the class name of that object
  92536. * @returns "ShadowGenerator"
  92537. */
  92538. getClassName(): string;
  92539. /**
  92540. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92541. * @param mesh Mesh to add
  92542. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92543. * @returns the Shadow Generator itself
  92544. */
  92545. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92546. /**
  92547. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92548. * @param mesh Mesh to remove
  92549. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92550. * @returns the Shadow Generator itself
  92551. */
  92552. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92553. /**
  92554. * Controls the extent to which the shadows fade out at the edge of the frustum
  92555. */
  92556. frustumEdgeFalloff: number;
  92557. protected _light: IShadowLight;
  92558. /**
  92559. * Returns the associated light object.
  92560. * @returns the light generating the shadow
  92561. */
  92562. getLight(): IShadowLight;
  92563. /**
  92564. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92565. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92566. * It might on the other hand introduce peter panning.
  92567. */
  92568. forceBackFacesOnly: boolean;
  92569. protected _scene: Scene;
  92570. protected _lightDirection: Vector3;
  92571. protected _effect: Effect;
  92572. protected _viewMatrix: Matrix;
  92573. protected _projectionMatrix: Matrix;
  92574. protected _transformMatrix: Matrix;
  92575. protected _cachedPosition: Vector3;
  92576. protected _cachedDirection: Vector3;
  92577. protected _cachedDefines: string;
  92578. protected _currentRenderID: number;
  92579. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92580. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92581. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92582. protected _blurPostProcesses: PostProcess[];
  92583. protected _mapSize: number;
  92584. protected _currentFaceIndex: number;
  92585. protected _currentFaceIndexCache: number;
  92586. protected _textureType: number;
  92587. protected _defaultTextureMatrix: Matrix;
  92588. protected _storedUniqueId: Nullable<number>;
  92589. /** @hidden */
  92590. static _SceneComponentInitialization: (scene: Scene) => void;
  92591. /**
  92592. * Creates a ShadowGenerator object.
  92593. * A ShadowGenerator is the required tool to use the shadows.
  92594. * Each light casting shadows needs to use its own ShadowGenerator.
  92595. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92596. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92597. * @param light The light object generating the shadows.
  92598. * @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.
  92599. */
  92600. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92601. protected _initializeGenerator(): void;
  92602. protected _createTargetRenderTexture(): void;
  92603. protected _initializeShadowMap(): void;
  92604. protected _initializeBlurRTTAndPostProcesses(): void;
  92605. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92606. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92607. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  92608. protected _applyFilterValues(): void;
  92609. /**
  92610. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92611. * @param onCompiled Callback triggered at the and of the effects compilation
  92612. * @param options Sets of optional options forcing the compilation with different modes
  92613. */
  92614. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92615. useInstances: boolean;
  92616. }>): void;
  92617. /**
  92618. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92619. * @param options Sets of optional options forcing the compilation with different modes
  92620. * @returns A promise that resolves when the compilation completes
  92621. */
  92622. forceCompilationAsync(options?: Partial<{
  92623. useInstances: boolean;
  92624. }>): Promise<void>;
  92625. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92626. private _prepareShadowDefines;
  92627. /**
  92628. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92629. * @param subMesh The submesh we want to render in the shadow map
  92630. * @param useInstances Defines wether will draw in the map using instances
  92631. * @returns true if ready otherwise, false
  92632. */
  92633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  92634. /**
  92635. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92636. * @param defines Defines of the material we want to update
  92637. * @param lightIndex Index of the light in the enabled light list of the material
  92638. */
  92639. prepareDefines(defines: any, lightIndex: number): void;
  92640. /**
  92641. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92642. * defined in the generator but impacting the effect).
  92643. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92644. * @param effect The effect we are binfing the information for
  92645. */
  92646. bindShadowLight(lightIndex: string, effect: Effect): void;
  92647. /**
  92648. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92649. * (eq to shadow prjection matrix * light transform matrix)
  92650. * @returns The transform matrix used to create the shadow map
  92651. */
  92652. getTransformMatrix(): Matrix;
  92653. /**
  92654. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92655. * Cube and 2D textures for instance.
  92656. */
  92657. recreateShadowMap(): void;
  92658. protected _disposeBlurPostProcesses(): void;
  92659. protected _disposeRTTandPostProcesses(): void;
  92660. /**
  92661. * Disposes the ShadowGenerator.
  92662. * Returns nothing.
  92663. */
  92664. dispose(): void;
  92665. /**
  92666. * Serializes the shadow generator setup to a json object.
  92667. * @returns The serialized JSON object
  92668. */
  92669. serialize(): any;
  92670. /**
  92671. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92672. * @param parsedShadowGenerator The JSON object to parse
  92673. * @param scene The scene to create the shadow map for
  92674. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92675. * @returns The parsed shadow generator
  92676. */
  92677. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92678. }
  92679. }
  92680. declare module BABYLON {
  92681. /**
  92682. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92683. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92684. * 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.
  92685. */
  92686. export abstract class Light extends Node {
  92687. /**
  92688. * Falloff Default: light is falling off following the material specification:
  92689. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92690. */
  92691. static readonly FALLOFF_DEFAULT: number;
  92692. /**
  92693. * Falloff Physical: light is falling off following the inverse squared distance law.
  92694. */
  92695. static readonly FALLOFF_PHYSICAL: number;
  92696. /**
  92697. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92698. * to enhance interoperability with other engines.
  92699. */
  92700. static readonly FALLOFF_GLTF: number;
  92701. /**
  92702. * Falloff Standard: light is falling off like in the standard material
  92703. * to enhance interoperability with other materials.
  92704. */
  92705. static readonly FALLOFF_STANDARD: number;
  92706. /**
  92707. * If every light affecting the material is in this lightmapMode,
  92708. * material.lightmapTexture adds or multiplies
  92709. * (depends on material.useLightmapAsShadowmap)
  92710. * after every other light calculations.
  92711. */
  92712. static readonly LIGHTMAP_DEFAULT: number;
  92713. /**
  92714. * material.lightmapTexture as only diffuse lighting from this light
  92715. * adds only specular lighting from this light
  92716. * adds dynamic shadows
  92717. */
  92718. static readonly LIGHTMAP_SPECULAR: number;
  92719. /**
  92720. * material.lightmapTexture as only lighting
  92721. * no light calculation from this light
  92722. * only adds dynamic shadows from this light
  92723. */
  92724. static readonly LIGHTMAP_SHADOWSONLY: number;
  92725. /**
  92726. * Each light type uses the default quantity according to its type:
  92727. * point/spot lights use luminous intensity
  92728. * directional lights use illuminance
  92729. */
  92730. static readonly INTENSITYMODE_AUTOMATIC: number;
  92731. /**
  92732. * lumen (lm)
  92733. */
  92734. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92735. /**
  92736. * candela (lm/sr)
  92737. */
  92738. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92739. /**
  92740. * lux (lm/m^2)
  92741. */
  92742. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92743. /**
  92744. * nit (cd/m^2)
  92745. */
  92746. static readonly INTENSITYMODE_LUMINANCE: number;
  92747. /**
  92748. * Light type const id of the point light.
  92749. */
  92750. static readonly LIGHTTYPEID_POINTLIGHT: number;
  92751. /**
  92752. * Light type const id of the directional light.
  92753. */
  92754. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  92755. /**
  92756. * Light type const id of the spot light.
  92757. */
  92758. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  92759. /**
  92760. * Light type const id of the hemispheric light.
  92761. */
  92762. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  92763. /**
  92764. * Diffuse gives the basic color to an object.
  92765. */
  92766. diffuse: Color3;
  92767. /**
  92768. * Specular produces a highlight color on an object.
  92769. * Note: This is note affecting PBR materials.
  92770. */
  92771. specular: Color3;
  92772. /**
  92773. * Defines the falloff type for this light. This lets overrriding how punctual light are
  92774. * falling off base on range or angle.
  92775. * This can be set to any values in Light.FALLOFF_x.
  92776. *
  92777. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  92778. * other types of materials.
  92779. */
  92780. falloffType: number;
  92781. /**
  92782. * Strength of the light.
  92783. * Note: By default it is define in the framework own unit.
  92784. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  92785. */
  92786. intensity: number;
  92787. private _range;
  92788. protected _inverseSquaredRange: number;
  92789. /**
  92790. * Defines how far from the source the light is impacting in scene units.
  92791. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92792. */
  92793. get range(): number;
  92794. /**
  92795. * Defines how far from the source the light is impacting in scene units.
  92796. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92797. */
  92798. set range(value: number);
  92799. /**
  92800. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  92801. * of light.
  92802. */
  92803. private _photometricScale;
  92804. private _intensityMode;
  92805. /**
  92806. * Gets the photometric scale used to interpret the intensity.
  92807. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92808. */
  92809. get intensityMode(): number;
  92810. /**
  92811. * Sets the photometric scale used to interpret the intensity.
  92812. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92813. */
  92814. set intensityMode(value: number);
  92815. private _radius;
  92816. /**
  92817. * Gets the light radius used by PBR Materials to simulate soft area lights.
  92818. */
  92819. get radius(): number;
  92820. /**
  92821. * sets the light radius used by PBR Materials to simulate soft area lights.
  92822. */
  92823. set radius(value: number);
  92824. private _renderPriority;
  92825. /**
  92826. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  92827. * exceeding the number allowed of the materials.
  92828. */
  92829. renderPriority: number;
  92830. private _shadowEnabled;
  92831. /**
  92832. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92833. * the current shadow generator.
  92834. */
  92835. get shadowEnabled(): boolean;
  92836. /**
  92837. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92838. * the current shadow generator.
  92839. */
  92840. set shadowEnabled(value: boolean);
  92841. private _includedOnlyMeshes;
  92842. /**
  92843. * Gets the only meshes impacted by this light.
  92844. */
  92845. get includedOnlyMeshes(): AbstractMesh[];
  92846. /**
  92847. * Sets the only meshes impacted by this light.
  92848. */
  92849. set includedOnlyMeshes(value: AbstractMesh[]);
  92850. private _excludedMeshes;
  92851. /**
  92852. * Gets the meshes not impacted by this light.
  92853. */
  92854. get excludedMeshes(): AbstractMesh[];
  92855. /**
  92856. * Sets the meshes not impacted by this light.
  92857. */
  92858. set excludedMeshes(value: AbstractMesh[]);
  92859. private _excludeWithLayerMask;
  92860. /**
  92861. * Gets the layer id use to find what meshes are not impacted by the light.
  92862. * Inactive if 0
  92863. */
  92864. get excludeWithLayerMask(): number;
  92865. /**
  92866. * Sets the layer id use to find what meshes are not impacted by the light.
  92867. * Inactive if 0
  92868. */
  92869. set excludeWithLayerMask(value: number);
  92870. private _includeOnlyWithLayerMask;
  92871. /**
  92872. * Gets the layer id use to find what meshes are impacted by the light.
  92873. * Inactive if 0
  92874. */
  92875. get includeOnlyWithLayerMask(): number;
  92876. /**
  92877. * Sets the layer id use to find what meshes are impacted by the light.
  92878. * Inactive if 0
  92879. */
  92880. set includeOnlyWithLayerMask(value: number);
  92881. private _lightmapMode;
  92882. /**
  92883. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92884. */
  92885. get lightmapMode(): number;
  92886. /**
  92887. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92888. */
  92889. set lightmapMode(value: number);
  92890. /**
  92891. * Shadow generator associted to the light.
  92892. * @hidden Internal use only.
  92893. */
  92894. _shadowGenerator: Nullable<IShadowGenerator>;
  92895. /**
  92896. * @hidden Internal use only.
  92897. */
  92898. _excludedMeshesIds: string[];
  92899. /**
  92900. * @hidden Internal use only.
  92901. */
  92902. _includedOnlyMeshesIds: string[];
  92903. /**
  92904. * The current light unifom buffer.
  92905. * @hidden Internal use only.
  92906. */
  92907. _uniformBuffer: UniformBuffer;
  92908. /** @hidden */
  92909. _renderId: number;
  92910. /**
  92911. * Creates a Light object in the scene.
  92912. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92913. * @param name The firendly name of the light
  92914. * @param scene The scene the light belongs too
  92915. */
  92916. constructor(name: string, scene: Scene);
  92917. protected abstract _buildUniformLayout(): void;
  92918. /**
  92919. * Sets the passed Effect "effect" with the Light information.
  92920. * @param effect The effect to update
  92921. * @param lightIndex The index of the light in the effect to update
  92922. * @returns The light
  92923. */
  92924. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  92925. /**
  92926. * Sets the passed Effect "effect" with the Light textures.
  92927. * @param effect The effect to update
  92928. * @param lightIndex The index of the light in the effect to update
  92929. * @returns The light
  92930. */
  92931. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  92932. /**
  92933. * Binds the lights information from the scene to the effect for the given mesh.
  92934. * @param lightIndex Light index
  92935. * @param scene The scene where the light belongs to
  92936. * @param effect The effect we are binding the data to
  92937. * @param useSpecular Defines if specular is supported
  92938. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  92939. */
  92940. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  92941. /**
  92942. * Sets the passed Effect "effect" with the Light information.
  92943. * @param effect The effect to update
  92944. * @param lightDataUniformName The uniform used to store light data (position or direction)
  92945. * @returns The light
  92946. */
  92947. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  92948. /**
  92949. * Returns the string "Light".
  92950. * @returns the class name
  92951. */
  92952. getClassName(): string;
  92953. /** @hidden */
  92954. readonly _isLight: boolean;
  92955. /**
  92956. * Converts the light information to a readable string for debug purpose.
  92957. * @param fullDetails Supports for multiple levels of logging within scene loading
  92958. * @returns the human readable light info
  92959. */
  92960. toString(fullDetails?: boolean): string;
  92961. /** @hidden */
  92962. protected _syncParentEnabledState(): void;
  92963. /**
  92964. * Set the enabled state of this node.
  92965. * @param value - the new enabled state
  92966. */
  92967. setEnabled(value: boolean): void;
  92968. /**
  92969. * Returns the Light associated shadow generator if any.
  92970. * @return the associated shadow generator.
  92971. */
  92972. getShadowGenerator(): Nullable<IShadowGenerator>;
  92973. /**
  92974. * Returns a Vector3, the absolute light position in the World.
  92975. * @returns the world space position of the light
  92976. */
  92977. getAbsolutePosition(): Vector3;
  92978. /**
  92979. * Specifies if the light will affect the passed mesh.
  92980. * @param mesh The mesh to test against the light
  92981. * @return true the mesh is affected otherwise, false.
  92982. */
  92983. canAffectMesh(mesh: AbstractMesh): boolean;
  92984. /**
  92985. * Sort function to order lights for rendering.
  92986. * @param a First Light object to compare to second.
  92987. * @param b Second Light object to compare first.
  92988. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  92989. */
  92990. static CompareLightsPriority(a: Light, b: Light): number;
  92991. /**
  92992. * Releases resources associated with this node.
  92993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92995. */
  92996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92997. /**
  92998. * Returns the light type ID (integer).
  92999. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93000. */
  93001. getTypeID(): number;
  93002. /**
  93003. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93004. * @returns the scaled intensity in intensity mode unit
  93005. */
  93006. getScaledIntensity(): number;
  93007. /**
  93008. * Returns a new Light object, named "name", from the current one.
  93009. * @param name The name of the cloned light
  93010. * @returns the new created light
  93011. */
  93012. clone(name: string): Nullable<Light>;
  93013. /**
  93014. * Serializes the current light into a Serialization object.
  93015. * @returns the serialized object.
  93016. */
  93017. serialize(): any;
  93018. /**
  93019. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93020. * This new light is named "name" and added to the passed scene.
  93021. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93022. * @param name The friendly name of the light
  93023. * @param scene The scene the new light will belong to
  93024. * @returns the constructor function
  93025. */
  93026. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93027. /**
  93028. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93029. * @param parsedLight The JSON representation of the light
  93030. * @param scene The scene to create the parsed light in
  93031. * @returns the created light after parsing
  93032. */
  93033. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93034. private _hookArrayForExcluded;
  93035. private _hookArrayForIncludedOnly;
  93036. private _resyncMeshes;
  93037. /**
  93038. * Forces the meshes to update their light related information in their rendering used effects
  93039. * @hidden Internal Use Only
  93040. */
  93041. _markMeshesAsLightDirty(): void;
  93042. /**
  93043. * Recomputes the cached photometric scale if needed.
  93044. */
  93045. private _computePhotometricScale;
  93046. /**
  93047. * Returns the Photometric Scale according to the light type and intensity mode.
  93048. */
  93049. private _getPhotometricScale;
  93050. /**
  93051. * Reorder the light in the scene according to their defined priority.
  93052. * @hidden Internal Use Only
  93053. */
  93054. _reorderLightsInScene(): void;
  93055. /**
  93056. * Prepares the list of defines specific to the light type.
  93057. * @param defines the list of defines
  93058. * @param lightIndex defines the index of the light for the effect
  93059. */
  93060. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93061. }
  93062. }
  93063. declare module BABYLON {
  93064. /**
  93065. * Interface used to define Action
  93066. */
  93067. export interface IAction {
  93068. /**
  93069. * Trigger for the action
  93070. */
  93071. trigger: number;
  93072. /** Options of the trigger */
  93073. triggerOptions: any;
  93074. /**
  93075. * Gets the trigger parameters
  93076. * @returns the trigger parameters
  93077. */
  93078. getTriggerParameter(): any;
  93079. /**
  93080. * Internal only - executes current action event
  93081. * @hidden
  93082. */
  93083. _executeCurrent(evt?: ActionEvent): void;
  93084. /**
  93085. * Serialize placeholder for child classes
  93086. * @param parent of child
  93087. * @returns the serialized object
  93088. */
  93089. serialize(parent: any): any;
  93090. /**
  93091. * Internal only
  93092. * @hidden
  93093. */
  93094. _prepare(): void;
  93095. /**
  93096. * Internal only - manager for action
  93097. * @hidden
  93098. */
  93099. _actionManager: AbstractActionManager;
  93100. /**
  93101. * Adds action to chain of actions, may be a DoNothingAction
  93102. * @param action defines the next action to execute
  93103. * @returns The action passed in
  93104. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93105. */
  93106. then(action: IAction): IAction;
  93107. }
  93108. /**
  93109. * The action to be carried out following a trigger
  93110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93111. */
  93112. export class Action implements IAction {
  93113. /** the trigger, with or without parameters, for the action */
  93114. triggerOptions: any;
  93115. /**
  93116. * Trigger for the action
  93117. */
  93118. trigger: number;
  93119. /**
  93120. * Internal only - manager for action
  93121. * @hidden
  93122. */
  93123. _actionManager: ActionManager;
  93124. private _nextActiveAction;
  93125. private _child;
  93126. private _condition?;
  93127. private _triggerParameter;
  93128. /**
  93129. * An event triggered prior to action being executed.
  93130. */
  93131. onBeforeExecuteObservable: Observable<Action>;
  93132. /**
  93133. * Creates a new Action
  93134. * @param triggerOptions the trigger, with or without parameters, for the action
  93135. * @param condition an optional determinant of action
  93136. */
  93137. constructor(
  93138. /** the trigger, with or without parameters, for the action */
  93139. triggerOptions: any, condition?: Condition);
  93140. /**
  93141. * Internal only
  93142. * @hidden
  93143. */
  93144. _prepare(): void;
  93145. /**
  93146. * Gets the trigger parameters
  93147. * @returns the trigger parameters
  93148. */
  93149. getTriggerParameter(): any;
  93150. /**
  93151. * Internal only - executes current action event
  93152. * @hidden
  93153. */
  93154. _executeCurrent(evt?: ActionEvent): void;
  93155. /**
  93156. * Execute placeholder for child classes
  93157. * @param evt optional action event
  93158. */
  93159. execute(evt?: ActionEvent): void;
  93160. /**
  93161. * Skips to next active action
  93162. */
  93163. skipToNextActiveAction(): void;
  93164. /**
  93165. * Adds action to chain of actions, may be a DoNothingAction
  93166. * @param action defines the next action to execute
  93167. * @returns The action passed in
  93168. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93169. */
  93170. then(action: Action): Action;
  93171. /**
  93172. * Internal only
  93173. * @hidden
  93174. */
  93175. _getProperty(propertyPath: string): string;
  93176. /**
  93177. * Internal only
  93178. * @hidden
  93179. */
  93180. _getEffectiveTarget(target: any, propertyPath: string): any;
  93181. /**
  93182. * Serialize placeholder for child classes
  93183. * @param parent of child
  93184. * @returns the serialized object
  93185. */
  93186. serialize(parent: any): any;
  93187. /**
  93188. * Internal only called by serialize
  93189. * @hidden
  93190. */
  93191. protected _serialize(serializedAction: any, parent?: any): any;
  93192. /**
  93193. * Internal only
  93194. * @hidden
  93195. */
  93196. static _SerializeValueAsString: (value: any) => string;
  93197. /**
  93198. * Internal only
  93199. * @hidden
  93200. */
  93201. static _GetTargetProperty: (target: Node | Scene) => {
  93202. name: string;
  93203. targetType: string;
  93204. value: string;
  93205. };
  93206. }
  93207. }
  93208. declare module BABYLON {
  93209. /**
  93210. * A Condition applied to an Action
  93211. */
  93212. export class Condition {
  93213. /**
  93214. * Internal only - manager for action
  93215. * @hidden
  93216. */
  93217. _actionManager: ActionManager;
  93218. /**
  93219. * Internal only
  93220. * @hidden
  93221. */
  93222. _evaluationId: number;
  93223. /**
  93224. * Internal only
  93225. * @hidden
  93226. */
  93227. _currentResult: boolean;
  93228. /**
  93229. * Creates a new Condition
  93230. * @param actionManager the manager of the action the condition is applied to
  93231. */
  93232. constructor(actionManager: ActionManager);
  93233. /**
  93234. * Check if the current condition is valid
  93235. * @returns a boolean
  93236. */
  93237. isValid(): boolean;
  93238. /**
  93239. * Internal only
  93240. * @hidden
  93241. */
  93242. _getProperty(propertyPath: string): string;
  93243. /**
  93244. * Internal only
  93245. * @hidden
  93246. */
  93247. _getEffectiveTarget(target: any, propertyPath: string): any;
  93248. /**
  93249. * Serialize placeholder for child classes
  93250. * @returns the serialized object
  93251. */
  93252. serialize(): any;
  93253. /**
  93254. * Internal only
  93255. * @hidden
  93256. */
  93257. protected _serialize(serializedCondition: any): any;
  93258. }
  93259. /**
  93260. * Defines specific conditional operators as extensions of Condition
  93261. */
  93262. export class ValueCondition extends Condition {
  93263. /** path to specify the property of the target the conditional operator uses */
  93264. propertyPath: string;
  93265. /** the value compared by the conditional operator against the current value of the property */
  93266. value: any;
  93267. /** the conditional operator, default ValueCondition.IsEqual */
  93268. operator: number;
  93269. /**
  93270. * Internal only
  93271. * @hidden
  93272. */
  93273. private static _IsEqual;
  93274. /**
  93275. * Internal only
  93276. * @hidden
  93277. */
  93278. private static _IsDifferent;
  93279. /**
  93280. * Internal only
  93281. * @hidden
  93282. */
  93283. private static _IsGreater;
  93284. /**
  93285. * Internal only
  93286. * @hidden
  93287. */
  93288. private static _IsLesser;
  93289. /**
  93290. * returns the number for IsEqual
  93291. */
  93292. static get IsEqual(): number;
  93293. /**
  93294. * Returns the number for IsDifferent
  93295. */
  93296. static get IsDifferent(): number;
  93297. /**
  93298. * Returns the number for IsGreater
  93299. */
  93300. static get IsGreater(): number;
  93301. /**
  93302. * Returns the number for IsLesser
  93303. */
  93304. static get IsLesser(): number;
  93305. /**
  93306. * Internal only The action manager for the condition
  93307. * @hidden
  93308. */
  93309. _actionManager: ActionManager;
  93310. /**
  93311. * Internal only
  93312. * @hidden
  93313. */
  93314. private _target;
  93315. /**
  93316. * Internal only
  93317. * @hidden
  93318. */
  93319. private _effectiveTarget;
  93320. /**
  93321. * Internal only
  93322. * @hidden
  93323. */
  93324. private _property;
  93325. /**
  93326. * Creates a new ValueCondition
  93327. * @param actionManager manager for the action the condition applies to
  93328. * @param target for the action
  93329. * @param propertyPath path to specify the property of the target the conditional operator uses
  93330. * @param value the value compared by the conditional operator against the current value of the property
  93331. * @param operator the conditional operator, default ValueCondition.IsEqual
  93332. */
  93333. constructor(actionManager: ActionManager, target: any,
  93334. /** path to specify the property of the target the conditional operator uses */
  93335. propertyPath: string,
  93336. /** the value compared by the conditional operator against the current value of the property */
  93337. value: any,
  93338. /** the conditional operator, default ValueCondition.IsEqual */
  93339. operator?: number);
  93340. /**
  93341. * Compares the given value with the property value for the specified conditional operator
  93342. * @returns the result of the comparison
  93343. */
  93344. isValid(): boolean;
  93345. /**
  93346. * Serialize the ValueCondition into a JSON compatible object
  93347. * @returns serialization object
  93348. */
  93349. serialize(): any;
  93350. /**
  93351. * Gets the name of the conditional operator for the ValueCondition
  93352. * @param operator the conditional operator
  93353. * @returns the name
  93354. */
  93355. static GetOperatorName(operator: number): string;
  93356. }
  93357. /**
  93358. * Defines a predicate condition as an extension of Condition
  93359. */
  93360. export class PredicateCondition extends Condition {
  93361. /** defines the predicate function used to validate the condition */
  93362. predicate: () => boolean;
  93363. /**
  93364. * Internal only - manager for action
  93365. * @hidden
  93366. */
  93367. _actionManager: ActionManager;
  93368. /**
  93369. * Creates a new PredicateCondition
  93370. * @param actionManager manager for the action the condition applies to
  93371. * @param predicate defines the predicate function used to validate the condition
  93372. */
  93373. constructor(actionManager: ActionManager,
  93374. /** defines the predicate function used to validate the condition */
  93375. predicate: () => boolean);
  93376. /**
  93377. * @returns the validity of the predicate condition
  93378. */
  93379. isValid(): boolean;
  93380. }
  93381. /**
  93382. * Defines a state condition as an extension of Condition
  93383. */
  93384. export class StateCondition extends Condition {
  93385. /** Value to compare with target state */
  93386. value: string;
  93387. /**
  93388. * Internal only - manager for action
  93389. * @hidden
  93390. */
  93391. _actionManager: ActionManager;
  93392. /**
  93393. * Internal only
  93394. * @hidden
  93395. */
  93396. private _target;
  93397. /**
  93398. * Creates a new StateCondition
  93399. * @param actionManager manager for the action the condition applies to
  93400. * @param target of the condition
  93401. * @param value to compare with target state
  93402. */
  93403. constructor(actionManager: ActionManager, target: any,
  93404. /** Value to compare with target state */
  93405. value: string);
  93406. /**
  93407. * Gets a boolean indicating if the current condition is met
  93408. * @returns the validity of the state
  93409. */
  93410. isValid(): boolean;
  93411. /**
  93412. * Serialize the StateCondition into a JSON compatible object
  93413. * @returns serialization object
  93414. */
  93415. serialize(): any;
  93416. }
  93417. }
  93418. declare module BABYLON {
  93419. /**
  93420. * This defines an action responsible to toggle a boolean once triggered.
  93421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93422. */
  93423. export class SwitchBooleanAction extends Action {
  93424. /**
  93425. * The path to the boolean property in the target object
  93426. */
  93427. propertyPath: string;
  93428. private _target;
  93429. private _effectiveTarget;
  93430. private _property;
  93431. /**
  93432. * Instantiate the action
  93433. * @param triggerOptions defines the trigger options
  93434. * @param target defines the object containing the boolean
  93435. * @param propertyPath defines the path to the boolean property in the target object
  93436. * @param condition defines the trigger related conditions
  93437. */
  93438. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93439. /** @hidden */
  93440. _prepare(): void;
  93441. /**
  93442. * Execute the action toggle the boolean value.
  93443. */
  93444. execute(): void;
  93445. /**
  93446. * Serializes the actions and its related information.
  93447. * @param parent defines the object to serialize in
  93448. * @returns the serialized object
  93449. */
  93450. serialize(parent: any): any;
  93451. }
  93452. /**
  93453. * This defines an action responsible to set a the state field of the target
  93454. * to a desired value once triggered.
  93455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93456. */
  93457. export class SetStateAction extends Action {
  93458. /**
  93459. * The value to store in the state field.
  93460. */
  93461. value: string;
  93462. private _target;
  93463. /**
  93464. * Instantiate the action
  93465. * @param triggerOptions defines the trigger options
  93466. * @param target defines the object containing the state property
  93467. * @param value defines the value to store in the state field
  93468. * @param condition defines the trigger related conditions
  93469. */
  93470. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93471. /**
  93472. * Execute the action and store the value on the target state property.
  93473. */
  93474. execute(): void;
  93475. /**
  93476. * Serializes the actions and its related information.
  93477. * @param parent defines the object to serialize in
  93478. * @returns the serialized object
  93479. */
  93480. serialize(parent: any): any;
  93481. }
  93482. /**
  93483. * This defines an action responsible to set a property of the target
  93484. * to a desired value once triggered.
  93485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93486. */
  93487. export class SetValueAction extends Action {
  93488. /**
  93489. * The path of the property to set in the target.
  93490. */
  93491. propertyPath: string;
  93492. /**
  93493. * The value to set in the property
  93494. */
  93495. value: any;
  93496. private _target;
  93497. private _effectiveTarget;
  93498. private _property;
  93499. /**
  93500. * Instantiate the action
  93501. * @param triggerOptions defines the trigger options
  93502. * @param target defines the object containing the property
  93503. * @param propertyPath defines the path of the property to set in the target
  93504. * @param value defines the value to set in the property
  93505. * @param condition defines the trigger related conditions
  93506. */
  93507. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93508. /** @hidden */
  93509. _prepare(): void;
  93510. /**
  93511. * Execute the action and set the targetted property to the desired value.
  93512. */
  93513. execute(): void;
  93514. /**
  93515. * Serializes the actions and its related information.
  93516. * @param parent defines the object to serialize in
  93517. * @returns the serialized object
  93518. */
  93519. serialize(parent: any): any;
  93520. }
  93521. /**
  93522. * This defines an action responsible to increment the target value
  93523. * to a desired value once triggered.
  93524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93525. */
  93526. export class IncrementValueAction extends Action {
  93527. /**
  93528. * The path of the property to increment in the target.
  93529. */
  93530. propertyPath: string;
  93531. /**
  93532. * The value we should increment the property by.
  93533. */
  93534. value: any;
  93535. private _target;
  93536. private _effectiveTarget;
  93537. private _property;
  93538. /**
  93539. * Instantiate the action
  93540. * @param triggerOptions defines the trigger options
  93541. * @param target defines the object containing the property
  93542. * @param propertyPath defines the path of the property to increment in the target
  93543. * @param value defines the value value we should increment the property by
  93544. * @param condition defines the trigger related conditions
  93545. */
  93546. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93547. /** @hidden */
  93548. _prepare(): void;
  93549. /**
  93550. * Execute the action and increment the target of the value amount.
  93551. */
  93552. execute(): void;
  93553. /**
  93554. * Serializes the actions and its related information.
  93555. * @param parent defines the object to serialize in
  93556. * @returns the serialized object
  93557. */
  93558. serialize(parent: any): any;
  93559. }
  93560. /**
  93561. * This defines an action responsible to start an animation once triggered.
  93562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93563. */
  93564. export class PlayAnimationAction extends Action {
  93565. /**
  93566. * Where the animation should start (animation frame)
  93567. */
  93568. from: number;
  93569. /**
  93570. * Where the animation should stop (animation frame)
  93571. */
  93572. to: number;
  93573. /**
  93574. * Define if the animation should loop or stop after the first play.
  93575. */
  93576. loop?: boolean;
  93577. private _target;
  93578. /**
  93579. * Instantiate the action
  93580. * @param triggerOptions defines the trigger options
  93581. * @param target defines the target animation or animation name
  93582. * @param from defines from where the animation should start (animation frame)
  93583. * @param end defines where the animation should stop (animation frame)
  93584. * @param loop defines if the animation should loop or stop after the first play
  93585. * @param condition defines the trigger related conditions
  93586. */
  93587. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93588. /** @hidden */
  93589. _prepare(): void;
  93590. /**
  93591. * Execute the action and play the animation.
  93592. */
  93593. execute(): void;
  93594. /**
  93595. * Serializes the actions and its related information.
  93596. * @param parent defines the object to serialize in
  93597. * @returns the serialized object
  93598. */
  93599. serialize(parent: any): any;
  93600. }
  93601. /**
  93602. * This defines an action responsible to stop an animation once triggered.
  93603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93604. */
  93605. export class StopAnimationAction extends Action {
  93606. private _target;
  93607. /**
  93608. * Instantiate the action
  93609. * @param triggerOptions defines the trigger options
  93610. * @param target defines the target animation or animation name
  93611. * @param condition defines the trigger related conditions
  93612. */
  93613. constructor(triggerOptions: any, target: any, condition?: Condition);
  93614. /** @hidden */
  93615. _prepare(): void;
  93616. /**
  93617. * Execute the action and stop the animation.
  93618. */
  93619. execute(): void;
  93620. /**
  93621. * Serializes the actions and its related information.
  93622. * @param parent defines the object to serialize in
  93623. * @returns the serialized object
  93624. */
  93625. serialize(parent: any): any;
  93626. }
  93627. /**
  93628. * This defines an action responsible that does nothing once triggered.
  93629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93630. */
  93631. export class DoNothingAction extends Action {
  93632. /**
  93633. * Instantiate the action
  93634. * @param triggerOptions defines the trigger options
  93635. * @param condition defines the trigger related conditions
  93636. */
  93637. constructor(triggerOptions?: any, condition?: Condition);
  93638. /**
  93639. * Execute the action and do nothing.
  93640. */
  93641. execute(): void;
  93642. /**
  93643. * Serializes the actions and its related information.
  93644. * @param parent defines the object to serialize in
  93645. * @returns the serialized object
  93646. */
  93647. serialize(parent: any): any;
  93648. }
  93649. /**
  93650. * This defines an action responsible to trigger several actions once triggered.
  93651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93652. */
  93653. export class CombineAction extends Action {
  93654. /**
  93655. * The list of aggregated animations to run.
  93656. */
  93657. children: Action[];
  93658. /**
  93659. * Instantiate the action
  93660. * @param triggerOptions defines the trigger options
  93661. * @param children defines the list of aggregated animations to run
  93662. * @param condition defines the trigger related conditions
  93663. */
  93664. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93665. /** @hidden */
  93666. _prepare(): void;
  93667. /**
  93668. * Execute the action and executes all the aggregated actions.
  93669. */
  93670. execute(evt: ActionEvent): void;
  93671. /**
  93672. * Serializes the actions and its related information.
  93673. * @param parent defines the object to serialize in
  93674. * @returns the serialized object
  93675. */
  93676. serialize(parent: any): any;
  93677. }
  93678. /**
  93679. * This defines an action responsible to run code (external event) once triggered.
  93680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93681. */
  93682. export class ExecuteCodeAction extends Action {
  93683. /**
  93684. * The callback function to run.
  93685. */
  93686. func: (evt: ActionEvent) => void;
  93687. /**
  93688. * Instantiate the action
  93689. * @param triggerOptions defines the trigger options
  93690. * @param func defines the callback function to run
  93691. * @param condition defines the trigger related conditions
  93692. */
  93693. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93694. /**
  93695. * Execute the action and run the attached code.
  93696. */
  93697. execute(evt: ActionEvent): void;
  93698. }
  93699. /**
  93700. * This defines an action responsible to set the parent property of the target once triggered.
  93701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93702. */
  93703. export class SetParentAction extends Action {
  93704. private _parent;
  93705. private _target;
  93706. /**
  93707. * Instantiate the action
  93708. * @param triggerOptions defines the trigger options
  93709. * @param target defines the target containing the parent property
  93710. * @param parent defines from where the animation should start (animation frame)
  93711. * @param condition defines the trigger related conditions
  93712. */
  93713. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93714. /** @hidden */
  93715. _prepare(): void;
  93716. /**
  93717. * Execute the action and set the parent property.
  93718. */
  93719. execute(): void;
  93720. /**
  93721. * Serializes the actions and its related information.
  93722. * @param parent defines the object to serialize in
  93723. * @returns the serialized object
  93724. */
  93725. serialize(parent: any): any;
  93726. }
  93727. }
  93728. declare module BABYLON {
  93729. /**
  93730. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93731. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93733. */
  93734. export class ActionManager extends AbstractActionManager {
  93735. /**
  93736. * Nothing
  93737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93738. */
  93739. static readonly NothingTrigger: number;
  93740. /**
  93741. * On pick
  93742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93743. */
  93744. static readonly OnPickTrigger: number;
  93745. /**
  93746. * On left pick
  93747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93748. */
  93749. static readonly OnLeftPickTrigger: number;
  93750. /**
  93751. * On right pick
  93752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93753. */
  93754. static readonly OnRightPickTrigger: number;
  93755. /**
  93756. * On center pick
  93757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93758. */
  93759. static readonly OnCenterPickTrigger: number;
  93760. /**
  93761. * On pick down
  93762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93763. */
  93764. static readonly OnPickDownTrigger: number;
  93765. /**
  93766. * On double pick
  93767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93768. */
  93769. static readonly OnDoublePickTrigger: number;
  93770. /**
  93771. * On pick up
  93772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93773. */
  93774. static readonly OnPickUpTrigger: number;
  93775. /**
  93776. * On pick out.
  93777. * This trigger will only be raised if you also declared a OnPickDown
  93778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93779. */
  93780. static readonly OnPickOutTrigger: number;
  93781. /**
  93782. * On long press
  93783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93784. */
  93785. static readonly OnLongPressTrigger: number;
  93786. /**
  93787. * On pointer over
  93788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93789. */
  93790. static readonly OnPointerOverTrigger: number;
  93791. /**
  93792. * On pointer out
  93793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93794. */
  93795. static readonly OnPointerOutTrigger: number;
  93796. /**
  93797. * On every frame
  93798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93799. */
  93800. static readonly OnEveryFrameTrigger: number;
  93801. /**
  93802. * On intersection enter
  93803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93804. */
  93805. static readonly OnIntersectionEnterTrigger: number;
  93806. /**
  93807. * On intersection exit
  93808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93809. */
  93810. static readonly OnIntersectionExitTrigger: number;
  93811. /**
  93812. * On key down
  93813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93814. */
  93815. static readonly OnKeyDownTrigger: number;
  93816. /**
  93817. * On key up
  93818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93819. */
  93820. static readonly OnKeyUpTrigger: number;
  93821. private _scene;
  93822. /**
  93823. * Creates a new action manager
  93824. * @param scene defines the hosting scene
  93825. */
  93826. constructor(scene: Scene);
  93827. /**
  93828. * Releases all associated resources
  93829. */
  93830. dispose(): void;
  93831. /**
  93832. * Gets hosting scene
  93833. * @returns the hosting scene
  93834. */
  93835. getScene(): Scene;
  93836. /**
  93837. * Does this action manager handles actions of any of the given triggers
  93838. * @param triggers defines the triggers to be tested
  93839. * @return a boolean indicating whether one (or more) of the triggers is handled
  93840. */
  93841. hasSpecificTriggers(triggers: number[]): boolean;
  93842. /**
  93843. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93844. * speed.
  93845. * @param triggerA defines the trigger to be tested
  93846. * @param triggerB defines the trigger to be tested
  93847. * @return a boolean indicating whether one (or more) of the triggers is handled
  93848. */
  93849. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93850. /**
  93851. * Does this action manager handles actions of a given trigger
  93852. * @param trigger defines the trigger to be tested
  93853. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93854. * @return whether the trigger is handled
  93855. */
  93856. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93857. /**
  93858. * Does this action manager has pointer triggers
  93859. */
  93860. get hasPointerTriggers(): boolean;
  93861. /**
  93862. * Does this action manager has pick triggers
  93863. */
  93864. get hasPickTriggers(): boolean;
  93865. /**
  93866. * Registers an action to this action manager
  93867. * @param action defines the action to be registered
  93868. * @return the action amended (prepared) after registration
  93869. */
  93870. registerAction(action: IAction): Nullable<IAction>;
  93871. /**
  93872. * Unregisters an action to this action manager
  93873. * @param action defines the action to be unregistered
  93874. * @return a boolean indicating whether the action has been unregistered
  93875. */
  93876. unregisterAction(action: IAction): Boolean;
  93877. /**
  93878. * Process a specific trigger
  93879. * @param trigger defines the trigger to process
  93880. * @param evt defines the event details to be processed
  93881. */
  93882. processTrigger(trigger: number, evt?: IActionEvent): void;
  93883. /** @hidden */
  93884. _getEffectiveTarget(target: any, propertyPath: string): any;
  93885. /** @hidden */
  93886. _getProperty(propertyPath: string): string;
  93887. /**
  93888. * Serialize this manager to a JSON object
  93889. * @param name defines the property name to store this manager
  93890. * @returns a JSON representation of this manager
  93891. */
  93892. serialize(name: string): any;
  93893. /**
  93894. * Creates a new ActionManager from a JSON data
  93895. * @param parsedActions defines the JSON data to read from
  93896. * @param object defines the hosting mesh
  93897. * @param scene defines the hosting scene
  93898. */
  93899. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  93900. /**
  93901. * Get a trigger name by index
  93902. * @param trigger defines the trigger index
  93903. * @returns a trigger name
  93904. */
  93905. static GetTriggerName(trigger: number): string;
  93906. }
  93907. }
  93908. declare module BABYLON {
  93909. /**
  93910. * Class used to represent a sprite
  93911. * @see http://doc.babylonjs.com/babylon101/sprites
  93912. */
  93913. export class Sprite {
  93914. /** defines the name */
  93915. name: string;
  93916. /** Gets or sets the current world position */
  93917. position: Vector3;
  93918. /** Gets or sets the main color */
  93919. color: Color4;
  93920. /** Gets or sets the width */
  93921. width: number;
  93922. /** Gets or sets the height */
  93923. height: number;
  93924. /** Gets or sets rotation angle */
  93925. angle: number;
  93926. /** Gets or sets the cell index in the sprite sheet */
  93927. cellIndex: number;
  93928. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  93929. cellRef: string;
  93930. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  93931. invertU: number;
  93932. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  93933. invertV: number;
  93934. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  93935. disposeWhenFinishedAnimating: boolean;
  93936. /** Gets the list of attached animations */
  93937. animations: Animation[];
  93938. /** Gets or sets a boolean indicating if the sprite can be picked */
  93939. isPickable: boolean;
  93940. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  93941. useAlphaForPicking: boolean;
  93942. /** @hidden */
  93943. _xOffset: number;
  93944. /** @hidden */
  93945. _yOffset: number;
  93946. /** @hidden */
  93947. _xSize: number;
  93948. /** @hidden */
  93949. _ySize: number;
  93950. /**
  93951. * Gets or sets the associated action manager
  93952. */
  93953. actionManager: Nullable<ActionManager>;
  93954. /**
  93955. * An event triggered when the control has been disposed
  93956. */
  93957. onDisposeObservable: Observable<Sprite>;
  93958. private _animationStarted;
  93959. private _loopAnimation;
  93960. private _fromIndex;
  93961. private _toIndex;
  93962. private _delay;
  93963. private _direction;
  93964. private _manager;
  93965. private _time;
  93966. private _onAnimationEnd;
  93967. /**
  93968. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  93969. */
  93970. isVisible: boolean;
  93971. /**
  93972. * Gets or sets the sprite size
  93973. */
  93974. get size(): number;
  93975. set size(value: number);
  93976. /**
  93977. * Creates a new Sprite
  93978. * @param name defines the name
  93979. * @param manager defines the manager
  93980. */
  93981. constructor(
  93982. /** defines the name */
  93983. name: string, manager: ISpriteManager);
  93984. /**
  93985. * Starts an animation
  93986. * @param from defines the initial key
  93987. * @param to defines the end key
  93988. * @param loop defines if the animation must loop
  93989. * @param delay defines the start delay (in ms)
  93990. * @param onAnimationEnd defines a callback to call when animation ends
  93991. */
  93992. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  93993. /** Stops current animation (if any) */
  93994. stopAnimation(): void;
  93995. /** @hidden */
  93996. _animate(deltaTime: number): void;
  93997. /** Release associated resources */
  93998. dispose(): void;
  93999. }
  94000. }
  94001. declare module BABYLON {
  94002. /**
  94003. * Information about the result of picking within a scene
  94004. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  94005. */
  94006. export class PickingInfo {
  94007. /** @hidden */
  94008. _pickingUnavailable: boolean;
  94009. /**
  94010. * If the pick collided with an object
  94011. */
  94012. hit: boolean;
  94013. /**
  94014. * Distance away where the pick collided
  94015. */
  94016. distance: number;
  94017. /**
  94018. * The location of pick collision
  94019. */
  94020. pickedPoint: Nullable<Vector3>;
  94021. /**
  94022. * The mesh corresponding the the pick collision
  94023. */
  94024. pickedMesh: Nullable<AbstractMesh>;
  94025. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94026. bu: number;
  94027. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94028. bv: number;
  94029. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94030. faceId: number;
  94031. /** Id of the the submesh that was picked */
  94032. subMeshId: number;
  94033. /** If a sprite was picked, this will be the sprite the pick collided with */
  94034. pickedSprite: Nullable<Sprite>;
  94035. /**
  94036. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94037. */
  94038. originMesh: Nullable<AbstractMesh>;
  94039. /**
  94040. * The ray that was used to perform the picking.
  94041. */
  94042. ray: Nullable<Ray>;
  94043. /**
  94044. * Gets the normal correspodning to the face the pick collided with
  94045. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94046. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94047. * @returns The normal correspodning to the face the pick collided with
  94048. */
  94049. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94050. /**
  94051. * Gets the texture coordinates of where the pick occured
  94052. * @returns the vector containing the coordnates of the texture
  94053. */
  94054. getTextureCoordinates(): Nullable<Vector2>;
  94055. }
  94056. }
  94057. declare module BABYLON {
  94058. /**
  94059. * Gather the list of pointer event types as constants.
  94060. */
  94061. export class PointerEventTypes {
  94062. /**
  94063. * 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.
  94064. */
  94065. static readonly POINTERDOWN: number;
  94066. /**
  94067. * The pointerup event is fired when a pointer is no longer active.
  94068. */
  94069. static readonly POINTERUP: number;
  94070. /**
  94071. * The pointermove event is fired when a pointer changes coordinates.
  94072. */
  94073. static readonly POINTERMOVE: number;
  94074. /**
  94075. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94076. */
  94077. static readonly POINTERWHEEL: number;
  94078. /**
  94079. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94080. */
  94081. static readonly POINTERPICK: number;
  94082. /**
  94083. * The pointertap event is fired when a the object has been touched and released without drag.
  94084. */
  94085. static readonly POINTERTAP: number;
  94086. /**
  94087. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94088. */
  94089. static readonly POINTERDOUBLETAP: number;
  94090. }
  94091. /**
  94092. * Base class of pointer info types.
  94093. */
  94094. export class PointerInfoBase {
  94095. /**
  94096. * Defines the type of event (PointerEventTypes)
  94097. */
  94098. type: number;
  94099. /**
  94100. * Defines the related dom event
  94101. */
  94102. event: PointerEvent | MouseWheelEvent;
  94103. /**
  94104. * Instantiates the base class of pointers info.
  94105. * @param type Defines the type of event (PointerEventTypes)
  94106. * @param event Defines the related dom event
  94107. */
  94108. constructor(
  94109. /**
  94110. * Defines the type of event (PointerEventTypes)
  94111. */
  94112. type: number,
  94113. /**
  94114. * Defines the related dom event
  94115. */
  94116. event: PointerEvent | MouseWheelEvent);
  94117. }
  94118. /**
  94119. * This class is used to store pointer related info for the onPrePointerObservable event.
  94120. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94121. */
  94122. export class PointerInfoPre extends PointerInfoBase {
  94123. /**
  94124. * Ray from a pointer if availible (eg. 6dof controller)
  94125. */
  94126. ray: Nullable<Ray>;
  94127. /**
  94128. * Defines the local position of the pointer on the canvas.
  94129. */
  94130. localPosition: Vector2;
  94131. /**
  94132. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94133. */
  94134. skipOnPointerObservable: boolean;
  94135. /**
  94136. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94137. * @param type Defines the type of event (PointerEventTypes)
  94138. * @param event Defines the related dom event
  94139. * @param localX Defines the local x coordinates of the pointer when the event occured
  94140. * @param localY Defines the local y coordinates of the pointer when the event occured
  94141. */
  94142. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94143. }
  94144. /**
  94145. * This type contains all the data related to a pointer event in Babylon.js.
  94146. * 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.
  94147. */
  94148. export class PointerInfo extends PointerInfoBase {
  94149. /**
  94150. * Defines the picking info associated to the info (if any)\
  94151. */
  94152. pickInfo: Nullable<PickingInfo>;
  94153. /**
  94154. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94155. * @param type Defines the type of event (PointerEventTypes)
  94156. * @param event Defines the related dom event
  94157. * @param pickInfo Defines the picking info associated to the info (if any)\
  94158. */
  94159. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94160. /**
  94161. * Defines the picking info associated to the info (if any)\
  94162. */
  94163. pickInfo: Nullable<PickingInfo>);
  94164. }
  94165. /**
  94166. * Data relating to a touch event on the screen.
  94167. */
  94168. export interface PointerTouch {
  94169. /**
  94170. * X coordinate of touch.
  94171. */
  94172. x: number;
  94173. /**
  94174. * Y coordinate of touch.
  94175. */
  94176. y: number;
  94177. /**
  94178. * Id of touch. Unique for each finger.
  94179. */
  94180. pointerId: number;
  94181. /**
  94182. * Event type passed from DOM.
  94183. */
  94184. type: any;
  94185. }
  94186. }
  94187. declare module BABYLON {
  94188. /**
  94189. * Manage the mouse inputs to control the movement of a free camera.
  94190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94191. */
  94192. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94193. /**
  94194. * Define if touch is enabled in the mouse input
  94195. */
  94196. touchEnabled: boolean;
  94197. /**
  94198. * Defines the camera the input is attached to.
  94199. */
  94200. camera: FreeCamera;
  94201. /**
  94202. * Defines the buttons associated with the input to handle camera move.
  94203. */
  94204. buttons: number[];
  94205. /**
  94206. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94207. */
  94208. angularSensibility: number;
  94209. private _pointerInput;
  94210. private _onMouseMove;
  94211. private _observer;
  94212. private previousPosition;
  94213. /**
  94214. * Observable for when a pointer move event occurs containing the move offset
  94215. */
  94216. onPointerMovedObservable: Observable<{
  94217. offsetX: number;
  94218. offsetY: number;
  94219. }>;
  94220. /**
  94221. * @hidden
  94222. * If the camera should be rotated automatically based on pointer movement
  94223. */
  94224. _allowCameraRotation: boolean;
  94225. /**
  94226. * Manage the mouse inputs to control the movement of a free camera.
  94227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94228. * @param touchEnabled Defines if touch is enabled or not
  94229. */
  94230. constructor(
  94231. /**
  94232. * Define if touch is enabled in the mouse input
  94233. */
  94234. touchEnabled?: boolean);
  94235. /**
  94236. * Attach the input controls to a specific dom element to get the input from.
  94237. * @param element Defines the element the controls should be listened from
  94238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94239. */
  94240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94241. /**
  94242. * Called on JS contextmenu event.
  94243. * Override this method to provide functionality.
  94244. */
  94245. protected onContextMenu(evt: PointerEvent): void;
  94246. /**
  94247. * Detach the current controls from the specified dom element.
  94248. * @param element Defines the element to stop listening the inputs from
  94249. */
  94250. detachControl(element: Nullable<HTMLElement>): void;
  94251. /**
  94252. * Gets the class name of the current intput.
  94253. * @returns the class name
  94254. */
  94255. getClassName(): string;
  94256. /**
  94257. * Get the friendly name associated with the input class.
  94258. * @returns the input friendly name
  94259. */
  94260. getSimpleName(): string;
  94261. }
  94262. }
  94263. declare module BABYLON {
  94264. /**
  94265. * Manage the touch inputs to control the movement of a free camera.
  94266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94267. */
  94268. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94269. /**
  94270. * Defines the camera the input is attached to.
  94271. */
  94272. camera: FreeCamera;
  94273. /**
  94274. * Defines the touch sensibility for rotation.
  94275. * The higher the faster.
  94276. */
  94277. touchAngularSensibility: number;
  94278. /**
  94279. * Defines the touch sensibility for move.
  94280. * The higher the faster.
  94281. */
  94282. touchMoveSensibility: number;
  94283. private _offsetX;
  94284. private _offsetY;
  94285. private _pointerPressed;
  94286. private _pointerInput;
  94287. private _observer;
  94288. private _onLostFocus;
  94289. /**
  94290. * Attach the input controls to a specific dom element to get the input from.
  94291. * @param element Defines the element the controls should be listened from
  94292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94293. */
  94294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94295. /**
  94296. * Detach the current controls from the specified dom element.
  94297. * @param element Defines the element to stop listening the inputs from
  94298. */
  94299. detachControl(element: Nullable<HTMLElement>): void;
  94300. /**
  94301. * Update the current camera state depending on the inputs that have been used this frame.
  94302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94303. */
  94304. checkInputs(): void;
  94305. /**
  94306. * Gets the class name of the current intput.
  94307. * @returns the class name
  94308. */
  94309. getClassName(): string;
  94310. /**
  94311. * Get the friendly name associated with the input class.
  94312. * @returns the input friendly name
  94313. */
  94314. getSimpleName(): string;
  94315. }
  94316. }
  94317. declare module BABYLON {
  94318. /**
  94319. * Default Inputs manager for the FreeCamera.
  94320. * It groups all the default supported inputs for ease of use.
  94321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94322. */
  94323. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94324. /**
  94325. * @hidden
  94326. */
  94327. _mouseInput: Nullable<FreeCameraMouseInput>;
  94328. /**
  94329. * Instantiates a new FreeCameraInputsManager.
  94330. * @param camera Defines the camera the inputs belong to
  94331. */
  94332. constructor(camera: FreeCamera);
  94333. /**
  94334. * Add keyboard input support to the input manager.
  94335. * @returns the current input manager
  94336. */
  94337. addKeyboard(): FreeCameraInputsManager;
  94338. /**
  94339. * Add mouse input support to the input manager.
  94340. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94341. * @returns the current input manager
  94342. */
  94343. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94344. /**
  94345. * Removes the mouse input support from the manager
  94346. * @returns the current input manager
  94347. */
  94348. removeMouse(): FreeCameraInputsManager;
  94349. /**
  94350. * Add touch input support to the input manager.
  94351. * @returns the current input manager
  94352. */
  94353. addTouch(): FreeCameraInputsManager;
  94354. /**
  94355. * Remove all attached input methods from a camera
  94356. */
  94357. clear(): void;
  94358. }
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94363. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94365. */
  94366. export class FreeCamera extends TargetCamera {
  94367. /**
  94368. * Define the collision ellipsoid of the camera.
  94369. * This is helpful to simulate a camera body like the player body around the camera
  94370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94371. */
  94372. ellipsoid: Vector3;
  94373. /**
  94374. * Define an offset for the position of the ellipsoid around the camera.
  94375. * This can be helpful to determine the center of the body near the gravity center of the body
  94376. * instead of its head.
  94377. */
  94378. ellipsoidOffset: Vector3;
  94379. /**
  94380. * Enable or disable collisions of the camera with the rest of the scene objects.
  94381. */
  94382. checkCollisions: boolean;
  94383. /**
  94384. * Enable or disable gravity on the camera.
  94385. */
  94386. applyGravity: boolean;
  94387. /**
  94388. * Define the input manager associated to the camera.
  94389. */
  94390. inputs: FreeCameraInputsManager;
  94391. /**
  94392. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94393. * Higher values reduce sensitivity.
  94394. */
  94395. get angularSensibility(): number;
  94396. /**
  94397. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94398. * Higher values reduce sensitivity.
  94399. */
  94400. set angularSensibility(value: number);
  94401. /**
  94402. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94403. */
  94404. get keysUp(): number[];
  94405. set keysUp(value: number[]);
  94406. /**
  94407. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94408. */
  94409. get keysUpward(): number[];
  94410. set keysUpward(value: number[]);
  94411. /**
  94412. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94413. */
  94414. get keysDown(): number[];
  94415. set keysDown(value: number[]);
  94416. /**
  94417. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94418. */
  94419. get keysDownward(): number[];
  94420. set keysDownward(value: number[]);
  94421. /**
  94422. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94423. */
  94424. get keysLeft(): number[];
  94425. set keysLeft(value: number[]);
  94426. /**
  94427. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94428. */
  94429. get keysRight(): number[];
  94430. set keysRight(value: number[]);
  94431. /**
  94432. * Event raised when the camera collide with a mesh in the scene.
  94433. */
  94434. onCollide: (collidedMesh: AbstractMesh) => void;
  94435. private _collider;
  94436. private _needMoveForGravity;
  94437. private _oldPosition;
  94438. private _diffPosition;
  94439. private _newPosition;
  94440. /** @hidden */
  94441. _localDirection: Vector3;
  94442. /** @hidden */
  94443. _transformedDirection: Vector3;
  94444. /**
  94445. * Instantiates a Free Camera.
  94446. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94447. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94448. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94449. * @param name Define the name of the camera in the scene
  94450. * @param position Define the start position of the camera in the scene
  94451. * @param scene Define the scene the camera belongs to
  94452. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94453. */
  94454. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94455. /**
  94456. * Attached controls to the current camera.
  94457. * @param element Defines the element the controls should be listened from
  94458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94459. */
  94460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94461. /**
  94462. * Detach the current controls from the camera.
  94463. * The camera will stop reacting to inputs.
  94464. * @param element Defines the element to stop listening the inputs from
  94465. */
  94466. detachControl(element: HTMLElement): void;
  94467. private _collisionMask;
  94468. /**
  94469. * Define a collision mask to limit the list of object the camera can collide with
  94470. */
  94471. get collisionMask(): number;
  94472. set collisionMask(mask: number);
  94473. /** @hidden */
  94474. _collideWithWorld(displacement: Vector3): void;
  94475. private _onCollisionPositionChange;
  94476. /** @hidden */
  94477. _checkInputs(): void;
  94478. /** @hidden */
  94479. _decideIfNeedsToMove(): boolean;
  94480. /** @hidden */
  94481. _updatePosition(): void;
  94482. /**
  94483. * Destroy the camera and release the current resources hold by it.
  94484. */
  94485. dispose(): void;
  94486. /**
  94487. * Gets the current object class name.
  94488. * @return the class name
  94489. */
  94490. getClassName(): string;
  94491. }
  94492. }
  94493. declare module BABYLON {
  94494. /**
  94495. * Represents a gamepad control stick position
  94496. */
  94497. export class StickValues {
  94498. /**
  94499. * The x component of the control stick
  94500. */
  94501. x: number;
  94502. /**
  94503. * The y component of the control stick
  94504. */
  94505. y: number;
  94506. /**
  94507. * Initializes the gamepad x and y control stick values
  94508. * @param x The x component of the gamepad control stick value
  94509. * @param y The y component of the gamepad control stick value
  94510. */
  94511. constructor(
  94512. /**
  94513. * The x component of the control stick
  94514. */
  94515. x: number,
  94516. /**
  94517. * The y component of the control stick
  94518. */
  94519. y: number);
  94520. }
  94521. /**
  94522. * An interface which manages callbacks for gamepad button changes
  94523. */
  94524. export interface GamepadButtonChanges {
  94525. /**
  94526. * Called when a gamepad has been changed
  94527. */
  94528. changed: boolean;
  94529. /**
  94530. * Called when a gamepad press event has been triggered
  94531. */
  94532. pressChanged: boolean;
  94533. /**
  94534. * Called when a touch event has been triggered
  94535. */
  94536. touchChanged: boolean;
  94537. /**
  94538. * Called when a value has changed
  94539. */
  94540. valueChanged: boolean;
  94541. }
  94542. /**
  94543. * Represents a gamepad
  94544. */
  94545. export class Gamepad {
  94546. /**
  94547. * The id of the gamepad
  94548. */
  94549. id: string;
  94550. /**
  94551. * The index of the gamepad
  94552. */
  94553. index: number;
  94554. /**
  94555. * The browser gamepad
  94556. */
  94557. browserGamepad: any;
  94558. /**
  94559. * Specifies what type of gamepad this represents
  94560. */
  94561. type: number;
  94562. private _leftStick;
  94563. private _rightStick;
  94564. /** @hidden */
  94565. _isConnected: boolean;
  94566. private _leftStickAxisX;
  94567. private _leftStickAxisY;
  94568. private _rightStickAxisX;
  94569. private _rightStickAxisY;
  94570. /**
  94571. * Triggered when the left control stick has been changed
  94572. */
  94573. private _onleftstickchanged;
  94574. /**
  94575. * Triggered when the right control stick has been changed
  94576. */
  94577. private _onrightstickchanged;
  94578. /**
  94579. * Represents a gamepad controller
  94580. */
  94581. static GAMEPAD: number;
  94582. /**
  94583. * Represents a generic controller
  94584. */
  94585. static GENERIC: number;
  94586. /**
  94587. * Represents an XBox controller
  94588. */
  94589. static XBOX: number;
  94590. /**
  94591. * Represents a pose-enabled controller
  94592. */
  94593. static POSE_ENABLED: number;
  94594. /**
  94595. * Represents an Dual Shock controller
  94596. */
  94597. static DUALSHOCK: number;
  94598. /**
  94599. * Specifies whether the left control stick should be Y-inverted
  94600. */
  94601. protected _invertLeftStickY: boolean;
  94602. /**
  94603. * Specifies if the gamepad has been connected
  94604. */
  94605. get isConnected(): boolean;
  94606. /**
  94607. * Initializes the gamepad
  94608. * @param id The id of the gamepad
  94609. * @param index The index of the gamepad
  94610. * @param browserGamepad The browser gamepad
  94611. * @param leftStickX The x component of the left joystick
  94612. * @param leftStickY The y component of the left joystick
  94613. * @param rightStickX The x component of the right joystick
  94614. * @param rightStickY The y component of the right joystick
  94615. */
  94616. constructor(
  94617. /**
  94618. * The id of the gamepad
  94619. */
  94620. id: string,
  94621. /**
  94622. * The index of the gamepad
  94623. */
  94624. index: number,
  94625. /**
  94626. * The browser gamepad
  94627. */
  94628. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94629. /**
  94630. * Callback triggered when the left joystick has changed
  94631. * @param callback
  94632. */
  94633. onleftstickchanged(callback: (values: StickValues) => void): void;
  94634. /**
  94635. * Callback triggered when the right joystick has changed
  94636. * @param callback
  94637. */
  94638. onrightstickchanged(callback: (values: StickValues) => void): void;
  94639. /**
  94640. * Gets the left joystick
  94641. */
  94642. get leftStick(): StickValues;
  94643. /**
  94644. * Sets the left joystick values
  94645. */
  94646. set leftStick(newValues: StickValues);
  94647. /**
  94648. * Gets the right joystick
  94649. */
  94650. get rightStick(): StickValues;
  94651. /**
  94652. * Sets the right joystick value
  94653. */
  94654. set rightStick(newValues: StickValues);
  94655. /**
  94656. * Updates the gamepad joystick positions
  94657. */
  94658. update(): void;
  94659. /**
  94660. * Disposes the gamepad
  94661. */
  94662. dispose(): void;
  94663. }
  94664. /**
  94665. * Represents a generic gamepad
  94666. */
  94667. export class GenericPad extends Gamepad {
  94668. private _buttons;
  94669. private _onbuttondown;
  94670. private _onbuttonup;
  94671. /**
  94672. * Observable triggered when a button has been pressed
  94673. */
  94674. onButtonDownObservable: Observable<number>;
  94675. /**
  94676. * Observable triggered when a button has been released
  94677. */
  94678. onButtonUpObservable: Observable<number>;
  94679. /**
  94680. * Callback triggered when a button has been pressed
  94681. * @param callback Called when a button has been pressed
  94682. */
  94683. onbuttondown(callback: (buttonPressed: number) => void): void;
  94684. /**
  94685. * Callback triggered when a button has been released
  94686. * @param callback Called when a button has been released
  94687. */
  94688. onbuttonup(callback: (buttonReleased: number) => void): void;
  94689. /**
  94690. * Initializes the generic gamepad
  94691. * @param id The id of the generic gamepad
  94692. * @param index The index of the generic gamepad
  94693. * @param browserGamepad The browser gamepad
  94694. */
  94695. constructor(id: string, index: number, browserGamepad: any);
  94696. private _setButtonValue;
  94697. /**
  94698. * Updates the generic gamepad
  94699. */
  94700. update(): void;
  94701. /**
  94702. * Disposes the generic gamepad
  94703. */
  94704. dispose(): void;
  94705. }
  94706. }
  94707. declare module BABYLON {
  94708. /**
  94709. * Defines the types of pose enabled controllers that are supported
  94710. */
  94711. export enum PoseEnabledControllerType {
  94712. /**
  94713. * HTC Vive
  94714. */
  94715. VIVE = 0,
  94716. /**
  94717. * Oculus Rift
  94718. */
  94719. OCULUS = 1,
  94720. /**
  94721. * Windows mixed reality
  94722. */
  94723. WINDOWS = 2,
  94724. /**
  94725. * Samsung gear VR
  94726. */
  94727. GEAR_VR = 3,
  94728. /**
  94729. * Google Daydream
  94730. */
  94731. DAYDREAM = 4,
  94732. /**
  94733. * Generic
  94734. */
  94735. GENERIC = 5
  94736. }
  94737. /**
  94738. * Defines the MutableGamepadButton interface for the state of a gamepad button
  94739. */
  94740. export interface MutableGamepadButton {
  94741. /**
  94742. * Value of the button/trigger
  94743. */
  94744. value: number;
  94745. /**
  94746. * If the button/trigger is currently touched
  94747. */
  94748. touched: boolean;
  94749. /**
  94750. * If the button/trigger is currently pressed
  94751. */
  94752. pressed: boolean;
  94753. }
  94754. /**
  94755. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  94756. * @hidden
  94757. */
  94758. export interface ExtendedGamepadButton extends GamepadButton {
  94759. /**
  94760. * If the button/trigger is currently pressed
  94761. */
  94762. readonly pressed: boolean;
  94763. /**
  94764. * If the button/trigger is currently touched
  94765. */
  94766. readonly touched: boolean;
  94767. /**
  94768. * Value of the button/trigger
  94769. */
  94770. readonly value: number;
  94771. }
  94772. /** @hidden */
  94773. export interface _GamePadFactory {
  94774. /**
  94775. * Returns whether or not the current gamepad can be created for this type of controller.
  94776. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94777. * @returns true if it can be created, otherwise false
  94778. */
  94779. canCreate(gamepadInfo: any): boolean;
  94780. /**
  94781. * Creates a new instance of the Gamepad.
  94782. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94783. * @returns the new gamepad instance
  94784. */
  94785. create(gamepadInfo: any): Gamepad;
  94786. }
  94787. /**
  94788. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94789. */
  94790. export class PoseEnabledControllerHelper {
  94791. /** @hidden */
  94792. static _ControllerFactories: _GamePadFactory[];
  94793. /** @hidden */
  94794. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  94795. /**
  94796. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94797. * @param vrGamepad the gamepad to initialized
  94798. * @returns a vr controller of the type the gamepad identified as
  94799. */
  94800. static InitiateController(vrGamepad: any): Gamepad;
  94801. }
  94802. /**
  94803. * Defines the PoseEnabledController object that contains state of a vr capable controller
  94804. */
  94805. export class PoseEnabledController extends Gamepad implements PoseControlled {
  94806. /**
  94807. * If the controller is used in a webXR session
  94808. */
  94809. isXR: boolean;
  94810. private _deviceRoomPosition;
  94811. private _deviceRoomRotationQuaternion;
  94812. /**
  94813. * The device position in babylon space
  94814. */
  94815. devicePosition: Vector3;
  94816. /**
  94817. * The device rotation in babylon space
  94818. */
  94819. deviceRotationQuaternion: Quaternion;
  94820. /**
  94821. * The scale factor of the device in babylon space
  94822. */
  94823. deviceScaleFactor: number;
  94824. /**
  94825. * (Likely devicePosition should be used instead) The device position in its room space
  94826. */
  94827. position: Vector3;
  94828. /**
  94829. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  94830. */
  94831. rotationQuaternion: Quaternion;
  94832. /**
  94833. * The type of controller (Eg. Windows mixed reality)
  94834. */
  94835. controllerType: PoseEnabledControllerType;
  94836. protected _calculatedPosition: Vector3;
  94837. private _calculatedRotation;
  94838. /**
  94839. * The raw pose from the device
  94840. */
  94841. rawPose: DevicePose;
  94842. private _trackPosition;
  94843. private _maxRotationDistFromHeadset;
  94844. private _draggedRoomRotation;
  94845. /**
  94846. * @hidden
  94847. */
  94848. _disableTrackPosition(fixedPosition: Vector3): void;
  94849. /**
  94850. * Internal, the mesh attached to the controller
  94851. * @hidden
  94852. */
  94853. _mesh: Nullable<AbstractMesh>;
  94854. private _poseControlledCamera;
  94855. private _leftHandSystemQuaternion;
  94856. /**
  94857. * Internal, matrix used to convert room space to babylon space
  94858. * @hidden
  94859. */
  94860. _deviceToWorld: Matrix;
  94861. /**
  94862. * Node to be used when casting a ray from the controller
  94863. * @hidden
  94864. */
  94865. _pointingPoseNode: Nullable<TransformNode>;
  94866. /**
  94867. * Name of the child mesh that can be used to cast a ray from the controller
  94868. */
  94869. static readonly POINTING_POSE: string;
  94870. /**
  94871. * Creates a new PoseEnabledController from a gamepad
  94872. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  94873. */
  94874. constructor(browserGamepad: any);
  94875. private _workingMatrix;
  94876. /**
  94877. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  94878. */
  94879. update(): void;
  94880. /**
  94881. * Updates only the pose device and mesh without doing any button event checking
  94882. */
  94883. protected _updatePoseAndMesh(): void;
  94884. /**
  94885. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  94886. * @param poseData raw pose fromthe device
  94887. */
  94888. updateFromDevice(poseData: DevicePose): void;
  94889. /**
  94890. * @hidden
  94891. */
  94892. _meshAttachedObservable: Observable<AbstractMesh>;
  94893. /**
  94894. * Attaches a mesh to the controller
  94895. * @param mesh the mesh to be attached
  94896. */
  94897. attachToMesh(mesh: AbstractMesh): void;
  94898. /**
  94899. * Attaches the controllers mesh to a camera
  94900. * @param camera the camera the mesh should be attached to
  94901. */
  94902. attachToPoseControlledCamera(camera: TargetCamera): void;
  94903. /**
  94904. * Disposes of the controller
  94905. */
  94906. dispose(): void;
  94907. /**
  94908. * The mesh that is attached to the controller
  94909. */
  94910. get mesh(): Nullable<AbstractMesh>;
  94911. /**
  94912. * Gets the ray of the controller in the direction the controller is pointing
  94913. * @param length the length the resulting ray should be
  94914. * @returns a ray in the direction the controller is pointing
  94915. */
  94916. getForwardRay(length?: number): Ray;
  94917. }
  94918. }
  94919. declare module BABYLON {
  94920. /**
  94921. * Defines the WebVRController object that represents controllers tracked in 3D space
  94922. */
  94923. export abstract class WebVRController extends PoseEnabledController {
  94924. /**
  94925. * Internal, the default controller model for the controller
  94926. */
  94927. protected _defaultModel: Nullable<AbstractMesh>;
  94928. /**
  94929. * Fired when the trigger state has changed
  94930. */
  94931. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  94932. /**
  94933. * Fired when the main button state has changed
  94934. */
  94935. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94936. /**
  94937. * Fired when the secondary button state has changed
  94938. */
  94939. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94940. /**
  94941. * Fired when the pad state has changed
  94942. */
  94943. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  94944. /**
  94945. * Fired when controllers stick values have changed
  94946. */
  94947. onPadValuesChangedObservable: Observable<StickValues>;
  94948. /**
  94949. * Array of button availible on the controller
  94950. */
  94951. protected _buttons: Array<MutableGamepadButton>;
  94952. private _onButtonStateChange;
  94953. /**
  94954. * Fired when a controller button's state has changed
  94955. * @param callback the callback containing the button that was modified
  94956. */
  94957. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  94958. /**
  94959. * X and Y axis corresponding to the controllers joystick
  94960. */
  94961. pad: StickValues;
  94962. /**
  94963. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  94964. */
  94965. hand: string;
  94966. /**
  94967. * The default controller model for the controller
  94968. */
  94969. get defaultModel(): Nullable<AbstractMesh>;
  94970. /**
  94971. * Creates a new WebVRController from a gamepad
  94972. * @param vrGamepad the gamepad that the WebVRController should be created from
  94973. */
  94974. constructor(vrGamepad: any);
  94975. /**
  94976. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  94977. */
  94978. update(): void;
  94979. /**
  94980. * Function to be called when a button is modified
  94981. */
  94982. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  94983. /**
  94984. * Loads a mesh and attaches it to the controller
  94985. * @param scene the scene the mesh should be added to
  94986. * @param meshLoaded callback for when the mesh has been loaded
  94987. */
  94988. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  94989. private _setButtonValue;
  94990. private _changes;
  94991. private _checkChanges;
  94992. /**
  94993. * Disposes of th webVRCOntroller
  94994. */
  94995. dispose(): void;
  94996. }
  94997. }
  94998. declare module BABYLON {
  94999. /**
  95000. * The HemisphericLight simulates the ambient environment light,
  95001. * so the passed direction is the light reflection direction, not the incoming direction.
  95002. */
  95003. export class HemisphericLight extends Light {
  95004. /**
  95005. * The groundColor is the light in the opposite direction to the one specified during creation.
  95006. * 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.
  95007. */
  95008. groundColor: Color3;
  95009. /**
  95010. * The light reflection direction, not the incoming direction.
  95011. */
  95012. direction: Vector3;
  95013. /**
  95014. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95015. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95016. * The HemisphericLight can't cast shadows.
  95017. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95018. * @param name The friendly name of the light
  95019. * @param direction The direction of the light reflection
  95020. * @param scene The scene the light belongs to
  95021. */
  95022. constructor(name: string, direction: Vector3, scene: Scene);
  95023. protected _buildUniformLayout(): void;
  95024. /**
  95025. * Returns the string "HemisphericLight".
  95026. * @return The class name
  95027. */
  95028. getClassName(): string;
  95029. /**
  95030. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95031. * Returns the updated direction.
  95032. * @param target The target the direction should point to
  95033. * @return The computed direction
  95034. */
  95035. setDirectionToTarget(target: Vector3): Vector3;
  95036. /**
  95037. * Returns the shadow generator associated to the light.
  95038. * @returns Always null for hemispheric lights because it does not support shadows.
  95039. */
  95040. getShadowGenerator(): Nullable<IShadowGenerator>;
  95041. /**
  95042. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95043. * @param effect The effect to update
  95044. * @param lightIndex The index of the light in the effect to update
  95045. * @returns The hemispheric light
  95046. */
  95047. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95048. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95049. /**
  95050. * Computes the world matrix of the node
  95051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95052. * @param useWasUpdatedFlag defines a reserved property
  95053. * @returns the world matrix
  95054. */
  95055. computeWorldMatrix(): Matrix;
  95056. /**
  95057. * Returns the integer 3.
  95058. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95059. */
  95060. getTypeID(): number;
  95061. /**
  95062. * Prepares the list of defines specific to the light type.
  95063. * @param defines the list of defines
  95064. * @param lightIndex defines the index of the light for the effect
  95065. */
  95066. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95067. }
  95068. }
  95069. declare module BABYLON {
  95070. /** @hidden */
  95071. export var vrMultiviewToSingleviewPixelShader: {
  95072. name: string;
  95073. shader: string;
  95074. };
  95075. }
  95076. declare module BABYLON {
  95077. /**
  95078. * Renders to multiple views with a single draw call
  95079. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95080. */
  95081. export class MultiviewRenderTarget extends RenderTargetTexture {
  95082. /**
  95083. * Creates a multiview render target
  95084. * @param scene scene used with the render target
  95085. * @param size the size of the render target (used for each view)
  95086. */
  95087. constructor(scene: Scene, size?: number | {
  95088. width: number;
  95089. height: number;
  95090. } | {
  95091. ratio: number;
  95092. });
  95093. /**
  95094. * @hidden
  95095. * @param faceIndex the face index, if its a cube texture
  95096. */
  95097. _bindFrameBuffer(faceIndex?: number): void;
  95098. /**
  95099. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95100. * @returns the view count
  95101. */
  95102. getViewCount(): number;
  95103. }
  95104. }
  95105. declare module BABYLON {
  95106. /**
  95107. * Represents a camera frustum
  95108. */
  95109. export class Frustum {
  95110. /**
  95111. * Gets the planes representing the frustum
  95112. * @param transform matrix to be applied to the returned planes
  95113. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95114. */
  95115. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95116. /**
  95117. * Gets the near frustum plane transformed by the transform matrix
  95118. * @param transform transformation matrix to be applied to the resulting frustum plane
  95119. * @param frustumPlane the resuling frustum plane
  95120. */
  95121. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95122. /**
  95123. * Gets the far frustum plane transformed by the transform matrix
  95124. * @param transform transformation matrix to be applied to the resulting frustum plane
  95125. * @param frustumPlane the resuling frustum plane
  95126. */
  95127. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95128. /**
  95129. * Gets the left frustum plane transformed by the transform matrix
  95130. * @param transform transformation matrix to be applied to the resulting frustum plane
  95131. * @param frustumPlane the resuling frustum plane
  95132. */
  95133. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95134. /**
  95135. * Gets the right frustum plane transformed by the transform matrix
  95136. * @param transform transformation matrix to be applied to the resulting frustum plane
  95137. * @param frustumPlane the resuling frustum plane
  95138. */
  95139. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95140. /**
  95141. * Gets the top frustum plane transformed by the transform matrix
  95142. * @param transform transformation matrix to be applied to the resulting frustum plane
  95143. * @param frustumPlane the resuling frustum plane
  95144. */
  95145. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95146. /**
  95147. * Gets the bottom frustum plane transformed by the transform matrix
  95148. * @param transform transformation matrix to be applied to the resulting frustum plane
  95149. * @param frustumPlane the resuling frustum plane
  95150. */
  95151. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95152. /**
  95153. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95154. * @param transform transformation matrix to be applied to the resulting frustum planes
  95155. * @param frustumPlanes the resuling frustum planes
  95156. */
  95157. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95158. }
  95159. }
  95160. declare module BABYLON {
  95161. interface Engine {
  95162. /**
  95163. * Creates a new multiview render target
  95164. * @param width defines the width of the texture
  95165. * @param height defines the height of the texture
  95166. * @returns the created multiview texture
  95167. */
  95168. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95169. /**
  95170. * Binds a multiview framebuffer to be drawn to
  95171. * @param multiviewTexture texture to bind
  95172. */
  95173. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95174. }
  95175. interface Camera {
  95176. /**
  95177. * @hidden
  95178. * 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)
  95179. */
  95180. _useMultiviewToSingleView: boolean;
  95181. /**
  95182. * @hidden
  95183. * 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)
  95184. */
  95185. _multiviewTexture: Nullable<RenderTargetTexture>;
  95186. /**
  95187. * @hidden
  95188. * ensures the multiview texture of the camera exists and has the specified width/height
  95189. * @param width height to set on the multiview texture
  95190. * @param height width to set on the multiview texture
  95191. */
  95192. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95193. }
  95194. interface Scene {
  95195. /** @hidden */
  95196. _transformMatrixR: Matrix;
  95197. /** @hidden */
  95198. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95199. /** @hidden */
  95200. _createMultiviewUbo(): void;
  95201. /** @hidden */
  95202. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95203. /** @hidden */
  95204. _renderMultiviewToSingleView(camera: Camera): void;
  95205. }
  95206. }
  95207. declare module BABYLON {
  95208. /**
  95209. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95210. * This will not be used for webXR as it supports displaying texture arrays directly
  95211. */
  95212. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95213. /**
  95214. * Initializes a VRMultiviewToSingleview
  95215. * @param name name of the post process
  95216. * @param camera camera to be applied to
  95217. * @param scaleFactor scaling factor to the size of the output texture
  95218. */
  95219. constructor(name: string, camera: Camera, scaleFactor: number);
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /**
  95224. * Interface used to define additional presentation attributes
  95225. */
  95226. export interface IVRPresentationAttributes {
  95227. /**
  95228. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95229. */
  95230. highRefreshRate: boolean;
  95231. /**
  95232. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95233. */
  95234. foveationLevel: number;
  95235. }
  95236. interface Engine {
  95237. /** @hidden */
  95238. _vrDisplay: any;
  95239. /** @hidden */
  95240. _vrSupported: boolean;
  95241. /** @hidden */
  95242. _oldSize: Size;
  95243. /** @hidden */
  95244. _oldHardwareScaleFactor: number;
  95245. /** @hidden */
  95246. _vrExclusivePointerMode: boolean;
  95247. /** @hidden */
  95248. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95249. /** @hidden */
  95250. _onVRDisplayPointerRestricted: () => void;
  95251. /** @hidden */
  95252. _onVRDisplayPointerUnrestricted: () => void;
  95253. /** @hidden */
  95254. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95255. /** @hidden */
  95256. _onVrDisplayDisconnect: Nullable<() => void>;
  95257. /** @hidden */
  95258. _onVrDisplayPresentChange: Nullable<() => void>;
  95259. /**
  95260. * Observable signaled when VR display mode changes
  95261. */
  95262. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95263. /**
  95264. * Observable signaled when VR request present is complete
  95265. */
  95266. onVRRequestPresentComplete: Observable<boolean>;
  95267. /**
  95268. * Observable signaled when VR request present starts
  95269. */
  95270. onVRRequestPresentStart: Observable<Engine>;
  95271. /**
  95272. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95273. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95274. */
  95275. isInVRExclusivePointerMode: boolean;
  95276. /**
  95277. * Gets a boolean indicating if a webVR device was detected
  95278. * @returns true if a webVR device was detected
  95279. */
  95280. isVRDevicePresent(): boolean;
  95281. /**
  95282. * Gets the current webVR device
  95283. * @returns the current webVR device (or null)
  95284. */
  95285. getVRDevice(): any;
  95286. /**
  95287. * Initializes a webVR display and starts listening to display change events
  95288. * The onVRDisplayChangedObservable will be notified upon these changes
  95289. * @returns A promise containing a VRDisplay and if vr is supported
  95290. */
  95291. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95292. /** @hidden */
  95293. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95294. /**
  95295. * Gets or sets the presentation attributes used to configure VR rendering
  95296. */
  95297. vrPresentationAttributes?: IVRPresentationAttributes;
  95298. /**
  95299. * Call this function to switch to webVR mode
  95300. * Will do nothing if webVR is not supported or if there is no webVR device
  95301. * @param options the webvr options provided to the camera. mainly used for multiview
  95302. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95303. */
  95304. enableVR(options: WebVROptions): void;
  95305. /** @hidden */
  95306. _onVRFullScreenTriggered(): void;
  95307. }
  95308. }
  95309. declare module BABYLON {
  95310. /**
  95311. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95312. * IMPORTANT!! The data is right-hand data.
  95313. * @export
  95314. * @interface DevicePose
  95315. */
  95316. export interface DevicePose {
  95317. /**
  95318. * The position of the device, values in array are [x,y,z].
  95319. */
  95320. readonly position: Nullable<Float32Array>;
  95321. /**
  95322. * The linearVelocity of the device, values in array are [x,y,z].
  95323. */
  95324. readonly linearVelocity: Nullable<Float32Array>;
  95325. /**
  95326. * The linearAcceleration of the device, values in array are [x,y,z].
  95327. */
  95328. readonly linearAcceleration: Nullable<Float32Array>;
  95329. /**
  95330. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95331. */
  95332. readonly orientation: Nullable<Float32Array>;
  95333. /**
  95334. * The angularVelocity of the device, values in array are [x,y,z].
  95335. */
  95336. readonly angularVelocity: Nullable<Float32Array>;
  95337. /**
  95338. * The angularAcceleration of the device, values in array are [x,y,z].
  95339. */
  95340. readonly angularAcceleration: Nullable<Float32Array>;
  95341. }
  95342. /**
  95343. * Interface representing a pose controlled object in Babylon.
  95344. * A pose controlled object has both regular pose values as well as pose values
  95345. * from an external device such as a VR head mounted display
  95346. */
  95347. export interface PoseControlled {
  95348. /**
  95349. * The position of the object in babylon space.
  95350. */
  95351. position: Vector3;
  95352. /**
  95353. * The rotation quaternion of the object in babylon space.
  95354. */
  95355. rotationQuaternion: Quaternion;
  95356. /**
  95357. * The position of the device in babylon space.
  95358. */
  95359. devicePosition?: Vector3;
  95360. /**
  95361. * The rotation quaternion of the device in babylon space.
  95362. */
  95363. deviceRotationQuaternion: Quaternion;
  95364. /**
  95365. * The raw pose coming from the device.
  95366. */
  95367. rawPose: Nullable<DevicePose>;
  95368. /**
  95369. * The scale of the device to be used when translating from device space to babylon space.
  95370. */
  95371. deviceScaleFactor: number;
  95372. /**
  95373. * Updates the poseControlled values based on the input device pose.
  95374. * @param poseData the pose data to update the object with
  95375. */
  95376. updateFromDevice(poseData: DevicePose): void;
  95377. }
  95378. /**
  95379. * Set of options to customize the webVRCamera
  95380. */
  95381. export interface WebVROptions {
  95382. /**
  95383. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95384. */
  95385. trackPosition?: boolean;
  95386. /**
  95387. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95388. */
  95389. positionScale?: number;
  95390. /**
  95391. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95392. */
  95393. displayName?: string;
  95394. /**
  95395. * Should the native controller meshes be initialized. (default: true)
  95396. */
  95397. controllerMeshes?: boolean;
  95398. /**
  95399. * Creating a default HemiLight only on controllers. (default: true)
  95400. */
  95401. defaultLightingOnControllers?: boolean;
  95402. /**
  95403. * If you don't want to use the default VR button of the helper. (default: false)
  95404. */
  95405. useCustomVRButton?: boolean;
  95406. /**
  95407. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95408. */
  95409. customVRButton?: HTMLButtonElement;
  95410. /**
  95411. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95412. */
  95413. rayLength?: number;
  95414. /**
  95415. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95416. */
  95417. defaultHeight?: number;
  95418. /**
  95419. * If multiview should be used if availible (default: false)
  95420. */
  95421. useMultiview?: boolean;
  95422. }
  95423. /**
  95424. * This represents a WebVR camera.
  95425. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95426. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95427. */
  95428. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95429. private webVROptions;
  95430. /**
  95431. * @hidden
  95432. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95433. */
  95434. _vrDevice: any;
  95435. /**
  95436. * The rawPose of the vrDevice.
  95437. */
  95438. rawPose: Nullable<DevicePose>;
  95439. private _onVREnabled;
  95440. private _specsVersion;
  95441. private _attached;
  95442. private _frameData;
  95443. protected _descendants: Array<Node>;
  95444. private _deviceRoomPosition;
  95445. /** @hidden */
  95446. _deviceRoomRotationQuaternion: Quaternion;
  95447. private _standingMatrix;
  95448. /**
  95449. * Represents device position in babylon space.
  95450. */
  95451. devicePosition: Vector3;
  95452. /**
  95453. * Represents device rotation in babylon space.
  95454. */
  95455. deviceRotationQuaternion: Quaternion;
  95456. /**
  95457. * The scale of the device to be used when translating from device space to babylon space.
  95458. */
  95459. deviceScaleFactor: number;
  95460. private _deviceToWorld;
  95461. private _worldToDevice;
  95462. /**
  95463. * References to the webVR controllers for the vrDevice.
  95464. */
  95465. controllers: Array<WebVRController>;
  95466. /**
  95467. * Emits an event when a controller is attached.
  95468. */
  95469. onControllersAttachedObservable: Observable<WebVRController[]>;
  95470. /**
  95471. * Emits an event when a controller's mesh has been loaded;
  95472. */
  95473. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95474. /**
  95475. * Emits an event when the HMD's pose has been updated.
  95476. */
  95477. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95478. private _poseSet;
  95479. /**
  95480. * If the rig cameras be used as parent instead of this camera.
  95481. */
  95482. rigParenting: boolean;
  95483. private _lightOnControllers;
  95484. private _defaultHeight?;
  95485. /**
  95486. * Instantiates a WebVRFreeCamera.
  95487. * @param name The name of the WebVRFreeCamera
  95488. * @param position The starting anchor position for the camera
  95489. * @param scene The scene the camera belongs to
  95490. * @param webVROptions a set of customizable options for the webVRCamera
  95491. */
  95492. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95493. /**
  95494. * Gets the device distance from the ground in meters.
  95495. * @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.
  95496. */
  95497. deviceDistanceToRoomGround(): number;
  95498. /**
  95499. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95500. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95501. */
  95502. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95503. /**
  95504. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95505. * @returns A promise with a boolean set to if the standing matrix is supported.
  95506. */
  95507. useStandingMatrixAsync(): Promise<boolean>;
  95508. /**
  95509. * Disposes the camera
  95510. */
  95511. dispose(): void;
  95512. /**
  95513. * Gets a vrController by name.
  95514. * @param name The name of the controller to retreive
  95515. * @returns the controller matching the name specified or null if not found
  95516. */
  95517. getControllerByName(name: string): Nullable<WebVRController>;
  95518. private _leftController;
  95519. /**
  95520. * The controller corresponding to the users left hand.
  95521. */
  95522. get leftController(): Nullable<WebVRController>;
  95523. private _rightController;
  95524. /**
  95525. * The controller corresponding to the users right hand.
  95526. */
  95527. get rightController(): Nullable<WebVRController>;
  95528. /**
  95529. * Casts a ray forward from the vrCamera's gaze.
  95530. * @param length Length of the ray (default: 100)
  95531. * @returns the ray corresponding to the gaze
  95532. */
  95533. getForwardRay(length?: number): Ray;
  95534. /**
  95535. * @hidden
  95536. * Updates the camera based on device's frame data
  95537. */
  95538. _checkInputs(): void;
  95539. /**
  95540. * Updates the poseControlled values based on the input device pose.
  95541. * @param poseData Pose coming from the device
  95542. */
  95543. updateFromDevice(poseData: DevicePose): void;
  95544. private _htmlElementAttached;
  95545. private _detachIfAttached;
  95546. /**
  95547. * WebVR's attach control will start broadcasting frames to the device.
  95548. * Note that in certain browsers (chrome for example) this function must be called
  95549. * within a user-interaction callback. Example:
  95550. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95551. *
  95552. * @param element html element to attach the vrDevice to
  95553. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95554. */
  95555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95556. /**
  95557. * Detaches the camera from the html element and disables VR
  95558. *
  95559. * @param element html element to detach from
  95560. */
  95561. detachControl(element: HTMLElement): void;
  95562. /**
  95563. * @returns the name of this class
  95564. */
  95565. getClassName(): string;
  95566. /**
  95567. * Calls resetPose on the vrDisplay
  95568. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95569. */
  95570. resetToCurrentRotation(): void;
  95571. /**
  95572. * @hidden
  95573. * Updates the rig cameras (left and right eye)
  95574. */
  95575. _updateRigCameras(): void;
  95576. private _workingVector;
  95577. private _oneVector;
  95578. private _workingMatrix;
  95579. private updateCacheCalled;
  95580. private _correctPositionIfNotTrackPosition;
  95581. /**
  95582. * @hidden
  95583. * Updates the cached values of the camera
  95584. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95585. */
  95586. _updateCache(ignoreParentClass?: boolean): void;
  95587. /**
  95588. * @hidden
  95589. * Get current device position in babylon world
  95590. */
  95591. _computeDevicePosition(): void;
  95592. /**
  95593. * Updates the current device position and rotation in the babylon world
  95594. */
  95595. update(): void;
  95596. /**
  95597. * @hidden
  95598. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95599. * @returns an identity matrix
  95600. */
  95601. _getViewMatrix(): Matrix;
  95602. private _tmpMatrix;
  95603. /**
  95604. * This function is called by the two RIG cameras.
  95605. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95606. * @hidden
  95607. */
  95608. _getWebVRViewMatrix(): Matrix;
  95609. /** @hidden */
  95610. _getWebVRProjectionMatrix(): Matrix;
  95611. private _onGamepadConnectedObserver;
  95612. private _onGamepadDisconnectedObserver;
  95613. private _updateCacheWhenTrackingDisabledObserver;
  95614. /**
  95615. * Initializes the controllers and their meshes
  95616. */
  95617. initControllers(): void;
  95618. }
  95619. }
  95620. declare module BABYLON {
  95621. /**
  95622. * Size options for a post process
  95623. */
  95624. export type PostProcessOptions = {
  95625. width: number;
  95626. height: number;
  95627. };
  95628. /**
  95629. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95630. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95631. */
  95632. export class PostProcess {
  95633. /** Name of the PostProcess. */
  95634. name: string;
  95635. /**
  95636. * Gets or sets the unique id of the post process
  95637. */
  95638. uniqueId: number;
  95639. /**
  95640. * Width of the texture to apply the post process on
  95641. */
  95642. width: number;
  95643. /**
  95644. * Height of the texture to apply the post process on
  95645. */
  95646. height: number;
  95647. /**
  95648. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95649. * @hidden
  95650. */
  95651. _outputTexture: Nullable<InternalTexture>;
  95652. /**
  95653. * Sampling mode used by the shader
  95654. * See https://doc.babylonjs.com/classes/3.1/texture
  95655. */
  95656. renderTargetSamplingMode: number;
  95657. /**
  95658. * Clear color to use when screen clearing
  95659. */
  95660. clearColor: Color4;
  95661. /**
  95662. * If the buffer needs to be cleared before applying the post process. (default: true)
  95663. * Should be set to false if shader will overwrite all previous pixels.
  95664. */
  95665. autoClear: boolean;
  95666. /**
  95667. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95668. */
  95669. alphaMode: number;
  95670. /**
  95671. * Sets the setAlphaBlendConstants of the babylon engine
  95672. */
  95673. alphaConstants: Color4;
  95674. /**
  95675. * Animations to be used for the post processing
  95676. */
  95677. animations: Animation[];
  95678. /**
  95679. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95680. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95681. */
  95682. enablePixelPerfectMode: boolean;
  95683. /**
  95684. * Force the postprocess to be applied without taking in account viewport
  95685. */
  95686. forceFullscreenViewport: boolean;
  95687. /**
  95688. * List of inspectable custom properties (used by the Inspector)
  95689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95690. */
  95691. inspectableCustomProperties: IInspectable[];
  95692. /**
  95693. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95694. *
  95695. * | Value | Type | Description |
  95696. * | ----- | ----------------------------------- | ----------- |
  95697. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95698. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95699. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95700. *
  95701. */
  95702. scaleMode: number;
  95703. /**
  95704. * Force textures to be a power of two (default: false)
  95705. */
  95706. alwaysForcePOT: boolean;
  95707. private _samples;
  95708. /**
  95709. * Number of sample textures (default: 1)
  95710. */
  95711. get samples(): number;
  95712. set samples(n: number);
  95713. /**
  95714. * Modify the scale of the post process to be the same as the viewport (default: false)
  95715. */
  95716. adaptScaleToCurrentViewport: boolean;
  95717. private _camera;
  95718. private _scene;
  95719. private _engine;
  95720. private _options;
  95721. private _reusable;
  95722. private _textureType;
  95723. private _textureFormat;
  95724. /**
  95725. * Smart array of input and output textures for the post process.
  95726. * @hidden
  95727. */
  95728. _textures: SmartArray<InternalTexture>;
  95729. /**
  95730. * The index in _textures that corresponds to the output texture.
  95731. * @hidden
  95732. */
  95733. _currentRenderTextureInd: number;
  95734. private _effect;
  95735. private _samplers;
  95736. private _fragmentUrl;
  95737. private _vertexUrl;
  95738. private _parameters;
  95739. private _scaleRatio;
  95740. protected _indexParameters: any;
  95741. private _shareOutputWithPostProcess;
  95742. private _texelSize;
  95743. private _forcedOutputTexture;
  95744. /**
  95745. * Returns the fragment url or shader name used in the post process.
  95746. * @returns the fragment url or name in the shader store.
  95747. */
  95748. getEffectName(): string;
  95749. /**
  95750. * An event triggered when the postprocess is activated.
  95751. */
  95752. onActivateObservable: Observable<Camera>;
  95753. private _onActivateObserver;
  95754. /**
  95755. * A function that is added to the onActivateObservable
  95756. */
  95757. set onActivate(callback: Nullable<(camera: Camera) => void>);
  95758. /**
  95759. * An event triggered when the postprocess changes its size.
  95760. */
  95761. onSizeChangedObservable: Observable<PostProcess>;
  95762. private _onSizeChangedObserver;
  95763. /**
  95764. * A function that is added to the onSizeChangedObservable
  95765. */
  95766. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  95767. /**
  95768. * An event triggered when the postprocess applies its effect.
  95769. */
  95770. onApplyObservable: Observable<Effect>;
  95771. private _onApplyObserver;
  95772. /**
  95773. * A function that is added to the onApplyObservable
  95774. */
  95775. set onApply(callback: (effect: Effect) => void);
  95776. /**
  95777. * An event triggered before rendering the postprocess
  95778. */
  95779. onBeforeRenderObservable: Observable<Effect>;
  95780. private _onBeforeRenderObserver;
  95781. /**
  95782. * A function that is added to the onBeforeRenderObservable
  95783. */
  95784. set onBeforeRender(callback: (effect: Effect) => void);
  95785. /**
  95786. * An event triggered after rendering the postprocess
  95787. */
  95788. onAfterRenderObservable: Observable<Effect>;
  95789. private _onAfterRenderObserver;
  95790. /**
  95791. * A function that is added to the onAfterRenderObservable
  95792. */
  95793. set onAfterRender(callback: (efect: Effect) => void);
  95794. /**
  95795. * 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
  95796. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  95797. */
  95798. get inputTexture(): InternalTexture;
  95799. set inputTexture(value: InternalTexture);
  95800. /**
  95801. * Gets the camera which post process is applied to.
  95802. * @returns The camera the post process is applied to.
  95803. */
  95804. getCamera(): Camera;
  95805. /**
  95806. * Gets the texel size of the postprocess.
  95807. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  95808. */
  95809. get texelSize(): Vector2;
  95810. /**
  95811. * Creates a new instance PostProcess
  95812. * @param name The name of the PostProcess.
  95813. * @param fragmentUrl The url of the fragment shader to be used.
  95814. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  95815. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  95816. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95817. * @param camera The camera to apply the render pass to.
  95818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95819. * @param engine The engine which the post process will be applied. (default: current engine)
  95820. * @param reusable If the post process can be reused on the same frame. (default: false)
  95821. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  95822. * @param textureType Type of textures used when performing the post process. (default: 0)
  95823. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  95824. * @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
  95825. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  95826. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  95827. */
  95828. constructor(
  95829. /** Name of the PostProcess. */
  95830. 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);
  95831. /**
  95832. * Gets a string idenfifying the name of the class
  95833. * @returns "PostProcess" string
  95834. */
  95835. getClassName(): string;
  95836. /**
  95837. * Gets the engine which this post process belongs to.
  95838. * @returns The engine the post process was enabled with.
  95839. */
  95840. getEngine(): Engine;
  95841. /**
  95842. * The effect that is created when initializing the post process.
  95843. * @returns The created effect corresponding the the postprocess.
  95844. */
  95845. getEffect(): Effect;
  95846. /**
  95847. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  95848. * @param postProcess The post process to share the output with.
  95849. * @returns This post process.
  95850. */
  95851. shareOutputWith(postProcess: PostProcess): PostProcess;
  95852. /**
  95853. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  95854. * This should be called if the post process that shares output with this post process is disabled/disposed.
  95855. */
  95856. useOwnOutput(): void;
  95857. /**
  95858. * Updates the effect with the current post process compile time values and recompiles the shader.
  95859. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95860. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  95861. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  95862. * @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
  95863. * @param onCompiled Called when the shader has been compiled.
  95864. * @param onError Called if there is an error when compiling a shader.
  95865. */
  95866. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95867. /**
  95868. * The post process is reusable if it can be used multiple times within one frame.
  95869. * @returns If the post process is reusable
  95870. */
  95871. isReusable(): boolean;
  95872. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  95873. markTextureDirty(): void;
  95874. /**
  95875. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  95876. * 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.
  95877. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  95878. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  95879. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  95880. * @returns The target texture that was bound to be written to.
  95881. */
  95882. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  95883. /**
  95884. * If the post process is supported.
  95885. */
  95886. get isSupported(): boolean;
  95887. /**
  95888. * The aspect ratio of the output texture.
  95889. */
  95890. get aspectRatio(): number;
  95891. /**
  95892. * Get a value indicating if the post-process is ready to be used
  95893. * @returns true if the post-process is ready (shader is compiled)
  95894. */
  95895. isReady(): boolean;
  95896. /**
  95897. * Binds all textures and uniforms to the shader, this will be run on every pass.
  95898. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  95899. */
  95900. apply(): Nullable<Effect>;
  95901. private _disposeTextures;
  95902. /**
  95903. * Disposes the post process.
  95904. * @param camera The camera to dispose the post process on.
  95905. */
  95906. dispose(camera?: Camera): void;
  95907. }
  95908. }
  95909. declare module BABYLON {
  95910. /** @hidden */
  95911. export var kernelBlurVaryingDeclaration: {
  95912. name: string;
  95913. shader: string;
  95914. };
  95915. }
  95916. declare module BABYLON {
  95917. /** @hidden */
  95918. export var kernelBlurFragment: {
  95919. name: string;
  95920. shader: string;
  95921. };
  95922. }
  95923. declare module BABYLON {
  95924. /** @hidden */
  95925. export var kernelBlurFragment2: {
  95926. name: string;
  95927. shader: string;
  95928. };
  95929. }
  95930. declare module BABYLON {
  95931. /** @hidden */
  95932. export var kernelBlurPixelShader: {
  95933. name: string;
  95934. shader: string;
  95935. };
  95936. }
  95937. declare module BABYLON {
  95938. /** @hidden */
  95939. export var kernelBlurVertex: {
  95940. name: string;
  95941. shader: string;
  95942. };
  95943. }
  95944. declare module BABYLON {
  95945. /** @hidden */
  95946. export var kernelBlurVertexShader: {
  95947. name: string;
  95948. shader: string;
  95949. };
  95950. }
  95951. declare module BABYLON {
  95952. /**
  95953. * The Blur Post Process which blurs an image based on a kernel and direction.
  95954. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  95955. */
  95956. export class BlurPostProcess extends PostProcess {
  95957. /** The direction in which to blur the image. */
  95958. direction: Vector2;
  95959. private blockCompilation;
  95960. protected _kernel: number;
  95961. protected _idealKernel: number;
  95962. protected _packedFloat: boolean;
  95963. private _staticDefines;
  95964. /**
  95965. * Sets the length in pixels of the blur sample region
  95966. */
  95967. set kernel(v: number);
  95968. /**
  95969. * Gets the length in pixels of the blur sample region
  95970. */
  95971. get kernel(): number;
  95972. /**
  95973. * Sets wether or not the blur needs to unpack/repack floats
  95974. */
  95975. set packedFloat(v: boolean);
  95976. /**
  95977. * Gets wether or not the blur is unpacking/repacking floats
  95978. */
  95979. get packedFloat(): boolean;
  95980. /**
  95981. * Creates a new instance BlurPostProcess
  95982. * @param name The name of the effect.
  95983. * @param direction The direction in which to blur the image.
  95984. * @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.
  95985. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95986. * @param camera The camera to apply the render pass to.
  95987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95988. * @param engine The engine which the post process will be applied. (default: current engine)
  95989. * @param reusable If the post process can be reused on the same frame. (default: false)
  95990. * @param textureType Type of textures used when performing the post process. (default: 0)
  95991. * @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)
  95992. */
  95993. constructor(name: string,
  95994. /** The direction in which to blur the image. */
  95995. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  95996. /**
  95997. * Updates the effect with the current post process compile time values and recompiles the shader.
  95998. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95999. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  96000. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  96001. * @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
  96002. * @param onCompiled Called when the shader has been compiled.
  96003. * @param onError Called if there is an error when compiling a shader.
  96004. */
  96005. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96006. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  96007. /**
  96008. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96009. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96010. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96011. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96012. * The gaps between physical kernels are compensated for in the weighting of the samples
  96013. * @param idealKernel Ideal blur kernel.
  96014. * @return Nearest best kernel.
  96015. */
  96016. protected _nearestBestKernel(idealKernel: number): number;
  96017. /**
  96018. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96019. * @param x The point on the Gaussian distribution to sample.
  96020. * @return the value of the Gaussian function at x.
  96021. */
  96022. protected _gaussianWeight(x: number): number;
  96023. /**
  96024. * Generates a string that can be used as a floating point number in GLSL.
  96025. * @param x Value to print.
  96026. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96027. * @return GLSL float string.
  96028. */
  96029. protected _glslFloat(x: number, decimalFigures?: number): string;
  96030. }
  96031. }
  96032. declare module BABYLON {
  96033. /**
  96034. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96035. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96036. * You can then easily use it as a reflectionTexture on a flat surface.
  96037. * In case the surface is not a plane, please consider relying on reflection probes.
  96038. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96039. */
  96040. export class MirrorTexture extends RenderTargetTexture {
  96041. private scene;
  96042. /**
  96043. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96044. * 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.
  96045. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96046. */
  96047. mirrorPlane: Plane;
  96048. /**
  96049. * Define the blur ratio used to blur the reflection if needed.
  96050. */
  96051. set blurRatio(value: number);
  96052. get blurRatio(): number;
  96053. /**
  96054. * Define the adaptive blur kernel used to blur the reflection if needed.
  96055. * This will autocompute the closest best match for the `blurKernel`
  96056. */
  96057. set adaptiveBlurKernel(value: number);
  96058. /**
  96059. * Define the blur kernel used to blur the reflection if needed.
  96060. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96061. */
  96062. set blurKernel(value: number);
  96063. /**
  96064. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96065. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96066. */
  96067. set blurKernelX(value: number);
  96068. get blurKernelX(): number;
  96069. /**
  96070. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96071. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96072. */
  96073. set blurKernelY(value: number);
  96074. get blurKernelY(): number;
  96075. private _autoComputeBlurKernel;
  96076. protected _onRatioRescale(): void;
  96077. private _updateGammaSpace;
  96078. private _imageProcessingConfigChangeObserver;
  96079. private _transformMatrix;
  96080. private _mirrorMatrix;
  96081. private _savedViewMatrix;
  96082. private _blurX;
  96083. private _blurY;
  96084. private _adaptiveBlurKernel;
  96085. private _blurKernelX;
  96086. private _blurKernelY;
  96087. private _blurRatio;
  96088. /**
  96089. * Instantiates a Mirror Texture.
  96090. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96091. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96092. * You can then easily use it as a reflectionTexture on a flat surface.
  96093. * In case the surface is not a plane, please consider relying on reflection probes.
  96094. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96095. * @param name
  96096. * @param size
  96097. * @param scene
  96098. * @param generateMipMaps
  96099. * @param type
  96100. * @param samplingMode
  96101. * @param generateDepthBuffer
  96102. */
  96103. constructor(name: string, size: number | {
  96104. width: number;
  96105. height: number;
  96106. } | {
  96107. ratio: number;
  96108. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96109. private _preparePostProcesses;
  96110. /**
  96111. * Clone the mirror texture.
  96112. * @returns the cloned texture
  96113. */
  96114. clone(): MirrorTexture;
  96115. /**
  96116. * Serialize the texture to a JSON representation you could use in Parse later on
  96117. * @returns the serialized JSON representation
  96118. */
  96119. serialize(): any;
  96120. /**
  96121. * Dispose the texture and release its associated resources.
  96122. */
  96123. dispose(): void;
  96124. }
  96125. }
  96126. declare module BABYLON {
  96127. /**
  96128. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96129. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96130. */
  96131. export class Texture extends BaseTexture {
  96132. /**
  96133. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96134. */
  96135. static SerializeBuffers: boolean;
  96136. /** @hidden */
  96137. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96138. /** @hidden */
  96139. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96140. /** @hidden */
  96141. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96142. /** nearest is mag = nearest and min = nearest and mip = linear */
  96143. static readonly NEAREST_SAMPLINGMODE: number;
  96144. /** nearest is mag = nearest and min = nearest and mip = linear */
  96145. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96147. static readonly BILINEAR_SAMPLINGMODE: number;
  96148. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96149. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96150. /** Trilinear is mag = linear and min = linear and mip = linear */
  96151. static readonly TRILINEAR_SAMPLINGMODE: number;
  96152. /** Trilinear is mag = linear and min = linear and mip = linear */
  96153. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96154. /** mag = nearest and min = nearest and mip = nearest */
  96155. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96156. /** mag = nearest and min = linear and mip = nearest */
  96157. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96158. /** mag = nearest and min = linear and mip = linear */
  96159. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96160. /** mag = nearest and min = linear and mip = none */
  96161. static readonly NEAREST_LINEAR: number;
  96162. /** mag = nearest and min = nearest and mip = none */
  96163. static readonly NEAREST_NEAREST: number;
  96164. /** mag = linear and min = nearest and mip = nearest */
  96165. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96166. /** mag = linear and min = nearest and mip = linear */
  96167. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96168. /** mag = linear and min = linear and mip = none */
  96169. static readonly LINEAR_LINEAR: number;
  96170. /** mag = linear and min = nearest and mip = none */
  96171. static readonly LINEAR_NEAREST: number;
  96172. /** Explicit coordinates mode */
  96173. static readonly EXPLICIT_MODE: number;
  96174. /** Spherical coordinates mode */
  96175. static readonly SPHERICAL_MODE: number;
  96176. /** Planar coordinates mode */
  96177. static readonly PLANAR_MODE: number;
  96178. /** Cubic coordinates mode */
  96179. static readonly CUBIC_MODE: number;
  96180. /** Projection coordinates mode */
  96181. static readonly PROJECTION_MODE: number;
  96182. /** Inverse Cubic coordinates mode */
  96183. static readonly SKYBOX_MODE: number;
  96184. /** Inverse Cubic coordinates mode */
  96185. static readonly INVCUBIC_MODE: number;
  96186. /** Equirectangular coordinates mode */
  96187. static readonly EQUIRECTANGULAR_MODE: number;
  96188. /** Equirectangular Fixed coordinates mode */
  96189. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96190. /** Equirectangular Fixed Mirrored coordinates mode */
  96191. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96192. /** Texture is not repeating outside of 0..1 UVs */
  96193. static readonly CLAMP_ADDRESSMODE: number;
  96194. /** Texture is repeating outside of 0..1 UVs */
  96195. static readonly WRAP_ADDRESSMODE: number;
  96196. /** Texture is repeating and mirrored */
  96197. static readonly MIRROR_ADDRESSMODE: number;
  96198. /**
  96199. * 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
  96200. */
  96201. static UseSerializedUrlIfAny: boolean;
  96202. /**
  96203. * Define the url of the texture.
  96204. */
  96205. url: Nullable<string>;
  96206. /**
  96207. * Define an offset on the texture to offset the u coordinates of the UVs
  96208. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96209. */
  96210. uOffset: number;
  96211. /**
  96212. * Define an offset on the texture to offset the v coordinates of the UVs
  96213. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96214. */
  96215. vOffset: number;
  96216. /**
  96217. * Define an offset on the texture to scale the u coordinates of the UVs
  96218. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96219. */
  96220. uScale: number;
  96221. /**
  96222. * Define an offset on the texture to scale the v coordinates of the UVs
  96223. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96224. */
  96225. vScale: number;
  96226. /**
  96227. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96228. * @see http://doc.babylonjs.com/how_to/more_materials
  96229. */
  96230. uAng: number;
  96231. /**
  96232. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96233. * @see http://doc.babylonjs.com/how_to/more_materials
  96234. */
  96235. vAng: number;
  96236. /**
  96237. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96238. * @see http://doc.babylonjs.com/how_to/more_materials
  96239. */
  96240. wAng: number;
  96241. /**
  96242. * Defines the center of rotation (U)
  96243. */
  96244. uRotationCenter: number;
  96245. /**
  96246. * Defines the center of rotation (V)
  96247. */
  96248. vRotationCenter: number;
  96249. /**
  96250. * Defines the center of rotation (W)
  96251. */
  96252. wRotationCenter: number;
  96253. /**
  96254. * Are mip maps generated for this texture or not.
  96255. */
  96256. get noMipmap(): boolean;
  96257. /**
  96258. * List of inspectable custom properties (used by the Inspector)
  96259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96260. */
  96261. inspectableCustomProperties: Nullable<IInspectable[]>;
  96262. private _noMipmap;
  96263. /** @hidden */
  96264. _invertY: boolean;
  96265. private _rowGenerationMatrix;
  96266. private _cachedTextureMatrix;
  96267. private _projectionModeMatrix;
  96268. private _t0;
  96269. private _t1;
  96270. private _t2;
  96271. private _cachedUOffset;
  96272. private _cachedVOffset;
  96273. private _cachedUScale;
  96274. private _cachedVScale;
  96275. private _cachedUAng;
  96276. private _cachedVAng;
  96277. private _cachedWAng;
  96278. private _cachedProjectionMatrixId;
  96279. private _cachedCoordinatesMode;
  96280. /** @hidden */
  96281. protected _initialSamplingMode: number;
  96282. /** @hidden */
  96283. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96284. private _deleteBuffer;
  96285. protected _format: Nullable<number>;
  96286. private _delayedOnLoad;
  96287. private _delayedOnError;
  96288. private _mimeType?;
  96289. /**
  96290. * Observable triggered once the texture has been loaded.
  96291. */
  96292. onLoadObservable: Observable<Texture>;
  96293. protected _isBlocking: boolean;
  96294. /**
  96295. * Is the texture preventing material to render while loading.
  96296. * If false, a default texture will be used instead of the loading one during the preparation step.
  96297. */
  96298. set isBlocking(value: boolean);
  96299. get isBlocking(): boolean;
  96300. /**
  96301. * Get the current sampling mode associated with the texture.
  96302. */
  96303. get samplingMode(): number;
  96304. /**
  96305. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96306. */
  96307. get invertY(): boolean;
  96308. /**
  96309. * Instantiates a new texture.
  96310. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96311. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96312. * @param url defines the url of the picture to load as a texture
  96313. * @param scene defines the scene or engine the texture will belong to
  96314. * @param noMipmap defines if the texture will require mip maps or not
  96315. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96316. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96317. * @param onLoad defines a callback triggered when the texture has been loaded
  96318. * @param onError defines a callback triggered when an error occurred during the loading session
  96319. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96320. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96321. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96322. * @param mimeType defines an optional mime type information
  96323. */
  96324. 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);
  96325. /**
  96326. * Update the url (and optional buffer) of this texture if url was null during construction.
  96327. * @param url the url of the texture
  96328. * @param buffer the buffer of the texture (defaults to null)
  96329. * @param onLoad callback called when the texture is loaded (defaults to null)
  96330. */
  96331. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96332. /**
  96333. * Finish the loading sequence of a texture flagged as delayed load.
  96334. * @hidden
  96335. */
  96336. delayLoad(): void;
  96337. private _prepareRowForTextureGeneration;
  96338. /**
  96339. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96340. * @returns the transform matrix of the texture.
  96341. */
  96342. getTextureMatrix(uBase?: number): Matrix;
  96343. /**
  96344. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96345. * @returns The reflection texture transform
  96346. */
  96347. getReflectionTextureMatrix(): Matrix;
  96348. /**
  96349. * Clones the texture.
  96350. * @returns the cloned texture
  96351. */
  96352. clone(): Texture;
  96353. /**
  96354. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96355. * @returns The JSON representation of the texture
  96356. */
  96357. serialize(): any;
  96358. /**
  96359. * Get the current class name of the texture useful for serialization or dynamic coding.
  96360. * @returns "Texture"
  96361. */
  96362. getClassName(): string;
  96363. /**
  96364. * Dispose the texture and release its associated resources.
  96365. */
  96366. dispose(): void;
  96367. /**
  96368. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96369. * @param parsedTexture Define the JSON representation of the texture
  96370. * @param scene Define the scene the parsed texture should be instantiated in
  96371. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96372. * @returns The parsed texture if successful
  96373. */
  96374. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96375. /**
  96376. * Creates a texture from its base 64 representation.
  96377. * @param data Define the base64 payload without the data: prefix
  96378. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96379. * @param scene Define the scene the texture should belong to
  96380. * @param noMipmap Forces the texture to not create mip map information if true
  96381. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96382. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96383. * @param onLoad define a callback triggered when the texture has been loaded
  96384. * @param onError define a callback triggered when an error occurred during the loading session
  96385. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96386. * @returns the created texture
  96387. */
  96388. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96389. /**
  96390. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96391. * @param data Define the base64 payload without the data: prefix
  96392. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96393. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96394. * @param scene Define the scene the texture should belong to
  96395. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96396. * @param noMipmap Forces the texture to not create mip map information if true
  96397. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96398. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96399. * @param onLoad define a callback triggered when the texture has been loaded
  96400. * @param onError define a callback triggered when an error occurred during the loading session
  96401. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96402. * @returns the created texture
  96403. */
  96404. 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;
  96405. }
  96406. }
  96407. declare module BABYLON {
  96408. /**
  96409. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96410. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96411. */
  96412. export class PostProcessManager {
  96413. private _scene;
  96414. private _indexBuffer;
  96415. private _vertexBuffers;
  96416. /**
  96417. * Creates a new instance PostProcess
  96418. * @param scene The scene that the post process is associated with.
  96419. */
  96420. constructor(scene: Scene);
  96421. private _prepareBuffers;
  96422. private _buildIndexBuffer;
  96423. /**
  96424. * Rebuilds the vertex buffers of the manager.
  96425. * @hidden
  96426. */
  96427. _rebuild(): void;
  96428. /**
  96429. * Prepares a frame to be run through a post process.
  96430. * @param sourceTexture The input texture to the post procesess. (default: null)
  96431. * @param postProcesses An array of post processes to be run. (default: null)
  96432. * @returns True if the post processes were able to be run.
  96433. * @hidden
  96434. */
  96435. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96436. /**
  96437. * Manually render a set of post processes to a texture.
  96438. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96439. * @param postProcesses An array of post processes to be run.
  96440. * @param targetTexture The target texture to render to.
  96441. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96442. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96443. * @param lodLevel defines which lod of the texture to render to
  96444. */
  96445. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96446. /**
  96447. * Finalize the result of the output of the postprocesses.
  96448. * @param doNotPresent If true the result will not be displayed to the screen.
  96449. * @param targetTexture The target texture to render to.
  96450. * @param faceIndex The index of the face to bind the target texture to.
  96451. * @param postProcesses The array of post processes to render.
  96452. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96453. * @hidden
  96454. */
  96455. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96456. /**
  96457. * Disposes of the post process manager.
  96458. */
  96459. dispose(): void;
  96460. }
  96461. }
  96462. declare module BABYLON {
  96463. /**
  96464. * This Helps creating a texture that will be created from a camera in your scene.
  96465. * It is basically a dynamic texture that could be used to create special effects for instance.
  96466. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96467. */
  96468. export class RenderTargetTexture extends Texture {
  96469. isCube: boolean;
  96470. /**
  96471. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96472. */
  96473. static readonly REFRESHRATE_RENDER_ONCE: number;
  96474. /**
  96475. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96476. */
  96477. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96478. /**
  96479. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96480. * the central point of your effect and can save a lot of performances.
  96481. */
  96482. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96483. /**
  96484. * Use this predicate to dynamically define the list of mesh you want to render.
  96485. * If set, the renderList property will be overwritten.
  96486. */
  96487. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96488. private _renderList;
  96489. /**
  96490. * Use this list to define the list of mesh you want to render.
  96491. */
  96492. get renderList(): Nullable<Array<AbstractMesh>>;
  96493. set renderList(value: Nullable<Array<AbstractMesh>>);
  96494. /**
  96495. * Use this function to overload the renderList array at rendering time.
  96496. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96497. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96498. * the cube (if the RTT is a cube, else layerOrFace=0).
  96499. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96500. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96501. * hold dummy elements!
  96502. */
  96503. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96504. private _hookArray;
  96505. /**
  96506. * Define if particles should be rendered in your texture.
  96507. */
  96508. renderParticles: boolean;
  96509. /**
  96510. * Define if sprites should be rendered in your texture.
  96511. */
  96512. renderSprites: boolean;
  96513. /**
  96514. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96515. */
  96516. coordinatesMode: number;
  96517. /**
  96518. * Define the camera used to render the texture.
  96519. */
  96520. activeCamera: Nullable<Camera>;
  96521. /**
  96522. * Override the mesh isReady function with your own one.
  96523. */
  96524. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96525. /**
  96526. * Override the render function of the texture with your own one.
  96527. */
  96528. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96529. /**
  96530. * Define if camera post processes should be use while rendering the texture.
  96531. */
  96532. useCameraPostProcesses: boolean;
  96533. /**
  96534. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96535. */
  96536. ignoreCameraViewport: boolean;
  96537. private _postProcessManager;
  96538. private _postProcesses;
  96539. private _resizeObserver;
  96540. /**
  96541. * An event triggered when the texture is unbind.
  96542. */
  96543. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96544. /**
  96545. * An event triggered when the texture is unbind.
  96546. */
  96547. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96548. private _onAfterUnbindObserver;
  96549. /**
  96550. * Set a after unbind callback in the texture.
  96551. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96552. */
  96553. set onAfterUnbind(callback: () => void);
  96554. /**
  96555. * An event triggered before rendering the texture
  96556. */
  96557. onBeforeRenderObservable: Observable<number>;
  96558. private _onBeforeRenderObserver;
  96559. /**
  96560. * Set a before render callback in the texture.
  96561. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96562. */
  96563. set onBeforeRender(callback: (faceIndex: number) => void);
  96564. /**
  96565. * An event triggered after rendering the texture
  96566. */
  96567. onAfterRenderObservable: Observable<number>;
  96568. private _onAfterRenderObserver;
  96569. /**
  96570. * Set a after render callback in the texture.
  96571. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96572. */
  96573. set onAfterRender(callback: (faceIndex: number) => void);
  96574. /**
  96575. * An event triggered after the texture clear
  96576. */
  96577. onClearObservable: Observable<Engine>;
  96578. private _onClearObserver;
  96579. /**
  96580. * Set a clear callback in the texture.
  96581. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96582. */
  96583. set onClear(callback: (Engine: Engine) => void);
  96584. /**
  96585. * An event triggered when the texture is resized.
  96586. */
  96587. onResizeObservable: Observable<RenderTargetTexture>;
  96588. /**
  96589. * Define the clear color of the Render Target if it should be different from the scene.
  96590. */
  96591. clearColor: Color4;
  96592. protected _size: number | {
  96593. width: number;
  96594. height: number;
  96595. layers?: number;
  96596. };
  96597. protected _initialSizeParameter: number | {
  96598. width: number;
  96599. height: number;
  96600. } | {
  96601. ratio: number;
  96602. };
  96603. protected _sizeRatio: Nullable<number>;
  96604. /** @hidden */
  96605. _generateMipMaps: boolean;
  96606. protected _renderingManager: RenderingManager;
  96607. /** @hidden */
  96608. _waitingRenderList: string[];
  96609. protected _doNotChangeAspectRatio: boolean;
  96610. protected _currentRefreshId: number;
  96611. protected _refreshRate: number;
  96612. protected _textureMatrix: Matrix;
  96613. protected _samples: number;
  96614. protected _renderTargetOptions: RenderTargetCreationOptions;
  96615. /**
  96616. * Gets render target creation options that were used.
  96617. */
  96618. get renderTargetOptions(): RenderTargetCreationOptions;
  96619. protected _engine: Engine;
  96620. protected _onRatioRescale(): void;
  96621. /**
  96622. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96623. * It must define where the camera used to render the texture is set
  96624. */
  96625. boundingBoxPosition: Vector3;
  96626. private _boundingBoxSize;
  96627. /**
  96628. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96629. * When defined, the cubemap will switch to local mode
  96630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96631. * @example https://www.babylonjs-playground.com/#RNASML
  96632. */
  96633. set boundingBoxSize(value: Vector3);
  96634. get boundingBoxSize(): Vector3;
  96635. /**
  96636. * In case the RTT has been created with a depth texture, get the associated
  96637. * depth texture.
  96638. * Otherwise, return null.
  96639. */
  96640. get depthStencilTexture(): Nullable<InternalTexture>;
  96641. /**
  96642. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96643. * or used a shadow, depth texture...
  96644. * @param name The friendly name of the texture
  96645. * @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)
  96646. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96647. * @param generateMipMaps True if mip maps need to be generated after render.
  96648. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96649. * @param type The type of the buffer in the RTT (int, half float, float...)
  96650. * @param isCube True if a cube texture needs to be created
  96651. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96652. * @param generateDepthBuffer True to generate a depth buffer
  96653. * @param generateStencilBuffer True to generate a stencil buffer
  96654. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96655. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96656. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96657. */
  96658. constructor(name: string, size: number | {
  96659. width: number;
  96660. height: number;
  96661. layers?: number;
  96662. } | {
  96663. ratio: number;
  96664. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96665. /**
  96666. * Creates a depth stencil texture.
  96667. * This is only available in WebGL 2 or with the depth texture extension available.
  96668. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96669. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96670. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96671. */
  96672. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96673. private _processSizeParameter;
  96674. /**
  96675. * Define the number of samples to use in case of MSAA.
  96676. * It defaults to one meaning no MSAA has been enabled.
  96677. */
  96678. get samples(): number;
  96679. set samples(value: number);
  96680. /**
  96681. * Resets the refresh counter of the texture and start bak from scratch.
  96682. * Could be useful to regenerate the texture if it is setup to render only once.
  96683. */
  96684. resetRefreshCounter(): void;
  96685. /**
  96686. * Define the refresh rate of the texture or the rendering frequency.
  96687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96688. */
  96689. get refreshRate(): number;
  96690. set refreshRate(value: number);
  96691. /**
  96692. * Adds a post process to the render target rendering passes.
  96693. * @param postProcess define the post process to add
  96694. */
  96695. addPostProcess(postProcess: PostProcess): void;
  96696. /**
  96697. * Clear all the post processes attached to the render target
  96698. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96699. */
  96700. clearPostProcesses(dispose?: boolean): void;
  96701. /**
  96702. * Remove one of the post process from the list of attached post processes to the texture
  96703. * @param postProcess define the post process to remove from the list
  96704. */
  96705. removePostProcess(postProcess: PostProcess): void;
  96706. /** @hidden */
  96707. _shouldRender(): boolean;
  96708. /**
  96709. * Gets the actual render size of the texture.
  96710. * @returns the width of the render size
  96711. */
  96712. getRenderSize(): number;
  96713. /**
  96714. * Gets the actual render width of the texture.
  96715. * @returns the width of the render size
  96716. */
  96717. getRenderWidth(): number;
  96718. /**
  96719. * Gets the actual render height of the texture.
  96720. * @returns the height of the render size
  96721. */
  96722. getRenderHeight(): number;
  96723. /**
  96724. * Gets the actual number of layers of the texture.
  96725. * @returns the number of layers
  96726. */
  96727. getRenderLayers(): number;
  96728. /**
  96729. * Get if the texture can be rescaled or not.
  96730. */
  96731. get canRescale(): boolean;
  96732. /**
  96733. * Resize the texture using a ratio.
  96734. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96735. */
  96736. scale(ratio: number): void;
  96737. /**
  96738. * Get the texture reflection matrix used to rotate/transform the reflection.
  96739. * @returns the reflection matrix
  96740. */
  96741. getReflectionTextureMatrix(): Matrix;
  96742. /**
  96743. * Resize the texture to a new desired size.
  96744. * Be carrefull as it will recreate all the data in the new texture.
  96745. * @param size Define the new size. It can be:
  96746. * - a number for squared texture,
  96747. * - an object containing { width: number, height: number }
  96748. * - or an object containing a ratio { ratio: number }
  96749. */
  96750. resize(size: number | {
  96751. width: number;
  96752. height: number;
  96753. } | {
  96754. ratio: number;
  96755. }): void;
  96756. private _defaultRenderListPrepared;
  96757. /**
  96758. * Renders all the objects from the render list into the texture.
  96759. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  96760. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  96761. */
  96762. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  96763. private _bestReflectionRenderTargetDimension;
  96764. private _prepareRenderingManager;
  96765. /**
  96766. * @hidden
  96767. * @param faceIndex face index to bind to if this is a cubetexture
  96768. * @param layer defines the index of the texture to bind in the array
  96769. */
  96770. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  96771. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  96772. private renderToTarget;
  96773. /**
  96774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96775. * This allowed control for front to back rendering or reversly depending of the special needs.
  96776. *
  96777. * @param renderingGroupId The rendering group id corresponding to its index
  96778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96781. */
  96782. 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;
  96783. /**
  96784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96785. *
  96786. * @param renderingGroupId The rendering group id corresponding to its index
  96787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96788. */
  96789. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  96790. /**
  96791. * Clones the texture.
  96792. * @returns the cloned texture
  96793. */
  96794. clone(): RenderTargetTexture;
  96795. /**
  96796. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96797. * @returns The JSON representation of the texture
  96798. */
  96799. serialize(): any;
  96800. /**
  96801. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  96802. */
  96803. disposeFramebufferObjects(): void;
  96804. /**
  96805. * Dispose the texture and release its associated resources.
  96806. */
  96807. dispose(): void;
  96808. /** @hidden */
  96809. _rebuild(): void;
  96810. /**
  96811. * Clear the info related to rendering groups preventing retention point in material dispose.
  96812. */
  96813. freeRenderingGroups(): void;
  96814. /**
  96815. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96816. * @returns the view count
  96817. */
  96818. getViewCount(): number;
  96819. }
  96820. }
  96821. declare module BABYLON {
  96822. /**
  96823. * Class used to manipulate GUIDs
  96824. */
  96825. export class GUID {
  96826. /**
  96827. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96828. * Be aware Math.random() could cause collisions, but:
  96829. * "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"
  96830. * @returns a pseudo random id
  96831. */
  96832. static RandomId(): string;
  96833. }
  96834. }
  96835. declare module BABYLON {
  96836. /**
  96837. * Options to be used when creating a shadow depth material
  96838. */
  96839. export interface IIOptionShadowDepthMaterial {
  96840. /** Variables in the vertex shader code that need to have their names remapped.
  96841. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  96842. * "var_name" should be either: worldPos or vNormalW
  96843. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  96844. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  96845. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  96846. */
  96847. remappedVariables?: string[];
  96848. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  96849. standalone?: boolean;
  96850. }
  96851. /**
  96852. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  96853. */
  96854. export class ShadowDepthWrapper {
  96855. private _scene;
  96856. private _options?;
  96857. private _baseMaterial;
  96858. private _onEffectCreatedObserver;
  96859. private _subMeshToEffect;
  96860. private _subMeshToDepthEffect;
  96861. private _meshes;
  96862. /** @hidden */
  96863. _matriceNames: any;
  96864. /** Gets the standalone status of the wrapper */
  96865. get standalone(): boolean;
  96866. /** Gets the base material the wrapper is built upon */
  96867. get baseMaterial(): Material;
  96868. /**
  96869. * Instantiate a new shadow depth wrapper.
  96870. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  96871. * generate the shadow depth map. For more information, please refer to the documentation:
  96872. * https://doc.babylonjs.com/babylon101/shadows
  96873. * @param baseMaterial Material to wrap
  96874. * @param scene Define the scene the material belongs to
  96875. * @param options Options used to create the wrapper
  96876. */
  96877. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  96878. /**
  96879. * Gets the effect to use to generate the depth map
  96880. * @param subMesh subMesh to get the effect for
  96881. * @param shadowGenerator shadow generator to get the effect for
  96882. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  96883. */
  96884. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  96885. /**
  96886. * Specifies that the submesh is ready to be used for depth rendering
  96887. * @param subMesh submesh to check
  96888. * @param defines the list of defines to take into account when checking the effect
  96889. * @param shadowGenerator combined with subMesh, it defines the effect to check
  96890. * @param useInstances specifies that instances should be used
  96891. * @returns a boolean indicating that the submesh is ready or not
  96892. */
  96893. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  96894. /**
  96895. * Disposes the resources
  96896. */
  96897. dispose(): void;
  96898. private _makeEffect;
  96899. }
  96900. }
  96901. declare module BABYLON {
  96902. /**
  96903. * Options for compiling materials.
  96904. */
  96905. export interface IMaterialCompilationOptions {
  96906. /**
  96907. * Defines whether clip planes are enabled.
  96908. */
  96909. clipPlane: boolean;
  96910. /**
  96911. * Defines whether instances are enabled.
  96912. */
  96913. useInstances: boolean;
  96914. }
  96915. /**
  96916. * Base class for the main features of a material in Babylon.js
  96917. */
  96918. export class Material implements IAnimatable {
  96919. /**
  96920. * Returns the triangle fill mode
  96921. */
  96922. static readonly TriangleFillMode: number;
  96923. /**
  96924. * Returns the wireframe mode
  96925. */
  96926. static readonly WireFrameFillMode: number;
  96927. /**
  96928. * Returns the point fill mode
  96929. */
  96930. static readonly PointFillMode: number;
  96931. /**
  96932. * Returns the point list draw mode
  96933. */
  96934. static readonly PointListDrawMode: number;
  96935. /**
  96936. * Returns the line list draw mode
  96937. */
  96938. static readonly LineListDrawMode: number;
  96939. /**
  96940. * Returns the line loop draw mode
  96941. */
  96942. static readonly LineLoopDrawMode: number;
  96943. /**
  96944. * Returns the line strip draw mode
  96945. */
  96946. static readonly LineStripDrawMode: number;
  96947. /**
  96948. * Returns the triangle strip draw mode
  96949. */
  96950. static readonly TriangleStripDrawMode: number;
  96951. /**
  96952. * Returns the triangle fan draw mode
  96953. */
  96954. static readonly TriangleFanDrawMode: number;
  96955. /**
  96956. * Stores the clock-wise side orientation
  96957. */
  96958. static readonly ClockWiseSideOrientation: number;
  96959. /**
  96960. * Stores the counter clock-wise side orientation
  96961. */
  96962. static readonly CounterClockWiseSideOrientation: number;
  96963. /**
  96964. * The dirty texture flag value
  96965. */
  96966. static readonly TextureDirtyFlag: number;
  96967. /**
  96968. * The dirty light flag value
  96969. */
  96970. static readonly LightDirtyFlag: number;
  96971. /**
  96972. * The dirty fresnel flag value
  96973. */
  96974. static readonly FresnelDirtyFlag: number;
  96975. /**
  96976. * The dirty attribute flag value
  96977. */
  96978. static readonly AttributesDirtyFlag: number;
  96979. /**
  96980. * The dirty misc flag value
  96981. */
  96982. static readonly MiscDirtyFlag: number;
  96983. /**
  96984. * The all dirty flag value
  96985. */
  96986. static readonly AllDirtyFlag: number;
  96987. /**
  96988. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  96989. */
  96990. static readonly MATERIAL_OPAQUE: number;
  96991. /**
  96992. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  96993. */
  96994. static readonly MATERIAL_ALPHATEST: number;
  96995. /**
  96996. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  96997. */
  96998. static readonly MATERIAL_ALPHABLEND: number;
  96999. /**
  97000. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  97001. * They are also discarded below the alpha cutoff threshold to improve performances.
  97002. */
  97003. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  97004. /**
  97005. * Custom callback helping to override the default shader used in the material.
  97006. */
  97007. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  97008. /**
  97009. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97010. */
  97011. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97012. /**
  97013. * The ID of the material
  97014. */
  97015. id: string;
  97016. /**
  97017. * Gets or sets the unique id of the material
  97018. */
  97019. uniqueId: number;
  97020. /**
  97021. * The name of the material
  97022. */
  97023. name: string;
  97024. /**
  97025. * Gets or sets user defined metadata
  97026. */
  97027. metadata: any;
  97028. /**
  97029. * For internal use only. Please do not use.
  97030. */
  97031. reservedDataStore: any;
  97032. /**
  97033. * Specifies if the ready state should be checked on each call
  97034. */
  97035. checkReadyOnEveryCall: boolean;
  97036. /**
  97037. * Specifies if the ready state should be checked once
  97038. */
  97039. checkReadyOnlyOnce: boolean;
  97040. /**
  97041. * The state of the material
  97042. */
  97043. state: string;
  97044. /**
  97045. * The alpha value of the material
  97046. */
  97047. protected _alpha: number;
  97048. /**
  97049. * List of inspectable custom properties (used by the Inspector)
  97050. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97051. */
  97052. inspectableCustomProperties: IInspectable[];
  97053. /**
  97054. * Sets the alpha value of the material
  97055. */
  97056. set alpha(value: number);
  97057. /**
  97058. * Gets the alpha value of the material
  97059. */
  97060. get alpha(): number;
  97061. /**
  97062. * Specifies if back face culling is enabled
  97063. */
  97064. protected _backFaceCulling: boolean;
  97065. /**
  97066. * Sets the back-face culling state
  97067. */
  97068. set backFaceCulling(value: boolean);
  97069. /**
  97070. * Gets the back-face culling state
  97071. */
  97072. get backFaceCulling(): boolean;
  97073. /**
  97074. * Stores the value for side orientation
  97075. */
  97076. sideOrientation: number;
  97077. /**
  97078. * Callback triggered when the material is compiled
  97079. */
  97080. onCompiled: Nullable<(effect: Effect) => void>;
  97081. /**
  97082. * Callback triggered when an error occurs
  97083. */
  97084. onError: Nullable<(effect: Effect, errors: string) => void>;
  97085. /**
  97086. * Callback triggered to get the render target textures
  97087. */
  97088. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97089. /**
  97090. * Gets a boolean indicating that current material needs to register RTT
  97091. */
  97092. get hasRenderTargetTextures(): boolean;
  97093. /**
  97094. * Specifies if the material should be serialized
  97095. */
  97096. doNotSerialize: boolean;
  97097. /**
  97098. * @hidden
  97099. */
  97100. _storeEffectOnSubMeshes: boolean;
  97101. /**
  97102. * Stores the animations for the material
  97103. */
  97104. animations: Nullable<Array<Animation>>;
  97105. /**
  97106. * An event triggered when the material is disposed
  97107. */
  97108. onDisposeObservable: Observable<Material>;
  97109. /**
  97110. * An observer which watches for dispose events
  97111. */
  97112. private _onDisposeObserver;
  97113. private _onUnBindObservable;
  97114. /**
  97115. * Called during a dispose event
  97116. */
  97117. set onDispose(callback: () => void);
  97118. private _onBindObservable;
  97119. /**
  97120. * An event triggered when the material is bound
  97121. */
  97122. get onBindObservable(): Observable<AbstractMesh>;
  97123. /**
  97124. * An observer which watches for bind events
  97125. */
  97126. private _onBindObserver;
  97127. /**
  97128. * Called during a bind event
  97129. */
  97130. set onBind(callback: (Mesh: AbstractMesh) => void);
  97131. /**
  97132. * An event triggered when the material is unbound
  97133. */
  97134. get onUnBindObservable(): Observable<Material>;
  97135. protected _onEffectCreatedObservable: Nullable<Observable<{
  97136. effect: Effect;
  97137. subMesh: Nullable<SubMesh>;
  97138. }>>;
  97139. /**
  97140. * An event triggered when the effect is (re)created
  97141. */
  97142. get onEffectCreatedObservable(): Observable<{
  97143. effect: Effect;
  97144. subMesh: Nullable<SubMesh>;
  97145. }>;
  97146. /**
  97147. * Stores the value of the alpha mode
  97148. */
  97149. private _alphaMode;
  97150. /**
  97151. * Sets the value of the alpha mode.
  97152. *
  97153. * | Value | Type | Description |
  97154. * | --- | --- | --- |
  97155. * | 0 | ALPHA_DISABLE | |
  97156. * | 1 | ALPHA_ADD | |
  97157. * | 2 | ALPHA_COMBINE | |
  97158. * | 3 | ALPHA_SUBTRACT | |
  97159. * | 4 | ALPHA_MULTIPLY | |
  97160. * | 5 | ALPHA_MAXIMIZED | |
  97161. * | 6 | ALPHA_ONEONE | |
  97162. * | 7 | ALPHA_PREMULTIPLIED | |
  97163. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97164. * | 9 | ALPHA_INTERPOLATE | |
  97165. * | 10 | ALPHA_SCREENMODE | |
  97166. *
  97167. */
  97168. set alphaMode(value: number);
  97169. /**
  97170. * Gets the value of the alpha mode
  97171. */
  97172. get alphaMode(): number;
  97173. /**
  97174. * Stores the state of the need depth pre-pass value
  97175. */
  97176. private _needDepthPrePass;
  97177. /**
  97178. * Sets the need depth pre-pass value
  97179. */
  97180. set needDepthPrePass(value: boolean);
  97181. /**
  97182. * Gets the depth pre-pass value
  97183. */
  97184. get needDepthPrePass(): boolean;
  97185. /**
  97186. * Specifies if depth writing should be disabled
  97187. */
  97188. disableDepthWrite: boolean;
  97189. /**
  97190. * Specifies if color writing should be disabled
  97191. */
  97192. disableColorWrite: boolean;
  97193. /**
  97194. * Specifies if depth writing should be forced
  97195. */
  97196. forceDepthWrite: boolean;
  97197. /**
  97198. * Specifies the depth function that should be used. 0 means the default engine function
  97199. */
  97200. depthFunction: number;
  97201. /**
  97202. * Specifies if there should be a separate pass for culling
  97203. */
  97204. separateCullingPass: boolean;
  97205. /**
  97206. * Stores the state specifing if fog should be enabled
  97207. */
  97208. private _fogEnabled;
  97209. /**
  97210. * Sets the state for enabling fog
  97211. */
  97212. set fogEnabled(value: boolean);
  97213. /**
  97214. * Gets the value of the fog enabled state
  97215. */
  97216. get fogEnabled(): boolean;
  97217. /**
  97218. * Stores the size of points
  97219. */
  97220. pointSize: number;
  97221. /**
  97222. * Stores the z offset value
  97223. */
  97224. zOffset: number;
  97225. get wireframe(): boolean;
  97226. /**
  97227. * Sets the state of wireframe mode
  97228. */
  97229. set wireframe(value: boolean);
  97230. /**
  97231. * Gets the value specifying if point clouds are enabled
  97232. */
  97233. get pointsCloud(): boolean;
  97234. /**
  97235. * Sets the state of point cloud mode
  97236. */
  97237. set pointsCloud(value: boolean);
  97238. /**
  97239. * Gets the material fill mode
  97240. */
  97241. get fillMode(): number;
  97242. /**
  97243. * Sets the material fill mode
  97244. */
  97245. set fillMode(value: number);
  97246. /**
  97247. * @hidden
  97248. * Stores the effects for the material
  97249. */
  97250. _effect: Nullable<Effect>;
  97251. /**
  97252. * Specifies if uniform buffers should be used
  97253. */
  97254. private _useUBO;
  97255. /**
  97256. * Stores a reference to the scene
  97257. */
  97258. private _scene;
  97259. /**
  97260. * Stores the fill mode state
  97261. */
  97262. private _fillMode;
  97263. /**
  97264. * Specifies if the depth write state should be cached
  97265. */
  97266. private _cachedDepthWriteState;
  97267. /**
  97268. * Specifies if the color write state should be cached
  97269. */
  97270. private _cachedColorWriteState;
  97271. /**
  97272. * Specifies if the depth function state should be cached
  97273. */
  97274. private _cachedDepthFunctionState;
  97275. /**
  97276. * Stores the uniform buffer
  97277. */
  97278. protected _uniformBuffer: UniformBuffer;
  97279. /** @hidden */
  97280. _indexInSceneMaterialArray: number;
  97281. /** @hidden */
  97282. meshMap: Nullable<{
  97283. [id: string]: AbstractMesh | undefined;
  97284. }>;
  97285. /**
  97286. * Creates a material instance
  97287. * @param name defines the name of the material
  97288. * @param scene defines the scene to reference
  97289. * @param doNotAdd specifies if the material should be added to the scene
  97290. */
  97291. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97292. /**
  97293. * Returns a string representation of the current material
  97294. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97295. * @returns a string with material information
  97296. */
  97297. toString(fullDetails?: boolean): string;
  97298. /**
  97299. * Gets the class name of the material
  97300. * @returns a string with the class name of the material
  97301. */
  97302. getClassName(): string;
  97303. /**
  97304. * Specifies if updates for the material been locked
  97305. */
  97306. get isFrozen(): boolean;
  97307. /**
  97308. * Locks updates for the material
  97309. */
  97310. freeze(): void;
  97311. /**
  97312. * Unlocks updates for the material
  97313. */
  97314. unfreeze(): void;
  97315. /**
  97316. * Specifies if the material is ready to be used
  97317. * @param mesh defines the mesh to check
  97318. * @param useInstances specifies if instances should be used
  97319. * @returns a boolean indicating if the material is ready to be used
  97320. */
  97321. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97322. /**
  97323. * Specifies that the submesh is ready to be used
  97324. * @param mesh defines the mesh to check
  97325. * @param subMesh defines which submesh to check
  97326. * @param useInstances specifies that instances should be used
  97327. * @returns a boolean indicating that the submesh is ready or not
  97328. */
  97329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97330. /**
  97331. * Returns the material effect
  97332. * @returns the effect associated with the material
  97333. */
  97334. getEffect(): Nullable<Effect>;
  97335. /**
  97336. * Returns the current scene
  97337. * @returns a Scene
  97338. */
  97339. getScene(): Scene;
  97340. /**
  97341. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97342. */
  97343. protected _forceAlphaTest: boolean;
  97344. /**
  97345. * The transparency mode of the material.
  97346. */
  97347. protected _transparencyMode: Nullable<number>;
  97348. /**
  97349. * Gets the current transparency mode.
  97350. */
  97351. get transparencyMode(): Nullable<number>;
  97352. /**
  97353. * Sets the transparency mode of the material.
  97354. *
  97355. * | Value | Type | Description |
  97356. * | ----- | ----------------------------------- | ----------- |
  97357. * | 0 | OPAQUE | |
  97358. * | 1 | ALPHATEST | |
  97359. * | 2 | ALPHABLEND | |
  97360. * | 3 | ALPHATESTANDBLEND | |
  97361. *
  97362. */
  97363. set transparencyMode(value: Nullable<number>);
  97364. /**
  97365. * Returns true if alpha blending should be disabled.
  97366. */
  97367. protected get _disableAlphaBlending(): boolean;
  97368. /**
  97369. * Specifies whether or not this material should be rendered in alpha blend mode.
  97370. * @returns a boolean specifying if alpha blending is needed
  97371. */
  97372. needAlphaBlending(): boolean;
  97373. /**
  97374. * Specifies if the mesh will require alpha blending
  97375. * @param mesh defines the mesh to check
  97376. * @returns a boolean specifying if alpha blending is needed for the mesh
  97377. */
  97378. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97379. /**
  97380. * Specifies whether or not this material should be rendered in alpha test mode.
  97381. * @returns a boolean specifying if an alpha test is needed.
  97382. */
  97383. needAlphaTesting(): boolean;
  97384. /**
  97385. * Specifies if material alpha testing should be turned on for the mesh
  97386. * @param mesh defines the mesh to check
  97387. */
  97388. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97389. /**
  97390. * Gets the texture used for the alpha test
  97391. * @returns the texture to use for alpha testing
  97392. */
  97393. getAlphaTestTexture(): Nullable<BaseTexture>;
  97394. /**
  97395. * Marks the material to indicate that it needs to be re-calculated
  97396. */
  97397. markDirty(): void;
  97398. /** @hidden */
  97399. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97400. /**
  97401. * Binds the material to the mesh
  97402. * @param world defines the world transformation matrix
  97403. * @param mesh defines the mesh to bind the material to
  97404. */
  97405. bind(world: Matrix, mesh?: Mesh): void;
  97406. /**
  97407. * Binds the submesh to the material
  97408. * @param world defines the world transformation matrix
  97409. * @param mesh defines the mesh containing the submesh
  97410. * @param subMesh defines the submesh to bind the material to
  97411. */
  97412. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97413. /**
  97414. * Binds the world matrix to the material
  97415. * @param world defines the world transformation matrix
  97416. */
  97417. bindOnlyWorldMatrix(world: Matrix): void;
  97418. /**
  97419. * Binds the scene's uniform buffer to the effect.
  97420. * @param effect defines the effect to bind to the scene uniform buffer
  97421. * @param sceneUbo defines the uniform buffer storing scene data
  97422. */
  97423. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97424. /**
  97425. * Binds the view matrix to the effect
  97426. * @param effect defines the effect to bind the view matrix to
  97427. */
  97428. bindView(effect: Effect): void;
  97429. /**
  97430. * Binds the view projection matrix to the effect
  97431. * @param effect defines the effect to bind the view projection matrix to
  97432. */
  97433. bindViewProjection(effect: Effect): void;
  97434. /**
  97435. * Processes to execute after binding the material to a mesh
  97436. * @param mesh defines the rendered mesh
  97437. */
  97438. protected _afterBind(mesh?: Mesh): void;
  97439. /**
  97440. * Unbinds the material from the mesh
  97441. */
  97442. unbind(): void;
  97443. /**
  97444. * Gets the active textures from the material
  97445. * @returns an array of textures
  97446. */
  97447. getActiveTextures(): BaseTexture[];
  97448. /**
  97449. * Specifies if the material uses a texture
  97450. * @param texture defines the texture to check against the material
  97451. * @returns a boolean specifying if the material uses the texture
  97452. */
  97453. hasTexture(texture: BaseTexture): boolean;
  97454. /**
  97455. * Makes a duplicate of the material, and gives it a new name
  97456. * @param name defines the new name for the duplicated material
  97457. * @returns the cloned material
  97458. */
  97459. clone(name: string): Nullable<Material>;
  97460. /**
  97461. * Gets the meshes bound to the material
  97462. * @returns an array of meshes bound to the material
  97463. */
  97464. getBindedMeshes(): AbstractMesh[];
  97465. /**
  97466. * Force shader compilation
  97467. * @param mesh defines the mesh associated with this material
  97468. * @param onCompiled defines a function to execute once the material is compiled
  97469. * @param options defines the options to configure the compilation
  97470. * @param onError defines a function to execute if the material fails compiling
  97471. */
  97472. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97473. /**
  97474. * Force shader compilation
  97475. * @param mesh defines the mesh that will use this material
  97476. * @param options defines additional options for compiling the shaders
  97477. * @returns a promise that resolves when the compilation completes
  97478. */
  97479. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97480. private static readonly _AllDirtyCallBack;
  97481. private static readonly _ImageProcessingDirtyCallBack;
  97482. private static readonly _TextureDirtyCallBack;
  97483. private static readonly _FresnelDirtyCallBack;
  97484. private static readonly _MiscDirtyCallBack;
  97485. private static readonly _LightsDirtyCallBack;
  97486. private static readonly _AttributeDirtyCallBack;
  97487. private static _FresnelAndMiscDirtyCallBack;
  97488. private static _TextureAndMiscDirtyCallBack;
  97489. private static readonly _DirtyCallbackArray;
  97490. private static readonly _RunDirtyCallBacks;
  97491. /**
  97492. * Marks a define in the material to indicate that it needs to be re-computed
  97493. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97494. */
  97495. markAsDirty(flag: number): void;
  97496. /**
  97497. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97498. * @param func defines a function which checks material defines against the submeshes
  97499. */
  97500. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97501. /**
  97502. * Indicates that we need to re-calculated for all submeshes
  97503. */
  97504. protected _markAllSubMeshesAsAllDirty(): void;
  97505. /**
  97506. * Indicates that image processing needs to be re-calculated for all submeshes
  97507. */
  97508. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97509. /**
  97510. * Indicates that textures need to be re-calculated for all submeshes
  97511. */
  97512. protected _markAllSubMeshesAsTexturesDirty(): void;
  97513. /**
  97514. * Indicates that fresnel needs to be re-calculated for all submeshes
  97515. */
  97516. protected _markAllSubMeshesAsFresnelDirty(): void;
  97517. /**
  97518. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97519. */
  97520. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97521. /**
  97522. * Indicates that lights need to be re-calculated for all submeshes
  97523. */
  97524. protected _markAllSubMeshesAsLightsDirty(): void;
  97525. /**
  97526. * Indicates that attributes need to be re-calculated for all submeshes
  97527. */
  97528. protected _markAllSubMeshesAsAttributesDirty(): void;
  97529. /**
  97530. * Indicates that misc needs to be re-calculated for all submeshes
  97531. */
  97532. protected _markAllSubMeshesAsMiscDirty(): void;
  97533. /**
  97534. * Indicates that textures and misc need to be re-calculated for all submeshes
  97535. */
  97536. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97537. /**
  97538. * Disposes the material
  97539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97542. */
  97543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97544. /** @hidden */
  97545. private releaseVertexArrayObject;
  97546. /**
  97547. * Serializes this material
  97548. * @returns the serialized material object
  97549. */
  97550. serialize(): any;
  97551. /**
  97552. * Creates a material from parsed material data
  97553. * @param parsedMaterial defines parsed material data
  97554. * @param scene defines the hosting scene
  97555. * @param rootUrl defines the root URL to use to load textures
  97556. * @returns a new material
  97557. */
  97558. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97559. }
  97560. }
  97561. declare module BABYLON {
  97562. /**
  97563. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97564. * separate meshes. This can be use to improve performances.
  97565. * @see http://doc.babylonjs.com/how_to/multi_materials
  97566. */
  97567. export class MultiMaterial extends Material {
  97568. private _subMaterials;
  97569. /**
  97570. * Gets or Sets the list of Materials used within the multi material.
  97571. * They need to be ordered according to the submeshes order in the associated mesh
  97572. */
  97573. get subMaterials(): Nullable<Material>[];
  97574. set subMaterials(value: Nullable<Material>[]);
  97575. /**
  97576. * Function used to align with Node.getChildren()
  97577. * @returns the list of Materials used within the multi material
  97578. */
  97579. getChildren(): Nullable<Material>[];
  97580. /**
  97581. * Instantiates a new Multi Material
  97582. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97583. * separate meshes. This can be use to improve performances.
  97584. * @see http://doc.babylonjs.com/how_to/multi_materials
  97585. * @param name Define the name in the scene
  97586. * @param scene Define the scene the material belongs to
  97587. */
  97588. constructor(name: string, scene: Scene);
  97589. private _hookArray;
  97590. /**
  97591. * Get one of the submaterial by its index in the submaterials array
  97592. * @param index The index to look the sub material at
  97593. * @returns The Material if the index has been defined
  97594. */
  97595. getSubMaterial(index: number): Nullable<Material>;
  97596. /**
  97597. * Get the list of active textures for the whole sub materials list.
  97598. * @returns All the textures that will be used during the rendering
  97599. */
  97600. getActiveTextures(): BaseTexture[];
  97601. /**
  97602. * Gets the current class name of the material e.g. "MultiMaterial"
  97603. * Mainly use in serialization.
  97604. * @returns the class name
  97605. */
  97606. getClassName(): string;
  97607. /**
  97608. * Checks if the material is ready to render the requested sub mesh
  97609. * @param mesh Define the mesh the submesh belongs to
  97610. * @param subMesh Define the sub mesh to look readyness for
  97611. * @param useInstances Define whether or not the material is used with instances
  97612. * @returns true if ready, otherwise false
  97613. */
  97614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97615. /**
  97616. * Clones the current material and its related sub materials
  97617. * @param name Define the name of the newly cloned material
  97618. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97619. * @returns the cloned material
  97620. */
  97621. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97622. /**
  97623. * Serializes the materials into a JSON representation.
  97624. * @returns the JSON representation
  97625. */
  97626. serialize(): any;
  97627. /**
  97628. * Dispose the material and release its associated resources
  97629. * @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)
  97630. * @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)
  97631. * @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)
  97632. */
  97633. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97634. /**
  97635. * Creates a MultiMaterial from parsed MultiMaterial data.
  97636. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97637. * @param scene defines the hosting scene
  97638. * @returns a new MultiMaterial
  97639. */
  97640. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97641. }
  97642. }
  97643. declare module BABYLON {
  97644. /**
  97645. * Base class for submeshes
  97646. */
  97647. export class BaseSubMesh {
  97648. /** @hidden */
  97649. _materialDefines: Nullable<MaterialDefines>;
  97650. /** @hidden */
  97651. _materialEffect: Nullable<Effect>;
  97652. /** @hidden */
  97653. _effectOverride: Nullable<Effect>;
  97654. /**
  97655. * Gets material defines used by the effect associated to the sub mesh
  97656. */
  97657. get materialDefines(): Nullable<MaterialDefines>;
  97658. /**
  97659. * Sets material defines used by the effect associated to the sub mesh
  97660. */
  97661. set materialDefines(defines: Nullable<MaterialDefines>);
  97662. /**
  97663. * Gets associated effect
  97664. */
  97665. get effect(): Nullable<Effect>;
  97666. /**
  97667. * Sets associated effect (effect used to render this submesh)
  97668. * @param effect defines the effect to associate with
  97669. * @param defines defines the set of defines used to compile this effect
  97670. */
  97671. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97672. }
  97673. /**
  97674. * Defines a subdivision inside a mesh
  97675. */
  97676. export class SubMesh extends BaseSubMesh implements ICullable {
  97677. /** the material index to use */
  97678. materialIndex: number;
  97679. /** vertex index start */
  97680. verticesStart: number;
  97681. /** vertices count */
  97682. verticesCount: number;
  97683. /** index start */
  97684. indexStart: number;
  97685. /** indices count */
  97686. indexCount: number;
  97687. /** @hidden */
  97688. _linesIndexCount: number;
  97689. private _mesh;
  97690. private _renderingMesh;
  97691. private _boundingInfo;
  97692. private _linesIndexBuffer;
  97693. /** @hidden */
  97694. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97695. /** @hidden */
  97696. _trianglePlanes: Plane[];
  97697. /** @hidden */
  97698. _lastColliderTransformMatrix: Nullable<Matrix>;
  97699. /** @hidden */
  97700. _renderId: number;
  97701. /** @hidden */
  97702. _alphaIndex: number;
  97703. /** @hidden */
  97704. _distanceToCamera: number;
  97705. /** @hidden */
  97706. _id: number;
  97707. private _currentMaterial;
  97708. /**
  97709. * Add a new submesh to a mesh
  97710. * @param materialIndex defines the material index to use
  97711. * @param verticesStart defines vertex index start
  97712. * @param verticesCount defines vertices count
  97713. * @param indexStart defines index start
  97714. * @param indexCount defines indices count
  97715. * @param mesh defines the parent mesh
  97716. * @param renderingMesh defines an optional rendering mesh
  97717. * @param createBoundingBox defines if bounding box should be created for this submesh
  97718. * @returns the new submesh
  97719. */
  97720. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97721. /**
  97722. * Creates a new submesh
  97723. * @param materialIndex defines the material index to use
  97724. * @param verticesStart defines vertex index start
  97725. * @param verticesCount defines vertices count
  97726. * @param indexStart defines index start
  97727. * @param indexCount defines indices count
  97728. * @param mesh defines the parent mesh
  97729. * @param renderingMesh defines an optional rendering mesh
  97730. * @param createBoundingBox defines if bounding box should be created for this submesh
  97731. */
  97732. constructor(
  97733. /** the material index to use */
  97734. materialIndex: number,
  97735. /** vertex index start */
  97736. verticesStart: number,
  97737. /** vertices count */
  97738. verticesCount: number,
  97739. /** index start */
  97740. indexStart: number,
  97741. /** indices count */
  97742. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  97743. /**
  97744. * Returns true if this submesh covers the entire parent mesh
  97745. * @ignorenaming
  97746. */
  97747. get IsGlobal(): boolean;
  97748. /**
  97749. * Returns the submesh BoudingInfo object
  97750. * @returns current bounding info (or mesh's one if the submesh is global)
  97751. */
  97752. getBoundingInfo(): BoundingInfo;
  97753. /**
  97754. * Sets the submesh BoundingInfo
  97755. * @param boundingInfo defines the new bounding info to use
  97756. * @returns the SubMesh
  97757. */
  97758. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  97759. /**
  97760. * Returns the mesh of the current submesh
  97761. * @return the parent mesh
  97762. */
  97763. getMesh(): AbstractMesh;
  97764. /**
  97765. * Returns the rendering mesh of the submesh
  97766. * @returns the rendering mesh (could be different from parent mesh)
  97767. */
  97768. getRenderingMesh(): Mesh;
  97769. /**
  97770. * Returns the submesh material
  97771. * @returns null or the current material
  97772. */
  97773. getMaterial(): Nullable<Material>;
  97774. /**
  97775. * Sets a new updated BoundingInfo object to the submesh
  97776. * @param data defines an optional position array to use to determine the bounding info
  97777. * @returns the SubMesh
  97778. */
  97779. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  97780. /** @hidden */
  97781. _checkCollision(collider: Collider): boolean;
  97782. /**
  97783. * Updates the submesh BoundingInfo
  97784. * @param world defines the world matrix to use to update the bounding info
  97785. * @returns the submesh
  97786. */
  97787. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  97788. /**
  97789. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  97790. * @param frustumPlanes defines the frustum planes
  97791. * @returns true if the submesh is intersecting with the frustum
  97792. */
  97793. isInFrustum(frustumPlanes: Plane[]): boolean;
  97794. /**
  97795. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  97796. * @param frustumPlanes defines the frustum planes
  97797. * @returns true if the submesh is inside the frustum
  97798. */
  97799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97800. /**
  97801. * Renders the submesh
  97802. * @param enableAlphaMode defines if alpha needs to be used
  97803. * @returns the submesh
  97804. */
  97805. render(enableAlphaMode: boolean): SubMesh;
  97806. /**
  97807. * @hidden
  97808. */
  97809. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  97810. /**
  97811. * Checks if the submesh intersects with a ray
  97812. * @param ray defines the ray to test
  97813. * @returns true is the passed ray intersects the submesh bounding box
  97814. */
  97815. canIntersects(ray: Ray): boolean;
  97816. /**
  97817. * Intersects current submesh with a ray
  97818. * @param ray defines the ray to test
  97819. * @param positions defines mesh's positions array
  97820. * @param indices defines mesh's indices array
  97821. * @param fastCheck defines if the first intersection will be used (and not the closest)
  97822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97823. * @returns intersection info or null if no intersection
  97824. */
  97825. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  97826. /** @hidden */
  97827. private _intersectLines;
  97828. /** @hidden */
  97829. private _intersectUnIndexedLines;
  97830. /** @hidden */
  97831. private _intersectTriangles;
  97832. /** @hidden */
  97833. private _intersectUnIndexedTriangles;
  97834. /** @hidden */
  97835. _rebuild(): void;
  97836. /**
  97837. * Creates a new submesh from the passed mesh
  97838. * @param newMesh defines the new hosting mesh
  97839. * @param newRenderingMesh defines an optional rendering mesh
  97840. * @returns the new submesh
  97841. */
  97842. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  97843. /**
  97844. * Release associated resources
  97845. */
  97846. dispose(): void;
  97847. /**
  97848. * Gets the class name
  97849. * @returns the string "SubMesh".
  97850. */
  97851. getClassName(): string;
  97852. /**
  97853. * Creates a new submesh from indices data
  97854. * @param materialIndex the index of the main mesh material
  97855. * @param startIndex the index where to start the copy in the mesh indices array
  97856. * @param indexCount the number of indices to copy then from the startIndex
  97857. * @param mesh the main mesh to create the submesh from
  97858. * @param renderingMesh the optional rendering mesh
  97859. * @returns a new submesh
  97860. */
  97861. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  97862. }
  97863. }
  97864. declare module BABYLON {
  97865. /**
  97866. * Class used to represent data loading progression
  97867. */
  97868. export class SceneLoaderFlags {
  97869. private static _ForceFullSceneLoadingForIncremental;
  97870. private static _ShowLoadingScreen;
  97871. private static _CleanBoneMatrixWeights;
  97872. private static _loggingLevel;
  97873. /**
  97874. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97875. */
  97876. static get ForceFullSceneLoadingForIncremental(): boolean;
  97877. static set ForceFullSceneLoadingForIncremental(value: boolean);
  97878. /**
  97879. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97880. */
  97881. static get ShowLoadingScreen(): boolean;
  97882. static set ShowLoadingScreen(value: boolean);
  97883. /**
  97884. * Defines the current logging level (while loading the scene)
  97885. * @ignorenaming
  97886. */
  97887. static get loggingLevel(): number;
  97888. static set loggingLevel(value: number);
  97889. /**
  97890. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97891. */
  97892. static get CleanBoneMatrixWeights(): boolean;
  97893. static set CleanBoneMatrixWeights(value: boolean);
  97894. }
  97895. }
  97896. declare module BABYLON {
  97897. /**
  97898. * Class used to store geometry data (vertex buffers + index buffer)
  97899. */
  97900. export class Geometry implements IGetSetVerticesData {
  97901. /**
  97902. * Gets or sets the ID of the geometry
  97903. */
  97904. id: string;
  97905. /**
  97906. * Gets or sets the unique ID of the geometry
  97907. */
  97908. uniqueId: number;
  97909. /**
  97910. * Gets the delay loading state of the geometry (none by default which means not delayed)
  97911. */
  97912. delayLoadState: number;
  97913. /**
  97914. * Gets the file containing the data to load when running in delay load state
  97915. */
  97916. delayLoadingFile: Nullable<string>;
  97917. /**
  97918. * Callback called when the geometry is updated
  97919. */
  97920. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  97921. private _scene;
  97922. private _engine;
  97923. private _meshes;
  97924. private _totalVertices;
  97925. /** @hidden */
  97926. _indices: IndicesArray;
  97927. /** @hidden */
  97928. _vertexBuffers: {
  97929. [key: string]: VertexBuffer;
  97930. };
  97931. private _isDisposed;
  97932. private _extend;
  97933. private _boundingBias;
  97934. /** @hidden */
  97935. _delayInfo: Array<string>;
  97936. private _indexBuffer;
  97937. private _indexBufferIsUpdatable;
  97938. /** @hidden */
  97939. _boundingInfo: Nullable<BoundingInfo>;
  97940. /** @hidden */
  97941. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  97942. /** @hidden */
  97943. _softwareSkinningFrameId: number;
  97944. private _vertexArrayObjects;
  97945. private _updatable;
  97946. /** @hidden */
  97947. _positions: Nullable<Vector3[]>;
  97948. /**
  97949. * 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
  97950. */
  97951. get boundingBias(): Vector2;
  97952. /**
  97953. * 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
  97954. */
  97955. set boundingBias(value: Vector2);
  97956. /**
  97957. * Static function used to attach a new empty geometry to a mesh
  97958. * @param mesh defines the mesh to attach the geometry to
  97959. * @returns the new Geometry
  97960. */
  97961. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  97962. /** Get the list of meshes using this geometry */
  97963. get meshes(): Mesh[];
  97964. /**
  97965. * Creates a new geometry
  97966. * @param id defines the unique ID
  97967. * @param scene defines the hosting scene
  97968. * @param vertexData defines the VertexData used to get geometry data
  97969. * @param updatable defines if geometry must be updatable (false by default)
  97970. * @param mesh defines the mesh that will be associated with the geometry
  97971. */
  97972. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  97973. /**
  97974. * Gets the current extend of the geometry
  97975. */
  97976. get extend(): {
  97977. minimum: Vector3;
  97978. maximum: Vector3;
  97979. };
  97980. /**
  97981. * Gets the hosting scene
  97982. * @returns the hosting Scene
  97983. */
  97984. getScene(): Scene;
  97985. /**
  97986. * Gets the hosting engine
  97987. * @returns the hosting Engine
  97988. */
  97989. getEngine(): Engine;
  97990. /**
  97991. * Defines if the geometry is ready to use
  97992. * @returns true if the geometry is ready to be used
  97993. */
  97994. isReady(): boolean;
  97995. /**
  97996. * Gets a value indicating that the geometry should not be serialized
  97997. */
  97998. get doNotSerialize(): boolean;
  97999. /** @hidden */
  98000. _rebuild(): void;
  98001. /**
  98002. * Affects all geometry data in one call
  98003. * @param vertexData defines the geometry data
  98004. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  98005. */
  98006. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  98007. /**
  98008. * Set specific vertex data
  98009. * @param kind defines the data kind (Position, normal, etc...)
  98010. * @param data defines the vertex data to use
  98011. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98012. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98013. */
  98014. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98015. /**
  98016. * Removes a specific vertex data
  98017. * @param kind defines the data kind (Position, normal, etc...)
  98018. */
  98019. removeVerticesData(kind: string): void;
  98020. /**
  98021. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98022. * @param buffer defines the vertex buffer to use
  98023. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98024. */
  98025. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98026. /**
  98027. * Update a specific vertex buffer
  98028. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98029. * It will do nothing if the buffer is not updatable
  98030. * @param kind defines the data kind (Position, normal, etc...)
  98031. * @param data defines the data to use
  98032. * @param offset defines the offset in the target buffer where to store the data
  98033. * @param useBytes set to true if the offset is in bytes
  98034. */
  98035. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98036. /**
  98037. * Update a specific vertex buffer
  98038. * This function will create a new buffer if the current one is not updatable
  98039. * @param kind defines the data kind (Position, normal, etc...)
  98040. * @param data defines the data to use
  98041. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98042. */
  98043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98044. private _updateBoundingInfo;
  98045. /** @hidden */
  98046. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98047. /**
  98048. * Gets total number of vertices
  98049. * @returns the total number of vertices
  98050. */
  98051. getTotalVertices(): number;
  98052. /**
  98053. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98054. * @param kind defines the data kind (Position, normal, etc...)
  98055. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98056. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98057. * @returns a float array containing vertex data
  98058. */
  98059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98060. /**
  98061. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98062. * @param kind defines the data kind (Position, normal, etc...)
  98063. * @returns true if the vertex buffer with the specified kind is updatable
  98064. */
  98065. isVertexBufferUpdatable(kind: string): boolean;
  98066. /**
  98067. * Gets a specific vertex buffer
  98068. * @param kind defines the data kind (Position, normal, etc...)
  98069. * @returns a VertexBuffer
  98070. */
  98071. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98072. /**
  98073. * Returns all vertex buffers
  98074. * @return an object holding all vertex buffers indexed by kind
  98075. */
  98076. getVertexBuffers(): Nullable<{
  98077. [key: string]: VertexBuffer;
  98078. }>;
  98079. /**
  98080. * Gets a boolean indicating if specific vertex buffer is present
  98081. * @param kind defines the data kind (Position, normal, etc...)
  98082. * @returns true if data is present
  98083. */
  98084. isVerticesDataPresent(kind: string): boolean;
  98085. /**
  98086. * Gets a list of all attached data kinds (Position, normal, etc...)
  98087. * @returns a list of string containing all kinds
  98088. */
  98089. getVerticesDataKinds(): string[];
  98090. /**
  98091. * Update index buffer
  98092. * @param indices defines the indices to store in the index buffer
  98093. * @param offset defines the offset in the target buffer where to store the data
  98094. * @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)
  98095. */
  98096. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98097. /**
  98098. * Creates a new index buffer
  98099. * @param indices defines the indices to store in the index buffer
  98100. * @param totalVertices defines the total number of vertices (could be null)
  98101. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98102. */
  98103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98104. /**
  98105. * Return the total number of indices
  98106. * @returns the total number of indices
  98107. */
  98108. getTotalIndices(): number;
  98109. /**
  98110. * Gets the index buffer array
  98111. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98112. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98113. * @returns the index buffer array
  98114. */
  98115. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98116. /**
  98117. * Gets the index buffer
  98118. * @return the index buffer
  98119. */
  98120. getIndexBuffer(): Nullable<DataBuffer>;
  98121. /** @hidden */
  98122. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98123. /**
  98124. * Release the associated resources for a specific mesh
  98125. * @param mesh defines the source mesh
  98126. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98127. */
  98128. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98129. /**
  98130. * Apply current geometry to a given mesh
  98131. * @param mesh defines the mesh to apply geometry to
  98132. */
  98133. applyToMesh(mesh: Mesh): void;
  98134. private _updateExtend;
  98135. private _applyToMesh;
  98136. private notifyUpdate;
  98137. /**
  98138. * Load the geometry if it was flagged as delay loaded
  98139. * @param scene defines the hosting scene
  98140. * @param onLoaded defines a callback called when the geometry is loaded
  98141. */
  98142. load(scene: Scene, onLoaded?: () => void): void;
  98143. private _queueLoad;
  98144. /**
  98145. * Invert the geometry to move from a right handed system to a left handed one.
  98146. */
  98147. toLeftHanded(): void;
  98148. /** @hidden */
  98149. _resetPointsArrayCache(): void;
  98150. /** @hidden */
  98151. _generatePointsArray(): boolean;
  98152. /**
  98153. * Gets a value indicating if the geometry is disposed
  98154. * @returns true if the geometry was disposed
  98155. */
  98156. isDisposed(): boolean;
  98157. private _disposeVertexArrayObjects;
  98158. /**
  98159. * Free all associated resources
  98160. */
  98161. dispose(): void;
  98162. /**
  98163. * Clone the current geometry into a new geometry
  98164. * @param id defines the unique ID of the new geometry
  98165. * @returns a new geometry object
  98166. */
  98167. copy(id: string): Geometry;
  98168. /**
  98169. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98170. * @return a JSON representation of the current geometry data (without the vertices data)
  98171. */
  98172. serialize(): any;
  98173. private toNumberArray;
  98174. /**
  98175. * Serialize all vertices data into a JSON oject
  98176. * @returns a JSON representation of the current geometry data
  98177. */
  98178. serializeVerticeData(): any;
  98179. /**
  98180. * Extracts a clone of a mesh geometry
  98181. * @param mesh defines the source mesh
  98182. * @param id defines the unique ID of the new geometry object
  98183. * @returns the new geometry object
  98184. */
  98185. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98186. /**
  98187. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98188. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98189. * Be aware Math.random() could cause collisions, but:
  98190. * "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"
  98191. * @returns a string containing a new GUID
  98192. */
  98193. static RandomId(): string;
  98194. /** @hidden */
  98195. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98196. private static _CleanMatricesWeights;
  98197. /**
  98198. * Create a new geometry from persisted data (Using .babylon file format)
  98199. * @param parsedVertexData defines the persisted data
  98200. * @param scene defines the hosting scene
  98201. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98202. * @returns the new geometry object
  98203. */
  98204. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98205. }
  98206. }
  98207. declare module BABYLON {
  98208. /**
  98209. * Define an interface for all classes that will get and set the data on vertices
  98210. */
  98211. export interface IGetSetVerticesData {
  98212. /**
  98213. * Gets a boolean indicating if specific vertex data is present
  98214. * @param kind defines the vertex data kind to use
  98215. * @returns true is data kind is present
  98216. */
  98217. isVerticesDataPresent(kind: string): boolean;
  98218. /**
  98219. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98220. * @param kind defines the data kind (Position, normal, etc...)
  98221. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98222. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98223. * @returns a float array containing vertex data
  98224. */
  98225. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98226. /**
  98227. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98228. * @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.
  98229. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98230. * @returns the indices array or an empty array if the mesh has no geometry
  98231. */
  98232. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98233. /**
  98234. * Set specific vertex data
  98235. * @param kind defines the data kind (Position, normal, etc...)
  98236. * @param data defines the vertex data to use
  98237. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98238. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98239. */
  98240. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98241. /**
  98242. * Update a specific associated vertex buffer
  98243. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98244. * - VertexBuffer.PositionKind
  98245. * - VertexBuffer.UVKind
  98246. * - VertexBuffer.UV2Kind
  98247. * - VertexBuffer.UV3Kind
  98248. * - VertexBuffer.UV4Kind
  98249. * - VertexBuffer.UV5Kind
  98250. * - VertexBuffer.UV6Kind
  98251. * - VertexBuffer.ColorKind
  98252. * - VertexBuffer.MatricesIndicesKind
  98253. * - VertexBuffer.MatricesIndicesExtraKind
  98254. * - VertexBuffer.MatricesWeightsKind
  98255. * - VertexBuffer.MatricesWeightsExtraKind
  98256. * @param data defines the data source
  98257. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98258. * @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)
  98259. */
  98260. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98261. /**
  98262. * Creates a new index buffer
  98263. * @param indices defines the indices to store in the index buffer
  98264. * @param totalVertices defines the total number of vertices (could be null)
  98265. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98266. */
  98267. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98268. }
  98269. /**
  98270. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98271. */
  98272. export class VertexData {
  98273. /**
  98274. * Mesh side orientation : usually the external or front surface
  98275. */
  98276. static readonly FRONTSIDE: number;
  98277. /**
  98278. * Mesh side orientation : usually the internal or back surface
  98279. */
  98280. static readonly BACKSIDE: number;
  98281. /**
  98282. * Mesh side orientation : both internal and external or front and back surfaces
  98283. */
  98284. static readonly DOUBLESIDE: number;
  98285. /**
  98286. * Mesh side orientation : by default, `FRONTSIDE`
  98287. */
  98288. static readonly DEFAULTSIDE: number;
  98289. /**
  98290. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98291. */
  98292. positions: Nullable<FloatArray>;
  98293. /**
  98294. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98295. */
  98296. normals: Nullable<FloatArray>;
  98297. /**
  98298. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98299. */
  98300. tangents: Nullable<FloatArray>;
  98301. /**
  98302. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98303. */
  98304. uvs: Nullable<FloatArray>;
  98305. /**
  98306. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98307. */
  98308. uvs2: Nullable<FloatArray>;
  98309. /**
  98310. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98311. */
  98312. uvs3: Nullable<FloatArray>;
  98313. /**
  98314. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98315. */
  98316. uvs4: Nullable<FloatArray>;
  98317. /**
  98318. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98319. */
  98320. uvs5: Nullable<FloatArray>;
  98321. /**
  98322. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98323. */
  98324. uvs6: Nullable<FloatArray>;
  98325. /**
  98326. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98327. */
  98328. colors: Nullable<FloatArray>;
  98329. /**
  98330. * 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).
  98331. */
  98332. matricesIndices: Nullable<FloatArray>;
  98333. /**
  98334. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98335. */
  98336. matricesWeights: Nullable<FloatArray>;
  98337. /**
  98338. * An array extending the number of possible indices
  98339. */
  98340. matricesIndicesExtra: Nullable<FloatArray>;
  98341. /**
  98342. * An array extending the number of possible weights when the number of indices is extended
  98343. */
  98344. matricesWeightsExtra: Nullable<FloatArray>;
  98345. /**
  98346. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98347. */
  98348. indices: Nullable<IndicesArray>;
  98349. /**
  98350. * Uses the passed data array to set the set the values for the specified kind of data
  98351. * @param data a linear array of floating numbers
  98352. * @param kind the type of data that is being set, eg positions, colors etc
  98353. */
  98354. set(data: FloatArray, kind: string): void;
  98355. /**
  98356. * Associates the vertexData to the passed Mesh.
  98357. * Sets it as updatable or not (default `false`)
  98358. * @param mesh the mesh the vertexData is applied to
  98359. * @param updatable when used and having the value true allows new data to update the vertexData
  98360. * @returns the VertexData
  98361. */
  98362. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98363. /**
  98364. * Associates the vertexData to the passed Geometry.
  98365. * Sets it as updatable or not (default `false`)
  98366. * @param geometry the geometry the vertexData is applied to
  98367. * @param updatable when used and having the value true allows new data to update the vertexData
  98368. * @returns VertexData
  98369. */
  98370. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98371. /**
  98372. * Updates the associated mesh
  98373. * @param mesh the mesh to be updated
  98374. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98375. * @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
  98376. * @returns VertexData
  98377. */
  98378. updateMesh(mesh: Mesh): VertexData;
  98379. /**
  98380. * Updates the associated geometry
  98381. * @param geometry the geometry to be updated
  98382. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98383. * @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
  98384. * @returns VertexData.
  98385. */
  98386. updateGeometry(geometry: Geometry): VertexData;
  98387. private _applyTo;
  98388. private _update;
  98389. /**
  98390. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98391. * @param matrix the transforming matrix
  98392. * @returns the VertexData
  98393. */
  98394. transform(matrix: Matrix): VertexData;
  98395. /**
  98396. * Merges the passed VertexData into the current one
  98397. * @param other the VertexData to be merged into the current one
  98398. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98399. * @returns the modified VertexData
  98400. */
  98401. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98402. private _mergeElement;
  98403. private _validate;
  98404. /**
  98405. * Serializes the VertexData
  98406. * @returns a serialized object
  98407. */
  98408. serialize(): any;
  98409. /**
  98410. * Extracts the vertexData from a mesh
  98411. * @param mesh the mesh from which to extract the VertexData
  98412. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98413. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98414. * @returns the object VertexData associated to the passed mesh
  98415. */
  98416. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98417. /**
  98418. * Extracts the vertexData from the geometry
  98419. * @param geometry the geometry from which to extract the VertexData
  98420. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98421. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98422. * @returns the object VertexData associated to the passed mesh
  98423. */
  98424. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98425. private static _ExtractFrom;
  98426. /**
  98427. * Creates the VertexData for a Ribbon
  98428. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98429. * * pathArray array of paths, each of which an array of successive Vector3
  98430. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98431. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98432. * * 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
  98433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98434. * * 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)
  98435. * * 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)
  98436. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98437. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98438. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98439. * @returns the VertexData of the ribbon
  98440. */
  98441. static CreateRibbon(options: {
  98442. pathArray: Vector3[][];
  98443. closeArray?: boolean;
  98444. closePath?: boolean;
  98445. offset?: number;
  98446. sideOrientation?: number;
  98447. frontUVs?: Vector4;
  98448. backUVs?: Vector4;
  98449. invertUV?: boolean;
  98450. uvs?: Vector2[];
  98451. colors?: Color4[];
  98452. }): VertexData;
  98453. /**
  98454. * Creates the VertexData for a box
  98455. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98456. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98457. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98458. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98459. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98460. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98461. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98463. * * 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)
  98464. * * 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)
  98465. * @returns the VertexData of the box
  98466. */
  98467. static CreateBox(options: {
  98468. size?: number;
  98469. width?: number;
  98470. height?: number;
  98471. depth?: number;
  98472. faceUV?: Vector4[];
  98473. faceColors?: Color4[];
  98474. sideOrientation?: number;
  98475. frontUVs?: Vector4;
  98476. backUVs?: Vector4;
  98477. }): VertexData;
  98478. /**
  98479. * Creates the VertexData for a tiled box
  98480. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98481. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98482. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98483. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98485. * @returns the VertexData of the box
  98486. */
  98487. static CreateTiledBox(options: {
  98488. pattern?: number;
  98489. width?: number;
  98490. height?: number;
  98491. depth?: number;
  98492. tileSize?: number;
  98493. tileWidth?: number;
  98494. tileHeight?: number;
  98495. alignHorizontal?: number;
  98496. alignVertical?: number;
  98497. faceUV?: Vector4[];
  98498. faceColors?: Color4[];
  98499. sideOrientation?: number;
  98500. }): VertexData;
  98501. /**
  98502. * Creates the VertexData for a tiled plane
  98503. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98504. * * pattern a limited pattern arrangement depending on the number
  98505. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98506. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98507. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98509. * * 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)
  98510. * * 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)
  98511. * @returns the VertexData of the tiled plane
  98512. */
  98513. static CreateTiledPlane(options: {
  98514. pattern?: number;
  98515. tileSize?: number;
  98516. tileWidth?: number;
  98517. tileHeight?: number;
  98518. size?: number;
  98519. width?: number;
  98520. height?: number;
  98521. alignHorizontal?: number;
  98522. alignVertical?: number;
  98523. sideOrientation?: number;
  98524. frontUVs?: Vector4;
  98525. backUVs?: Vector4;
  98526. }): VertexData;
  98527. /**
  98528. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98530. * * segments sets the number of horizontal strips optional, default 32
  98531. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98532. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98533. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98534. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98535. * * 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
  98536. * * 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
  98537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98538. * * 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)
  98539. * * 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)
  98540. * @returns the VertexData of the ellipsoid
  98541. */
  98542. static CreateSphere(options: {
  98543. segments?: number;
  98544. diameter?: number;
  98545. diameterX?: number;
  98546. diameterY?: number;
  98547. diameterZ?: number;
  98548. arc?: number;
  98549. slice?: number;
  98550. sideOrientation?: number;
  98551. frontUVs?: Vector4;
  98552. backUVs?: Vector4;
  98553. }): VertexData;
  98554. /**
  98555. * Creates the VertexData for a cylinder, cone or prism
  98556. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98557. * * height sets the height (y direction) of the cylinder, optional, default 2
  98558. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98559. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98560. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98561. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98562. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98563. * * 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
  98564. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98565. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98566. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98567. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98569. * * 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)
  98570. * * 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)
  98571. * @returns the VertexData of the cylinder, cone or prism
  98572. */
  98573. static CreateCylinder(options: {
  98574. height?: number;
  98575. diameterTop?: number;
  98576. diameterBottom?: number;
  98577. diameter?: number;
  98578. tessellation?: number;
  98579. subdivisions?: number;
  98580. arc?: number;
  98581. faceColors?: Color4[];
  98582. faceUV?: Vector4[];
  98583. hasRings?: boolean;
  98584. enclose?: boolean;
  98585. sideOrientation?: number;
  98586. frontUVs?: Vector4;
  98587. backUVs?: Vector4;
  98588. }): VertexData;
  98589. /**
  98590. * Creates the VertexData for a torus
  98591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98592. * * diameter the diameter of the torus, optional default 1
  98593. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98594. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98596. * * 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)
  98597. * * 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)
  98598. * @returns the VertexData of the torus
  98599. */
  98600. static CreateTorus(options: {
  98601. diameter?: number;
  98602. thickness?: number;
  98603. tessellation?: number;
  98604. sideOrientation?: number;
  98605. frontUVs?: Vector4;
  98606. backUVs?: Vector4;
  98607. }): VertexData;
  98608. /**
  98609. * Creates the VertexData of the LineSystem
  98610. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98611. * - lines an array of lines, each line being an array of successive Vector3
  98612. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98613. * @returns the VertexData of the LineSystem
  98614. */
  98615. static CreateLineSystem(options: {
  98616. lines: Vector3[][];
  98617. colors?: Nullable<Color4[][]>;
  98618. }): VertexData;
  98619. /**
  98620. * Create the VertexData for a DashedLines
  98621. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98622. * - points an array successive Vector3
  98623. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98624. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98625. * - dashNb the intended total number of dashes, optional, default 200
  98626. * @returns the VertexData for the DashedLines
  98627. */
  98628. static CreateDashedLines(options: {
  98629. points: Vector3[];
  98630. dashSize?: number;
  98631. gapSize?: number;
  98632. dashNb?: number;
  98633. }): VertexData;
  98634. /**
  98635. * Creates the VertexData for a Ground
  98636. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98637. * - width the width (x direction) of the ground, optional, default 1
  98638. * - height the height (z direction) of the ground, optional, default 1
  98639. * - subdivisions the number of subdivisions per side, optional, default 1
  98640. * @returns the VertexData of the Ground
  98641. */
  98642. static CreateGround(options: {
  98643. width?: number;
  98644. height?: number;
  98645. subdivisions?: number;
  98646. subdivisionsX?: number;
  98647. subdivisionsY?: number;
  98648. }): VertexData;
  98649. /**
  98650. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98651. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98652. * * xmin the ground minimum X coordinate, optional, default -1
  98653. * * zmin the ground minimum Z coordinate, optional, default -1
  98654. * * xmax the ground maximum X coordinate, optional, default 1
  98655. * * zmax the ground maximum Z coordinate, optional, default 1
  98656. * * 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}
  98657. * * 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}
  98658. * @returns the VertexData of the TiledGround
  98659. */
  98660. static CreateTiledGround(options: {
  98661. xmin: number;
  98662. zmin: number;
  98663. xmax: number;
  98664. zmax: number;
  98665. subdivisions?: {
  98666. w: number;
  98667. h: number;
  98668. };
  98669. precision?: {
  98670. w: number;
  98671. h: number;
  98672. };
  98673. }): VertexData;
  98674. /**
  98675. * Creates the VertexData of the Ground designed from a heightmap
  98676. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98677. * * width the width (x direction) of the ground
  98678. * * height the height (z direction) of the ground
  98679. * * subdivisions the number of subdivisions per side
  98680. * * minHeight the minimum altitude on the ground, optional, default 0
  98681. * * maxHeight the maximum altitude on the ground, optional default 1
  98682. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98683. * * buffer the array holding the image color data
  98684. * * bufferWidth the width of image
  98685. * * bufferHeight the height of image
  98686. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98687. * @returns the VertexData of the Ground designed from a heightmap
  98688. */
  98689. static CreateGroundFromHeightMap(options: {
  98690. width: number;
  98691. height: number;
  98692. subdivisions: number;
  98693. minHeight: number;
  98694. maxHeight: number;
  98695. colorFilter: Color3;
  98696. buffer: Uint8Array;
  98697. bufferWidth: number;
  98698. bufferHeight: number;
  98699. alphaFilter: number;
  98700. }): VertexData;
  98701. /**
  98702. * Creates the VertexData for a Plane
  98703. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98704. * * size sets the width and height of the plane to the value of size, optional default 1
  98705. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98706. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98708. * * 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)
  98709. * * 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)
  98710. * @returns the VertexData of the box
  98711. */
  98712. static CreatePlane(options: {
  98713. size?: number;
  98714. width?: number;
  98715. height?: number;
  98716. sideOrientation?: number;
  98717. frontUVs?: Vector4;
  98718. backUVs?: Vector4;
  98719. }): VertexData;
  98720. /**
  98721. * Creates the VertexData of the Disc or regular Polygon
  98722. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98723. * * radius the radius of the disc, optional default 0.5
  98724. * * tessellation the number of polygon sides, optional, default 64
  98725. * * 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
  98726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98727. * * 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)
  98728. * * 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)
  98729. * @returns the VertexData of the box
  98730. */
  98731. static CreateDisc(options: {
  98732. radius?: number;
  98733. tessellation?: number;
  98734. arc?: number;
  98735. sideOrientation?: number;
  98736. frontUVs?: Vector4;
  98737. backUVs?: Vector4;
  98738. }): VertexData;
  98739. /**
  98740. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  98741. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  98742. * @param polygon a mesh built from polygonTriangulation.build()
  98743. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98744. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98745. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98746. * @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)
  98747. * @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)
  98748. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  98749. * @returns the VertexData of the Polygon
  98750. */
  98751. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  98752. /**
  98753. * Creates the VertexData of the IcoSphere
  98754. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  98755. * * radius the radius of the IcoSphere, optional default 1
  98756. * * radiusX allows stretching in the x direction, optional, default radius
  98757. * * radiusY allows stretching in the y direction, optional, default radius
  98758. * * radiusZ allows stretching in the z direction, optional, default radius
  98759. * * flat when true creates a flat shaded mesh, optional, default true
  98760. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98762. * * 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)
  98763. * * 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)
  98764. * @returns the VertexData of the IcoSphere
  98765. */
  98766. static CreateIcoSphere(options: {
  98767. radius?: number;
  98768. radiusX?: number;
  98769. radiusY?: number;
  98770. radiusZ?: number;
  98771. flat?: boolean;
  98772. subdivisions?: number;
  98773. sideOrientation?: number;
  98774. frontUVs?: Vector4;
  98775. backUVs?: Vector4;
  98776. }): VertexData;
  98777. /**
  98778. * Creates the VertexData for a Polyhedron
  98779. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  98780. * * type provided types are:
  98781. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  98782. * * 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)
  98783. * * size the size of the IcoSphere, optional default 1
  98784. * * sizeX allows stretching in the x direction, optional, default size
  98785. * * sizeY allows stretching in the y direction, optional, default size
  98786. * * sizeZ allows stretching in the z direction, optional, default size
  98787. * * 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
  98788. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98789. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98790. * * flat when true creates a flat shaded mesh, optional, default true
  98791. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98793. * * 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)
  98794. * * 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)
  98795. * @returns the VertexData of the Polyhedron
  98796. */
  98797. static CreatePolyhedron(options: {
  98798. type?: number;
  98799. size?: number;
  98800. sizeX?: number;
  98801. sizeY?: number;
  98802. sizeZ?: number;
  98803. custom?: any;
  98804. faceUV?: Vector4[];
  98805. faceColors?: Color4[];
  98806. flat?: boolean;
  98807. sideOrientation?: number;
  98808. frontUVs?: Vector4;
  98809. backUVs?: Vector4;
  98810. }): VertexData;
  98811. /**
  98812. * Creates the VertexData for a TorusKnot
  98813. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  98814. * * radius the radius of the torus knot, optional, default 2
  98815. * * tube the thickness of the tube, optional, default 0.5
  98816. * * radialSegments the number of sides on each tube segments, optional, default 32
  98817. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  98818. * * p the number of windings around the z axis, optional, default 2
  98819. * * q the number of windings around the x axis, optional, default 3
  98820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98821. * * 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)
  98822. * * 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)
  98823. * @returns the VertexData of the Torus Knot
  98824. */
  98825. static CreateTorusKnot(options: {
  98826. radius?: number;
  98827. tube?: number;
  98828. radialSegments?: number;
  98829. tubularSegments?: number;
  98830. p?: number;
  98831. q?: number;
  98832. sideOrientation?: number;
  98833. frontUVs?: Vector4;
  98834. backUVs?: Vector4;
  98835. }): VertexData;
  98836. /**
  98837. * Compute normals for given positions and indices
  98838. * @param positions an array of vertex positions, [...., x, y, z, ......]
  98839. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  98840. * @param normals an array of vertex normals, [...., x, y, z, ......]
  98841. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  98842. * * facetNormals : optional array of facet normals (vector3)
  98843. * * facetPositions : optional array of facet positions (vector3)
  98844. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  98845. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  98846. * * bInfo : optional bounding info, required for facetPartitioning computation
  98847. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  98848. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  98849. * * useRightHandedSystem: optional boolean to for right handed system computation
  98850. * * depthSort : optional boolean to enable the facet depth sort computation
  98851. * * distanceTo : optional Vector3 to compute the facet depth from this location
  98852. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  98853. */
  98854. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  98855. facetNormals?: any;
  98856. facetPositions?: any;
  98857. facetPartitioning?: any;
  98858. ratio?: number;
  98859. bInfo?: any;
  98860. bbSize?: Vector3;
  98861. subDiv?: any;
  98862. useRightHandedSystem?: boolean;
  98863. depthSort?: boolean;
  98864. distanceTo?: Vector3;
  98865. depthSortedFacets?: any;
  98866. }): void;
  98867. /** @hidden */
  98868. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  98869. /**
  98870. * Applies VertexData created from the imported parameters to the geometry
  98871. * @param parsedVertexData the parsed data from an imported file
  98872. * @param geometry the geometry to apply the VertexData to
  98873. */
  98874. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  98875. }
  98876. }
  98877. declare module BABYLON {
  98878. /**
  98879. * Defines a target to use with MorphTargetManager
  98880. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98881. */
  98882. export class MorphTarget implements IAnimatable {
  98883. /** defines the name of the target */
  98884. name: string;
  98885. /**
  98886. * Gets or sets the list of animations
  98887. */
  98888. animations: Animation[];
  98889. private _scene;
  98890. private _positions;
  98891. private _normals;
  98892. private _tangents;
  98893. private _uvs;
  98894. private _influence;
  98895. private _uniqueId;
  98896. /**
  98897. * Observable raised when the influence changes
  98898. */
  98899. onInfluenceChanged: Observable<boolean>;
  98900. /** @hidden */
  98901. _onDataLayoutChanged: Observable<void>;
  98902. /**
  98903. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  98904. */
  98905. get influence(): number;
  98906. set influence(influence: number);
  98907. /**
  98908. * Gets or sets the id of the morph Target
  98909. */
  98910. id: string;
  98911. private _animationPropertiesOverride;
  98912. /**
  98913. * Gets or sets the animation properties override
  98914. */
  98915. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  98916. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  98917. /**
  98918. * Creates a new MorphTarget
  98919. * @param name defines the name of the target
  98920. * @param influence defines the influence to use
  98921. * @param scene defines the scene the morphtarget belongs to
  98922. */
  98923. constructor(
  98924. /** defines the name of the target */
  98925. name: string, influence?: number, scene?: Nullable<Scene>);
  98926. /**
  98927. * Gets the unique ID of this manager
  98928. */
  98929. get uniqueId(): number;
  98930. /**
  98931. * Gets a boolean defining if the target contains position data
  98932. */
  98933. get hasPositions(): boolean;
  98934. /**
  98935. * Gets a boolean defining if the target contains normal data
  98936. */
  98937. get hasNormals(): boolean;
  98938. /**
  98939. * Gets a boolean defining if the target contains tangent data
  98940. */
  98941. get hasTangents(): boolean;
  98942. /**
  98943. * Gets a boolean defining if the target contains texture coordinates data
  98944. */
  98945. get hasUVs(): boolean;
  98946. /**
  98947. * Affects position data to this target
  98948. * @param data defines the position data to use
  98949. */
  98950. setPositions(data: Nullable<FloatArray>): void;
  98951. /**
  98952. * Gets the position data stored in this target
  98953. * @returns a FloatArray containing the position data (or null if not present)
  98954. */
  98955. getPositions(): Nullable<FloatArray>;
  98956. /**
  98957. * Affects normal data to this target
  98958. * @param data defines the normal data to use
  98959. */
  98960. setNormals(data: Nullable<FloatArray>): void;
  98961. /**
  98962. * Gets the normal data stored in this target
  98963. * @returns a FloatArray containing the normal data (or null if not present)
  98964. */
  98965. getNormals(): Nullable<FloatArray>;
  98966. /**
  98967. * Affects tangent data to this target
  98968. * @param data defines the tangent data to use
  98969. */
  98970. setTangents(data: Nullable<FloatArray>): void;
  98971. /**
  98972. * Gets the tangent data stored in this target
  98973. * @returns a FloatArray containing the tangent data (or null if not present)
  98974. */
  98975. getTangents(): Nullable<FloatArray>;
  98976. /**
  98977. * Affects texture coordinates data to this target
  98978. * @param data defines the texture coordinates data to use
  98979. */
  98980. setUVs(data: Nullable<FloatArray>): void;
  98981. /**
  98982. * Gets the texture coordinates data stored in this target
  98983. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  98984. */
  98985. getUVs(): Nullable<FloatArray>;
  98986. /**
  98987. * Clone the current target
  98988. * @returns a new MorphTarget
  98989. */
  98990. clone(): MorphTarget;
  98991. /**
  98992. * Serializes the current target into a Serialization object
  98993. * @returns the serialized object
  98994. */
  98995. serialize(): any;
  98996. /**
  98997. * Returns the string "MorphTarget"
  98998. * @returns "MorphTarget"
  98999. */
  99000. getClassName(): string;
  99001. /**
  99002. * Creates a new target from serialized data
  99003. * @param serializationObject defines the serialized data to use
  99004. * @returns a new MorphTarget
  99005. */
  99006. static Parse(serializationObject: any): MorphTarget;
  99007. /**
  99008. * Creates a MorphTarget from mesh data
  99009. * @param mesh defines the source mesh
  99010. * @param name defines the name to use for the new target
  99011. * @param influence defines the influence to attach to the target
  99012. * @returns a new MorphTarget
  99013. */
  99014. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99015. }
  99016. }
  99017. declare module BABYLON {
  99018. /**
  99019. * This class is used to deform meshes using morphing between different targets
  99020. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99021. */
  99022. export class MorphTargetManager {
  99023. private _targets;
  99024. private _targetInfluenceChangedObservers;
  99025. private _targetDataLayoutChangedObservers;
  99026. private _activeTargets;
  99027. private _scene;
  99028. private _influences;
  99029. private _supportsNormals;
  99030. private _supportsTangents;
  99031. private _supportsUVs;
  99032. private _vertexCount;
  99033. private _uniqueId;
  99034. private _tempInfluences;
  99035. /**
  99036. * Gets or sets a boolean indicating if normals must be morphed
  99037. */
  99038. enableNormalMorphing: boolean;
  99039. /**
  99040. * Gets or sets a boolean indicating if tangents must be morphed
  99041. */
  99042. enableTangentMorphing: boolean;
  99043. /**
  99044. * Gets or sets a boolean indicating if UV must be morphed
  99045. */
  99046. enableUVMorphing: boolean;
  99047. /**
  99048. * Creates a new MorphTargetManager
  99049. * @param scene defines the current scene
  99050. */
  99051. constructor(scene?: Nullable<Scene>);
  99052. /**
  99053. * Gets the unique ID of this manager
  99054. */
  99055. get uniqueId(): number;
  99056. /**
  99057. * Gets the number of vertices handled by this manager
  99058. */
  99059. get vertexCount(): number;
  99060. /**
  99061. * Gets a boolean indicating if this manager supports morphing of normals
  99062. */
  99063. get supportsNormals(): boolean;
  99064. /**
  99065. * Gets a boolean indicating if this manager supports morphing of tangents
  99066. */
  99067. get supportsTangents(): boolean;
  99068. /**
  99069. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99070. */
  99071. get supportsUVs(): boolean;
  99072. /**
  99073. * Gets the number of targets stored in this manager
  99074. */
  99075. get numTargets(): number;
  99076. /**
  99077. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99078. */
  99079. get numInfluencers(): number;
  99080. /**
  99081. * Gets the list of influences (one per target)
  99082. */
  99083. get influences(): Float32Array;
  99084. /**
  99085. * Gets the active target at specified index. An active target is a target with an influence > 0
  99086. * @param index defines the index to check
  99087. * @returns the requested target
  99088. */
  99089. getActiveTarget(index: number): MorphTarget;
  99090. /**
  99091. * Gets the target at specified index
  99092. * @param index defines the index to check
  99093. * @returns the requested target
  99094. */
  99095. getTarget(index: number): MorphTarget;
  99096. /**
  99097. * Add a new target to this manager
  99098. * @param target defines the target to add
  99099. */
  99100. addTarget(target: MorphTarget): void;
  99101. /**
  99102. * Removes a target from the manager
  99103. * @param target defines the target to remove
  99104. */
  99105. removeTarget(target: MorphTarget): void;
  99106. /**
  99107. * Clone the current manager
  99108. * @returns a new MorphTargetManager
  99109. */
  99110. clone(): MorphTargetManager;
  99111. /**
  99112. * Serializes the current manager into a Serialization object
  99113. * @returns the serialized object
  99114. */
  99115. serialize(): any;
  99116. private _syncActiveTargets;
  99117. /**
  99118. * Syncrhonize the targets with all the meshes using this morph target manager
  99119. */
  99120. synchronize(): void;
  99121. /**
  99122. * Creates a new MorphTargetManager from serialized data
  99123. * @param serializationObject defines the serialized data
  99124. * @param scene defines the hosting scene
  99125. * @returns the new MorphTargetManager
  99126. */
  99127. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99128. }
  99129. }
  99130. declare module BABYLON {
  99131. /**
  99132. * Class used to represent a specific level of detail of a mesh
  99133. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99134. */
  99135. export class MeshLODLevel {
  99136. /** Defines the distance where this level should start being displayed */
  99137. distance: number;
  99138. /** Defines the mesh to use to render this level */
  99139. mesh: Nullable<Mesh>;
  99140. /**
  99141. * Creates a new LOD level
  99142. * @param distance defines the distance where this level should star being displayed
  99143. * @param mesh defines the mesh to use to render this level
  99144. */
  99145. constructor(
  99146. /** Defines the distance where this level should start being displayed */
  99147. distance: number,
  99148. /** Defines the mesh to use to render this level */
  99149. mesh: Nullable<Mesh>);
  99150. }
  99151. }
  99152. declare module BABYLON {
  99153. /**
  99154. * Mesh representing the gorund
  99155. */
  99156. export class GroundMesh extends Mesh {
  99157. /** If octree should be generated */
  99158. generateOctree: boolean;
  99159. private _heightQuads;
  99160. /** @hidden */
  99161. _subdivisionsX: number;
  99162. /** @hidden */
  99163. _subdivisionsY: number;
  99164. /** @hidden */
  99165. _width: number;
  99166. /** @hidden */
  99167. _height: number;
  99168. /** @hidden */
  99169. _minX: number;
  99170. /** @hidden */
  99171. _maxX: number;
  99172. /** @hidden */
  99173. _minZ: number;
  99174. /** @hidden */
  99175. _maxZ: number;
  99176. constructor(name: string, scene: Scene);
  99177. /**
  99178. * "GroundMesh"
  99179. * @returns "GroundMesh"
  99180. */
  99181. getClassName(): string;
  99182. /**
  99183. * The minimum of x and y subdivisions
  99184. */
  99185. get subdivisions(): number;
  99186. /**
  99187. * X subdivisions
  99188. */
  99189. get subdivisionsX(): number;
  99190. /**
  99191. * Y subdivisions
  99192. */
  99193. get subdivisionsY(): number;
  99194. /**
  99195. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99196. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99197. * @param chunksCount the number of subdivisions for x and y
  99198. * @param octreeBlocksSize (Default: 32)
  99199. */
  99200. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99201. /**
  99202. * Returns a height (y) value in the Worl system :
  99203. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99204. * @param x x coordinate
  99205. * @param z z coordinate
  99206. * @returns the ground y position if (x, z) are outside the ground surface.
  99207. */
  99208. getHeightAtCoordinates(x: number, z: number): number;
  99209. /**
  99210. * Returns a normalized vector (Vector3) orthogonal to the ground
  99211. * at the ground coordinates (x, z) expressed in the World system.
  99212. * @param x x coordinate
  99213. * @param z z coordinate
  99214. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99215. */
  99216. getNormalAtCoordinates(x: number, z: number): Vector3;
  99217. /**
  99218. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99219. * at the ground coordinates (x, z) expressed in the World system.
  99220. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99221. * @param x x coordinate
  99222. * @param z z coordinate
  99223. * @param ref vector to store the result
  99224. * @returns the GroundMesh.
  99225. */
  99226. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99227. /**
  99228. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99229. * if the ground has been updated.
  99230. * This can be used in the render loop.
  99231. * @returns the GroundMesh.
  99232. */
  99233. updateCoordinateHeights(): GroundMesh;
  99234. private _getFacetAt;
  99235. private _initHeightQuads;
  99236. private _computeHeightQuads;
  99237. /**
  99238. * Serializes this ground mesh
  99239. * @param serializationObject object to write serialization to
  99240. */
  99241. serialize(serializationObject: any): void;
  99242. /**
  99243. * Parses a serialized ground mesh
  99244. * @param parsedMesh the serialized mesh
  99245. * @param scene the scene to create the ground mesh in
  99246. * @returns the created ground mesh
  99247. */
  99248. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99249. }
  99250. }
  99251. declare module BABYLON {
  99252. /**
  99253. * Interface for Physics-Joint data
  99254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99255. */
  99256. export interface PhysicsJointData {
  99257. /**
  99258. * The main pivot of the joint
  99259. */
  99260. mainPivot?: Vector3;
  99261. /**
  99262. * The connected pivot of the joint
  99263. */
  99264. connectedPivot?: Vector3;
  99265. /**
  99266. * The main axis of the joint
  99267. */
  99268. mainAxis?: Vector3;
  99269. /**
  99270. * The connected axis of the joint
  99271. */
  99272. connectedAxis?: Vector3;
  99273. /**
  99274. * The collision of the joint
  99275. */
  99276. collision?: boolean;
  99277. /**
  99278. * Native Oimo/Cannon/Energy data
  99279. */
  99280. nativeParams?: any;
  99281. }
  99282. /**
  99283. * This is a holder class for the physics joint created by the physics plugin
  99284. * It holds a set of functions to control the underlying joint
  99285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99286. */
  99287. export class PhysicsJoint {
  99288. /**
  99289. * The type of the physics joint
  99290. */
  99291. type: number;
  99292. /**
  99293. * The data for the physics joint
  99294. */
  99295. jointData: PhysicsJointData;
  99296. private _physicsJoint;
  99297. protected _physicsPlugin: IPhysicsEnginePlugin;
  99298. /**
  99299. * Initializes the physics joint
  99300. * @param type The type of the physics joint
  99301. * @param jointData The data for the physics joint
  99302. */
  99303. constructor(
  99304. /**
  99305. * The type of the physics joint
  99306. */
  99307. type: number,
  99308. /**
  99309. * The data for the physics joint
  99310. */
  99311. jointData: PhysicsJointData);
  99312. /**
  99313. * Gets the physics joint
  99314. */
  99315. get physicsJoint(): any;
  99316. /**
  99317. * Sets the physics joint
  99318. */
  99319. set physicsJoint(newJoint: any);
  99320. /**
  99321. * Sets the physics plugin
  99322. */
  99323. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99324. /**
  99325. * Execute a function that is physics-plugin specific.
  99326. * @param {Function} func the function that will be executed.
  99327. * It accepts two parameters: the physics world and the physics joint
  99328. */
  99329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99330. /**
  99331. * Distance-Joint type
  99332. */
  99333. static DistanceJoint: number;
  99334. /**
  99335. * Hinge-Joint type
  99336. */
  99337. static HingeJoint: number;
  99338. /**
  99339. * Ball-and-Socket joint type
  99340. */
  99341. static BallAndSocketJoint: number;
  99342. /**
  99343. * Wheel-Joint type
  99344. */
  99345. static WheelJoint: number;
  99346. /**
  99347. * Slider-Joint type
  99348. */
  99349. static SliderJoint: number;
  99350. /**
  99351. * Prismatic-Joint type
  99352. */
  99353. static PrismaticJoint: number;
  99354. /**
  99355. * Universal-Joint type
  99356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99357. */
  99358. static UniversalJoint: number;
  99359. /**
  99360. * Hinge-Joint 2 type
  99361. */
  99362. static Hinge2Joint: number;
  99363. /**
  99364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99365. */
  99366. static PointToPointJoint: number;
  99367. /**
  99368. * Spring-Joint type
  99369. */
  99370. static SpringJoint: number;
  99371. /**
  99372. * Lock-Joint type
  99373. */
  99374. static LockJoint: number;
  99375. }
  99376. /**
  99377. * A class representing a physics distance joint
  99378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99379. */
  99380. export class DistanceJoint extends PhysicsJoint {
  99381. /**
  99382. *
  99383. * @param jointData The data for the Distance-Joint
  99384. */
  99385. constructor(jointData: DistanceJointData);
  99386. /**
  99387. * Update the predefined distance.
  99388. * @param maxDistance The maximum preferred distance
  99389. * @param minDistance The minimum preferred distance
  99390. */
  99391. updateDistance(maxDistance: number, minDistance?: number): void;
  99392. }
  99393. /**
  99394. * Represents a Motor-Enabled Joint
  99395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99396. */
  99397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99398. /**
  99399. * Initializes the Motor-Enabled Joint
  99400. * @param type The type of the joint
  99401. * @param jointData The physica joint data for the joint
  99402. */
  99403. constructor(type: number, jointData: PhysicsJointData);
  99404. /**
  99405. * Set the motor values.
  99406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99407. * @param force the force to apply
  99408. * @param maxForce max force for this motor.
  99409. */
  99410. setMotor(force?: number, maxForce?: number): void;
  99411. /**
  99412. * Set the motor's limits.
  99413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99414. * @param upperLimit The upper limit of the motor
  99415. * @param lowerLimit The lower limit of the motor
  99416. */
  99417. setLimit(upperLimit: number, lowerLimit?: number): void;
  99418. }
  99419. /**
  99420. * This class represents a single physics Hinge-Joint
  99421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99422. */
  99423. export class HingeJoint extends MotorEnabledJoint {
  99424. /**
  99425. * Initializes the Hinge-Joint
  99426. * @param jointData The joint data for the Hinge-Joint
  99427. */
  99428. constructor(jointData: PhysicsJointData);
  99429. /**
  99430. * Set the motor values.
  99431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99432. * @param {number} force the force to apply
  99433. * @param {number} maxForce max force for this motor.
  99434. */
  99435. setMotor(force?: number, maxForce?: number): void;
  99436. /**
  99437. * Set the motor's limits.
  99438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99439. * @param upperLimit The upper limit of the motor
  99440. * @param lowerLimit The lower limit of the motor
  99441. */
  99442. setLimit(upperLimit: number, lowerLimit?: number): void;
  99443. }
  99444. /**
  99445. * This class represents a dual hinge physics joint (same as wheel joint)
  99446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99447. */
  99448. export class Hinge2Joint extends MotorEnabledJoint {
  99449. /**
  99450. * Initializes the Hinge2-Joint
  99451. * @param jointData The joint data for the Hinge2-Joint
  99452. */
  99453. constructor(jointData: PhysicsJointData);
  99454. /**
  99455. * Set the motor values.
  99456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99457. * @param {number} targetSpeed the speed the motor is to reach
  99458. * @param {number} maxForce max force for this motor.
  99459. * @param {motorIndex} the motor's index, 0 or 1.
  99460. */
  99461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99462. /**
  99463. * Set the motor limits.
  99464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99465. * @param {number} upperLimit the upper limit
  99466. * @param {number} lowerLimit lower limit
  99467. * @param {motorIndex} the motor's index, 0 or 1.
  99468. */
  99469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99470. }
  99471. /**
  99472. * Interface for a motor enabled joint
  99473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99474. */
  99475. export interface IMotorEnabledJoint {
  99476. /**
  99477. * Physics joint
  99478. */
  99479. physicsJoint: any;
  99480. /**
  99481. * Sets the motor of the motor-enabled joint
  99482. * @param force The force of the motor
  99483. * @param maxForce The maximum force of the motor
  99484. * @param motorIndex The index of the motor
  99485. */
  99486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99487. /**
  99488. * Sets the limit of the motor
  99489. * @param upperLimit The upper limit of the motor
  99490. * @param lowerLimit The lower limit of the motor
  99491. * @param motorIndex The index of the motor
  99492. */
  99493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99494. }
  99495. /**
  99496. * Joint data for a Distance-Joint
  99497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99498. */
  99499. export interface DistanceJointData extends PhysicsJointData {
  99500. /**
  99501. * Max distance the 2 joint objects can be apart
  99502. */
  99503. maxDistance: number;
  99504. }
  99505. /**
  99506. * Joint data from a spring joint
  99507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99508. */
  99509. export interface SpringJointData extends PhysicsJointData {
  99510. /**
  99511. * Length of the spring
  99512. */
  99513. length: number;
  99514. /**
  99515. * Stiffness of the spring
  99516. */
  99517. stiffness: number;
  99518. /**
  99519. * Damping of the spring
  99520. */
  99521. damping: number;
  99522. /** this callback will be called when applying the force to the impostors. */
  99523. forceApplicationCallback: () => void;
  99524. }
  99525. }
  99526. declare module BABYLON {
  99527. /**
  99528. * Holds the data for the raycast result
  99529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99530. */
  99531. export class PhysicsRaycastResult {
  99532. private _hasHit;
  99533. private _hitDistance;
  99534. private _hitNormalWorld;
  99535. private _hitPointWorld;
  99536. private _rayFromWorld;
  99537. private _rayToWorld;
  99538. /**
  99539. * Gets if there was a hit
  99540. */
  99541. get hasHit(): boolean;
  99542. /**
  99543. * Gets the distance from the hit
  99544. */
  99545. get hitDistance(): number;
  99546. /**
  99547. * Gets the hit normal/direction in the world
  99548. */
  99549. get hitNormalWorld(): Vector3;
  99550. /**
  99551. * Gets the hit point in the world
  99552. */
  99553. get hitPointWorld(): Vector3;
  99554. /**
  99555. * Gets the ray "start point" of the ray in the world
  99556. */
  99557. get rayFromWorld(): Vector3;
  99558. /**
  99559. * Gets the ray "end point" of the ray in the world
  99560. */
  99561. get rayToWorld(): Vector3;
  99562. /**
  99563. * Sets the hit data (normal & point in world space)
  99564. * @param hitNormalWorld defines the normal in world space
  99565. * @param hitPointWorld defines the point in world space
  99566. */
  99567. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99568. /**
  99569. * Sets the distance from the start point to the hit point
  99570. * @param distance
  99571. */
  99572. setHitDistance(distance: number): void;
  99573. /**
  99574. * Calculates the distance manually
  99575. */
  99576. calculateHitDistance(): void;
  99577. /**
  99578. * Resets all the values to default
  99579. * @param from The from point on world space
  99580. * @param to The to point on world space
  99581. */
  99582. reset(from?: Vector3, to?: Vector3): void;
  99583. }
  99584. /**
  99585. * Interface for the size containing width and height
  99586. */
  99587. interface IXYZ {
  99588. /**
  99589. * X
  99590. */
  99591. x: number;
  99592. /**
  99593. * Y
  99594. */
  99595. y: number;
  99596. /**
  99597. * Z
  99598. */
  99599. z: number;
  99600. }
  99601. }
  99602. declare module BABYLON {
  99603. /**
  99604. * Interface used to describe a physics joint
  99605. */
  99606. export interface PhysicsImpostorJoint {
  99607. /** Defines the main impostor to which the joint is linked */
  99608. mainImpostor: PhysicsImpostor;
  99609. /** Defines the impostor that is connected to the main impostor using this joint */
  99610. connectedImpostor: PhysicsImpostor;
  99611. /** Defines the joint itself */
  99612. joint: PhysicsJoint;
  99613. }
  99614. /** @hidden */
  99615. export interface IPhysicsEnginePlugin {
  99616. world: any;
  99617. name: string;
  99618. setGravity(gravity: Vector3): void;
  99619. setTimeStep(timeStep: number): void;
  99620. getTimeStep(): number;
  99621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99625. removePhysicsBody(impostor: PhysicsImpostor): void;
  99626. generateJoint(joint: PhysicsImpostorJoint): void;
  99627. removeJoint(joint: PhysicsImpostorJoint): void;
  99628. isSupported(): boolean;
  99629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99636. getBodyMass(impostor: PhysicsImpostor): number;
  99637. getBodyFriction(impostor: PhysicsImpostor): number;
  99638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99639. getBodyRestitution(impostor: PhysicsImpostor): number;
  99640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99641. getBodyPressure?(impostor: PhysicsImpostor): number;
  99642. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99643. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99644. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99645. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99646. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99647. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99648. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99649. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99650. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99651. sleepBody(impostor: PhysicsImpostor): void;
  99652. wakeUpBody(impostor: PhysicsImpostor): void;
  99653. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99655. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99657. getRadius(impostor: PhysicsImpostor): number;
  99658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99660. dispose(): void;
  99661. }
  99662. /**
  99663. * Interface used to define a physics engine
  99664. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99665. */
  99666. export interface IPhysicsEngine {
  99667. /**
  99668. * Gets the gravity vector used by the simulation
  99669. */
  99670. gravity: Vector3;
  99671. /**
  99672. * Sets the gravity vector used by the simulation
  99673. * @param gravity defines the gravity vector to use
  99674. */
  99675. setGravity(gravity: Vector3): void;
  99676. /**
  99677. * Set the time step of the physics engine.
  99678. * Default is 1/60.
  99679. * To slow it down, enter 1/600 for example.
  99680. * To speed it up, 1/30
  99681. * @param newTimeStep the new timestep to apply to this world.
  99682. */
  99683. setTimeStep(newTimeStep: number): void;
  99684. /**
  99685. * Get the time step of the physics engine.
  99686. * @returns the current time step
  99687. */
  99688. getTimeStep(): number;
  99689. /**
  99690. * Set the sub time step of the physics engine.
  99691. * Default is 0 meaning there is no sub steps
  99692. * To increase physics resolution precision, set a small value (like 1 ms)
  99693. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99694. */
  99695. setSubTimeStep(subTimeStep: number): void;
  99696. /**
  99697. * Get the sub time step of the physics engine.
  99698. * @returns the current sub time step
  99699. */
  99700. getSubTimeStep(): number;
  99701. /**
  99702. * Release all resources
  99703. */
  99704. dispose(): void;
  99705. /**
  99706. * Gets the name of the current physics plugin
  99707. * @returns the name of the plugin
  99708. */
  99709. getPhysicsPluginName(): string;
  99710. /**
  99711. * Adding a new impostor for the impostor tracking.
  99712. * This will be done by the impostor itself.
  99713. * @param impostor the impostor to add
  99714. */
  99715. addImpostor(impostor: PhysicsImpostor): void;
  99716. /**
  99717. * Remove an impostor from the engine.
  99718. * This impostor and its mesh will not longer be updated by the physics engine.
  99719. * @param impostor the impostor to remove
  99720. */
  99721. removeImpostor(impostor: PhysicsImpostor): void;
  99722. /**
  99723. * Add a joint to the physics engine
  99724. * @param mainImpostor defines the main impostor to which the joint is added.
  99725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99726. * @param joint defines the joint that will connect both impostors.
  99727. */
  99728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99729. /**
  99730. * Removes a joint from the simulation
  99731. * @param mainImpostor defines the impostor used with the joint
  99732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99733. * @param joint defines the joint to remove
  99734. */
  99735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99736. /**
  99737. * Gets the current plugin used to run the simulation
  99738. * @returns current plugin
  99739. */
  99740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  99741. /**
  99742. * Gets the list of physic impostors
  99743. * @returns an array of PhysicsImpostor
  99744. */
  99745. getImpostors(): Array<PhysicsImpostor>;
  99746. /**
  99747. * Gets the impostor for a physics enabled object
  99748. * @param object defines the object impersonated by the impostor
  99749. * @returns the PhysicsImpostor or null if not found
  99750. */
  99751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99752. /**
  99753. * Gets the impostor for a physics body object
  99754. * @param body defines physics body used by the impostor
  99755. * @returns the PhysicsImpostor or null if not found
  99756. */
  99757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  99758. /**
  99759. * Does a raycast in the physics world
  99760. * @param from when should the ray start?
  99761. * @param to when should the ray end?
  99762. * @returns PhysicsRaycastResult
  99763. */
  99764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99765. /**
  99766. * Called by the scene. No need to call it.
  99767. * @param delta defines the timespam between frames
  99768. */
  99769. _step(delta: number): void;
  99770. }
  99771. }
  99772. declare module BABYLON {
  99773. /**
  99774. * The interface for the physics imposter parameters
  99775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99776. */
  99777. export interface PhysicsImpostorParameters {
  99778. /**
  99779. * The mass of the physics imposter
  99780. */
  99781. mass: number;
  99782. /**
  99783. * The friction of the physics imposter
  99784. */
  99785. friction?: number;
  99786. /**
  99787. * The coefficient of restitution of the physics imposter
  99788. */
  99789. restitution?: number;
  99790. /**
  99791. * The native options of the physics imposter
  99792. */
  99793. nativeOptions?: any;
  99794. /**
  99795. * Specifies if the parent should be ignored
  99796. */
  99797. ignoreParent?: boolean;
  99798. /**
  99799. * Specifies if bi-directional transformations should be disabled
  99800. */
  99801. disableBidirectionalTransformation?: boolean;
  99802. /**
  99803. * The pressure inside the physics imposter, soft object only
  99804. */
  99805. pressure?: number;
  99806. /**
  99807. * The stiffness the physics imposter, soft object only
  99808. */
  99809. stiffness?: number;
  99810. /**
  99811. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  99812. */
  99813. velocityIterations?: number;
  99814. /**
  99815. * The number of iterations used in maintaining consistent vertex positions, soft object only
  99816. */
  99817. positionIterations?: number;
  99818. /**
  99819. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  99820. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  99821. * Add to fix multiple points
  99822. */
  99823. fixedPoints?: number;
  99824. /**
  99825. * The collision margin around a soft object
  99826. */
  99827. margin?: number;
  99828. /**
  99829. * The collision margin around a soft object
  99830. */
  99831. damping?: number;
  99832. /**
  99833. * The path for a rope based on an extrusion
  99834. */
  99835. path?: any;
  99836. /**
  99837. * The shape of an extrusion used for a rope based on an extrusion
  99838. */
  99839. shape?: any;
  99840. }
  99841. /**
  99842. * Interface for a physics-enabled object
  99843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99844. */
  99845. export interface IPhysicsEnabledObject {
  99846. /**
  99847. * The position of the physics-enabled object
  99848. */
  99849. position: Vector3;
  99850. /**
  99851. * The rotation of the physics-enabled object
  99852. */
  99853. rotationQuaternion: Nullable<Quaternion>;
  99854. /**
  99855. * The scale of the physics-enabled object
  99856. */
  99857. scaling: Vector3;
  99858. /**
  99859. * The rotation of the physics-enabled object
  99860. */
  99861. rotation?: Vector3;
  99862. /**
  99863. * The parent of the physics-enabled object
  99864. */
  99865. parent?: any;
  99866. /**
  99867. * The bounding info of the physics-enabled object
  99868. * @returns The bounding info of the physics-enabled object
  99869. */
  99870. getBoundingInfo(): BoundingInfo;
  99871. /**
  99872. * Computes the world matrix
  99873. * @param force Specifies if the world matrix should be computed by force
  99874. * @returns A world matrix
  99875. */
  99876. computeWorldMatrix(force: boolean): Matrix;
  99877. /**
  99878. * Gets the world matrix
  99879. * @returns A world matrix
  99880. */
  99881. getWorldMatrix?(): Matrix;
  99882. /**
  99883. * Gets the child meshes
  99884. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  99885. * @returns An array of abstract meshes
  99886. */
  99887. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  99888. /**
  99889. * Gets the vertex data
  99890. * @param kind The type of vertex data
  99891. * @returns A nullable array of numbers, or a float32 array
  99892. */
  99893. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  99894. /**
  99895. * Gets the indices from the mesh
  99896. * @returns A nullable array of index arrays
  99897. */
  99898. getIndices?(): Nullable<IndicesArray>;
  99899. /**
  99900. * Gets the scene from the mesh
  99901. * @returns the indices array or null
  99902. */
  99903. getScene?(): Scene;
  99904. /**
  99905. * Gets the absolute position from the mesh
  99906. * @returns the absolute position
  99907. */
  99908. getAbsolutePosition(): Vector3;
  99909. /**
  99910. * Gets the absolute pivot point from the mesh
  99911. * @returns the absolute pivot point
  99912. */
  99913. getAbsolutePivotPoint(): Vector3;
  99914. /**
  99915. * Rotates the mesh
  99916. * @param axis The axis of rotation
  99917. * @param amount The amount of rotation
  99918. * @param space The space of the rotation
  99919. * @returns The rotation transform node
  99920. */
  99921. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  99922. /**
  99923. * Translates the mesh
  99924. * @param axis The axis of translation
  99925. * @param distance The distance of translation
  99926. * @param space The space of the translation
  99927. * @returns The transform node
  99928. */
  99929. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  99930. /**
  99931. * Sets the absolute position of the mesh
  99932. * @param absolutePosition The absolute position of the mesh
  99933. * @returns The transform node
  99934. */
  99935. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  99936. /**
  99937. * Gets the class name of the mesh
  99938. * @returns The class name
  99939. */
  99940. getClassName(): string;
  99941. }
  99942. /**
  99943. * Represents a physics imposter
  99944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99945. */
  99946. export class PhysicsImpostor {
  99947. /**
  99948. * The physics-enabled object used as the physics imposter
  99949. */
  99950. object: IPhysicsEnabledObject;
  99951. /**
  99952. * The type of the physics imposter
  99953. */
  99954. type: number;
  99955. private _options;
  99956. private _scene?;
  99957. /**
  99958. * The default object size of the imposter
  99959. */
  99960. static DEFAULT_OBJECT_SIZE: Vector3;
  99961. /**
  99962. * The identity quaternion of the imposter
  99963. */
  99964. static IDENTITY_QUATERNION: Quaternion;
  99965. /** @hidden */
  99966. _pluginData: any;
  99967. private _physicsEngine;
  99968. private _physicsBody;
  99969. private _bodyUpdateRequired;
  99970. private _onBeforePhysicsStepCallbacks;
  99971. private _onAfterPhysicsStepCallbacks;
  99972. /** @hidden */
  99973. _onPhysicsCollideCallbacks: Array<{
  99974. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  99975. otherImpostors: Array<PhysicsImpostor>;
  99976. }>;
  99977. private _deltaPosition;
  99978. private _deltaRotation;
  99979. private _deltaRotationConjugated;
  99980. /** @hidden */
  99981. _isFromLine: boolean;
  99982. private _parent;
  99983. private _isDisposed;
  99984. private static _tmpVecs;
  99985. private static _tmpQuat;
  99986. /**
  99987. * Specifies if the physics imposter is disposed
  99988. */
  99989. get isDisposed(): boolean;
  99990. /**
  99991. * Gets the mass of the physics imposter
  99992. */
  99993. get mass(): number;
  99994. set mass(value: number);
  99995. /**
  99996. * Gets the coefficient of friction
  99997. */
  99998. get friction(): number;
  99999. /**
  100000. * Sets the coefficient of friction
  100001. */
  100002. set friction(value: number);
  100003. /**
  100004. * Gets the coefficient of restitution
  100005. */
  100006. get restitution(): number;
  100007. /**
  100008. * Sets the coefficient of restitution
  100009. */
  100010. set restitution(value: number);
  100011. /**
  100012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100013. */
  100014. get pressure(): number;
  100015. /**
  100016. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100017. */
  100018. set pressure(value: number);
  100019. /**
  100020. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100021. */
  100022. get stiffness(): number;
  100023. /**
  100024. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100025. */
  100026. set stiffness(value: number);
  100027. /**
  100028. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100029. */
  100030. get velocityIterations(): number;
  100031. /**
  100032. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100033. */
  100034. set velocityIterations(value: number);
  100035. /**
  100036. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100037. */
  100038. get positionIterations(): number;
  100039. /**
  100040. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100041. */
  100042. set positionIterations(value: number);
  100043. /**
  100044. * The unique id of the physics imposter
  100045. * set by the physics engine when adding this impostor to the array
  100046. */
  100047. uniqueId: number;
  100048. /**
  100049. * @hidden
  100050. */
  100051. soft: boolean;
  100052. /**
  100053. * @hidden
  100054. */
  100055. segments: number;
  100056. private _joints;
  100057. /**
  100058. * Initializes the physics imposter
  100059. * @param object The physics-enabled object used as the physics imposter
  100060. * @param type The type of the physics imposter
  100061. * @param _options The options for the physics imposter
  100062. * @param _scene The Babylon scene
  100063. */
  100064. constructor(
  100065. /**
  100066. * The physics-enabled object used as the physics imposter
  100067. */
  100068. object: IPhysicsEnabledObject,
  100069. /**
  100070. * The type of the physics imposter
  100071. */
  100072. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100073. /**
  100074. * This function will completly initialize this impostor.
  100075. * It will create a new body - but only if this mesh has no parent.
  100076. * If it has, this impostor will not be used other than to define the impostor
  100077. * of the child mesh.
  100078. * @hidden
  100079. */
  100080. _init(): void;
  100081. private _getPhysicsParent;
  100082. /**
  100083. * Should a new body be generated.
  100084. * @returns boolean specifying if body initialization is required
  100085. */
  100086. isBodyInitRequired(): boolean;
  100087. /**
  100088. * Sets the updated scaling
  100089. * @param updated Specifies if the scaling is updated
  100090. */
  100091. setScalingUpdated(): void;
  100092. /**
  100093. * Force a regeneration of this or the parent's impostor's body.
  100094. * Use under cautious - This will remove all joints already implemented.
  100095. */
  100096. forceUpdate(): void;
  100097. /**
  100098. * Gets the body that holds this impostor. Either its own, or its parent.
  100099. */
  100100. get physicsBody(): any;
  100101. /**
  100102. * Get the parent of the physics imposter
  100103. * @returns Physics imposter or null
  100104. */
  100105. get parent(): Nullable<PhysicsImpostor>;
  100106. /**
  100107. * Sets the parent of the physics imposter
  100108. */
  100109. set parent(value: Nullable<PhysicsImpostor>);
  100110. /**
  100111. * Set the physics body. Used mainly by the physics engine/plugin
  100112. */
  100113. set physicsBody(physicsBody: any);
  100114. /**
  100115. * Resets the update flags
  100116. */
  100117. resetUpdateFlags(): void;
  100118. /**
  100119. * Gets the object extend size
  100120. * @returns the object extend size
  100121. */
  100122. getObjectExtendSize(): Vector3;
  100123. /**
  100124. * Gets the object center
  100125. * @returns The object center
  100126. */
  100127. getObjectCenter(): Vector3;
  100128. /**
  100129. * Get a specific parameter from the options parameters
  100130. * @param paramName The object parameter name
  100131. * @returns The object parameter
  100132. */
  100133. getParam(paramName: string): any;
  100134. /**
  100135. * Sets a specific parameter in the options given to the physics plugin
  100136. * @param paramName The parameter name
  100137. * @param value The value of the parameter
  100138. */
  100139. setParam(paramName: string, value: number): void;
  100140. /**
  100141. * Specifically change the body's mass option. Won't recreate the physics body object
  100142. * @param mass The mass of the physics imposter
  100143. */
  100144. setMass(mass: number): void;
  100145. /**
  100146. * Gets the linear velocity
  100147. * @returns linear velocity or null
  100148. */
  100149. getLinearVelocity(): Nullable<Vector3>;
  100150. /**
  100151. * Sets the linear velocity
  100152. * @param velocity linear velocity or null
  100153. */
  100154. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100155. /**
  100156. * Gets the angular velocity
  100157. * @returns angular velocity or null
  100158. */
  100159. getAngularVelocity(): Nullable<Vector3>;
  100160. /**
  100161. * Sets the angular velocity
  100162. * @param velocity The velocity or null
  100163. */
  100164. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100165. /**
  100166. * Execute a function with the physics plugin native code
  100167. * Provide a function the will have two variables - the world object and the physics body object
  100168. * @param func The function to execute with the physics plugin native code
  100169. */
  100170. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100171. /**
  100172. * Register a function that will be executed before the physics world is stepping forward
  100173. * @param func The function to execute before the physics world is stepped forward
  100174. */
  100175. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100176. /**
  100177. * Unregister a function that will be executed before the physics world is stepping forward
  100178. * @param func The function to execute before the physics world is stepped forward
  100179. */
  100180. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100181. /**
  100182. * Register a function that will be executed after the physics step
  100183. * @param func The function to execute after physics step
  100184. */
  100185. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100186. /**
  100187. * Unregisters a function that will be executed after the physics step
  100188. * @param func The function to execute after physics step
  100189. */
  100190. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100191. /**
  100192. * register a function that will be executed when this impostor collides against a different body
  100193. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100194. * @param func Callback that is executed on collision
  100195. */
  100196. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100197. /**
  100198. * Unregisters the physics imposter on contact
  100199. * @param collideAgainst The physics object to collide against
  100200. * @param func Callback to execute on collision
  100201. */
  100202. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100203. private _tmpQuat;
  100204. private _tmpQuat2;
  100205. /**
  100206. * Get the parent rotation
  100207. * @returns The parent rotation
  100208. */
  100209. getParentsRotation(): Quaternion;
  100210. /**
  100211. * this function is executed by the physics engine.
  100212. */
  100213. beforeStep: () => void;
  100214. /**
  100215. * this function is executed by the physics engine
  100216. */
  100217. afterStep: () => void;
  100218. /**
  100219. * Legacy collision detection event support
  100220. */
  100221. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100222. /**
  100223. * event and body object due to cannon's event-based architecture.
  100224. */
  100225. onCollide: (e: {
  100226. body: any;
  100227. }) => void;
  100228. /**
  100229. * Apply a force
  100230. * @param force The force to apply
  100231. * @param contactPoint The contact point for the force
  100232. * @returns The physics imposter
  100233. */
  100234. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100235. /**
  100236. * Apply an impulse
  100237. * @param force The impulse force
  100238. * @param contactPoint The contact point for the impulse force
  100239. * @returns The physics imposter
  100240. */
  100241. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100242. /**
  100243. * A help function to create a joint
  100244. * @param otherImpostor A physics imposter used to create a joint
  100245. * @param jointType The type of joint
  100246. * @param jointData The data for the joint
  100247. * @returns The physics imposter
  100248. */
  100249. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100250. /**
  100251. * Add a joint to this impostor with a different impostor
  100252. * @param otherImpostor A physics imposter used to add a joint
  100253. * @param joint The joint to add
  100254. * @returns The physics imposter
  100255. */
  100256. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100257. /**
  100258. * Add an anchor to a cloth impostor
  100259. * @param otherImpostor rigid impostor to anchor to
  100260. * @param width ratio across width from 0 to 1
  100261. * @param height ratio up height from 0 to 1
  100262. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100263. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100264. * @returns impostor the soft imposter
  100265. */
  100266. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100267. /**
  100268. * Add a hook to a rope impostor
  100269. * @param otherImpostor rigid impostor to anchor to
  100270. * @param length ratio across rope from 0 to 1
  100271. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100272. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100273. * @returns impostor the rope imposter
  100274. */
  100275. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100276. /**
  100277. * Will keep this body still, in a sleep mode.
  100278. * @returns the physics imposter
  100279. */
  100280. sleep(): PhysicsImpostor;
  100281. /**
  100282. * Wake the body up.
  100283. * @returns The physics imposter
  100284. */
  100285. wakeUp(): PhysicsImpostor;
  100286. /**
  100287. * Clones the physics imposter
  100288. * @param newObject The physics imposter clones to this physics-enabled object
  100289. * @returns A nullable physics imposter
  100290. */
  100291. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100292. /**
  100293. * Disposes the physics imposter
  100294. */
  100295. dispose(): void;
  100296. /**
  100297. * Sets the delta position
  100298. * @param position The delta position amount
  100299. */
  100300. setDeltaPosition(position: Vector3): void;
  100301. /**
  100302. * Sets the delta rotation
  100303. * @param rotation The delta rotation amount
  100304. */
  100305. setDeltaRotation(rotation: Quaternion): void;
  100306. /**
  100307. * Gets the box size of the physics imposter and stores the result in the input parameter
  100308. * @param result Stores the box size
  100309. * @returns The physics imposter
  100310. */
  100311. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100312. /**
  100313. * Gets the radius of the physics imposter
  100314. * @returns Radius of the physics imposter
  100315. */
  100316. getRadius(): number;
  100317. /**
  100318. * Sync a bone with this impostor
  100319. * @param bone The bone to sync to the impostor.
  100320. * @param boneMesh The mesh that the bone is influencing.
  100321. * @param jointPivot The pivot of the joint / bone in local space.
  100322. * @param distToJoint Optional distance from the impostor to the joint.
  100323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100324. */
  100325. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100326. /**
  100327. * Sync impostor to a bone
  100328. * @param bone The bone that the impostor will be synced to.
  100329. * @param boneMesh The mesh that the bone is influencing.
  100330. * @param jointPivot The pivot of the joint / bone in local space.
  100331. * @param distToJoint Optional distance from the impostor to the joint.
  100332. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100333. * @param boneAxis Optional vector3 axis the bone is aligned with
  100334. */
  100335. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100336. /**
  100337. * No-Imposter type
  100338. */
  100339. static NoImpostor: number;
  100340. /**
  100341. * Sphere-Imposter type
  100342. */
  100343. static SphereImpostor: number;
  100344. /**
  100345. * Box-Imposter type
  100346. */
  100347. static BoxImpostor: number;
  100348. /**
  100349. * Plane-Imposter type
  100350. */
  100351. static PlaneImpostor: number;
  100352. /**
  100353. * Mesh-imposter type
  100354. */
  100355. static MeshImpostor: number;
  100356. /**
  100357. * Capsule-Impostor type (Ammo.js plugin only)
  100358. */
  100359. static CapsuleImpostor: number;
  100360. /**
  100361. * Cylinder-Imposter type
  100362. */
  100363. static CylinderImpostor: number;
  100364. /**
  100365. * Particle-Imposter type
  100366. */
  100367. static ParticleImpostor: number;
  100368. /**
  100369. * Heightmap-Imposter type
  100370. */
  100371. static HeightmapImpostor: number;
  100372. /**
  100373. * ConvexHull-Impostor type (Ammo.js plugin only)
  100374. */
  100375. static ConvexHullImpostor: number;
  100376. /**
  100377. * Custom-Imposter type (Ammo.js plugin only)
  100378. */
  100379. static CustomImpostor: number;
  100380. /**
  100381. * Rope-Imposter type
  100382. */
  100383. static RopeImpostor: number;
  100384. /**
  100385. * Cloth-Imposter type
  100386. */
  100387. static ClothImpostor: number;
  100388. /**
  100389. * Softbody-Imposter type
  100390. */
  100391. static SoftbodyImpostor: number;
  100392. }
  100393. }
  100394. declare module BABYLON {
  100395. /**
  100396. * @hidden
  100397. **/
  100398. export class _CreationDataStorage {
  100399. closePath?: boolean;
  100400. closeArray?: boolean;
  100401. idx: number[];
  100402. dashSize: number;
  100403. gapSize: number;
  100404. path3D: Path3D;
  100405. pathArray: Vector3[][];
  100406. arc: number;
  100407. radius: number;
  100408. cap: number;
  100409. tessellation: number;
  100410. }
  100411. /**
  100412. * @hidden
  100413. **/
  100414. class _InstanceDataStorage {
  100415. visibleInstances: any;
  100416. batchCache: _InstancesBatch;
  100417. instancesBufferSize: number;
  100418. instancesBuffer: Nullable<Buffer>;
  100419. instancesData: Float32Array;
  100420. overridenInstanceCount: number;
  100421. isFrozen: boolean;
  100422. previousBatch: Nullable<_InstancesBatch>;
  100423. hardwareInstancedRendering: boolean;
  100424. sideOrientation: number;
  100425. manualUpdate: boolean;
  100426. }
  100427. /**
  100428. * @hidden
  100429. **/
  100430. export class _InstancesBatch {
  100431. mustReturn: boolean;
  100432. visibleInstances: Nullable<InstancedMesh[]>[];
  100433. renderSelf: boolean[];
  100434. hardwareInstancedRendering: boolean[];
  100435. }
  100436. /**
  100437. * Class used to represent renderable models
  100438. */
  100439. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100440. /**
  100441. * Mesh side orientation : usually the external or front surface
  100442. */
  100443. static readonly FRONTSIDE: number;
  100444. /**
  100445. * Mesh side orientation : usually the internal or back surface
  100446. */
  100447. static readonly BACKSIDE: number;
  100448. /**
  100449. * Mesh side orientation : both internal and external or front and back surfaces
  100450. */
  100451. static readonly DOUBLESIDE: number;
  100452. /**
  100453. * Mesh side orientation : by default, `FRONTSIDE`
  100454. */
  100455. static readonly DEFAULTSIDE: number;
  100456. /**
  100457. * Mesh cap setting : no cap
  100458. */
  100459. static readonly NO_CAP: number;
  100460. /**
  100461. * Mesh cap setting : one cap at the beginning of the mesh
  100462. */
  100463. static readonly CAP_START: number;
  100464. /**
  100465. * Mesh cap setting : one cap at the end of the mesh
  100466. */
  100467. static readonly CAP_END: number;
  100468. /**
  100469. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100470. */
  100471. static readonly CAP_ALL: number;
  100472. /**
  100473. * Mesh pattern setting : no flip or rotate
  100474. */
  100475. static readonly NO_FLIP: number;
  100476. /**
  100477. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100478. */
  100479. static readonly FLIP_TILE: number;
  100480. /**
  100481. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100482. */
  100483. static readonly ROTATE_TILE: number;
  100484. /**
  100485. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100486. */
  100487. static readonly FLIP_ROW: number;
  100488. /**
  100489. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100490. */
  100491. static readonly ROTATE_ROW: number;
  100492. /**
  100493. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100494. */
  100495. static readonly FLIP_N_ROTATE_TILE: number;
  100496. /**
  100497. * Mesh pattern setting : rotate pattern and rotate
  100498. */
  100499. static readonly FLIP_N_ROTATE_ROW: number;
  100500. /**
  100501. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100502. */
  100503. static readonly CENTER: number;
  100504. /**
  100505. * Mesh tile positioning : part tiles on left
  100506. */
  100507. static readonly LEFT: number;
  100508. /**
  100509. * Mesh tile positioning : part tiles on right
  100510. */
  100511. static readonly RIGHT: number;
  100512. /**
  100513. * Mesh tile positioning : part tiles on top
  100514. */
  100515. static readonly TOP: number;
  100516. /**
  100517. * Mesh tile positioning : part tiles on bottom
  100518. */
  100519. static readonly BOTTOM: number;
  100520. /**
  100521. * Gets the default side orientation.
  100522. * @param orientation the orientation to value to attempt to get
  100523. * @returns the default orientation
  100524. * @hidden
  100525. */
  100526. static _GetDefaultSideOrientation(orientation?: number): number;
  100527. private _internalMeshDataInfo;
  100528. /**
  100529. * An event triggered before rendering the mesh
  100530. */
  100531. get onBeforeRenderObservable(): Observable<Mesh>;
  100532. /**
  100533. * An event triggered before binding the mesh
  100534. */
  100535. get onBeforeBindObservable(): Observable<Mesh>;
  100536. /**
  100537. * An event triggered after rendering the mesh
  100538. */
  100539. get onAfterRenderObservable(): Observable<Mesh>;
  100540. /**
  100541. * An event triggered before drawing the mesh
  100542. */
  100543. get onBeforeDrawObservable(): Observable<Mesh>;
  100544. private _onBeforeDrawObserver;
  100545. /**
  100546. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100547. */
  100548. set onBeforeDraw(callback: () => void);
  100549. get hasInstances(): boolean;
  100550. /**
  100551. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100552. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100553. */
  100554. delayLoadState: number;
  100555. /**
  100556. * Gets the list of instances created from this mesh
  100557. * it is not supposed to be modified manually.
  100558. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100559. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100560. */
  100561. instances: InstancedMesh[];
  100562. /**
  100563. * Gets the file containing delay loading data for this mesh
  100564. */
  100565. delayLoadingFile: string;
  100566. /** @hidden */
  100567. _binaryInfo: any;
  100568. /**
  100569. * User defined function used to change how LOD level selection is done
  100570. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100571. */
  100572. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100573. /**
  100574. * Gets or sets the morph target manager
  100575. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100576. */
  100577. get morphTargetManager(): Nullable<MorphTargetManager>;
  100578. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100579. /** @hidden */
  100580. _creationDataStorage: Nullable<_CreationDataStorage>;
  100581. /** @hidden */
  100582. _geometry: Nullable<Geometry>;
  100583. /** @hidden */
  100584. _delayInfo: Array<string>;
  100585. /** @hidden */
  100586. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100587. /** @hidden */
  100588. _instanceDataStorage: _InstanceDataStorage;
  100589. private _effectiveMaterial;
  100590. /** @hidden */
  100591. _shouldGenerateFlatShading: boolean;
  100592. /** @hidden */
  100593. _originalBuilderSideOrientation: number;
  100594. /**
  100595. * Use this property to change the original side orientation defined at construction time
  100596. */
  100597. overrideMaterialSideOrientation: Nullable<number>;
  100598. /**
  100599. * Gets the source mesh (the one used to clone this one from)
  100600. */
  100601. get source(): Nullable<Mesh>;
  100602. /**
  100603. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100604. */
  100605. get isUnIndexed(): boolean;
  100606. set isUnIndexed(value: boolean);
  100607. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100608. get worldMatrixInstancedBuffer(): Float32Array;
  100609. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100610. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100611. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100612. /**
  100613. * @constructor
  100614. * @param name The value used by scene.getMeshByName() to do a lookup.
  100615. * @param scene The scene to add this mesh to.
  100616. * @param parent The parent of this mesh, if it has one
  100617. * @param source An optional Mesh from which geometry is shared, cloned.
  100618. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100619. * When false, achieved by calling a clone(), also passing False.
  100620. * This will make creation of children, recursive.
  100621. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100622. */
  100623. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100624. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100625. doNotInstantiate: boolean;
  100626. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100627. /**
  100628. * Gets the class name
  100629. * @returns the string "Mesh".
  100630. */
  100631. getClassName(): string;
  100632. /** @hidden */
  100633. get _isMesh(): boolean;
  100634. /**
  100635. * Returns a description of this mesh
  100636. * @param fullDetails define if full details about this mesh must be used
  100637. * @returns a descriptive string representing this mesh
  100638. */
  100639. toString(fullDetails?: boolean): string;
  100640. /** @hidden */
  100641. _unBindEffect(): void;
  100642. /**
  100643. * Gets a boolean indicating if this mesh has LOD
  100644. */
  100645. get hasLODLevels(): boolean;
  100646. /**
  100647. * Gets the list of MeshLODLevel associated with the current mesh
  100648. * @returns an array of MeshLODLevel
  100649. */
  100650. getLODLevels(): MeshLODLevel[];
  100651. private _sortLODLevels;
  100652. /**
  100653. * Add a mesh as LOD level triggered at the given distance.
  100654. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100655. * @param distance The distance from the center of the object to show this level
  100656. * @param mesh The mesh to be added as LOD level (can be null)
  100657. * @return This mesh (for chaining)
  100658. */
  100659. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100660. /**
  100661. * Returns the LOD level mesh at the passed distance or null if not found.
  100662. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100663. * @param distance The distance from the center of the object to show this level
  100664. * @returns a Mesh or `null`
  100665. */
  100666. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100667. /**
  100668. * Remove a mesh from the LOD array
  100669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100670. * @param mesh defines the mesh to be removed
  100671. * @return This mesh (for chaining)
  100672. */
  100673. removeLODLevel(mesh: Mesh): Mesh;
  100674. /**
  100675. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100677. * @param camera defines the camera to use to compute distance
  100678. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100679. * @return This mesh (for chaining)
  100680. */
  100681. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100682. /**
  100683. * Gets the mesh internal Geometry object
  100684. */
  100685. get geometry(): Nullable<Geometry>;
  100686. /**
  100687. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100688. * @returns the total number of vertices
  100689. */
  100690. getTotalVertices(): number;
  100691. /**
  100692. * Returns the content of an associated vertex buffer
  100693. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100694. * - VertexBuffer.PositionKind
  100695. * - VertexBuffer.UVKind
  100696. * - VertexBuffer.UV2Kind
  100697. * - VertexBuffer.UV3Kind
  100698. * - VertexBuffer.UV4Kind
  100699. * - VertexBuffer.UV5Kind
  100700. * - VertexBuffer.UV6Kind
  100701. * - VertexBuffer.ColorKind
  100702. * - VertexBuffer.MatricesIndicesKind
  100703. * - VertexBuffer.MatricesIndicesExtraKind
  100704. * - VertexBuffer.MatricesWeightsKind
  100705. * - VertexBuffer.MatricesWeightsExtraKind
  100706. * @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
  100707. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100708. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100709. */
  100710. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100711. /**
  100712. * Returns the mesh VertexBuffer object from the requested `kind`
  100713. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100714. * - VertexBuffer.PositionKind
  100715. * - VertexBuffer.NormalKind
  100716. * - VertexBuffer.UVKind
  100717. * - VertexBuffer.UV2Kind
  100718. * - VertexBuffer.UV3Kind
  100719. * - VertexBuffer.UV4Kind
  100720. * - VertexBuffer.UV5Kind
  100721. * - VertexBuffer.UV6Kind
  100722. * - VertexBuffer.ColorKind
  100723. * - VertexBuffer.MatricesIndicesKind
  100724. * - VertexBuffer.MatricesIndicesExtraKind
  100725. * - VertexBuffer.MatricesWeightsKind
  100726. * - VertexBuffer.MatricesWeightsExtraKind
  100727. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100728. */
  100729. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100730. /**
  100731. * Tests if a specific vertex buffer is associated with this mesh
  100732. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100733. * - VertexBuffer.PositionKind
  100734. * - VertexBuffer.NormalKind
  100735. * - VertexBuffer.UVKind
  100736. * - VertexBuffer.UV2Kind
  100737. * - VertexBuffer.UV3Kind
  100738. * - VertexBuffer.UV4Kind
  100739. * - VertexBuffer.UV5Kind
  100740. * - VertexBuffer.UV6Kind
  100741. * - VertexBuffer.ColorKind
  100742. * - VertexBuffer.MatricesIndicesKind
  100743. * - VertexBuffer.MatricesIndicesExtraKind
  100744. * - VertexBuffer.MatricesWeightsKind
  100745. * - VertexBuffer.MatricesWeightsExtraKind
  100746. * @returns a boolean
  100747. */
  100748. isVerticesDataPresent(kind: string): boolean;
  100749. /**
  100750. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  100751. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100752. * - VertexBuffer.PositionKind
  100753. * - VertexBuffer.UVKind
  100754. * - VertexBuffer.UV2Kind
  100755. * - VertexBuffer.UV3Kind
  100756. * - VertexBuffer.UV4Kind
  100757. * - VertexBuffer.UV5Kind
  100758. * - VertexBuffer.UV6Kind
  100759. * - VertexBuffer.ColorKind
  100760. * - VertexBuffer.MatricesIndicesKind
  100761. * - VertexBuffer.MatricesIndicesExtraKind
  100762. * - VertexBuffer.MatricesWeightsKind
  100763. * - VertexBuffer.MatricesWeightsExtraKind
  100764. * @returns a boolean
  100765. */
  100766. isVertexBufferUpdatable(kind: string): boolean;
  100767. /**
  100768. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  100769. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100770. * - VertexBuffer.PositionKind
  100771. * - VertexBuffer.NormalKind
  100772. * - VertexBuffer.UVKind
  100773. * - VertexBuffer.UV2Kind
  100774. * - VertexBuffer.UV3Kind
  100775. * - VertexBuffer.UV4Kind
  100776. * - VertexBuffer.UV5Kind
  100777. * - VertexBuffer.UV6Kind
  100778. * - VertexBuffer.ColorKind
  100779. * - VertexBuffer.MatricesIndicesKind
  100780. * - VertexBuffer.MatricesIndicesExtraKind
  100781. * - VertexBuffer.MatricesWeightsKind
  100782. * - VertexBuffer.MatricesWeightsExtraKind
  100783. * @returns an array of strings
  100784. */
  100785. getVerticesDataKinds(): string[];
  100786. /**
  100787. * Returns a positive integer : the total number of indices in this mesh geometry.
  100788. * @returns the numner of indices or zero if the mesh has no geometry.
  100789. */
  100790. getTotalIndices(): number;
  100791. /**
  100792. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  100793. * @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.
  100794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  100795. * @returns the indices array or an empty array if the mesh has no geometry
  100796. */
  100797. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  100798. get isBlocked(): boolean;
  100799. /**
  100800. * Determine if the current mesh is ready to be rendered
  100801. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100802. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  100803. * @returns true if all associated assets are ready (material, textures, shaders)
  100804. */
  100805. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  100806. /**
  100807. * 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.
  100808. */
  100809. get areNormalsFrozen(): boolean;
  100810. /**
  100811. * 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.
  100812. * @returns the current mesh
  100813. */
  100814. freezeNormals(): Mesh;
  100815. /**
  100816. * 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
  100817. * @returns the current mesh
  100818. */
  100819. unfreezeNormals(): Mesh;
  100820. /**
  100821. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  100822. */
  100823. set overridenInstanceCount(count: number);
  100824. /** @hidden */
  100825. _preActivate(): Mesh;
  100826. /** @hidden */
  100827. _preActivateForIntermediateRendering(renderId: number): Mesh;
  100828. /** @hidden */
  100829. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  100830. /**
  100831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100832. * This means the mesh underlying bounding box and sphere are recomputed.
  100833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100834. * @returns the current mesh
  100835. */
  100836. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  100837. /** @hidden */
  100838. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  100839. /**
  100840. * This function will subdivide the mesh into multiple submeshes
  100841. * @param count defines the expected number of submeshes
  100842. */
  100843. subdivide(count: number): void;
  100844. /**
  100845. * Copy a FloatArray into a specific associated vertex buffer
  100846. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100847. * - VertexBuffer.PositionKind
  100848. * - VertexBuffer.UVKind
  100849. * - VertexBuffer.UV2Kind
  100850. * - VertexBuffer.UV3Kind
  100851. * - VertexBuffer.UV4Kind
  100852. * - VertexBuffer.UV5Kind
  100853. * - VertexBuffer.UV6Kind
  100854. * - VertexBuffer.ColorKind
  100855. * - VertexBuffer.MatricesIndicesKind
  100856. * - VertexBuffer.MatricesIndicesExtraKind
  100857. * - VertexBuffer.MatricesWeightsKind
  100858. * - VertexBuffer.MatricesWeightsExtraKind
  100859. * @param data defines the data source
  100860. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100861. * @param stride defines the data stride size (can be null)
  100862. * @returns the current mesh
  100863. */
  100864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100865. /**
  100866. * Delete a vertex buffer associated with this mesh
  100867. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  100868. * - VertexBuffer.PositionKind
  100869. * - VertexBuffer.UVKind
  100870. * - VertexBuffer.UV2Kind
  100871. * - VertexBuffer.UV3Kind
  100872. * - VertexBuffer.UV4Kind
  100873. * - VertexBuffer.UV5Kind
  100874. * - VertexBuffer.UV6Kind
  100875. * - VertexBuffer.ColorKind
  100876. * - VertexBuffer.MatricesIndicesKind
  100877. * - VertexBuffer.MatricesIndicesExtraKind
  100878. * - VertexBuffer.MatricesWeightsKind
  100879. * - VertexBuffer.MatricesWeightsExtraKind
  100880. */
  100881. removeVerticesData(kind: string): void;
  100882. /**
  100883. * Flags an associated vertex buffer as updatable
  100884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  100885. * - VertexBuffer.PositionKind
  100886. * - VertexBuffer.UVKind
  100887. * - VertexBuffer.UV2Kind
  100888. * - VertexBuffer.UV3Kind
  100889. * - VertexBuffer.UV4Kind
  100890. * - VertexBuffer.UV5Kind
  100891. * - VertexBuffer.UV6Kind
  100892. * - VertexBuffer.ColorKind
  100893. * - VertexBuffer.MatricesIndicesKind
  100894. * - VertexBuffer.MatricesIndicesExtraKind
  100895. * - VertexBuffer.MatricesWeightsKind
  100896. * - VertexBuffer.MatricesWeightsExtraKind
  100897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100898. */
  100899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  100900. /**
  100901. * Sets the mesh global Vertex Buffer
  100902. * @param buffer defines the buffer to use
  100903. * @returns the current mesh
  100904. */
  100905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  100906. /**
  100907. * Update a specific associated vertex buffer
  100908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100909. * - VertexBuffer.PositionKind
  100910. * - VertexBuffer.UVKind
  100911. * - VertexBuffer.UV2Kind
  100912. * - VertexBuffer.UV3Kind
  100913. * - VertexBuffer.UV4Kind
  100914. * - VertexBuffer.UV5Kind
  100915. * - VertexBuffer.UV6Kind
  100916. * - VertexBuffer.ColorKind
  100917. * - VertexBuffer.MatricesIndicesKind
  100918. * - VertexBuffer.MatricesIndicesExtraKind
  100919. * - VertexBuffer.MatricesWeightsKind
  100920. * - VertexBuffer.MatricesWeightsExtraKind
  100921. * @param data defines the data source
  100922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  100923. * @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)
  100924. * @returns the current mesh
  100925. */
  100926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100927. /**
  100928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  100929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  100930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  100931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  100932. * @returns the current mesh
  100933. */
  100934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  100935. /**
  100936. * Creates a un-shared specific occurence of the geometry for the mesh.
  100937. * @returns the current mesh
  100938. */
  100939. makeGeometryUnique(): Mesh;
  100940. /**
  100941. * Set the index buffer of this mesh
  100942. * @param indices defines the source data
  100943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  100944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  100945. * @returns the current mesh
  100946. */
  100947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  100948. /**
  100949. * Update the current index buffer
  100950. * @param indices defines the source data
  100951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100952. * @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)
  100953. * @returns the current mesh
  100954. */
  100955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100956. /**
  100957. * Invert the geometry to move from a right handed system to a left handed one.
  100958. * @returns the current mesh
  100959. */
  100960. toLeftHanded(): Mesh;
  100961. /** @hidden */
  100962. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  100963. /** @hidden */
  100964. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  100965. /**
  100966. * Registers for this mesh a javascript function called just before the rendering process
  100967. * @param func defines the function to call before rendering this mesh
  100968. * @returns the current mesh
  100969. */
  100970. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100971. /**
  100972. * Disposes a previously registered javascript function called before the rendering
  100973. * @param func defines the function to remove
  100974. * @returns the current mesh
  100975. */
  100976. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100977. /**
  100978. * Registers for this mesh a javascript function called just after the rendering is complete
  100979. * @param func defines the function to call after rendering this mesh
  100980. * @returns the current mesh
  100981. */
  100982. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100983. /**
  100984. * Disposes a previously registered javascript function called after the rendering.
  100985. * @param func defines the function to remove
  100986. * @returns the current mesh
  100987. */
  100988. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100989. /** @hidden */
  100990. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  100991. /** @hidden */
  100992. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  100993. /** @hidden */
  100994. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  100995. /** @hidden */
  100996. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  100997. /** @hidden */
  100998. _rebuild(): void;
  100999. /** @hidden */
  101000. _freeze(): void;
  101001. /** @hidden */
  101002. _unFreeze(): void;
  101003. /**
  101004. * 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
  101005. * @param subMesh defines the subMesh to render
  101006. * @param enableAlphaMode defines if alpha mode can be changed
  101007. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  101008. * @returns the current mesh
  101009. */
  101010. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101011. private _onBeforeDraw;
  101012. /**
  101013. * Renormalize the mesh and patch it up if there are no weights
  101014. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101015. * However in the case of zero weights then we set just a single influence to 1.
  101016. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101017. */
  101018. cleanMatrixWeights(): void;
  101019. private normalizeSkinFourWeights;
  101020. private normalizeSkinWeightsAndExtra;
  101021. /**
  101022. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101023. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101024. * the user know there was an issue with importing the mesh
  101025. * @returns a validation object with skinned, valid and report string
  101026. */
  101027. validateSkinning(): {
  101028. skinned: boolean;
  101029. valid: boolean;
  101030. report: string;
  101031. };
  101032. /** @hidden */
  101033. _checkDelayState(): Mesh;
  101034. private _queueLoad;
  101035. /**
  101036. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101037. * A mesh is in the frustum if its bounding box intersects the frustum
  101038. * @param frustumPlanes defines the frustum to test
  101039. * @returns true if the mesh is in the frustum planes
  101040. */
  101041. isInFrustum(frustumPlanes: Plane[]): boolean;
  101042. /**
  101043. * Sets the mesh material by the material or multiMaterial `id` property
  101044. * @param id is a string identifying the material or the multiMaterial
  101045. * @returns the current mesh
  101046. */
  101047. setMaterialByID(id: string): Mesh;
  101048. /**
  101049. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101050. * @returns an array of IAnimatable
  101051. */
  101052. getAnimatables(): IAnimatable[];
  101053. /**
  101054. * Modifies the mesh geometry according to the passed transformation matrix.
  101055. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101056. * The mesh normals are modified using the same transformation.
  101057. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101058. * @param transform defines the transform matrix to use
  101059. * @see http://doc.babylonjs.com/resources/baking_transformations
  101060. * @returns the current mesh
  101061. */
  101062. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101063. /**
  101064. * Modifies the mesh geometry according to its own current World Matrix.
  101065. * The mesh World Matrix is then reset.
  101066. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101067. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101068. * @see http://doc.babylonjs.com/resources/baking_transformations
  101069. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101070. * @returns the current mesh
  101071. */
  101072. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101073. /** @hidden */
  101074. get _positions(): Nullable<Vector3[]>;
  101075. /** @hidden */
  101076. _resetPointsArrayCache(): Mesh;
  101077. /** @hidden */
  101078. _generatePointsArray(): boolean;
  101079. /**
  101080. * Returns a new Mesh object generated from the current mesh properties.
  101081. * This method must not get confused with createInstance()
  101082. * @param name is a string, the name given to the new mesh
  101083. * @param newParent can be any Node object (default `null`)
  101084. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101085. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101086. * @returns a new mesh
  101087. */
  101088. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101089. /**
  101090. * Releases resources associated with this mesh.
  101091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101093. */
  101094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101095. /** @hidden */
  101096. _disposeInstanceSpecificData(): void;
  101097. /**
  101098. * Modifies the mesh geometry according to a displacement map.
  101099. * 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.
  101100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101101. * @param url is a string, the URL from the image file is to be downloaded.
  101102. * @param minHeight is the lower limit of the displacement.
  101103. * @param maxHeight is the upper limit of the displacement.
  101104. * @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.
  101105. * @param uvOffset is an optional vector2 used to offset UV.
  101106. * @param uvScale is an optional vector2 used to scale UV.
  101107. * @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.
  101108. * @returns the Mesh.
  101109. */
  101110. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101111. /**
  101112. * Modifies the mesh geometry according to a displacementMap buffer.
  101113. * 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.
  101114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101115. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101116. * @param heightMapWidth is the width of the buffer image.
  101117. * @param heightMapHeight is the height of the buffer image.
  101118. * @param minHeight is the lower limit of the displacement.
  101119. * @param maxHeight is the upper limit of the displacement.
  101120. * @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.
  101121. * @param uvOffset is an optional vector2 used to offset UV.
  101122. * @param uvScale is an optional vector2 used to scale UV.
  101123. * @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.
  101124. * @returns the Mesh.
  101125. */
  101126. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101127. /**
  101128. * Modify the mesh to get a flat shading rendering.
  101129. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101130. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101131. * @returns current mesh
  101132. */
  101133. convertToFlatShadedMesh(): Mesh;
  101134. /**
  101135. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101136. * In other words, more vertices, no more indices and a single bigger VBO.
  101137. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101138. * @returns current mesh
  101139. */
  101140. convertToUnIndexedMesh(): Mesh;
  101141. /**
  101142. * Inverses facet orientations.
  101143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101144. * @param flipNormals will also inverts the normals
  101145. * @returns current mesh
  101146. */
  101147. flipFaces(flipNormals?: boolean): Mesh;
  101148. /**
  101149. * Increase the number of facets and hence vertices in a mesh
  101150. * Vertex normals are interpolated from existing vertex normals
  101151. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101152. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101153. */
  101154. increaseVertices(numberPerEdge: number): void;
  101155. /**
  101156. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101157. * This will undo any application of covertToFlatShadedMesh
  101158. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101159. */
  101160. forceSharedVertices(): void;
  101161. /** @hidden */
  101162. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101163. /** @hidden */
  101164. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101165. /**
  101166. * Creates a new InstancedMesh object from the mesh model.
  101167. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101168. * @param name defines the name of the new instance
  101169. * @returns a new InstancedMesh
  101170. */
  101171. createInstance(name: string): InstancedMesh;
  101172. /**
  101173. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101174. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101175. * @returns the current mesh
  101176. */
  101177. synchronizeInstances(): Mesh;
  101178. /**
  101179. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101180. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101181. * This should be used together with the simplification to avoid disappearing triangles.
  101182. * @param successCallback an optional success callback to be called after the optimization finished.
  101183. * @returns the current mesh
  101184. */
  101185. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101186. /**
  101187. * Serialize current mesh
  101188. * @param serializationObject defines the object which will receive the serialization data
  101189. */
  101190. serialize(serializationObject: any): void;
  101191. /** @hidden */
  101192. _syncGeometryWithMorphTargetManager(): void;
  101193. /** @hidden */
  101194. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101195. /**
  101196. * Returns a new Mesh object parsed from the source provided.
  101197. * @param parsedMesh is the source
  101198. * @param scene defines the hosting scene
  101199. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101200. * @returns a new Mesh
  101201. */
  101202. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101203. /**
  101204. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101205. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101206. * @param name defines the name of the mesh to create
  101207. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101208. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101209. * @param closePath creates a seam between the first and the last points of each path of the path array
  101210. * @param offset is taken in account only if the `pathArray` is containing a single path
  101211. * @param scene defines the hosting scene
  101212. * @param updatable defines if the mesh must be flagged as updatable
  101213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101214. * @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)
  101215. * @returns a new Mesh
  101216. */
  101217. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101218. /**
  101219. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101220. * @param name defines the name of the mesh to create
  101221. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101222. * @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
  101223. * @param scene defines the hosting scene
  101224. * @param updatable defines if the mesh must be flagged as updatable
  101225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101226. * @returns a new Mesh
  101227. */
  101228. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101229. /**
  101230. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101231. * @param name defines the name of the mesh to create
  101232. * @param size sets the size (float) of each box side (default 1)
  101233. * @param scene defines the hosting scene
  101234. * @param updatable defines if the mesh must be flagged as updatable
  101235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101236. * @returns a new Mesh
  101237. */
  101238. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101239. /**
  101240. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101241. * @param name defines the name of the mesh to create
  101242. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101243. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101244. * @param scene defines the hosting scene
  101245. * @param updatable defines if the mesh must be flagged as updatable
  101246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101247. * @returns a new Mesh
  101248. */
  101249. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101250. /**
  101251. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101252. * @param name defines the name of the mesh to create
  101253. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101254. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101255. * @param scene defines the hosting scene
  101256. * @returns a new Mesh
  101257. */
  101258. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101259. /**
  101260. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101261. * @param name defines the name of the mesh to create
  101262. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101263. * @param diameterTop set the top cap diameter (floats, default 1)
  101264. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101265. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101266. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101267. * @param scene defines the hosting scene
  101268. * @param updatable defines if the mesh must be flagged as updatable
  101269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101270. * @returns a new Mesh
  101271. */
  101272. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101273. /**
  101274. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101275. * @param name defines the name of the mesh to create
  101276. * @param diameter sets the diameter size (float) of the torus (default 1)
  101277. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101278. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101279. * @param scene defines the hosting scene
  101280. * @param updatable defines if the mesh must be flagged as updatable
  101281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101282. * @returns a new Mesh
  101283. */
  101284. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101285. /**
  101286. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101287. * @param name defines the name of the mesh to create
  101288. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101289. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101290. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101291. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101292. * @param p the number of windings on X axis (positive integers, default 2)
  101293. * @param q the number of windings on Y axis (positive integers, default 3)
  101294. * @param scene defines the hosting scene
  101295. * @param updatable defines if the mesh must be flagged as updatable
  101296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101297. * @returns a new Mesh
  101298. */
  101299. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101300. /**
  101301. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101302. * @param name defines the name of the mesh to create
  101303. * @param points is an array successive Vector3
  101304. * @param scene defines the hosting scene
  101305. * @param updatable defines if the mesh must be flagged as updatable
  101306. * @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).
  101307. * @returns a new Mesh
  101308. */
  101309. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101310. /**
  101311. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101312. * @param name defines the name of the mesh to create
  101313. * @param points is an array successive Vector3
  101314. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101315. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101316. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101317. * @param scene defines the hosting scene
  101318. * @param updatable defines if the mesh must be flagged as updatable
  101319. * @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)
  101320. * @returns a new Mesh
  101321. */
  101322. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101323. /**
  101324. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101325. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101326. * 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.
  101327. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101328. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101329. * Remember you can only change the shape positions, not their number when updating a polygon.
  101330. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101331. * @param name defines the name of the mesh to create
  101332. * @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
  101333. * @param scene defines the hosting scene
  101334. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101335. * @param updatable defines if the mesh must be flagged as updatable
  101336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101337. * @param earcutInjection can be used to inject your own earcut reference
  101338. * @returns a new Mesh
  101339. */
  101340. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101341. /**
  101342. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101343. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101344. * @param name defines the name of the mesh to create
  101345. * @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
  101346. * @param depth defines the height of extrusion
  101347. * @param scene defines the hosting scene
  101348. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101349. * @param updatable defines if the mesh must be flagged as updatable
  101350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101351. * @param earcutInjection can be used to inject your own earcut reference
  101352. * @returns a new Mesh
  101353. */
  101354. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101355. /**
  101356. * Creates an extruded shape mesh.
  101357. * 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
  101358. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101359. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101360. * @param name defines the name of the mesh to create
  101361. * @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
  101362. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101363. * @param scale is the value to scale the shape
  101364. * @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
  101365. * @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
  101366. * @param scene defines the hosting scene
  101367. * @param updatable defines if the mesh must be flagged as updatable
  101368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101369. * @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)
  101370. * @returns a new Mesh
  101371. */
  101372. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101373. /**
  101374. * Creates an custom extruded shape mesh.
  101375. * The custom extrusion is a parametric shape.
  101376. * It has no predefined shape. Its final shape will depend on the input parameters.
  101377. * Please consider using the same method from the MeshBuilder class instead
  101378. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101379. * @param name defines the name of the mesh to create
  101380. * @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
  101381. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101382. * @param scaleFunction is a custom Javascript function called on each path point
  101383. * @param rotationFunction is a custom Javascript function called on each path point
  101384. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101385. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101386. * @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
  101387. * @param scene defines the hosting scene
  101388. * @param updatable defines if the mesh must be flagged as updatable
  101389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101390. * @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)
  101391. * @returns a new Mesh
  101392. */
  101393. 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;
  101394. /**
  101395. * Creates lathe mesh.
  101396. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101397. * Please consider using the same method from the MeshBuilder class instead
  101398. * @param name defines the name of the mesh to create
  101399. * @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
  101400. * @param radius is the radius value of the lathe
  101401. * @param tessellation is the side number of the lathe.
  101402. * @param scene defines the hosting scene
  101403. * @param updatable defines if the mesh must be flagged as updatable
  101404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101405. * @returns a new Mesh
  101406. */
  101407. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101408. /**
  101409. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101410. * @param name defines the name of the mesh to create
  101411. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101412. * @param scene defines the hosting scene
  101413. * @param updatable defines if the mesh must be flagged as updatable
  101414. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101415. * @returns a new Mesh
  101416. */
  101417. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101418. /**
  101419. * Creates a ground mesh.
  101420. * Please consider using the same method from the MeshBuilder class instead
  101421. * @param name defines the name of the mesh to create
  101422. * @param width set the width of the ground
  101423. * @param height set the height of the ground
  101424. * @param subdivisions sets the number of subdivisions per side
  101425. * @param scene defines the hosting scene
  101426. * @param updatable defines if the mesh must be flagged as updatable
  101427. * @returns a new Mesh
  101428. */
  101429. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101430. /**
  101431. * Creates a tiled ground mesh.
  101432. * Please consider using the same method from the MeshBuilder class instead
  101433. * @param name defines the name of the mesh to create
  101434. * @param xmin set the ground minimum X coordinate
  101435. * @param zmin set the ground minimum Y coordinate
  101436. * @param xmax set the ground maximum X coordinate
  101437. * @param zmax set the ground maximum Z coordinate
  101438. * @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
  101439. * @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
  101440. * @param scene defines the hosting scene
  101441. * @param updatable defines if the mesh must be flagged as updatable
  101442. * @returns a new Mesh
  101443. */
  101444. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101445. w: number;
  101446. h: number;
  101447. }, precision: {
  101448. w: number;
  101449. h: number;
  101450. }, scene: Scene, updatable?: boolean): Mesh;
  101451. /**
  101452. * Creates a ground mesh from a height map.
  101453. * Please consider using the same method from the MeshBuilder class instead
  101454. * @see http://doc.babylonjs.com/babylon101/height_map
  101455. * @param name defines the name of the mesh to create
  101456. * @param url sets the URL of the height map image resource
  101457. * @param width set the ground width size
  101458. * @param height set the ground height size
  101459. * @param subdivisions sets the number of subdivision per side
  101460. * @param minHeight is the minimum altitude on the ground
  101461. * @param maxHeight is the maximum altitude on the ground
  101462. * @param scene defines the hosting scene
  101463. * @param updatable defines if the mesh must be flagged as updatable
  101464. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101465. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101466. * @returns a new Mesh
  101467. */
  101468. 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;
  101469. /**
  101470. * Creates a tube mesh.
  101471. * The tube is a parametric shape.
  101472. * It has no predefined shape. Its final shape will depend on the input parameters.
  101473. * Please consider using the same method from the MeshBuilder class instead
  101474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101475. * @param name defines the name of the mesh to create
  101476. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101477. * @param radius sets the tube radius size
  101478. * @param tessellation is the number of sides on the tubular surface
  101479. * @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
  101480. * @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
  101481. * @param scene defines the hosting scene
  101482. * @param updatable defines if the mesh must be flagged as updatable
  101483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101484. * @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)
  101485. * @returns a new Mesh
  101486. */
  101487. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101488. (i: number, distance: number): number;
  101489. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101490. /**
  101491. * Creates a polyhedron mesh.
  101492. * Please consider using the same method from the MeshBuilder class instead.
  101493. * * 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
  101494. * * The parameter `size` (positive float, default 1) sets the polygon size
  101495. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101496. * * 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`
  101497. * * 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
  101498. * * 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)`)
  101499. * * 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
  101500. * * 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
  101501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101502. * * If you create a double-sided mesh, you can choose what parts of 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
  101503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101504. * @param name defines the name of the mesh to create
  101505. * @param options defines the options used to create the mesh
  101506. * @param scene defines the hosting scene
  101507. * @returns a new Mesh
  101508. */
  101509. static CreatePolyhedron(name: string, options: {
  101510. type?: number;
  101511. size?: number;
  101512. sizeX?: number;
  101513. sizeY?: number;
  101514. sizeZ?: number;
  101515. custom?: any;
  101516. faceUV?: Vector4[];
  101517. faceColors?: Color4[];
  101518. updatable?: boolean;
  101519. sideOrientation?: number;
  101520. }, scene: Scene): Mesh;
  101521. /**
  101522. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101523. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101524. * * 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`)
  101525. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101526. * * 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
  101527. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101528. * * If you create a double-sided mesh, you can choose what parts of 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
  101529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101530. * @param name defines the name of the mesh
  101531. * @param options defines the options used to create the mesh
  101532. * @param scene defines the hosting scene
  101533. * @returns a new Mesh
  101534. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101535. */
  101536. static CreateIcoSphere(name: string, options: {
  101537. radius?: number;
  101538. flat?: boolean;
  101539. subdivisions?: number;
  101540. sideOrientation?: number;
  101541. updatable?: boolean;
  101542. }, scene: Scene): Mesh;
  101543. /**
  101544. * Creates a decal mesh.
  101545. * Please consider using the same method from the MeshBuilder class instead.
  101546. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101547. * @param name defines the name of the mesh
  101548. * @param sourceMesh defines the mesh receiving the decal
  101549. * @param position sets the position of the decal in world coordinates
  101550. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101551. * @param size sets the decal scaling
  101552. * @param angle sets the angle to rotate the decal
  101553. * @returns a new Mesh
  101554. */
  101555. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101556. /**
  101557. * Prepare internal position array for software CPU skinning
  101558. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101559. */
  101560. setPositionsForCPUSkinning(): Float32Array;
  101561. /**
  101562. * Prepare internal normal array for software CPU skinning
  101563. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101564. */
  101565. setNormalsForCPUSkinning(): Float32Array;
  101566. /**
  101567. * Updates the vertex buffer by applying transformation from the bones
  101568. * @param skeleton defines the skeleton to apply to current mesh
  101569. * @returns the current mesh
  101570. */
  101571. applySkeleton(skeleton: Skeleton): Mesh;
  101572. /**
  101573. * 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
  101574. * @param meshes defines the list of meshes to scan
  101575. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101576. */
  101577. static MinMax(meshes: AbstractMesh[]): {
  101578. min: Vector3;
  101579. max: Vector3;
  101580. };
  101581. /**
  101582. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101583. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101584. * @returns a vector3
  101585. */
  101586. static Center(meshesOrMinMaxVector: {
  101587. min: Vector3;
  101588. max: Vector3;
  101589. } | AbstractMesh[]): Vector3;
  101590. /**
  101591. * Merge the array of meshes into a single mesh for performance reasons.
  101592. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101593. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101594. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101595. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101596. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101597. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101598. * @returns a new mesh
  101599. */
  101600. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101601. /** @hidden */
  101602. addInstance(instance: InstancedMesh): void;
  101603. /** @hidden */
  101604. removeInstance(instance: InstancedMesh): void;
  101605. }
  101606. }
  101607. declare module BABYLON {
  101608. /**
  101609. * This is the base class of all the camera used in the application.
  101610. * @see http://doc.babylonjs.com/features/cameras
  101611. */
  101612. export class Camera extends Node {
  101613. /** @hidden */
  101614. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101615. /**
  101616. * This is the default projection mode used by the cameras.
  101617. * It helps recreating a feeling of perspective and better appreciate depth.
  101618. * This is the best way to simulate real life cameras.
  101619. */
  101620. static readonly PERSPECTIVE_CAMERA: number;
  101621. /**
  101622. * This helps creating camera with an orthographic mode.
  101623. * 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.
  101624. */
  101625. static readonly ORTHOGRAPHIC_CAMERA: number;
  101626. /**
  101627. * This is the default FOV mode for perspective cameras.
  101628. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101629. */
  101630. static readonly FOVMODE_VERTICAL_FIXED: number;
  101631. /**
  101632. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101633. */
  101634. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101635. /**
  101636. * This specifies ther is no need for a camera rig.
  101637. * Basically only one eye is rendered corresponding to the camera.
  101638. */
  101639. static readonly RIG_MODE_NONE: number;
  101640. /**
  101641. * Simulates a camera Rig with one blue eye and one red eye.
  101642. * This can be use with 3d blue and red glasses.
  101643. */
  101644. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101645. /**
  101646. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101647. */
  101648. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101649. /**
  101650. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101651. */
  101652. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101653. /**
  101654. * Defines that both eyes of the camera will be rendered over under each other.
  101655. */
  101656. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101657. /**
  101658. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101659. */
  101660. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101661. /**
  101662. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101663. */
  101664. static readonly RIG_MODE_VR: number;
  101665. /**
  101666. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101667. */
  101668. static readonly RIG_MODE_WEBVR: number;
  101669. /**
  101670. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101671. */
  101672. static readonly RIG_MODE_CUSTOM: number;
  101673. /**
  101674. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101675. */
  101676. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101677. /**
  101678. * Define the input manager associated with the camera.
  101679. */
  101680. inputs: CameraInputsManager<Camera>;
  101681. /** @hidden */
  101682. _position: Vector3;
  101683. /**
  101684. * Define the current local position of the camera in the scene
  101685. */
  101686. get position(): Vector3;
  101687. set position(newPosition: Vector3);
  101688. /**
  101689. * The vector the camera should consider as up.
  101690. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101691. */
  101692. upVector: Vector3;
  101693. /**
  101694. * Define the current limit on the left side for an orthographic camera
  101695. * In scene unit
  101696. */
  101697. orthoLeft: Nullable<number>;
  101698. /**
  101699. * Define the current limit on the right side for an orthographic camera
  101700. * In scene unit
  101701. */
  101702. orthoRight: Nullable<number>;
  101703. /**
  101704. * Define the current limit on the bottom side for an orthographic camera
  101705. * In scene unit
  101706. */
  101707. orthoBottom: Nullable<number>;
  101708. /**
  101709. * Define the current limit on the top side for an orthographic camera
  101710. * In scene unit
  101711. */
  101712. orthoTop: Nullable<number>;
  101713. /**
  101714. * Field Of View is set in Radians. (default is 0.8)
  101715. */
  101716. fov: number;
  101717. /**
  101718. * Define the minimum distance the camera can see from.
  101719. * This is important to note that the depth buffer are not infinite and the closer it starts
  101720. * the more your scene might encounter depth fighting issue.
  101721. */
  101722. minZ: number;
  101723. /**
  101724. * Define the maximum distance the camera can see to.
  101725. * This is important to note that the depth buffer are not infinite and the further it end
  101726. * the more your scene might encounter depth fighting issue.
  101727. */
  101728. maxZ: number;
  101729. /**
  101730. * Define the default inertia of the camera.
  101731. * This helps giving a smooth feeling to the camera movement.
  101732. */
  101733. inertia: number;
  101734. /**
  101735. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  101736. */
  101737. mode: number;
  101738. /**
  101739. * Define whether the camera is intermediate.
  101740. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  101741. */
  101742. isIntermediate: boolean;
  101743. /**
  101744. * Define the viewport of the camera.
  101745. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  101746. */
  101747. viewport: Viewport;
  101748. /**
  101749. * Restricts the camera to viewing objects with the same layerMask.
  101750. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  101751. */
  101752. layerMask: number;
  101753. /**
  101754. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  101755. */
  101756. fovMode: number;
  101757. /**
  101758. * Rig mode of the camera.
  101759. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  101760. * This is normally controlled byt the camera themselves as internal use.
  101761. */
  101762. cameraRigMode: number;
  101763. /**
  101764. * Defines the distance between both "eyes" in case of a RIG
  101765. */
  101766. interaxialDistance: number;
  101767. /**
  101768. * Defines if stereoscopic rendering is done side by side or over under.
  101769. */
  101770. isStereoscopicSideBySide: boolean;
  101771. /**
  101772. * 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
  101773. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  101774. * else in the scene. (Eg. security camera)
  101775. *
  101776. * 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)
  101777. */
  101778. customRenderTargets: RenderTargetTexture[];
  101779. /**
  101780. * When set, the camera will render to this render target instead of the default canvas
  101781. *
  101782. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  101783. */
  101784. outputRenderTarget: Nullable<RenderTargetTexture>;
  101785. /**
  101786. * Observable triggered when the camera view matrix has changed.
  101787. */
  101788. onViewMatrixChangedObservable: Observable<Camera>;
  101789. /**
  101790. * Observable triggered when the camera Projection matrix has changed.
  101791. */
  101792. onProjectionMatrixChangedObservable: Observable<Camera>;
  101793. /**
  101794. * Observable triggered when the inputs have been processed.
  101795. */
  101796. onAfterCheckInputsObservable: Observable<Camera>;
  101797. /**
  101798. * Observable triggered when reset has been called and applied to the camera.
  101799. */
  101800. onRestoreStateObservable: Observable<Camera>;
  101801. /**
  101802. * Is this camera a part of a rig system?
  101803. */
  101804. isRigCamera: boolean;
  101805. /**
  101806. * If isRigCamera set to true this will be set with the parent camera.
  101807. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  101808. */
  101809. rigParent?: Camera;
  101810. /** @hidden */
  101811. _cameraRigParams: any;
  101812. /** @hidden */
  101813. _rigCameras: Camera[];
  101814. /** @hidden */
  101815. _rigPostProcess: Nullable<PostProcess>;
  101816. protected _webvrViewMatrix: Matrix;
  101817. /** @hidden */
  101818. _skipRendering: boolean;
  101819. /** @hidden */
  101820. _projectionMatrix: Matrix;
  101821. /** @hidden */
  101822. _postProcesses: Nullable<PostProcess>[];
  101823. /** @hidden */
  101824. _activeMeshes: SmartArray<AbstractMesh>;
  101825. protected _globalPosition: Vector3;
  101826. /** @hidden */
  101827. _computedViewMatrix: Matrix;
  101828. private _doNotComputeProjectionMatrix;
  101829. private _transformMatrix;
  101830. private _frustumPlanes;
  101831. private _refreshFrustumPlanes;
  101832. private _storedFov;
  101833. private _stateStored;
  101834. /**
  101835. * Instantiates a new camera object.
  101836. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  101837. * @see http://doc.babylonjs.com/features/cameras
  101838. * @param name Defines the name of the camera in the scene
  101839. * @param position Defines the position of the camera
  101840. * @param scene Defines the scene the camera belongs too
  101841. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  101842. */
  101843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101844. /**
  101845. * Store current camera state (fov, position, etc..)
  101846. * @returns the camera
  101847. */
  101848. storeState(): Camera;
  101849. /**
  101850. * Restores the camera state values if it has been stored. You must call storeState() first
  101851. */
  101852. protected _restoreStateValues(): boolean;
  101853. /**
  101854. * Restored camera state. You must call storeState() first.
  101855. * @returns true if restored and false otherwise
  101856. */
  101857. restoreState(): boolean;
  101858. /**
  101859. * Gets the class name of the camera.
  101860. * @returns the class name
  101861. */
  101862. getClassName(): string;
  101863. /** @hidden */
  101864. readonly _isCamera: boolean;
  101865. /**
  101866. * Gets a string representation of the camera useful for debug purpose.
  101867. * @param fullDetails Defines that a more verboe level of logging is required
  101868. * @returns the string representation
  101869. */
  101870. toString(fullDetails?: boolean): string;
  101871. /**
  101872. * Gets the current world space position of the camera.
  101873. */
  101874. get globalPosition(): Vector3;
  101875. /**
  101876. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  101877. * @returns the active meshe list
  101878. */
  101879. getActiveMeshes(): SmartArray<AbstractMesh>;
  101880. /**
  101881. * Check whether a mesh is part of the current active mesh list of the camera
  101882. * @param mesh Defines the mesh to check
  101883. * @returns true if active, false otherwise
  101884. */
  101885. isActiveMesh(mesh: Mesh): boolean;
  101886. /**
  101887. * Is this camera ready to be used/rendered
  101888. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  101889. * @return true if the camera is ready
  101890. */
  101891. isReady(completeCheck?: boolean): boolean;
  101892. /** @hidden */
  101893. _initCache(): void;
  101894. /** @hidden */
  101895. _updateCache(ignoreParentClass?: boolean): void;
  101896. /** @hidden */
  101897. _isSynchronized(): boolean;
  101898. /** @hidden */
  101899. _isSynchronizedViewMatrix(): boolean;
  101900. /** @hidden */
  101901. _isSynchronizedProjectionMatrix(): boolean;
  101902. /**
  101903. * Attach the input controls to a specific dom element to get the input from.
  101904. * @param element Defines the element the controls should be listened from
  101905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101906. */
  101907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101908. /**
  101909. * Detach the current controls from the specified dom element.
  101910. * @param element Defines the element to stop listening the inputs from
  101911. */
  101912. detachControl(element: HTMLElement): void;
  101913. /**
  101914. * Update the camera state according to the different inputs gathered during the frame.
  101915. */
  101916. update(): void;
  101917. /** @hidden */
  101918. _checkInputs(): void;
  101919. /** @hidden */
  101920. get rigCameras(): Camera[];
  101921. /**
  101922. * Gets the post process used by the rig cameras
  101923. */
  101924. get rigPostProcess(): Nullable<PostProcess>;
  101925. /**
  101926. * Internal, gets the first post proces.
  101927. * @returns the first post process to be run on this camera.
  101928. */
  101929. _getFirstPostProcess(): Nullable<PostProcess>;
  101930. private _cascadePostProcessesToRigCams;
  101931. /**
  101932. * Attach a post process to the camera.
  101933. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101934. * @param postProcess The post process to attach to the camera
  101935. * @param insertAt The position of the post process in case several of them are in use in the scene
  101936. * @returns the position the post process has been inserted at
  101937. */
  101938. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  101939. /**
  101940. * Detach a post process to the camera.
  101941. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101942. * @param postProcess The post process to detach from the camera
  101943. */
  101944. detachPostProcess(postProcess: PostProcess): void;
  101945. /**
  101946. * Gets the current world matrix of the camera
  101947. */
  101948. getWorldMatrix(): Matrix;
  101949. /** @hidden */
  101950. _getViewMatrix(): Matrix;
  101951. /**
  101952. * Gets the current view matrix of the camera.
  101953. * @param force forces the camera to recompute the matrix without looking at the cached state
  101954. * @returns the view matrix
  101955. */
  101956. getViewMatrix(force?: boolean): Matrix;
  101957. /**
  101958. * Freeze the projection matrix.
  101959. * It will prevent the cache check of the camera projection compute and can speed up perf
  101960. * if no parameter of the camera are meant to change
  101961. * @param projection Defines manually a projection if necessary
  101962. */
  101963. freezeProjectionMatrix(projection?: Matrix): void;
  101964. /**
  101965. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  101966. */
  101967. unfreezeProjectionMatrix(): void;
  101968. /**
  101969. * Gets the current projection matrix of the camera.
  101970. * @param force forces the camera to recompute the matrix without looking at the cached state
  101971. * @returns the projection matrix
  101972. */
  101973. getProjectionMatrix(force?: boolean): Matrix;
  101974. /**
  101975. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  101976. * @returns a Matrix
  101977. */
  101978. getTransformationMatrix(): Matrix;
  101979. private _updateFrustumPlanes;
  101980. /**
  101981. * Checks if a cullable object (mesh...) is in the camera frustum
  101982. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  101983. * @param target The object to check
  101984. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  101985. * @returns true if the object is in frustum otherwise false
  101986. */
  101987. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  101988. /**
  101989. * Checks if a cullable object (mesh...) is in the camera frustum
  101990. * Unlike isInFrustum this cheks the full bounding box
  101991. * @param target The object to check
  101992. * @returns true if the object is in frustum otherwise false
  101993. */
  101994. isCompletelyInFrustum(target: ICullable): boolean;
  101995. /**
  101996. * Gets a ray in the forward direction from the camera.
  101997. * @param length Defines the length of the ray to create
  101998. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  101999. * @param origin Defines the start point of the ray which defaults to the camera position
  102000. * @returns the forward ray
  102001. */
  102002. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  102003. /**
  102004. * Releases resources associated with this node.
  102005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102007. */
  102008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102009. /** @hidden */
  102010. _isLeftCamera: boolean;
  102011. /**
  102012. * Gets the left camera of a rig setup in case of Rigged Camera
  102013. */
  102014. get isLeftCamera(): boolean;
  102015. /** @hidden */
  102016. _isRightCamera: boolean;
  102017. /**
  102018. * Gets the right camera of a rig setup in case of Rigged Camera
  102019. */
  102020. get isRightCamera(): boolean;
  102021. /**
  102022. * Gets the left camera of a rig setup in case of Rigged Camera
  102023. */
  102024. get leftCamera(): Nullable<FreeCamera>;
  102025. /**
  102026. * Gets the right camera of a rig setup in case of Rigged Camera
  102027. */
  102028. get rightCamera(): Nullable<FreeCamera>;
  102029. /**
  102030. * Gets the left camera target of a rig setup in case of Rigged Camera
  102031. * @returns the target position
  102032. */
  102033. getLeftTarget(): Nullable<Vector3>;
  102034. /**
  102035. * Gets the right camera target of a rig setup in case of Rigged Camera
  102036. * @returns the target position
  102037. */
  102038. getRightTarget(): Nullable<Vector3>;
  102039. /**
  102040. * @hidden
  102041. */
  102042. setCameraRigMode(mode: number, rigParams: any): void;
  102043. /** @hidden */
  102044. static _setStereoscopicRigMode(camera: Camera): void;
  102045. /** @hidden */
  102046. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102047. /** @hidden */
  102048. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102049. /** @hidden */
  102050. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102051. /** @hidden */
  102052. _getVRProjectionMatrix(): Matrix;
  102053. protected _updateCameraRotationMatrix(): void;
  102054. protected _updateWebVRCameraRotationMatrix(): void;
  102055. /**
  102056. * This function MUST be overwritten by the different WebVR cameras available.
  102057. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102058. * @hidden
  102059. */
  102060. _getWebVRProjectionMatrix(): Matrix;
  102061. /**
  102062. * This function MUST be overwritten by the different WebVR cameras available.
  102063. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102064. * @hidden
  102065. */
  102066. _getWebVRViewMatrix(): Matrix;
  102067. /** @hidden */
  102068. setCameraRigParameter(name: string, value: any): void;
  102069. /**
  102070. * needs to be overridden by children so sub has required properties to be copied
  102071. * @hidden
  102072. */
  102073. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102074. /**
  102075. * May need to be overridden by children
  102076. * @hidden
  102077. */
  102078. _updateRigCameras(): void;
  102079. /** @hidden */
  102080. _setupInputs(): void;
  102081. /**
  102082. * Serialiaze the camera setup to a json represention
  102083. * @returns the JSON representation
  102084. */
  102085. serialize(): any;
  102086. /**
  102087. * Clones the current camera.
  102088. * @param name The cloned camera name
  102089. * @returns the cloned camera
  102090. */
  102091. clone(name: string): Camera;
  102092. /**
  102093. * Gets the direction of the camera relative to a given local axis.
  102094. * @param localAxis Defines the reference axis to provide a relative direction.
  102095. * @return the direction
  102096. */
  102097. getDirection(localAxis: Vector3): Vector3;
  102098. /**
  102099. * Returns the current camera absolute rotation
  102100. */
  102101. get absoluteRotation(): Quaternion;
  102102. /**
  102103. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102104. * @param localAxis Defines the reference axis to provide a relative direction.
  102105. * @param result Defines the vector to store the result in
  102106. */
  102107. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102108. /**
  102109. * Gets a camera constructor for a given camera type
  102110. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102111. * @param name The name of the camera the result will be able to instantiate
  102112. * @param scene The scene the result will construct the camera in
  102113. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102114. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102115. * @returns a factory method to construc the camera
  102116. */
  102117. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102118. /**
  102119. * Compute the world matrix of the camera.
  102120. * @returns the camera world matrix
  102121. */
  102122. computeWorldMatrix(): Matrix;
  102123. /**
  102124. * Parse a JSON and creates the camera from the parsed information
  102125. * @param parsedCamera The JSON to parse
  102126. * @param scene The scene to instantiate the camera in
  102127. * @returns the newly constructed camera
  102128. */
  102129. static Parse(parsedCamera: any, scene: Scene): Camera;
  102130. }
  102131. }
  102132. declare module BABYLON {
  102133. /**
  102134. * Class containing static functions to help procedurally build meshes
  102135. */
  102136. export class DiscBuilder {
  102137. /**
  102138. * Creates a plane polygonal mesh. By default, this is a disc
  102139. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102140. * * 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
  102141. * * 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
  102142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102145. * @param name defines the name of the mesh
  102146. * @param options defines the options used to create the mesh
  102147. * @param scene defines the hosting scene
  102148. * @returns the plane polygonal mesh
  102149. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102150. */
  102151. static CreateDisc(name: string, options: {
  102152. radius?: number;
  102153. tessellation?: number;
  102154. arc?: number;
  102155. updatable?: boolean;
  102156. sideOrientation?: number;
  102157. frontUVs?: Vector4;
  102158. backUVs?: Vector4;
  102159. }, scene?: Nullable<Scene>): Mesh;
  102160. }
  102161. }
  102162. declare module BABYLON {
  102163. /**
  102164. * Options to be used when creating a FresnelParameters.
  102165. */
  102166. export type IFresnelParametersCreationOptions = {
  102167. /**
  102168. * Define the color used on edges (grazing angle)
  102169. */
  102170. leftColor?: Color3;
  102171. /**
  102172. * Define the color used on center
  102173. */
  102174. rightColor?: Color3;
  102175. /**
  102176. * Define bias applied to computed fresnel term
  102177. */
  102178. bias?: number;
  102179. /**
  102180. * Defined the power exponent applied to fresnel term
  102181. */
  102182. power?: number;
  102183. /**
  102184. * Define if the fresnel effect is enable or not.
  102185. */
  102186. isEnabled?: boolean;
  102187. };
  102188. /**
  102189. * Serialized format for FresnelParameters.
  102190. */
  102191. export type IFresnelParametersSerialized = {
  102192. /**
  102193. * Define the color used on edges (grazing angle) [as an array]
  102194. */
  102195. leftColor: number[];
  102196. /**
  102197. * Define the color used on center [as an array]
  102198. */
  102199. rightColor: number[];
  102200. /**
  102201. * Define bias applied to computed fresnel term
  102202. */
  102203. bias: number;
  102204. /**
  102205. * Defined the power exponent applied to fresnel term
  102206. */
  102207. power?: number;
  102208. /**
  102209. * Define if the fresnel effect is enable or not.
  102210. */
  102211. isEnabled: boolean;
  102212. };
  102213. /**
  102214. * This represents all the required information to add a fresnel effect on a material:
  102215. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102216. */
  102217. export class FresnelParameters {
  102218. private _isEnabled;
  102219. /**
  102220. * Define if the fresnel effect is enable or not.
  102221. */
  102222. get isEnabled(): boolean;
  102223. set isEnabled(value: boolean);
  102224. /**
  102225. * Define the color used on edges (grazing angle)
  102226. */
  102227. leftColor: Color3;
  102228. /**
  102229. * Define the color used on center
  102230. */
  102231. rightColor: Color3;
  102232. /**
  102233. * Define bias applied to computed fresnel term
  102234. */
  102235. bias: number;
  102236. /**
  102237. * Defined the power exponent applied to fresnel term
  102238. */
  102239. power: number;
  102240. /**
  102241. * Creates a new FresnelParameters object.
  102242. *
  102243. * @param options provide your own settings to optionally to override defaults
  102244. */
  102245. constructor(options?: IFresnelParametersCreationOptions);
  102246. /**
  102247. * Clones the current fresnel and its valuues
  102248. * @returns a clone fresnel configuration
  102249. */
  102250. clone(): FresnelParameters;
  102251. /**
  102252. * Determines equality between FresnelParameters objects
  102253. * @param otherFresnelParameters defines the second operand
  102254. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102255. */
  102256. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102257. /**
  102258. * Serializes the current fresnel parameters to a JSON representation.
  102259. * @return the JSON serialization
  102260. */
  102261. serialize(): IFresnelParametersSerialized;
  102262. /**
  102263. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102264. * @param parsedFresnelParameters Define the JSON representation
  102265. * @returns the parsed parameters
  102266. */
  102267. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102268. }
  102269. }
  102270. declare module BABYLON {
  102271. /**
  102272. * Base class of materials working in push mode in babylon JS
  102273. * @hidden
  102274. */
  102275. export class PushMaterial extends Material {
  102276. protected _activeEffect: Effect;
  102277. protected _normalMatrix: Matrix;
  102278. /**
  102279. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102280. * This means that the material can keep using a previous shader while a new one is being compiled.
  102281. * This is mostly used when shader parallel compilation is supported (true by default)
  102282. */
  102283. allowShaderHotSwapping: boolean;
  102284. constructor(name: string, scene: Scene);
  102285. getEffect(): Effect;
  102286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102287. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102288. /**
  102289. * Binds the given world matrix to the active effect
  102290. *
  102291. * @param world the matrix to bind
  102292. */
  102293. bindOnlyWorldMatrix(world: Matrix): void;
  102294. /**
  102295. * Binds the given normal matrix to the active effect
  102296. *
  102297. * @param normalMatrix the matrix to bind
  102298. */
  102299. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102300. bind(world: Matrix, mesh?: Mesh): void;
  102301. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102302. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102303. }
  102304. }
  102305. declare module BABYLON {
  102306. /**
  102307. * This groups all the flags used to control the materials channel.
  102308. */
  102309. export class MaterialFlags {
  102310. private static _DiffuseTextureEnabled;
  102311. /**
  102312. * Are diffuse textures enabled in the application.
  102313. */
  102314. static get DiffuseTextureEnabled(): boolean;
  102315. static set DiffuseTextureEnabled(value: boolean);
  102316. private static _AmbientTextureEnabled;
  102317. /**
  102318. * Are ambient textures enabled in the application.
  102319. */
  102320. static get AmbientTextureEnabled(): boolean;
  102321. static set AmbientTextureEnabled(value: boolean);
  102322. private static _OpacityTextureEnabled;
  102323. /**
  102324. * Are opacity textures enabled in the application.
  102325. */
  102326. static get OpacityTextureEnabled(): boolean;
  102327. static set OpacityTextureEnabled(value: boolean);
  102328. private static _ReflectionTextureEnabled;
  102329. /**
  102330. * Are reflection textures enabled in the application.
  102331. */
  102332. static get ReflectionTextureEnabled(): boolean;
  102333. static set ReflectionTextureEnabled(value: boolean);
  102334. private static _EmissiveTextureEnabled;
  102335. /**
  102336. * Are emissive textures enabled in the application.
  102337. */
  102338. static get EmissiveTextureEnabled(): boolean;
  102339. static set EmissiveTextureEnabled(value: boolean);
  102340. private static _SpecularTextureEnabled;
  102341. /**
  102342. * Are specular textures enabled in the application.
  102343. */
  102344. static get SpecularTextureEnabled(): boolean;
  102345. static set SpecularTextureEnabled(value: boolean);
  102346. private static _BumpTextureEnabled;
  102347. /**
  102348. * Are bump textures enabled in the application.
  102349. */
  102350. static get BumpTextureEnabled(): boolean;
  102351. static set BumpTextureEnabled(value: boolean);
  102352. private static _LightmapTextureEnabled;
  102353. /**
  102354. * Are lightmap textures enabled in the application.
  102355. */
  102356. static get LightmapTextureEnabled(): boolean;
  102357. static set LightmapTextureEnabled(value: boolean);
  102358. private static _RefractionTextureEnabled;
  102359. /**
  102360. * Are refraction textures enabled in the application.
  102361. */
  102362. static get RefractionTextureEnabled(): boolean;
  102363. static set RefractionTextureEnabled(value: boolean);
  102364. private static _ColorGradingTextureEnabled;
  102365. /**
  102366. * Are color grading textures enabled in the application.
  102367. */
  102368. static get ColorGradingTextureEnabled(): boolean;
  102369. static set ColorGradingTextureEnabled(value: boolean);
  102370. private static _FresnelEnabled;
  102371. /**
  102372. * Are fresnels enabled in the application.
  102373. */
  102374. static get FresnelEnabled(): boolean;
  102375. static set FresnelEnabled(value: boolean);
  102376. private static _ClearCoatTextureEnabled;
  102377. /**
  102378. * Are clear coat textures enabled in the application.
  102379. */
  102380. static get ClearCoatTextureEnabled(): boolean;
  102381. static set ClearCoatTextureEnabled(value: boolean);
  102382. private static _ClearCoatBumpTextureEnabled;
  102383. /**
  102384. * Are clear coat bump textures enabled in the application.
  102385. */
  102386. static get ClearCoatBumpTextureEnabled(): boolean;
  102387. static set ClearCoatBumpTextureEnabled(value: boolean);
  102388. private static _ClearCoatTintTextureEnabled;
  102389. /**
  102390. * Are clear coat tint textures enabled in the application.
  102391. */
  102392. static get ClearCoatTintTextureEnabled(): boolean;
  102393. static set ClearCoatTintTextureEnabled(value: boolean);
  102394. private static _SheenTextureEnabled;
  102395. /**
  102396. * Are sheen textures enabled in the application.
  102397. */
  102398. static get SheenTextureEnabled(): boolean;
  102399. static set SheenTextureEnabled(value: boolean);
  102400. private static _AnisotropicTextureEnabled;
  102401. /**
  102402. * Are anisotropic textures enabled in the application.
  102403. */
  102404. static get AnisotropicTextureEnabled(): boolean;
  102405. static set AnisotropicTextureEnabled(value: boolean);
  102406. private static _ThicknessTextureEnabled;
  102407. /**
  102408. * Are thickness textures enabled in the application.
  102409. */
  102410. static get ThicknessTextureEnabled(): boolean;
  102411. static set ThicknessTextureEnabled(value: boolean);
  102412. }
  102413. }
  102414. declare module BABYLON {
  102415. /** @hidden */
  102416. export var defaultFragmentDeclaration: {
  102417. name: string;
  102418. shader: string;
  102419. };
  102420. }
  102421. declare module BABYLON {
  102422. /** @hidden */
  102423. export var defaultUboDeclaration: {
  102424. name: string;
  102425. shader: string;
  102426. };
  102427. }
  102428. declare module BABYLON {
  102429. /** @hidden */
  102430. export var lightFragmentDeclaration: {
  102431. name: string;
  102432. shader: string;
  102433. };
  102434. }
  102435. declare module BABYLON {
  102436. /** @hidden */
  102437. export var lightUboDeclaration: {
  102438. name: string;
  102439. shader: string;
  102440. };
  102441. }
  102442. declare module BABYLON {
  102443. /** @hidden */
  102444. export var lightsFragmentFunctions: {
  102445. name: string;
  102446. shader: string;
  102447. };
  102448. }
  102449. declare module BABYLON {
  102450. /** @hidden */
  102451. export var shadowsFragmentFunctions: {
  102452. name: string;
  102453. shader: string;
  102454. };
  102455. }
  102456. declare module BABYLON {
  102457. /** @hidden */
  102458. export var fresnelFunction: {
  102459. name: string;
  102460. shader: string;
  102461. };
  102462. }
  102463. declare module BABYLON {
  102464. /** @hidden */
  102465. export var reflectionFunction: {
  102466. name: string;
  102467. shader: string;
  102468. };
  102469. }
  102470. declare module BABYLON {
  102471. /** @hidden */
  102472. export var bumpFragmentMainFunctions: {
  102473. name: string;
  102474. shader: string;
  102475. };
  102476. }
  102477. declare module BABYLON {
  102478. /** @hidden */
  102479. export var bumpFragmentFunctions: {
  102480. name: string;
  102481. shader: string;
  102482. };
  102483. }
  102484. declare module BABYLON {
  102485. /** @hidden */
  102486. export var logDepthDeclaration: {
  102487. name: string;
  102488. shader: string;
  102489. };
  102490. }
  102491. declare module BABYLON {
  102492. /** @hidden */
  102493. export var bumpFragment: {
  102494. name: string;
  102495. shader: string;
  102496. };
  102497. }
  102498. declare module BABYLON {
  102499. /** @hidden */
  102500. export var depthPrePass: {
  102501. name: string;
  102502. shader: string;
  102503. };
  102504. }
  102505. declare module BABYLON {
  102506. /** @hidden */
  102507. export var lightFragment: {
  102508. name: string;
  102509. shader: string;
  102510. };
  102511. }
  102512. declare module BABYLON {
  102513. /** @hidden */
  102514. export var logDepthFragment: {
  102515. name: string;
  102516. shader: string;
  102517. };
  102518. }
  102519. declare module BABYLON {
  102520. /** @hidden */
  102521. export var defaultPixelShader: {
  102522. name: string;
  102523. shader: string;
  102524. };
  102525. }
  102526. declare module BABYLON {
  102527. /** @hidden */
  102528. export var defaultVertexDeclaration: {
  102529. name: string;
  102530. shader: string;
  102531. };
  102532. }
  102533. declare module BABYLON {
  102534. /** @hidden */
  102535. export var bumpVertexDeclaration: {
  102536. name: string;
  102537. shader: string;
  102538. };
  102539. }
  102540. declare module BABYLON {
  102541. /** @hidden */
  102542. export var bumpVertex: {
  102543. name: string;
  102544. shader: string;
  102545. };
  102546. }
  102547. declare module BABYLON {
  102548. /** @hidden */
  102549. export var fogVertex: {
  102550. name: string;
  102551. shader: string;
  102552. };
  102553. }
  102554. declare module BABYLON {
  102555. /** @hidden */
  102556. export var shadowsVertex: {
  102557. name: string;
  102558. shader: string;
  102559. };
  102560. }
  102561. declare module BABYLON {
  102562. /** @hidden */
  102563. export var pointCloudVertex: {
  102564. name: string;
  102565. shader: string;
  102566. };
  102567. }
  102568. declare module BABYLON {
  102569. /** @hidden */
  102570. export var logDepthVertex: {
  102571. name: string;
  102572. shader: string;
  102573. };
  102574. }
  102575. declare module BABYLON {
  102576. /** @hidden */
  102577. export var defaultVertexShader: {
  102578. name: string;
  102579. shader: string;
  102580. };
  102581. }
  102582. declare module BABYLON {
  102583. /** @hidden */
  102584. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102585. MAINUV1: boolean;
  102586. MAINUV2: boolean;
  102587. DIFFUSE: boolean;
  102588. DIFFUSEDIRECTUV: number;
  102589. AMBIENT: boolean;
  102590. AMBIENTDIRECTUV: number;
  102591. OPACITY: boolean;
  102592. OPACITYDIRECTUV: number;
  102593. OPACITYRGB: boolean;
  102594. REFLECTION: boolean;
  102595. EMISSIVE: boolean;
  102596. EMISSIVEDIRECTUV: number;
  102597. SPECULAR: boolean;
  102598. SPECULARDIRECTUV: number;
  102599. BUMP: boolean;
  102600. BUMPDIRECTUV: number;
  102601. PARALLAX: boolean;
  102602. PARALLAXOCCLUSION: boolean;
  102603. SPECULAROVERALPHA: boolean;
  102604. CLIPPLANE: boolean;
  102605. CLIPPLANE2: boolean;
  102606. CLIPPLANE3: boolean;
  102607. CLIPPLANE4: boolean;
  102608. CLIPPLANE5: boolean;
  102609. CLIPPLANE6: boolean;
  102610. ALPHATEST: boolean;
  102611. DEPTHPREPASS: boolean;
  102612. ALPHAFROMDIFFUSE: boolean;
  102613. POINTSIZE: boolean;
  102614. FOG: boolean;
  102615. SPECULARTERM: boolean;
  102616. DIFFUSEFRESNEL: boolean;
  102617. OPACITYFRESNEL: boolean;
  102618. REFLECTIONFRESNEL: boolean;
  102619. REFRACTIONFRESNEL: boolean;
  102620. EMISSIVEFRESNEL: boolean;
  102621. FRESNEL: boolean;
  102622. NORMAL: boolean;
  102623. UV1: boolean;
  102624. UV2: boolean;
  102625. VERTEXCOLOR: boolean;
  102626. VERTEXALPHA: boolean;
  102627. NUM_BONE_INFLUENCERS: number;
  102628. BonesPerMesh: number;
  102629. BONETEXTURE: boolean;
  102630. INSTANCES: boolean;
  102631. GLOSSINESS: boolean;
  102632. ROUGHNESS: boolean;
  102633. EMISSIVEASILLUMINATION: boolean;
  102634. LINKEMISSIVEWITHDIFFUSE: boolean;
  102635. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102636. LIGHTMAP: boolean;
  102637. LIGHTMAPDIRECTUV: number;
  102638. OBJECTSPACE_NORMALMAP: boolean;
  102639. USELIGHTMAPASSHADOWMAP: boolean;
  102640. REFLECTIONMAP_3D: boolean;
  102641. REFLECTIONMAP_SPHERICAL: boolean;
  102642. REFLECTIONMAP_PLANAR: boolean;
  102643. REFLECTIONMAP_CUBIC: boolean;
  102644. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102645. REFLECTIONMAP_PROJECTION: boolean;
  102646. REFLECTIONMAP_SKYBOX: boolean;
  102647. REFLECTIONMAP_EXPLICIT: boolean;
  102648. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102649. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102650. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102651. INVERTCUBICMAP: boolean;
  102652. LOGARITHMICDEPTH: boolean;
  102653. REFRACTION: boolean;
  102654. REFRACTIONMAP_3D: boolean;
  102655. REFLECTIONOVERALPHA: boolean;
  102656. TWOSIDEDLIGHTING: boolean;
  102657. SHADOWFLOAT: boolean;
  102658. MORPHTARGETS: boolean;
  102659. MORPHTARGETS_NORMAL: boolean;
  102660. MORPHTARGETS_TANGENT: boolean;
  102661. MORPHTARGETS_UV: boolean;
  102662. NUM_MORPH_INFLUENCERS: number;
  102663. NONUNIFORMSCALING: boolean;
  102664. PREMULTIPLYALPHA: boolean;
  102665. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102666. ALPHABLEND: boolean;
  102667. IMAGEPROCESSING: boolean;
  102668. VIGNETTE: boolean;
  102669. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102670. VIGNETTEBLENDMODEOPAQUE: boolean;
  102671. TONEMAPPING: boolean;
  102672. TONEMAPPING_ACES: boolean;
  102673. CONTRAST: boolean;
  102674. COLORCURVES: boolean;
  102675. COLORGRADING: boolean;
  102676. COLORGRADING3D: boolean;
  102677. SAMPLER3DGREENDEPTH: boolean;
  102678. SAMPLER3DBGRMAP: boolean;
  102679. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102680. MULTIVIEW: boolean;
  102681. /**
  102682. * If the reflection texture on this material is in linear color space
  102683. * @hidden
  102684. */
  102685. IS_REFLECTION_LINEAR: boolean;
  102686. /**
  102687. * If the refraction texture on this material is in linear color space
  102688. * @hidden
  102689. */
  102690. IS_REFRACTION_LINEAR: boolean;
  102691. EXPOSURE: boolean;
  102692. constructor();
  102693. setReflectionMode(modeToEnable: string): void;
  102694. }
  102695. /**
  102696. * This is the default material used in Babylon. It is the best trade off between quality
  102697. * and performances.
  102698. * @see http://doc.babylonjs.com/babylon101/materials
  102699. */
  102700. export class StandardMaterial extends PushMaterial {
  102701. private _diffuseTexture;
  102702. /**
  102703. * The basic texture of the material as viewed under a light.
  102704. */
  102705. diffuseTexture: Nullable<BaseTexture>;
  102706. private _ambientTexture;
  102707. /**
  102708. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102709. */
  102710. ambientTexture: Nullable<BaseTexture>;
  102711. private _opacityTexture;
  102712. /**
  102713. * Define the transparency of the material from a texture.
  102714. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102715. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102716. */
  102717. opacityTexture: Nullable<BaseTexture>;
  102718. private _reflectionTexture;
  102719. /**
  102720. * Define the texture used to display the reflection.
  102721. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102722. */
  102723. reflectionTexture: Nullable<BaseTexture>;
  102724. private _emissiveTexture;
  102725. /**
  102726. * Define texture of the material as if self lit.
  102727. * This will be mixed in the final result even in the absence of light.
  102728. */
  102729. emissiveTexture: Nullable<BaseTexture>;
  102730. private _specularTexture;
  102731. /**
  102732. * Define how the color and intensity of the highlight given by the light in the material.
  102733. */
  102734. specularTexture: Nullable<BaseTexture>;
  102735. private _bumpTexture;
  102736. /**
  102737. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102738. * 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.
  102739. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102740. */
  102741. bumpTexture: Nullable<BaseTexture>;
  102742. private _lightmapTexture;
  102743. /**
  102744. * Complex lighting can be computationally expensive to compute at runtime.
  102745. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102746. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102747. */
  102748. lightmapTexture: Nullable<BaseTexture>;
  102749. private _refractionTexture;
  102750. /**
  102751. * Define the texture used to display the refraction.
  102752. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102753. */
  102754. refractionTexture: Nullable<BaseTexture>;
  102755. /**
  102756. * The color of the material lit by the environmental background lighting.
  102757. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102758. */
  102759. ambientColor: Color3;
  102760. /**
  102761. * The basic color of the material as viewed under a light.
  102762. */
  102763. diffuseColor: Color3;
  102764. /**
  102765. * Define how the color and intensity of the highlight given by the light in the material.
  102766. */
  102767. specularColor: Color3;
  102768. /**
  102769. * Define the color of the material as if self lit.
  102770. * This will be mixed in the final result even in the absence of light.
  102771. */
  102772. emissiveColor: Color3;
  102773. /**
  102774. * Defines how sharp are the highlights in the material.
  102775. * The bigger the value the sharper giving a more glossy feeling to the result.
  102776. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102777. */
  102778. specularPower: number;
  102779. private _useAlphaFromDiffuseTexture;
  102780. /**
  102781. * Does the transparency come from the diffuse texture alpha channel.
  102782. */
  102783. useAlphaFromDiffuseTexture: boolean;
  102784. private _useEmissiveAsIllumination;
  102785. /**
  102786. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102787. */
  102788. useEmissiveAsIllumination: boolean;
  102789. private _linkEmissiveWithDiffuse;
  102790. /**
  102791. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102792. * the emissive level when the final color is close to one.
  102793. */
  102794. linkEmissiveWithDiffuse: boolean;
  102795. private _useSpecularOverAlpha;
  102796. /**
  102797. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102798. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102799. */
  102800. useSpecularOverAlpha: boolean;
  102801. private _useReflectionOverAlpha;
  102802. /**
  102803. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102804. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102805. */
  102806. useReflectionOverAlpha: boolean;
  102807. private _disableLighting;
  102808. /**
  102809. * Does lights from the scene impacts this material.
  102810. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102811. */
  102812. disableLighting: boolean;
  102813. private _useObjectSpaceNormalMap;
  102814. /**
  102815. * Allows using an object space normal map (instead of tangent space).
  102816. */
  102817. useObjectSpaceNormalMap: boolean;
  102818. private _useParallax;
  102819. /**
  102820. * Is parallax enabled or not.
  102821. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102822. */
  102823. useParallax: boolean;
  102824. private _useParallaxOcclusion;
  102825. /**
  102826. * Is parallax occlusion enabled or not.
  102827. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102828. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102829. */
  102830. useParallaxOcclusion: boolean;
  102831. /**
  102832. * 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.
  102833. */
  102834. parallaxScaleBias: number;
  102835. private _roughness;
  102836. /**
  102837. * Helps to define how blurry the reflections should appears in the material.
  102838. */
  102839. roughness: number;
  102840. /**
  102841. * In case of refraction, define the value of the index of refraction.
  102842. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102843. */
  102844. indexOfRefraction: number;
  102845. /**
  102846. * Invert the refraction texture alongside the y axis.
  102847. * It can be useful with procedural textures or probe for instance.
  102848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102849. */
  102850. invertRefractionY: boolean;
  102851. /**
  102852. * Defines the alpha limits in alpha test mode.
  102853. */
  102854. alphaCutOff: number;
  102855. private _useLightmapAsShadowmap;
  102856. /**
  102857. * In case of light mapping, define whether the map contains light or shadow informations.
  102858. */
  102859. useLightmapAsShadowmap: boolean;
  102860. private _diffuseFresnelParameters;
  102861. /**
  102862. * Define the diffuse fresnel parameters of the material.
  102863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102864. */
  102865. diffuseFresnelParameters: FresnelParameters;
  102866. private _opacityFresnelParameters;
  102867. /**
  102868. * Define the opacity fresnel parameters of the material.
  102869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102870. */
  102871. opacityFresnelParameters: FresnelParameters;
  102872. private _reflectionFresnelParameters;
  102873. /**
  102874. * Define the reflection fresnel parameters of the material.
  102875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102876. */
  102877. reflectionFresnelParameters: FresnelParameters;
  102878. private _refractionFresnelParameters;
  102879. /**
  102880. * Define the refraction fresnel parameters of the material.
  102881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102882. */
  102883. refractionFresnelParameters: FresnelParameters;
  102884. private _emissiveFresnelParameters;
  102885. /**
  102886. * Define the emissive fresnel parameters of the material.
  102887. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102888. */
  102889. emissiveFresnelParameters: FresnelParameters;
  102890. private _useReflectionFresnelFromSpecular;
  102891. /**
  102892. * If true automatically deducts the fresnels values from the material specularity.
  102893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102894. */
  102895. useReflectionFresnelFromSpecular: boolean;
  102896. private _useGlossinessFromSpecularMapAlpha;
  102897. /**
  102898. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102899. */
  102900. useGlossinessFromSpecularMapAlpha: boolean;
  102901. private _maxSimultaneousLights;
  102902. /**
  102903. * Defines the maximum number of lights that can be used in the material
  102904. */
  102905. maxSimultaneousLights: number;
  102906. private _invertNormalMapX;
  102907. /**
  102908. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102909. */
  102910. invertNormalMapX: boolean;
  102911. private _invertNormalMapY;
  102912. /**
  102913. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102914. */
  102915. invertNormalMapY: boolean;
  102916. private _twoSidedLighting;
  102917. /**
  102918. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102919. */
  102920. twoSidedLighting: boolean;
  102921. /**
  102922. * Default configuration related to image processing available in the standard Material.
  102923. */
  102924. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102925. /**
  102926. * Gets the image processing configuration used either in this material.
  102927. */
  102928. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102929. /**
  102930. * Sets the Default image processing configuration used either in the this material.
  102931. *
  102932. * If sets to null, the scene one is in use.
  102933. */
  102934. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102935. /**
  102936. * Keep track of the image processing observer to allow dispose and replace.
  102937. */
  102938. private _imageProcessingObserver;
  102939. /**
  102940. * Attaches a new image processing configuration to the Standard Material.
  102941. * @param configuration
  102942. */
  102943. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102944. /**
  102945. * Gets wether the color curves effect is enabled.
  102946. */
  102947. get cameraColorCurvesEnabled(): boolean;
  102948. /**
  102949. * Sets wether the color curves effect is enabled.
  102950. */
  102951. set cameraColorCurvesEnabled(value: boolean);
  102952. /**
  102953. * Gets wether the color grading effect is enabled.
  102954. */
  102955. get cameraColorGradingEnabled(): boolean;
  102956. /**
  102957. * Gets wether the color grading effect is enabled.
  102958. */
  102959. set cameraColorGradingEnabled(value: boolean);
  102960. /**
  102961. * Gets wether tonemapping is enabled or not.
  102962. */
  102963. get cameraToneMappingEnabled(): boolean;
  102964. /**
  102965. * Sets wether tonemapping is enabled or not
  102966. */
  102967. set cameraToneMappingEnabled(value: boolean);
  102968. /**
  102969. * The camera exposure used on this material.
  102970. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102971. * This corresponds to a photographic exposure.
  102972. */
  102973. get cameraExposure(): number;
  102974. /**
  102975. * The camera exposure used on this material.
  102976. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102977. * This corresponds to a photographic exposure.
  102978. */
  102979. set cameraExposure(value: number);
  102980. /**
  102981. * Gets The camera contrast used on this material.
  102982. */
  102983. get cameraContrast(): number;
  102984. /**
  102985. * Sets The camera contrast used on this material.
  102986. */
  102987. set cameraContrast(value: number);
  102988. /**
  102989. * Gets the Color Grading 2D Lookup Texture.
  102990. */
  102991. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  102992. /**
  102993. * Sets the Color Grading 2D Lookup Texture.
  102994. */
  102995. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  102996. /**
  102997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102999. * 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;
  103000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103001. */
  103002. get cameraColorCurves(): Nullable<ColorCurves>;
  103003. /**
  103004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103006. * 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;
  103007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103008. */
  103009. set cameraColorCurves(value: Nullable<ColorCurves>);
  103010. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103011. protected _worldViewProjectionMatrix: Matrix;
  103012. protected _globalAmbientColor: Color3;
  103013. protected _useLogarithmicDepth: boolean;
  103014. protected _rebuildInParallel: boolean;
  103015. /**
  103016. * Instantiates a new standard material.
  103017. * This is the default material used in Babylon. It is the best trade off between quality
  103018. * and performances.
  103019. * @see http://doc.babylonjs.com/babylon101/materials
  103020. * @param name Define the name of the material in the scene
  103021. * @param scene Define the scene the material belong to
  103022. */
  103023. constructor(name: string, scene: Scene);
  103024. /**
  103025. * Gets a boolean indicating that current material needs to register RTT
  103026. */
  103027. get hasRenderTargetTextures(): boolean;
  103028. /**
  103029. * Gets the current class name of the material e.g. "StandardMaterial"
  103030. * Mainly use in serialization.
  103031. * @returns the class name
  103032. */
  103033. getClassName(): string;
  103034. /**
  103035. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103036. * You can try switching to logarithmic depth.
  103037. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103038. */
  103039. get useLogarithmicDepth(): boolean;
  103040. set useLogarithmicDepth(value: boolean);
  103041. /**
  103042. * Specifies if the material will require alpha blending
  103043. * @returns a boolean specifying if alpha blending is needed
  103044. */
  103045. needAlphaBlending(): boolean;
  103046. /**
  103047. * Specifies if this material should be rendered in alpha test mode
  103048. * @returns a boolean specifying if an alpha test is needed.
  103049. */
  103050. needAlphaTesting(): boolean;
  103051. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103052. /**
  103053. * Get the texture used for alpha test purpose.
  103054. * @returns the diffuse texture in case of the standard material.
  103055. */
  103056. getAlphaTestTexture(): Nullable<BaseTexture>;
  103057. /**
  103058. * Get if the submesh is ready to be used and all its information available.
  103059. * Child classes can use it to update shaders
  103060. * @param mesh defines the mesh to check
  103061. * @param subMesh defines which submesh to check
  103062. * @param useInstances specifies that instances should be used
  103063. * @returns a boolean indicating that the submesh is ready or not
  103064. */
  103065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103066. /**
  103067. * Builds the material UBO layouts.
  103068. * Used internally during the effect preparation.
  103069. */
  103070. buildUniformLayout(): void;
  103071. /**
  103072. * Unbinds the material from the mesh
  103073. */
  103074. unbind(): void;
  103075. /**
  103076. * Binds the submesh to this material by preparing the effect and shader to draw
  103077. * @param world defines the world transformation matrix
  103078. * @param mesh defines the mesh containing the submesh
  103079. * @param subMesh defines the submesh to bind the material to
  103080. */
  103081. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103082. /**
  103083. * Get the list of animatables in the material.
  103084. * @returns the list of animatables object used in the material
  103085. */
  103086. getAnimatables(): IAnimatable[];
  103087. /**
  103088. * Gets the active textures from the material
  103089. * @returns an array of textures
  103090. */
  103091. getActiveTextures(): BaseTexture[];
  103092. /**
  103093. * Specifies if the material uses a texture
  103094. * @param texture defines the texture to check against the material
  103095. * @returns a boolean specifying if the material uses the texture
  103096. */
  103097. hasTexture(texture: BaseTexture): boolean;
  103098. /**
  103099. * Disposes the material
  103100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103102. */
  103103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103104. /**
  103105. * Makes a duplicate of the material, and gives it a new name
  103106. * @param name defines the new name for the duplicated material
  103107. * @returns the cloned material
  103108. */
  103109. clone(name: string): StandardMaterial;
  103110. /**
  103111. * Serializes this material in a JSON representation
  103112. * @returns the serialized material object
  103113. */
  103114. serialize(): any;
  103115. /**
  103116. * Creates a standard material from parsed material data
  103117. * @param source defines the JSON representation of the material
  103118. * @param scene defines the hosting scene
  103119. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103120. * @returns a new standard material
  103121. */
  103122. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103123. /**
  103124. * Are diffuse textures enabled in the application.
  103125. */
  103126. static get DiffuseTextureEnabled(): boolean;
  103127. static set DiffuseTextureEnabled(value: boolean);
  103128. /**
  103129. * Are ambient textures enabled in the application.
  103130. */
  103131. static get AmbientTextureEnabled(): boolean;
  103132. static set AmbientTextureEnabled(value: boolean);
  103133. /**
  103134. * Are opacity textures enabled in the application.
  103135. */
  103136. static get OpacityTextureEnabled(): boolean;
  103137. static set OpacityTextureEnabled(value: boolean);
  103138. /**
  103139. * Are reflection textures enabled in the application.
  103140. */
  103141. static get ReflectionTextureEnabled(): boolean;
  103142. static set ReflectionTextureEnabled(value: boolean);
  103143. /**
  103144. * Are emissive textures enabled in the application.
  103145. */
  103146. static get EmissiveTextureEnabled(): boolean;
  103147. static set EmissiveTextureEnabled(value: boolean);
  103148. /**
  103149. * Are specular textures enabled in the application.
  103150. */
  103151. static get SpecularTextureEnabled(): boolean;
  103152. static set SpecularTextureEnabled(value: boolean);
  103153. /**
  103154. * Are bump textures enabled in the application.
  103155. */
  103156. static get BumpTextureEnabled(): boolean;
  103157. static set BumpTextureEnabled(value: boolean);
  103158. /**
  103159. * Are lightmap textures enabled in the application.
  103160. */
  103161. static get LightmapTextureEnabled(): boolean;
  103162. static set LightmapTextureEnabled(value: boolean);
  103163. /**
  103164. * Are refraction textures enabled in the application.
  103165. */
  103166. static get RefractionTextureEnabled(): boolean;
  103167. static set RefractionTextureEnabled(value: boolean);
  103168. /**
  103169. * Are color grading textures enabled in the application.
  103170. */
  103171. static get ColorGradingTextureEnabled(): boolean;
  103172. static set ColorGradingTextureEnabled(value: boolean);
  103173. /**
  103174. * Are fresnels enabled in the application.
  103175. */
  103176. static get FresnelEnabled(): boolean;
  103177. static set FresnelEnabled(value: boolean);
  103178. }
  103179. }
  103180. declare module BABYLON {
  103181. /**
  103182. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103183. *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.
  103184. * The SPS is also a particle system. It provides some methods to manage the particles.
  103185. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103186. *
  103187. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103188. */
  103189. export class SolidParticleSystem implements IDisposable {
  103190. /**
  103191. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103192. * Example : var p = SPS.particles[i];
  103193. */
  103194. particles: SolidParticle[];
  103195. /**
  103196. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103197. */
  103198. nbParticles: number;
  103199. /**
  103200. * If the particles must ever face the camera (default false). Useful for planar particles.
  103201. */
  103202. billboard: boolean;
  103203. /**
  103204. * Recompute normals when adding a shape
  103205. */
  103206. recomputeNormals: boolean;
  103207. /**
  103208. * This a counter ofr your own usage. It's not set by any SPS functions.
  103209. */
  103210. counter: number;
  103211. /**
  103212. * The SPS name. This name is also given to the underlying mesh.
  103213. */
  103214. name: string;
  103215. /**
  103216. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103217. */
  103218. mesh: Mesh;
  103219. /**
  103220. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103221. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103222. */
  103223. vars: any;
  103224. /**
  103225. * This array is populated when the SPS is set as 'pickable'.
  103226. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103227. * Each element of this array is an object `{idx: int, faceId: int}`.
  103228. * `idx` is the picked particle index in the `SPS.particles` array
  103229. * `faceId` is the picked face index counted within this particle.
  103230. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103231. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103232. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103233. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103234. */
  103235. pickedParticles: {
  103236. idx: number;
  103237. faceId: number;
  103238. }[];
  103239. /**
  103240. * This array is populated when the SPS is set as 'pickable'
  103241. * Each key of this array is a submesh index.
  103242. * Each element of this array is a second array defined like this :
  103243. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103244. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103245. * `idx` is the picked particle index in the `SPS.particles` array
  103246. * `faceId` is the picked face index counted within this particle.
  103247. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103248. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103249. */
  103250. pickedBySubMesh: {
  103251. idx: number;
  103252. faceId: number;
  103253. }[][];
  103254. /**
  103255. * This array is populated when `enableDepthSort` is set to true.
  103256. * Each element of this array is an instance of the class DepthSortedParticle.
  103257. */
  103258. depthSortedParticles: DepthSortedParticle[];
  103259. /**
  103260. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103261. * @hidden
  103262. */
  103263. _bSphereOnly: boolean;
  103264. /**
  103265. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103266. * @hidden
  103267. */
  103268. _bSphereRadiusFactor: number;
  103269. private _scene;
  103270. private _positions;
  103271. private _indices;
  103272. private _normals;
  103273. private _colors;
  103274. private _uvs;
  103275. private _indices32;
  103276. private _positions32;
  103277. private _normals32;
  103278. private _fixedNormal32;
  103279. private _colors32;
  103280. private _uvs32;
  103281. private _index;
  103282. private _updatable;
  103283. private _pickable;
  103284. private _isVisibilityBoxLocked;
  103285. private _alwaysVisible;
  103286. private _depthSort;
  103287. private _expandable;
  103288. private _shapeCounter;
  103289. private _copy;
  103290. private _color;
  103291. private _computeParticleColor;
  103292. private _computeParticleTexture;
  103293. private _computeParticleRotation;
  103294. private _computeParticleVertex;
  103295. private _computeBoundingBox;
  103296. private _depthSortParticles;
  103297. private _camera;
  103298. private _mustUnrotateFixedNormals;
  103299. private _particlesIntersect;
  103300. private _needs32Bits;
  103301. private _isNotBuilt;
  103302. private _lastParticleId;
  103303. private _idxOfId;
  103304. private _multimaterialEnabled;
  103305. private _useModelMaterial;
  103306. private _indicesByMaterial;
  103307. private _materialIndexes;
  103308. private _depthSortFunction;
  103309. private _materialSortFunction;
  103310. private _materials;
  103311. private _multimaterial;
  103312. private _materialIndexesById;
  103313. private _defaultMaterial;
  103314. private _autoUpdateSubMeshes;
  103315. private _tmpVertex;
  103316. /**
  103317. * Creates a SPS (Solid Particle System) object.
  103318. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103319. * @param scene (Scene) is the scene in which the SPS is added.
  103320. * @param options defines the options of the sps e.g.
  103321. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103322. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103323. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103324. * * 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.
  103325. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103326. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103327. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103328. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103329. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103330. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103331. */
  103332. constructor(name: string, scene: Scene, options?: {
  103333. updatable?: boolean;
  103334. isPickable?: boolean;
  103335. enableDepthSort?: boolean;
  103336. particleIntersection?: boolean;
  103337. boundingSphereOnly?: boolean;
  103338. bSphereRadiusFactor?: number;
  103339. expandable?: boolean;
  103340. useModelMaterial?: boolean;
  103341. enableMultiMaterial?: boolean;
  103342. });
  103343. /**
  103344. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103345. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103346. * @returns the created mesh
  103347. */
  103348. buildMesh(): Mesh;
  103349. /**
  103350. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103351. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103352. * Thus the particles generated from `digest()` have their property `position` set yet.
  103353. * @param mesh ( Mesh ) is the mesh to be digested
  103354. * @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
  103355. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103356. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103357. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103358. * @returns the current SPS
  103359. */
  103360. digest(mesh: Mesh, options?: {
  103361. facetNb?: number;
  103362. number?: number;
  103363. delta?: number;
  103364. storage?: [];
  103365. }): SolidParticleSystem;
  103366. /**
  103367. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103368. * @hidden
  103369. */
  103370. private _unrotateFixedNormals;
  103371. /**
  103372. * Resets the temporary working copy particle
  103373. * @hidden
  103374. */
  103375. private _resetCopy;
  103376. /**
  103377. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103378. * @param p the current index in the positions array to be updated
  103379. * @param ind the current index in the indices array
  103380. * @param shape a Vector3 array, the shape geometry
  103381. * @param positions the positions array to be updated
  103382. * @param meshInd the shape indices array
  103383. * @param indices the indices array to be updated
  103384. * @param meshUV the shape uv array
  103385. * @param uvs the uv array to be updated
  103386. * @param meshCol the shape color array
  103387. * @param colors the color array to be updated
  103388. * @param meshNor the shape normals array
  103389. * @param normals the normals array to be updated
  103390. * @param idx the particle index
  103391. * @param idxInShape the particle index in its shape
  103392. * @param options the addShape() method passed options
  103393. * @model the particle model
  103394. * @hidden
  103395. */
  103396. private _meshBuilder;
  103397. /**
  103398. * Returns a shape Vector3 array from positions float array
  103399. * @param positions float array
  103400. * @returns a vector3 array
  103401. * @hidden
  103402. */
  103403. private _posToShape;
  103404. /**
  103405. * Returns a shapeUV array from a float uvs (array deep copy)
  103406. * @param uvs as a float array
  103407. * @returns a shapeUV array
  103408. * @hidden
  103409. */
  103410. private _uvsToShapeUV;
  103411. /**
  103412. * Adds a new particle object in the particles array
  103413. * @param idx particle index in particles array
  103414. * @param id particle id
  103415. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103416. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103417. * @param model particle ModelShape object
  103418. * @param shapeId model shape identifier
  103419. * @param idxInShape index of the particle in the current model
  103420. * @param bInfo model bounding info object
  103421. * @param storage target storage array, if any
  103422. * @hidden
  103423. */
  103424. private _addParticle;
  103425. /**
  103426. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103427. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103428. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103429. * @param nb (positive integer) the number of particles to be created from this model
  103430. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103431. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103432. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103433. * @returns the number of shapes in the system
  103434. */
  103435. addShape(mesh: Mesh, nb: number, options?: {
  103436. positionFunction?: any;
  103437. vertexFunction?: any;
  103438. storage?: [];
  103439. }): number;
  103440. /**
  103441. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103442. * @hidden
  103443. */
  103444. private _rebuildParticle;
  103445. /**
  103446. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103447. * @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.
  103448. * @returns the SPS.
  103449. */
  103450. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103451. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103452. * Returns an array with the removed particles.
  103453. * 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.
  103454. * The SPS can't be empty so at least one particle needs to remain in place.
  103455. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103456. * @param start index of the first particle to remove
  103457. * @param end index of the last particle to remove (included)
  103458. * @returns an array populated with the removed particles
  103459. */
  103460. removeParticles(start: number, end: number): SolidParticle[];
  103461. /**
  103462. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103463. * @param solidParticleArray an array populated with Solid Particles objects
  103464. * @returns the SPS
  103465. */
  103466. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103467. /**
  103468. * Creates a new particle and modifies the SPS mesh geometry :
  103469. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103470. * - calls _addParticle() to populate the particle array
  103471. * factorized code from addShape() and insertParticlesFromArray()
  103472. * @param idx particle index in the particles array
  103473. * @param i particle index in its shape
  103474. * @param modelShape particle ModelShape object
  103475. * @param shape shape vertex array
  103476. * @param meshInd shape indices array
  103477. * @param meshUV shape uv array
  103478. * @param meshCol shape color array
  103479. * @param meshNor shape normals array
  103480. * @param bbInfo shape bounding info
  103481. * @param storage target particle storage
  103482. * @options addShape() passed options
  103483. * @hidden
  103484. */
  103485. private _insertNewParticle;
  103486. /**
  103487. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103488. * This method calls `updateParticle()` for each particle of the SPS.
  103489. * For an animated SPS, it is usually called within the render loop.
  103490. * 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.
  103491. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103492. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103493. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103494. * @returns the SPS.
  103495. */
  103496. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103497. /**
  103498. * Disposes the SPS.
  103499. */
  103500. dispose(): void;
  103501. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103502. * idx is the particle index in the SPS
  103503. * faceId is the picked face index counted within this particle.
  103504. * Returns null if the pickInfo can't identify a picked particle.
  103505. * @param pickingInfo (PickingInfo object)
  103506. * @returns {idx: number, faceId: number} or null
  103507. */
  103508. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103509. idx: number;
  103510. faceId: number;
  103511. }>;
  103512. /**
  103513. * Returns a SolidParticle object from its identifier : particle.id
  103514. * @param id (integer) the particle Id
  103515. * @returns the searched particle or null if not found in the SPS.
  103516. */
  103517. getParticleById(id: number): Nullable<SolidParticle>;
  103518. /**
  103519. * Returns a new array populated with the particles having the passed shapeId.
  103520. * @param shapeId (integer) the shape identifier
  103521. * @returns a new solid particle array
  103522. */
  103523. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103524. /**
  103525. * Populates the passed array "ref" with the particles having the passed shapeId.
  103526. * @param shapeId the shape identifier
  103527. * @returns the SPS
  103528. * @param ref
  103529. */
  103530. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103531. /**
  103532. * Computes the required SubMeshes according the materials assigned to the particles.
  103533. * @returns the solid particle system.
  103534. * Does nothing if called before the SPS mesh is built.
  103535. */
  103536. computeSubMeshes(): SolidParticleSystem;
  103537. /**
  103538. * Sorts the solid particles by material when MultiMaterial is enabled.
  103539. * Updates the indices32 array.
  103540. * Updates the indicesByMaterial array.
  103541. * Updates the mesh indices array.
  103542. * @returns the SPS
  103543. * @hidden
  103544. */
  103545. private _sortParticlesByMaterial;
  103546. /**
  103547. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103548. * @hidden
  103549. */
  103550. private _setMaterialIndexesById;
  103551. /**
  103552. * Returns an array with unique values of Materials from the passed array
  103553. * @param array the material array to be checked and filtered
  103554. * @hidden
  103555. */
  103556. private _filterUniqueMaterialId;
  103557. /**
  103558. * Sets a new Standard Material as _defaultMaterial if not already set.
  103559. * @hidden
  103560. */
  103561. private _setDefaultMaterial;
  103562. /**
  103563. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103564. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103565. * @returns the SPS.
  103566. */
  103567. refreshVisibleSize(): SolidParticleSystem;
  103568. /**
  103569. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103570. * @param size the size (float) of the visibility box
  103571. * note : this doesn't lock the SPS mesh bounding box.
  103572. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103573. */
  103574. setVisibilityBox(size: number): void;
  103575. /**
  103576. * Gets whether the SPS as always visible or not
  103577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103578. */
  103579. get isAlwaysVisible(): boolean;
  103580. /**
  103581. * Sets the SPS as always visible or not
  103582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103583. */
  103584. set isAlwaysVisible(val: boolean);
  103585. /**
  103586. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103588. */
  103589. set isVisibilityBoxLocked(val: boolean);
  103590. /**
  103591. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103592. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103593. */
  103594. get isVisibilityBoxLocked(): boolean;
  103595. /**
  103596. * Tells to `setParticles()` to compute the particle rotations or not.
  103597. * Default value : true. The SPS is faster when it's set to false.
  103598. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103599. */
  103600. set computeParticleRotation(val: boolean);
  103601. /**
  103602. * Tells to `setParticles()` to compute the particle colors or not.
  103603. * Default value : true. The SPS is faster when it's set to false.
  103604. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103605. */
  103606. set computeParticleColor(val: boolean);
  103607. set computeParticleTexture(val: boolean);
  103608. /**
  103609. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103610. * Default value : false. The SPS is faster when it's set to false.
  103611. * Note : the particle custom vertex positions aren't stored values.
  103612. */
  103613. set computeParticleVertex(val: boolean);
  103614. /**
  103615. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103616. */
  103617. set computeBoundingBox(val: boolean);
  103618. /**
  103619. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103620. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103621. * Default : `true`
  103622. */
  103623. set depthSortParticles(val: boolean);
  103624. /**
  103625. * Gets if `setParticles()` computes the particle rotations or not.
  103626. * Default value : true. The SPS is faster when it's set to false.
  103627. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103628. */
  103629. get computeParticleRotation(): boolean;
  103630. /**
  103631. * Gets if `setParticles()` computes the particle colors or not.
  103632. * Default value : true. The SPS is faster when it's set to false.
  103633. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103634. */
  103635. get computeParticleColor(): boolean;
  103636. /**
  103637. * Gets if `setParticles()` computes the particle textures or not.
  103638. * Default value : true. The SPS is faster when it's set to false.
  103639. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103640. */
  103641. get computeParticleTexture(): boolean;
  103642. /**
  103643. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103644. * Default value : false. The SPS is faster when it's set to false.
  103645. * Note : the particle custom vertex positions aren't stored values.
  103646. */
  103647. get computeParticleVertex(): boolean;
  103648. /**
  103649. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103650. */
  103651. get computeBoundingBox(): boolean;
  103652. /**
  103653. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103654. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103655. * Default : `true`
  103656. */
  103657. get depthSortParticles(): boolean;
  103658. /**
  103659. * Gets if the SPS is created as expandable at construction time.
  103660. * Default : `false`
  103661. */
  103662. get expandable(): boolean;
  103663. /**
  103664. * Gets if the SPS supports the Multi Materials
  103665. */
  103666. get multimaterialEnabled(): boolean;
  103667. /**
  103668. * Gets if the SPS uses the model materials for its own multimaterial.
  103669. */
  103670. get useModelMaterial(): boolean;
  103671. /**
  103672. * The SPS used material array.
  103673. */
  103674. get materials(): Material[];
  103675. /**
  103676. * Sets the SPS MultiMaterial from the passed materials.
  103677. * Note : the passed array is internally copied and not used then by reference.
  103678. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103679. */
  103680. setMultiMaterial(materials: Material[]): void;
  103681. /**
  103682. * The SPS computed multimaterial object
  103683. */
  103684. get multimaterial(): MultiMaterial;
  103685. set multimaterial(mm: MultiMaterial);
  103686. /**
  103687. * If the subMeshes must be updated on the next call to setParticles()
  103688. */
  103689. get autoUpdateSubMeshes(): boolean;
  103690. set autoUpdateSubMeshes(val: boolean);
  103691. /**
  103692. * This function does nothing. It may be overwritten to set all the particle first values.
  103693. * The SPS doesn't call this function, you may have to call it by your own.
  103694. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103695. */
  103696. initParticles(): void;
  103697. /**
  103698. * This function does nothing. It may be overwritten to recycle a particle.
  103699. * The SPS doesn't call this function, you may have to call it by your own.
  103700. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103701. * @param particle The particle to recycle
  103702. * @returns the recycled particle
  103703. */
  103704. recycleParticle(particle: SolidParticle): SolidParticle;
  103705. /**
  103706. * Updates a particle : this function should be overwritten by the user.
  103707. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103708. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103709. * @example : just set a particle position or velocity and recycle conditions
  103710. * @param particle The particle to update
  103711. * @returns the updated particle
  103712. */
  103713. updateParticle(particle: SolidParticle): SolidParticle;
  103714. /**
  103715. * Updates a vertex of a particle : it can be overwritten by the user.
  103716. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103717. * @param particle the current particle
  103718. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  103719. * @param pt the index of the current vertex in the particle shape
  103720. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103721. * @example : just set a vertex particle position or color
  103722. * @returns the sps
  103723. */
  103724. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  103725. /**
  103726. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103727. * This does nothing and may be overwritten by the user.
  103728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103730. * @param update the boolean update value actually passed to setParticles()
  103731. */
  103732. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103733. /**
  103734. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103735. * This will be passed three parameters.
  103736. * This does nothing and may be overwritten by the user.
  103737. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103738. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103739. * @param update the boolean update value actually passed to setParticles()
  103740. */
  103741. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103742. }
  103743. }
  103744. declare module BABYLON {
  103745. /**
  103746. * Represents one particle of a solid particle system.
  103747. */
  103748. export class SolidParticle {
  103749. /**
  103750. * particle global index
  103751. */
  103752. idx: number;
  103753. /**
  103754. * particle identifier
  103755. */
  103756. id: number;
  103757. /**
  103758. * The color of the particle
  103759. */
  103760. color: Nullable<Color4>;
  103761. /**
  103762. * The world space position of the particle.
  103763. */
  103764. position: Vector3;
  103765. /**
  103766. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  103767. */
  103768. rotation: Vector3;
  103769. /**
  103770. * The world space rotation quaternion of the particle.
  103771. */
  103772. rotationQuaternion: Nullable<Quaternion>;
  103773. /**
  103774. * The scaling of the particle.
  103775. */
  103776. scaling: Vector3;
  103777. /**
  103778. * The uvs of the particle.
  103779. */
  103780. uvs: Vector4;
  103781. /**
  103782. * The current speed of the particle.
  103783. */
  103784. velocity: Vector3;
  103785. /**
  103786. * The pivot point in the particle local space.
  103787. */
  103788. pivot: Vector3;
  103789. /**
  103790. * Must the particle be translated from its pivot point in its local space ?
  103791. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  103792. * Default : false
  103793. */
  103794. translateFromPivot: boolean;
  103795. /**
  103796. * Is the particle active or not ?
  103797. */
  103798. alive: boolean;
  103799. /**
  103800. * Is the particle visible or not ?
  103801. */
  103802. isVisible: boolean;
  103803. /**
  103804. * Index of this particle in the global "positions" array (Internal use)
  103805. * @hidden
  103806. */
  103807. _pos: number;
  103808. /**
  103809. * @hidden Index of this particle in the global "indices" array (Internal use)
  103810. */
  103811. _ind: number;
  103812. /**
  103813. * @hidden ModelShape of this particle (Internal use)
  103814. */
  103815. _model: ModelShape;
  103816. /**
  103817. * ModelShape id of this particle
  103818. */
  103819. shapeId: number;
  103820. /**
  103821. * Index of the particle in its shape id
  103822. */
  103823. idxInShape: number;
  103824. /**
  103825. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  103826. */
  103827. _modelBoundingInfo: BoundingInfo;
  103828. /**
  103829. * @hidden Particle BoundingInfo object (Internal use)
  103830. */
  103831. _boundingInfo: BoundingInfo;
  103832. /**
  103833. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  103834. */
  103835. _sps: SolidParticleSystem;
  103836. /**
  103837. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  103838. */
  103839. _stillInvisible: boolean;
  103840. /**
  103841. * @hidden Last computed particle rotation matrix
  103842. */
  103843. _rotationMatrix: number[];
  103844. /**
  103845. * Parent particle Id, if any.
  103846. * Default null.
  103847. */
  103848. parentId: Nullable<number>;
  103849. /**
  103850. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  103851. */
  103852. materialIndex: Nullable<number>;
  103853. /**
  103854. * Custom object or properties.
  103855. */
  103856. props: Nullable<any>;
  103857. /**
  103858. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  103859. * The possible values are :
  103860. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  103861. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103862. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  103863. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  103864. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103865. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  103866. * */
  103867. cullingStrategy: number;
  103868. /**
  103869. * @hidden Internal global position in the SPS.
  103870. */
  103871. _globalPosition: Vector3;
  103872. /**
  103873. * Creates a Solid Particle object.
  103874. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  103875. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  103876. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  103877. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  103878. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  103879. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  103880. * @param shapeId (integer) is the model shape identifier in the SPS.
  103881. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  103882. * @param sps defines the sps it is associated to
  103883. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  103884. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  103885. */
  103886. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  103887. /**
  103888. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  103889. * @param target the particle target
  103890. * @returns the current particle
  103891. */
  103892. copyToRef(target: SolidParticle): SolidParticle;
  103893. /**
  103894. * Legacy support, changed scale to scaling
  103895. */
  103896. get scale(): Vector3;
  103897. /**
  103898. * Legacy support, changed scale to scaling
  103899. */
  103900. set scale(scale: Vector3);
  103901. /**
  103902. * Legacy support, changed quaternion to rotationQuaternion
  103903. */
  103904. get quaternion(): Nullable<Quaternion>;
  103905. /**
  103906. * Legacy support, changed quaternion to rotationQuaternion
  103907. */
  103908. set quaternion(q: Nullable<Quaternion>);
  103909. /**
  103910. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  103911. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  103912. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  103913. * @returns true if it intersects
  103914. */
  103915. intersectsMesh(target: Mesh | SolidParticle): boolean;
  103916. /**
  103917. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  103918. * A particle is in the frustum if its bounding box intersects the frustum
  103919. * @param frustumPlanes defines the frustum to test
  103920. * @returns true if the particle is in the frustum planes
  103921. */
  103922. isInFrustum(frustumPlanes: Plane[]): boolean;
  103923. /**
  103924. * get the rotation matrix of the particle
  103925. * @hidden
  103926. */
  103927. getRotationMatrix(m: Matrix): void;
  103928. }
  103929. /**
  103930. * Represents the shape of the model used by one particle of a solid particle system.
  103931. * SPS internal tool, don't use it manually.
  103932. */
  103933. export class ModelShape {
  103934. /**
  103935. * The shape id
  103936. * @hidden
  103937. */
  103938. shapeID: number;
  103939. /**
  103940. * flat array of model positions (internal use)
  103941. * @hidden
  103942. */
  103943. _shape: Vector3[];
  103944. /**
  103945. * flat array of model UVs (internal use)
  103946. * @hidden
  103947. */
  103948. _shapeUV: number[];
  103949. /**
  103950. * color array of the model
  103951. * @hidden
  103952. */
  103953. _shapeColors: number[];
  103954. /**
  103955. * indices array of the model
  103956. * @hidden
  103957. */
  103958. _indices: number[];
  103959. /**
  103960. * normals array of the model
  103961. * @hidden
  103962. */
  103963. _normals: number[];
  103964. /**
  103965. * length of the shape in the model indices array (internal use)
  103966. * @hidden
  103967. */
  103968. _indicesLength: number;
  103969. /**
  103970. * Custom position function (internal use)
  103971. * @hidden
  103972. */
  103973. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  103974. /**
  103975. * Custom vertex function (internal use)
  103976. * @hidden
  103977. */
  103978. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  103979. /**
  103980. * Model material (internal use)
  103981. * @hidden
  103982. */
  103983. _material: Nullable<Material>;
  103984. /**
  103985. * 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.
  103986. * SPS internal tool, don't use it manually.
  103987. * @hidden
  103988. */
  103989. 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>);
  103990. }
  103991. /**
  103992. * Represents a Depth Sorted Particle in the solid particle system.
  103993. * @hidden
  103994. */
  103995. export class DepthSortedParticle {
  103996. /**
  103997. * Particle index
  103998. */
  103999. idx: number;
  104000. /**
  104001. * Index of the particle in the "indices" array
  104002. */
  104003. ind: number;
  104004. /**
  104005. * Length of the particle shape in the "indices" array
  104006. */
  104007. indicesLength: number;
  104008. /**
  104009. * Squared distance from the particle to the camera
  104010. */
  104011. sqDistance: number;
  104012. /**
  104013. * Material index when used with MultiMaterials
  104014. */
  104015. materialIndex: number;
  104016. /**
  104017. * Creates a new sorted particle
  104018. * @param materialIndex
  104019. */
  104020. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104021. }
  104022. /**
  104023. * Represents a solid particle vertex
  104024. */
  104025. export class SolidParticleVertex {
  104026. /**
  104027. * Vertex position
  104028. */
  104029. position: Vector3;
  104030. /**
  104031. * Vertex color
  104032. */
  104033. color: Color4;
  104034. /**
  104035. * Vertex UV
  104036. */
  104037. uv: Vector2;
  104038. /**
  104039. * Creates a new solid particle vertex
  104040. */
  104041. constructor();
  104042. /** Vertex x coordinate */
  104043. get x(): number;
  104044. set x(val: number);
  104045. /** Vertex y coordinate */
  104046. get y(): number;
  104047. set y(val: number);
  104048. /** Vertex z coordinate */
  104049. get z(): number;
  104050. set z(val: number);
  104051. }
  104052. }
  104053. declare module BABYLON {
  104054. /**
  104055. * @hidden
  104056. */
  104057. export class _MeshCollisionData {
  104058. _checkCollisions: boolean;
  104059. _collisionMask: number;
  104060. _collisionGroup: number;
  104061. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104062. _collider: Nullable<Collider>;
  104063. _oldPositionForCollisions: Vector3;
  104064. _diffPositionForCollisions: Vector3;
  104065. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104066. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104067. }
  104068. }
  104069. declare module BABYLON {
  104070. /** @hidden */
  104071. class _FacetDataStorage {
  104072. facetPositions: Vector3[];
  104073. facetNormals: Vector3[];
  104074. facetPartitioning: number[][];
  104075. facetNb: number;
  104076. partitioningSubdivisions: number;
  104077. partitioningBBoxRatio: number;
  104078. facetDataEnabled: boolean;
  104079. facetParameters: any;
  104080. bbSize: Vector3;
  104081. subDiv: {
  104082. max: number;
  104083. X: number;
  104084. Y: number;
  104085. Z: number;
  104086. };
  104087. facetDepthSort: boolean;
  104088. facetDepthSortEnabled: boolean;
  104089. depthSortedIndices: IndicesArray;
  104090. depthSortedFacets: {
  104091. ind: number;
  104092. sqDistance: number;
  104093. }[];
  104094. facetDepthSortFunction: (f1: {
  104095. ind: number;
  104096. sqDistance: number;
  104097. }, f2: {
  104098. ind: number;
  104099. sqDistance: number;
  104100. }) => number;
  104101. facetDepthSortFrom: Vector3;
  104102. facetDepthSortOrigin: Vector3;
  104103. invertedMatrix: Matrix;
  104104. }
  104105. /**
  104106. * @hidden
  104107. **/
  104108. class _InternalAbstractMeshDataInfo {
  104109. _hasVertexAlpha: boolean;
  104110. _useVertexColors: boolean;
  104111. _numBoneInfluencers: number;
  104112. _applyFog: boolean;
  104113. _receiveShadows: boolean;
  104114. _facetData: _FacetDataStorage;
  104115. _visibility: number;
  104116. _skeleton: Nullable<Skeleton>;
  104117. _layerMask: number;
  104118. _computeBonesUsingShaders: boolean;
  104119. _isActive: boolean;
  104120. _onlyForInstances: boolean;
  104121. _isActiveIntermediate: boolean;
  104122. _onlyForInstancesIntermediate: boolean;
  104123. _actAsRegularMesh: boolean;
  104124. }
  104125. /**
  104126. * Class used to store all common mesh properties
  104127. */
  104128. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104129. /** No occlusion */
  104130. static OCCLUSION_TYPE_NONE: number;
  104131. /** Occlusion set to optimisitic */
  104132. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104133. /** Occlusion set to strict */
  104134. static OCCLUSION_TYPE_STRICT: number;
  104135. /** Use an accurante occlusion algorithm */
  104136. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104137. /** Use a conservative occlusion algorithm */
  104138. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104139. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104140. * Test order :
  104141. * Is the bounding sphere outside the frustum ?
  104142. * If not, are the bounding box vertices outside the frustum ?
  104143. * It not, then the cullable object is in the frustum.
  104144. */
  104145. static readonly CULLINGSTRATEGY_STANDARD: number;
  104146. /** Culling strategy : Bounding Sphere Only.
  104147. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104148. * It's also less accurate than the standard because some not visible objects can still be selected.
  104149. * Test : is the bounding sphere outside the frustum ?
  104150. * If not, then the cullable object is in the frustum.
  104151. */
  104152. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104153. /** Culling strategy : Optimistic Inclusion.
  104154. * This in an inclusion test first, then the standard exclusion test.
  104155. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104156. * 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.
  104157. * Anyway, it's as accurate as the standard strategy.
  104158. * Test :
  104159. * Is the cullable object bounding sphere center in the frustum ?
  104160. * If not, apply the default culling strategy.
  104161. */
  104162. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104163. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104164. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104165. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104166. * 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.
  104167. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104168. * Test :
  104169. * Is the cullable object bounding sphere center in the frustum ?
  104170. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104171. */
  104172. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104173. /**
  104174. * No billboard
  104175. */
  104176. static get BILLBOARDMODE_NONE(): number;
  104177. /** Billboard on X axis */
  104178. static get BILLBOARDMODE_X(): number;
  104179. /** Billboard on Y axis */
  104180. static get BILLBOARDMODE_Y(): number;
  104181. /** Billboard on Z axis */
  104182. static get BILLBOARDMODE_Z(): number;
  104183. /** Billboard on all axes */
  104184. static get BILLBOARDMODE_ALL(): number;
  104185. /** Billboard on using position instead of orientation */
  104186. static get BILLBOARDMODE_USE_POSITION(): number;
  104187. /** @hidden */
  104188. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104189. /**
  104190. * The culling strategy to use to check whether the mesh must be rendered or not.
  104191. * This value can be changed at any time and will be used on the next render mesh selection.
  104192. * The possible values are :
  104193. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104194. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104195. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104196. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104197. * Please read each static variable documentation to get details about the culling process.
  104198. * */
  104199. cullingStrategy: number;
  104200. /**
  104201. * Gets the number of facets in the mesh
  104202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104203. */
  104204. get facetNb(): number;
  104205. /**
  104206. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104208. */
  104209. get partitioningSubdivisions(): number;
  104210. set partitioningSubdivisions(nb: number);
  104211. /**
  104212. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104213. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104215. */
  104216. get partitioningBBoxRatio(): number;
  104217. set partitioningBBoxRatio(ratio: number);
  104218. /**
  104219. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104220. * Works only for updatable meshes.
  104221. * Doesn't work with multi-materials
  104222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104223. */
  104224. get mustDepthSortFacets(): boolean;
  104225. set mustDepthSortFacets(sort: boolean);
  104226. /**
  104227. * The location (Vector3) where the facet depth sort must be computed from.
  104228. * By default, the active camera position.
  104229. * Used only when facet depth sort is enabled
  104230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104231. */
  104232. get facetDepthSortFrom(): Vector3;
  104233. set facetDepthSortFrom(location: Vector3);
  104234. /**
  104235. * gets a boolean indicating if facetData is enabled
  104236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104237. */
  104238. get isFacetDataEnabled(): boolean;
  104239. /** @hidden */
  104240. _updateNonUniformScalingState(value: boolean): boolean;
  104241. /**
  104242. * An event triggered when this mesh collides with another one
  104243. */
  104244. onCollideObservable: Observable<AbstractMesh>;
  104245. /** Set a function to call when this mesh collides with another one */
  104246. set onCollide(callback: () => void);
  104247. /**
  104248. * An event triggered when the collision's position changes
  104249. */
  104250. onCollisionPositionChangeObservable: Observable<Vector3>;
  104251. /** Set a function to call when the collision's position changes */
  104252. set onCollisionPositionChange(callback: () => void);
  104253. /**
  104254. * An event triggered when material is changed
  104255. */
  104256. onMaterialChangedObservable: Observable<AbstractMesh>;
  104257. /**
  104258. * Gets or sets the orientation for POV movement & rotation
  104259. */
  104260. definedFacingForward: boolean;
  104261. /** @hidden */
  104262. _occlusionQuery: Nullable<WebGLQuery>;
  104263. /** @hidden */
  104264. _renderingGroup: Nullable<RenderingGroup>;
  104265. /**
  104266. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104267. */
  104268. get visibility(): number;
  104269. /**
  104270. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104271. */
  104272. set visibility(value: number);
  104273. /** Gets or sets the alpha index used to sort transparent meshes
  104274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104275. */
  104276. alphaIndex: number;
  104277. /**
  104278. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104279. */
  104280. isVisible: boolean;
  104281. /**
  104282. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104283. */
  104284. isPickable: boolean;
  104285. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104286. showSubMeshesBoundingBox: boolean;
  104287. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104288. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104289. */
  104290. isBlocker: boolean;
  104291. /**
  104292. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104293. */
  104294. enablePointerMoveEvents: boolean;
  104295. /**
  104296. * Specifies the rendering group id for this mesh (0 by default)
  104297. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104298. */
  104299. renderingGroupId: number;
  104300. private _material;
  104301. /** Gets or sets current material */
  104302. get material(): Nullable<Material>;
  104303. set material(value: Nullable<Material>);
  104304. /**
  104305. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104306. * @see http://doc.babylonjs.com/babylon101/shadows
  104307. */
  104308. get receiveShadows(): boolean;
  104309. set receiveShadows(value: boolean);
  104310. /** Defines color to use when rendering outline */
  104311. outlineColor: Color3;
  104312. /** Define width to use when rendering outline */
  104313. outlineWidth: number;
  104314. /** Defines color to use when rendering overlay */
  104315. overlayColor: Color3;
  104316. /** Defines alpha to use when rendering overlay */
  104317. overlayAlpha: number;
  104318. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104319. get hasVertexAlpha(): boolean;
  104320. set hasVertexAlpha(value: boolean);
  104321. /** 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) */
  104322. get useVertexColors(): boolean;
  104323. set useVertexColors(value: boolean);
  104324. /**
  104325. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104326. */
  104327. get computeBonesUsingShaders(): boolean;
  104328. set computeBonesUsingShaders(value: boolean);
  104329. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104330. get numBoneInfluencers(): number;
  104331. set numBoneInfluencers(value: number);
  104332. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104333. get applyFog(): boolean;
  104334. set applyFog(value: boolean);
  104335. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104336. useOctreeForRenderingSelection: boolean;
  104337. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104338. useOctreeForPicking: boolean;
  104339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104340. useOctreeForCollisions: boolean;
  104341. /**
  104342. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104343. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104344. */
  104345. get layerMask(): number;
  104346. set layerMask(value: number);
  104347. /**
  104348. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104349. */
  104350. alwaysSelectAsActiveMesh: boolean;
  104351. /**
  104352. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104353. */
  104354. doNotSyncBoundingInfo: boolean;
  104355. /**
  104356. * Gets or sets the current action manager
  104357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104358. */
  104359. actionManager: Nullable<AbstractActionManager>;
  104360. private _meshCollisionData;
  104361. /**
  104362. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104364. */
  104365. ellipsoid: Vector3;
  104366. /**
  104367. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104369. */
  104370. ellipsoidOffset: Vector3;
  104371. /**
  104372. * Gets or sets a collision mask used to mask collisions (default is -1).
  104373. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104374. */
  104375. get collisionMask(): number;
  104376. set collisionMask(mask: number);
  104377. /**
  104378. * Gets or sets the current collision group mask (-1 by default).
  104379. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104380. */
  104381. get collisionGroup(): number;
  104382. set collisionGroup(mask: number);
  104383. /**
  104384. * Gets or sets current surrounding meshes (null by default).
  104385. *
  104386. * By default collision detection is tested against every mesh in the scene.
  104387. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104388. * meshes will be tested for the collision.
  104389. *
  104390. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104391. */
  104392. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104393. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104394. /**
  104395. * Defines edge width used when edgesRenderer is enabled
  104396. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104397. */
  104398. edgesWidth: number;
  104399. /**
  104400. * Defines edge color used when edgesRenderer is enabled
  104401. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104402. */
  104403. edgesColor: Color4;
  104404. /** @hidden */
  104405. _edgesRenderer: Nullable<IEdgesRenderer>;
  104406. /** @hidden */
  104407. _masterMesh: Nullable<AbstractMesh>;
  104408. /** @hidden */
  104409. _boundingInfo: Nullable<BoundingInfo>;
  104410. /** @hidden */
  104411. _renderId: number;
  104412. /**
  104413. * Gets or sets the list of subMeshes
  104414. * @see http://doc.babylonjs.com/how_to/multi_materials
  104415. */
  104416. subMeshes: SubMesh[];
  104417. /** @hidden */
  104418. _intersectionsInProgress: AbstractMesh[];
  104419. /** @hidden */
  104420. _unIndexed: boolean;
  104421. /** @hidden */
  104422. _lightSources: Light[];
  104423. /** Gets the list of lights affecting that mesh */
  104424. get lightSources(): Light[];
  104425. /** @hidden */
  104426. get _positions(): Nullable<Vector3[]>;
  104427. /** @hidden */
  104428. _waitingData: {
  104429. lods: Nullable<any>;
  104430. actions: Nullable<any>;
  104431. freezeWorldMatrix: Nullable<boolean>;
  104432. };
  104433. /** @hidden */
  104434. _bonesTransformMatrices: Nullable<Float32Array>;
  104435. /** @hidden */
  104436. _transformMatrixTexture: Nullable<RawTexture>;
  104437. /**
  104438. * Gets or sets a skeleton to apply skining transformations
  104439. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104440. */
  104441. set skeleton(value: Nullable<Skeleton>);
  104442. get skeleton(): Nullable<Skeleton>;
  104443. /**
  104444. * An event triggered when the mesh is rebuilt.
  104445. */
  104446. onRebuildObservable: Observable<AbstractMesh>;
  104447. /**
  104448. * Creates a new AbstractMesh
  104449. * @param name defines the name of the mesh
  104450. * @param scene defines the hosting scene
  104451. */
  104452. constructor(name: string, scene?: Nullable<Scene>);
  104453. /**
  104454. * Returns the string "AbstractMesh"
  104455. * @returns "AbstractMesh"
  104456. */
  104457. getClassName(): string;
  104458. /**
  104459. * Gets a string representation of the current mesh
  104460. * @param fullDetails defines a boolean indicating if full details must be included
  104461. * @returns a string representation of the current mesh
  104462. */
  104463. toString(fullDetails?: boolean): string;
  104464. /**
  104465. * @hidden
  104466. */
  104467. protected _getEffectiveParent(): Nullable<Node>;
  104468. /** @hidden */
  104469. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104470. /** @hidden */
  104471. _rebuild(): void;
  104472. /** @hidden */
  104473. _resyncLightSources(): void;
  104474. /** @hidden */
  104475. _resyncLightSource(light: Light): void;
  104476. /** @hidden */
  104477. _unBindEffect(): void;
  104478. /** @hidden */
  104479. _removeLightSource(light: Light, dispose: boolean): void;
  104480. private _markSubMeshesAsDirty;
  104481. /** @hidden */
  104482. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104483. /** @hidden */
  104484. _markSubMeshesAsAttributesDirty(): void;
  104485. /** @hidden */
  104486. _markSubMeshesAsMiscDirty(): void;
  104487. /**
  104488. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104489. */
  104490. get scaling(): Vector3;
  104491. set scaling(newScaling: Vector3);
  104492. /**
  104493. * Returns true if the mesh is blocked. Implemented by child classes
  104494. */
  104495. get isBlocked(): boolean;
  104496. /**
  104497. * Returns the mesh itself by default. Implemented by child classes
  104498. * @param camera defines the camera to use to pick the right LOD level
  104499. * @returns the currentAbstractMesh
  104500. */
  104501. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104502. /**
  104503. * Returns 0 by default. Implemented by child classes
  104504. * @returns an integer
  104505. */
  104506. getTotalVertices(): number;
  104507. /**
  104508. * Returns a positive integer : the total number of indices in this mesh geometry.
  104509. * @returns the numner of indices or zero if the mesh has no geometry.
  104510. */
  104511. getTotalIndices(): number;
  104512. /**
  104513. * Returns null by default. Implemented by child classes
  104514. * @returns null
  104515. */
  104516. getIndices(): Nullable<IndicesArray>;
  104517. /**
  104518. * Returns the array of the requested vertex data kind. Implemented by child classes
  104519. * @param kind defines the vertex data kind to use
  104520. * @returns null
  104521. */
  104522. getVerticesData(kind: string): Nullable<FloatArray>;
  104523. /**
  104524. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104525. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104526. * Note that a new underlying VertexBuffer object is created each call.
  104527. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104528. * @param kind defines vertex data kind:
  104529. * * VertexBuffer.PositionKind
  104530. * * VertexBuffer.UVKind
  104531. * * VertexBuffer.UV2Kind
  104532. * * VertexBuffer.UV3Kind
  104533. * * VertexBuffer.UV4Kind
  104534. * * VertexBuffer.UV5Kind
  104535. * * VertexBuffer.UV6Kind
  104536. * * VertexBuffer.ColorKind
  104537. * * VertexBuffer.MatricesIndicesKind
  104538. * * VertexBuffer.MatricesIndicesExtraKind
  104539. * * VertexBuffer.MatricesWeightsKind
  104540. * * VertexBuffer.MatricesWeightsExtraKind
  104541. * @param data defines the data source
  104542. * @param updatable defines if the data must be flagged as updatable (or static)
  104543. * @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
  104544. * @returns the current mesh
  104545. */
  104546. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104547. /**
  104548. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104549. * If the mesh has no geometry, it is simply returned as it is.
  104550. * @param kind defines vertex data kind:
  104551. * * VertexBuffer.PositionKind
  104552. * * VertexBuffer.UVKind
  104553. * * VertexBuffer.UV2Kind
  104554. * * VertexBuffer.UV3Kind
  104555. * * VertexBuffer.UV4Kind
  104556. * * VertexBuffer.UV5Kind
  104557. * * VertexBuffer.UV6Kind
  104558. * * VertexBuffer.ColorKind
  104559. * * VertexBuffer.MatricesIndicesKind
  104560. * * VertexBuffer.MatricesIndicesExtraKind
  104561. * * VertexBuffer.MatricesWeightsKind
  104562. * * VertexBuffer.MatricesWeightsExtraKind
  104563. * @param data defines the data source
  104564. * @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
  104565. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104566. * @returns the current mesh
  104567. */
  104568. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104569. /**
  104570. * Sets the mesh indices,
  104571. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104572. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104573. * @param totalVertices Defines the total number of vertices
  104574. * @returns the current mesh
  104575. */
  104576. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104577. /**
  104578. * Gets a boolean indicating if specific vertex data is present
  104579. * @param kind defines the vertex data kind to use
  104580. * @returns true is data kind is present
  104581. */
  104582. isVerticesDataPresent(kind: string): boolean;
  104583. /**
  104584. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104585. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104586. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104587. * @returns a BoundingInfo
  104588. */
  104589. getBoundingInfo(): BoundingInfo;
  104590. /**
  104591. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104592. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104593. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104594. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104595. * @returns the current mesh
  104596. */
  104597. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104598. /**
  104599. * Overwrite the current bounding info
  104600. * @param boundingInfo defines the new bounding info
  104601. * @returns the current mesh
  104602. */
  104603. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104604. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104605. get useBones(): boolean;
  104606. /** @hidden */
  104607. _preActivate(): void;
  104608. /** @hidden */
  104609. _preActivateForIntermediateRendering(renderId: number): void;
  104610. /** @hidden */
  104611. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104612. /** @hidden */
  104613. _postActivate(): void;
  104614. /** @hidden */
  104615. _freeze(): void;
  104616. /** @hidden */
  104617. _unFreeze(): void;
  104618. /**
  104619. * Gets the current world matrix
  104620. * @returns a Matrix
  104621. */
  104622. getWorldMatrix(): Matrix;
  104623. /** @hidden */
  104624. _getWorldMatrixDeterminant(): number;
  104625. /**
  104626. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104627. */
  104628. get isAnInstance(): boolean;
  104629. /**
  104630. * Gets a boolean indicating if this mesh has instances
  104631. */
  104632. get hasInstances(): boolean;
  104633. /**
  104634. * Perform relative position change from the point of view of behind the front of the mesh.
  104635. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104636. * Supports definition of mesh facing forward or backward
  104637. * @param amountRight defines the distance on the right axis
  104638. * @param amountUp defines the distance on the up axis
  104639. * @param amountForward defines the distance on the forward axis
  104640. * @returns the current mesh
  104641. */
  104642. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104643. /**
  104644. * Calculate relative position change from the point of view of behind the front of the mesh.
  104645. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104646. * Supports definition of mesh facing forward or backward
  104647. * @param amountRight defines the distance on the right axis
  104648. * @param amountUp defines the distance on the up axis
  104649. * @param amountForward defines the distance on the forward axis
  104650. * @returns the new displacement vector
  104651. */
  104652. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104653. /**
  104654. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104655. * Supports definition of mesh facing forward or backward
  104656. * @param flipBack defines the flip
  104657. * @param twirlClockwise defines the twirl
  104658. * @param tiltRight defines the tilt
  104659. * @returns the current mesh
  104660. */
  104661. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104662. /**
  104663. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104664. * Supports definition of mesh facing forward or backward.
  104665. * @param flipBack defines the flip
  104666. * @param twirlClockwise defines the twirl
  104667. * @param tiltRight defines the tilt
  104668. * @returns the new rotation vector
  104669. */
  104670. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104671. /**
  104672. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104673. * This means the mesh underlying bounding box and sphere are recomputed.
  104674. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104675. * @returns the current mesh
  104676. */
  104677. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104678. /** @hidden */
  104679. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104680. /** @hidden */
  104681. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104682. /** @hidden */
  104683. _updateBoundingInfo(): AbstractMesh;
  104684. /** @hidden */
  104685. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104686. /** @hidden */
  104687. protected _afterComputeWorldMatrix(): void;
  104688. /** @hidden */
  104689. get _effectiveMesh(): AbstractMesh;
  104690. /**
  104691. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104692. * A mesh is in the frustum if its bounding box intersects the frustum
  104693. * @param frustumPlanes defines the frustum to test
  104694. * @returns true if the mesh is in the frustum planes
  104695. */
  104696. isInFrustum(frustumPlanes: Plane[]): boolean;
  104697. /**
  104698. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104699. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104700. * @param frustumPlanes defines the frustum to test
  104701. * @returns true if the mesh is completely in the frustum planes
  104702. */
  104703. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104704. /**
  104705. * True if the mesh intersects another mesh or a SolidParticle object
  104706. * @param mesh defines a target mesh or SolidParticle to test
  104707. * @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)
  104708. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104709. * @returns true if there is an intersection
  104710. */
  104711. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104712. /**
  104713. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104714. * @param point defines the point to test
  104715. * @returns true if there is an intersection
  104716. */
  104717. intersectsPoint(point: Vector3): boolean;
  104718. /**
  104719. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104721. */
  104722. get checkCollisions(): boolean;
  104723. set checkCollisions(collisionEnabled: boolean);
  104724. /**
  104725. * Gets Collider object used to compute collisions (not physics)
  104726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104727. */
  104728. get collider(): Nullable<Collider>;
  104729. /**
  104730. * Move the mesh using collision engine
  104731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104732. * @param displacement defines the requested displacement vector
  104733. * @returns the current mesh
  104734. */
  104735. moveWithCollisions(displacement: Vector3): AbstractMesh;
  104736. private _onCollisionPositionChange;
  104737. /** @hidden */
  104738. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  104739. /** @hidden */
  104740. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  104741. /** @hidden */
  104742. _checkCollision(collider: Collider): AbstractMesh;
  104743. /** @hidden */
  104744. _generatePointsArray(): boolean;
  104745. /**
  104746. * Checks if the passed Ray intersects with the mesh
  104747. * @param ray defines the ray to use
  104748. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  104749. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104750. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  104751. * @returns the picking info
  104752. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  104753. */
  104754. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  104755. /**
  104756. * Clones the current mesh
  104757. * @param name defines the mesh name
  104758. * @param newParent defines the new mesh parent
  104759. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  104760. * @returns the new mesh
  104761. */
  104762. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  104763. /**
  104764. * Disposes all the submeshes of the current meshnp
  104765. * @returns the current mesh
  104766. */
  104767. releaseSubMeshes(): AbstractMesh;
  104768. /**
  104769. * Releases resources associated with this abstract mesh.
  104770. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104771. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104772. */
  104773. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104774. /**
  104775. * Adds the passed mesh as a child to the current mesh
  104776. * @param mesh defines the child mesh
  104777. * @returns the current mesh
  104778. */
  104779. addChild(mesh: AbstractMesh): AbstractMesh;
  104780. /**
  104781. * Removes the passed mesh from the current mesh children list
  104782. * @param mesh defines the child mesh
  104783. * @returns the current mesh
  104784. */
  104785. removeChild(mesh: AbstractMesh): AbstractMesh;
  104786. /** @hidden */
  104787. private _initFacetData;
  104788. /**
  104789. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  104790. * This method can be called within the render loop.
  104791. * 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
  104792. * @returns the current mesh
  104793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104794. */
  104795. updateFacetData(): AbstractMesh;
  104796. /**
  104797. * Returns the facetLocalNormals array.
  104798. * The normals are expressed in the mesh local spac
  104799. * @returns an array of Vector3
  104800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104801. */
  104802. getFacetLocalNormals(): Vector3[];
  104803. /**
  104804. * Returns the facetLocalPositions array.
  104805. * The facet positions are expressed in the mesh local space
  104806. * @returns an array of Vector3
  104807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104808. */
  104809. getFacetLocalPositions(): Vector3[];
  104810. /**
  104811. * Returns the facetLocalPartioning array
  104812. * @returns an array of array of numbers
  104813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104814. */
  104815. getFacetLocalPartitioning(): number[][];
  104816. /**
  104817. * Returns the i-th facet position in the world system.
  104818. * This method allocates a new Vector3 per call
  104819. * @param i defines the facet index
  104820. * @returns a new Vector3
  104821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104822. */
  104823. getFacetPosition(i: number): Vector3;
  104824. /**
  104825. * Sets the reference Vector3 with the i-th facet position in the world system
  104826. * @param i defines the facet index
  104827. * @param ref defines the target vector
  104828. * @returns the current mesh
  104829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104830. */
  104831. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  104832. /**
  104833. * Returns the i-th facet normal in the world system.
  104834. * This method allocates a new Vector3 per call
  104835. * @param i defines the facet index
  104836. * @returns a new Vector3
  104837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104838. */
  104839. getFacetNormal(i: number): Vector3;
  104840. /**
  104841. * Sets the reference Vector3 with the i-th facet normal in the world system
  104842. * @param i defines the facet index
  104843. * @param ref defines the target vector
  104844. * @returns the current mesh
  104845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104846. */
  104847. getFacetNormalToRef(i: number, ref: Vector3): this;
  104848. /**
  104849. * 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)
  104850. * @param x defines x coordinate
  104851. * @param y defines y coordinate
  104852. * @param z defines z coordinate
  104853. * @returns the array of facet indexes
  104854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104855. */
  104856. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  104857. /**
  104858. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  104859. * @param projected sets as the (x,y,z) world projection on the facet
  104860. * @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
  104861. * @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
  104862. * @param x defines x coordinate
  104863. * @param y defines y coordinate
  104864. * @param z defines z coordinate
  104865. * @returns the face index if found (or null instead)
  104866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104867. */
  104868. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104869. /**
  104870. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  104871. * @param projected sets as the (x,y,z) local projection on the facet
  104872. * @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
  104873. * @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
  104874. * @param x defines x coordinate
  104875. * @param y defines y coordinate
  104876. * @param z defines z coordinate
  104877. * @returns the face index if found (or null instead)
  104878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104879. */
  104880. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104881. /**
  104882. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  104883. * @returns the parameters
  104884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104885. */
  104886. getFacetDataParameters(): any;
  104887. /**
  104888. * Disables the feature FacetData and frees the related memory
  104889. * @returns the current mesh
  104890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104891. */
  104892. disableFacetData(): AbstractMesh;
  104893. /**
  104894. * Updates the AbstractMesh indices array
  104895. * @param indices defines the data source
  104896. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104897. * @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)
  104898. * @returns the current mesh
  104899. */
  104900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104901. /**
  104902. * Creates new normals data for the mesh
  104903. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  104904. * @returns the current mesh
  104905. */
  104906. createNormals(updatable: boolean): AbstractMesh;
  104907. /**
  104908. * Align the mesh with a normal
  104909. * @param normal defines the normal to use
  104910. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  104911. * @returns the current mesh
  104912. */
  104913. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  104914. /** @hidden */
  104915. _checkOcclusionQuery(): boolean;
  104916. /**
  104917. * Disables the mesh edge rendering mode
  104918. * @returns the currentAbstractMesh
  104919. */
  104920. disableEdgesRendering(): AbstractMesh;
  104921. /**
  104922. * Enables the edge rendering mode on the mesh.
  104923. * This mode makes the mesh edges visible
  104924. * @param epsilon defines the maximal distance between two angles to detect a face
  104925. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  104926. * @returns the currentAbstractMesh
  104927. * @see https://www.babylonjs-playground.com/#19O9TU#0
  104928. */
  104929. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  104930. }
  104931. }
  104932. declare module BABYLON {
  104933. /**
  104934. * Interface used to define ActionEvent
  104935. */
  104936. export interface IActionEvent {
  104937. /** The mesh or sprite that triggered the action */
  104938. source: any;
  104939. /** The X mouse cursor position at the time of the event */
  104940. pointerX: number;
  104941. /** The Y mouse cursor position at the time of the event */
  104942. pointerY: number;
  104943. /** The mesh that is currently pointed at (can be null) */
  104944. meshUnderPointer: Nullable<AbstractMesh>;
  104945. /** the original (browser) event that triggered the ActionEvent */
  104946. sourceEvent?: any;
  104947. /** additional data for the event */
  104948. additionalData?: any;
  104949. }
  104950. /**
  104951. * ActionEvent is the event being sent when an action is triggered.
  104952. */
  104953. export class ActionEvent implements IActionEvent {
  104954. /** The mesh or sprite that triggered the action */
  104955. source: any;
  104956. /** The X mouse cursor position at the time of the event */
  104957. pointerX: number;
  104958. /** The Y mouse cursor position at the time of the event */
  104959. pointerY: number;
  104960. /** The mesh that is currently pointed at (can be null) */
  104961. meshUnderPointer: Nullable<AbstractMesh>;
  104962. /** the original (browser) event that triggered the ActionEvent */
  104963. sourceEvent?: any;
  104964. /** additional data for the event */
  104965. additionalData?: any;
  104966. /**
  104967. * Creates a new ActionEvent
  104968. * @param source The mesh or sprite that triggered the action
  104969. * @param pointerX The X mouse cursor position at the time of the event
  104970. * @param pointerY The Y mouse cursor position at the time of the event
  104971. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  104972. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  104973. * @param additionalData additional data for the event
  104974. */
  104975. constructor(
  104976. /** The mesh or sprite that triggered the action */
  104977. source: any,
  104978. /** The X mouse cursor position at the time of the event */
  104979. pointerX: number,
  104980. /** The Y mouse cursor position at the time of the event */
  104981. pointerY: number,
  104982. /** The mesh that is currently pointed at (can be null) */
  104983. meshUnderPointer: Nullable<AbstractMesh>,
  104984. /** the original (browser) event that triggered the ActionEvent */
  104985. sourceEvent?: any,
  104986. /** additional data for the event */
  104987. additionalData?: any);
  104988. /**
  104989. * Helper function to auto-create an ActionEvent from a source mesh.
  104990. * @param source The source mesh that triggered the event
  104991. * @param evt The original (browser) event
  104992. * @param additionalData additional data for the event
  104993. * @returns the new ActionEvent
  104994. */
  104995. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  104996. /**
  104997. * Helper function to auto-create an ActionEvent from a source sprite
  104998. * @param source The source sprite that triggered the event
  104999. * @param scene Scene associated with the sprite
  105000. * @param evt The original (browser) event
  105001. * @param additionalData additional data for the event
  105002. * @returns the new ActionEvent
  105003. */
  105004. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  105005. /**
  105006. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  105007. * @param scene the scene where the event occurred
  105008. * @param evt The original (browser) event
  105009. * @returns the new ActionEvent
  105010. */
  105011. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105012. /**
  105013. * Helper function to auto-create an ActionEvent from a primitive
  105014. * @param prim defines the target primitive
  105015. * @param pointerPos defines the pointer position
  105016. * @param evt The original (browser) event
  105017. * @param additionalData additional data for the event
  105018. * @returns the new ActionEvent
  105019. */
  105020. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105021. }
  105022. }
  105023. declare module BABYLON {
  105024. /**
  105025. * Abstract class used to decouple action Manager from scene and meshes.
  105026. * Do not instantiate.
  105027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105028. */
  105029. export abstract class AbstractActionManager implements IDisposable {
  105030. /** Gets the list of active triggers */
  105031. static Triggers: {
  105032. [key: string]: number;
  105033. };
  105034. /** Gets the cursor to use when hovering items */
  105035. hoverCursor: string;
  105036. /** Gets the list of actions */
  105037. actions: IAction[];
  105038. /**
  105039. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105040. */
  105041. isRecursive: boolean;
  105042. /**
  105043. * Releases all associated resources
  105044. */
  105045. abstract dispose(): void;
  105046. /**
  105047. * Does this action manager has pointer triggers
  105048. */
  105049. abstract get hasPointerTriggers(): boolean;
  105050. /**
  105051. * Does this action manager has pick triggers
  105052. */
  105053. abstract get hasPickTriggers(): boolean;
  105054. /**
  105055. * Process a specific trigger
  105056. * @param trigger defines the trigger to process
  105057. * @param evt defines the event details to be processed
  105058. */
  105059. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105060. /**
  105061. * Does this action manager handles actions of any of the given triggers
  105062. * @param triggers defines the triggers to be tested
  105063. * @return a boolean indicating whether one (or more) of the triggers is handled
  105064. */
  105065. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105066. /**
  105067. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105068. * speed.
  105069. * @param triggerA defines the trigger to be tested
  105070. * @param triggerB defines the trigger to be tested
  105071. * @return a boolean indicating whether one (or more) of the triggers is handled
  105072. */
  105073. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105074. /**
  105075. * Does this action manager handles actions of a given trigger
  105076. * @param trigger defines the trigger to be tested
  105077. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105078. * @return whether the trigger is handled
  105079. */
  105080. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105081. /**
  105082. * Serialize this manager to a JSON object
  105083. * @param name defines the property name to store this manager
  105084. * @returns a JSON representation of this manager
  105085. */
  105086. abstract serialize(name: string): any;
  105087. /**
  105088. * Registers an action to this action manager
  105089. * @param action defines the action to be registered
  105090. * @return the action amended (prepared) after registration
  105091. */
  105092. abstract registerAction(action: IAction): Nullable<IAction>;
  105093. /**
  105094. * Unregisters an action to this action manager
  105095. * @param action defines the action to be unregistered
  105096. * @return a boolean indicating whether the action has been unregistered
  105097. */
  105098. abstract unregisterAction(action: IAction): Boolean;
  105099. /**
  105100. * Does exist one action manager with at least one trigger
  105101. **/
  105102. static get HasTriggers(): boolean;
  105103. /**
  105104. * Does exist one action manager with at least one pick trigger
  105105. **/
  105106. static get HasPickTriggers(): boolean;
  105107. /**
  105108. * Does exist one action manager that handles actions of a given trigger
  105109. * @param trigger defines the trigger to be tested
  105110. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105111. **/
  105112. static HasSpecificTrigger(trigger: number): boolean;
  105113. }
  105114. }
  105115. declare module BABYLON {
  105116. /**
  105117. * Defines how a node can be built from a string name.
  105118. */
  105119. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105120. /**
  105121. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105122. */
  105123. export class Node implements IBehaviorAware<Node> {
  105124. /** @hidden */
  105125. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105126. private static _NodeConstructors;
  105127. /**
  105128. * Add a new node constructor
  105129. * @param type defines the type name of the node to construct
  105130. * @param constructorFunc defines the constructor function
  105131. */
  105132. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105133. /**
  105134. * Returns a node constructor based on type name
  105135. * @param type defines the type name
  105136. * @param name defines the new node name
  105137. * @param scene defines the hosting scene
  105138. * @param options defines optional options to transmit to constructors
  105139. * @returns the new constructor or null
  105140. */
  105141. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105142. /**
  105143. * Gets or sets the name of the node
  105144. */
  105145. name: string;
  105146. /**
  105147. * Gets or sets the id of the node
  105148. */
  105149. id: string;
  105150. /**
  105151. * Gets or sets the unique id of the node
  105152. */
  105153. uniqueId: number;
  105154. /**
  105155. * Gets or sets a string used to store user defined state for the node
  105156. */
  105157. state: string;
  105158. /**
  105159. * Gets or sets an object used to store user defined information for the node
  105160. */
  105161. metadata: any;
  105162. /**
  105163. * For internal use only. Please do not use.
  105164. */
  105165. reservedDataStore: any;
  105166. /**
  105167. * List of inspectable custom properties (used by the Inspector)
  105168. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105169. */
  105170. inspectableCustomProperties: IInspectable[];
  105171. private _doNotSerialize;
  105172. /**
  105173. * Gets or sets a boolean used to define if the node must be serialized
  105174. */
  105175. get doNotSerialize(): boolean;
  105176. set doNotSerialize(value: boolean);
  105177. /** @hidden */
  105178. _isDisposed: boolean;
  105179. /**
  105180. * Gets a list of Animations associated with the node
  105181. */
  105182. animations: Animation[];
  105183. protected _ranges: {
  105184. [name: string]: Nullable<AnimationRange>;
  105185. };
  105186. /**
  105187. * Callback raised when the node is ready to be used
  105188. */
  105189. onReady: Nullable<(node: Node) => void>;
  105190. private _isEnabled;
  105191. private _isParentEnabled;
  105192. private _isReady;
  105193. /** @hidden */
  105194. _currentRenderId: number;
  105195. private _parentUpdateId;
  105196. /** @hidden */
  105197. _childUpdateId: number;
  105198. /** @hidden */
  105199. _waitingParentId: Nullable<string>;
  105200. /** @hidden */
  105201. _scene: Scene;
  105202. /** @hidden */
  105203. _cache: any;
  105204. private _parentNode;
  105205. private _children;
  105206. /** @hidden */
  105207. _worldMatrix: Matrix;
  105208. /** @hidden */
  105209. _worldMatrixDeterminant: number;
  105210. /** @hidden */
  105211. _worldMatrixDeterminantIsDirty: boolean;
  105212. /** @hidden */
  105213. private _sceneRootNodesIndex;
  105214. /**
  105215. * Gets a boolean indicating if the node has been disposed
  105216. * @returns true if the node was disposed
  105217. */
  105218. isDisposed(): boolean;
  105219. /**
  105220. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105221. * @see https://doc.babylonjs.com/how_to/parenting
  105222. */
  105223. set parent(parent: Nullable<Node>);
  105224. get parent(): Nullable<Node>;
  105225. /** @hidden */
  105226. _addToSceneRootNodes(): void;
  105227. /** @hidden */
  105228. _removeFromSceneRootNodes(): void;
  105229. private _animationPropertiesOverride;
  105230. /**
  105231. * Gets or sets the animation properties override
  105232. */
  105233. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105234. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105235. /**
  105236. * Gets a string idenfifying the name of the class
  105237. * @returns "Node" string
  105238. */
  105239. getClassName(): string;
  105240. /** @hidden */
  105241. readonly _isNode: boolean;
  105242. /**
  105243. * An event triggered when the mesh is disposed
  105244. */
  105245. onDisposeObservable: Observable<Node>;
  105246. private _onDisposeObserver;
  105247. /**
  105248. * Sets a callback that will be raised when the node will be disposed
  105249. */
  105250. set onDispose(callback: () => void);
  105251. /**
  105252. * Creates a new Node
  105253. * @param name the name and id to be given to this node
  105254. * @param scene the scene this node will be added to
  105255. */
  105256. constructor(name: string, scene?: Nullable<Scene>);
  105257. /**
  105258. * Gets the scene of the node
  105259. * @returns a scene
  105260. */
  105261. getScene(): Scene;
  105262. /**
  105263. * Gets the engine of the node
  105264. * @returns a Engine
  105265. */
  105266. getEngine(): Engine;
  105267. private _behaviors;
  105268. /**
  105269. * Attach a behavior to the node
  105270. * @see http://doc.babylonjs.com/features/behaviour
  105271. * @param behavior defines the behavior to attach
  105272. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105273. * @returns the current Node
  105274. */
  105275. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105276. /**
  105277. * Remove an attached behavior
  105278. * @see http://doc.babylonjs.com/features/behaviour
  105279. * @param behavior defines the behavior to attach
  105280. * @returns the current Node
  105281. */
  105282. removeBehavior(behavior: Behavior<Node>): Node;
  105283. /**
  105284. * Gets the list of attached behaviors
  105285. * @see http://doc.babylonjs.com/features/behaviour
  105286. */
  105287. get behaviors(): Behavior<Node>[];
  105288. /**
  105289. * Gets an attached behavior by name
  105290. * @param name defines the name of the behavior to look for
  105291. * @see http://doc.babylonjs.com/features/behaviour
  105292. * @returns null if behavior was not found else the requested behavior
  105293. */
  105294. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105295. /**
  105296. * Returns the latest update of the World matrix
  105297. * @returns a Matrix
  105298. */
  105299. getWorldMatrix(): Matrix;
  105300. /** @hidden */
  105301. _getWorldMatrixDeterminant(): number;
  105302. /**
  105303. * Returns directly the latest state of the mesh World matrix.
  105304. * A Matrix is returned.
  105305. */
  105306. get worldMatrixFromCache(): Matrix;
  105307. /** @hidden */
  105308. _initCache(): void;
  105309. /** @hidden */
  105310. updateCache(force?: boolean): void;
  105311. /** @hidden */
  105312. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105313. /** @hidden */
  105314. _updateCache(ignoreParentClass?: boolean): void;
  105315. /** @hidden */
  105316. _isSynchronized(): boolean;
  105317. /** @hidden */
  105318. _markSyncedWithParent(): void;
  105319. /** @hidden */
  105320. isSynchronizedWithParent(): boolean;
  105321. /** @hidden */
  105322. isSynchronized(): boolean;
  105323. /**
  105324. * Is this node ready to be used/rendered
  105325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105326. * @return true if the node is ready
  105327. */
  105328. isReady(completeCheck?: boolean): boolean;
  105329. /**
  105330. * Is this node enabled?
  105331. * 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
  105332. * @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
  105333. * @return whether this node (and its parent) is enabled
  105334. */
  105335. isEnabled(checkAncestors?: boolean): boolean;
  105336. /** @hidden */
  105337. protected _syncParentEnabledState(): void;
  105338. /**
  105339. * Set the enabled state of this node
  105340. * @param value defines the new enabled state
  105341. */
  105342. setEnabled(value: boolean): void;
  105343. /**
  105344. * Is this node a descendant of the given node?
  105345. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105346. * @param ancestor defines the parent node to inspect
  105347. * @returns a boolean indicating if this node is a descendant of the given node
  105348. */
  105349. isDescendantOf(ancestor: Node): boolean;
  105350. /** @hidden */
  105351. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105352. /**
  105353. * Will return all nodes that have this node as ascendant
  105354. * @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
  105355. * @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
  105356. * @return all children nodes of all types
  105357. */
  105358. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105359. /**
  105360. * Get all child-meshes of this node
  105361. * @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)
  105362. * @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
  105363. * @returns an array of AbstractMesh
  105364. */
  105365. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105366. /**
  105367. * Get all direct children of this node
  105368. * @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
  105369. * @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)
  105370. * @returns an array of Node
  105371. */
  105372. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105373. /** @hidden */
  105374. _setReady(state: boolean): void;
  105375. /**
  105376. * Get an animation by name
  105377. * @param name defines the name of the animation to look for
  105378. * @returns null if not found else the requested animation
  105379. */
  105380. getAnimationByName(name: string): Nullable<Animation>;
  105381. /**
  105382. * Creates an animation range for this node
  105383. * @param name defines the name of the range
  105384. * @param from defines the starting key
  105385. * @param to defines the end key
  105386. */
  105387. createAnimationRange(name: string, from: number, to: number): void;
  105388. /**
  105389. * Delete a specific animation range
  105390. * @param name defines the name of the range to delete
  105391. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105392. */
  105393. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105394. /**
  105395. * Get an animation range by name
  105396. * @param name defines the name of the animation range to look for
  105397. * @returns null if not found else the requested animation range
  105398. */
  105399. getAnimationRange(name: string): Nullable<AnimationRange>;
  105400. /**
  105401. * Gets the list of all animation ranges defined on this node
  105402. * @returns an array
  105403. */
  105404. getAnimationRanges(): Nullable<AnimationRange>[];
  105405. /**
  105406. * Will start the animation sequence
  105407. * @param name defines the range frames for animation sequence
  105408. * @param loop defines if the animation should loop (false by default)
  105409. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105410. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105411. * @returns the object created for this animation. If range does not exist, it will return null
  105412. */
  105413. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105414. /**
  105415. * Serialize animation ranges into a JSON compatible object
  105416. * @returns serialization object
  105417. */
  105418. serializeAnimationRanges(): any;
  105419. /**
  105420. * Computes the world matrix of the node
  105421. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105422. * @returns the world matrix
  105423. */
  105424. computeWorldMatrix(force?: boolean): Matrix;
  105425. /**
  105426. * Releases resources associated with this node.
  105427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105429. */
  105430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105431. /**
  105432. * Parse animation range data from a serialization object and store them into a given node
  105433. * @param node defines where to store the animation ranges
  105434. * @param parsedNode defines the serialization object to read data from
  105435. * @param scene defines the hosting scene
  105436. */
  105437. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105438. /**
  105439. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105440. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105441. * @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
  105442. * @returns the new bounding vectors
  105443. */
  105444. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105445. min: Vector3;
  105446. max: Vector3;
  105447. };
  105448. }
  105449. }
  105450. declare module BABYLON {
  105451. /**
  105452. * @hidden
  105453. */
  105454. export class _IAnimationState {
  105455. key: number;
  105456. repeatCount: number;
  105457. workValue?: any;
  105458. loopMode?: number;
  105459. offsetValue?: any;
  105460. highLimitValue?: any;
  105461. }
  105462. /**
  105463. * Class used to store any kind of animation
  105464. */
  105465. export class Animation {
  105466. /**Name of the animation */
  105467. name: string;
  105468. /**Property to animate */
  105469. targetProperty: string;
  105470. /**The frames per second of the animation */
  105471. framePerSecond: number;
  105472. /**The data type of the animation */
  105473. dataType: number;
  105474. /**The loop mode of the animation */
  105475. loopMode?: number | undefined;
  105476. /**Specifies if blending should be enabled */
  105477. enableBlending?: boolean | undefined;
  105478. /**
  105479. * Use matrix interpolation instead of using direct key value when animating matrices
  105480. */
  105481. static AllowMatricesInterpolation: boolean;
  105482. /**
  105483. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105484. */
  105485. static AllowMatrixDecomposeForInterpolation: boolean;
  105486. /**
  105487. * Stores the key frames of the animation
  105488. */
  105489. private _keys;
  105490. /**
  105491. * Stores the easing function of the animation
  105492. */
  105493. private _easingFunction;
  105494. /**
  105495. * @hidden Internal use only
  105496. */
  105497. _runtimeAnimations: RuntimeAnimation[];
  105498. /**
  105499. * The set of event that will be linked to this animation
  105500. */
  105501. private _events;
  105502. /**
  105503. * Stores an array of target property paths
  105504. */
  105505. targetPropertyPath: string[];
  105506. /**
  105507. * Stores the blending speed of the animation
  105508. */
  105509. blendingSpeed: number;
  105510. /**
  105511. * Stores the animation ranges for the animation
  105512. */
  105513. private _ranges;
  105514. /**
  105515. * @hidden Internal use
  105516. */
  105517. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105518. /**
  105519. * Sets up an animation
  105520. * @param property The property to animate
  105521. * @param animationType The animation type to apply
  105522. * @param framePerSecond The frames per second of the animation
  105523. * @param easingFunction The easing function used in the animation
  105524. * @returns The created animation
  105525. */
  105526. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105527. /**
  105528. * Create and start an animation on a node
  105529. * @param name defines the name of the global animation that will be run on all nodes
  105530. * @param node defines the root node where the animation will take place
  105531. * @param targetProperty defines property to animate
  105532. * @param framePerSecond defines the number of frame per second yo use
  105533. * @param totalFrame defines the number of frames in total
  105534. * @param from defines the initial value
  105535. * @param to defines the final value
  105536. * @param loopMode defines which loop mode you want to use (off by default)
  105537. * @param easingFunction defines the easing function to use (linear by default)
  105538. * @param onAnimationEnd defines the callback to call when animation end
  105539. * @returns the animatable created for this animation
  105540. */
  105541. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105542. /**
  105543. * Create and start an animation on a node and its descendants
  105544. * @param name defines the name of the global animation that will be run on all nodes
  105545. * @param node defines the root node where the animation will take place
  105546. * @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
  105547. * @param targetProperty defines property to animate
  105548. * @param framePerSecond defines the number of frame per second to use
  105549. * @param totalFrame defines the number of frames in total
  105550. * @param from defines the initial value
  105551. * @param to defines the final value
  105552. * @param loopMode defines which loop mode you want to use (off by default)
  105553. * @param easingFunction defines the easing function to use (linear by default)
  105554. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105555. * @returns the list of animatables created for all nodes
  105556. * @example https://www.babylonjs-playground.com/#MH0VLI
  105557. */
  105558. 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[]>;
  105559. /**
  105560. * Creates a new animation, merges it with the existing animations and starts it
  105561. * @param name Name of the animation
  105562. * @param node Node which contains the scene that begins the animations
  105563. * @param targetProperty Specifies which property to animate
  105564. * @param framePerSecond The frames per second of the animation
  105565. * @param totalFrame The total number of frames
  105566. * @param from The frame at the beginning of the animation
  105567. * @param to The frame at the end of the animation
  105568. * @param loopMode Specifies the loop mode of the animation
  105569. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105570. * @param onAnimationEnd Callback to run once the animation is complete
  105571. * @returns Nullable animation
  105572. */
  105573. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105574. /**
  105575. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105576. * @param sourceAnimation defines the Animation containing keyframes to convert
  105577. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105578. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105579. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105580. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105581. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105582. */
  105583. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105584. /**
  105585. * Transition property of an host to the target Value
  105586. * @param property The property to transition
  105587. * @param targetValue The target Value of the property
  105588. * @param host The object where the property to animate belongs
  105589. * @param scene Scene used to run the animation
  105590. * @param frameRate Framerate (in frame/s) to use
  105591. * @param transition The transition type we want to use
  105592. * @param duration The duration of the animation, in milliseconds
  105593. * @param onAnimationEnd Callback trigger at the end of the animation
  105594. * @returns Nullable animation
  105595. */
  105596. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105597. /**
  105598. * Return the array of runtime animations currently using this animation
  105599. */
  105600. get runtimeAnimations(): RuntimeAnimation[];
  105601. /**
  105602. * Specifies if any of the runtime animations are currently running
  105603. */
  105604. get hasRunningRuntimeAnimations(): boolean;
  105605. /**
  105606. * Initializes the animation
  105607. * @param name Name of the animation
  105608. * @param targetProperty Property to animate
  105609. * @param framePerSecond The frames per second of the animation
  105610. * @param dataType The data type of the animation
  105611. * @param loopMode The loop mode of the animation
  105612. * @param enableBlending Specifies if blending should be enabled
  105613. */
  105614. constructor(
  105615. /**Name of the animation */
  105616. name: string,
  105617. /**Property to animate */
  105618. targetProperty: string,
  105619. /**The frames per second of the animation */
  105620. framePerSecond: number,
  105621. /**The data type of the animation */
  105622. dataType: number,
  105623. /**The loop mode of the animation */
  105624. loopMode?: number | undefined,
  105625. /**Specifies if blending should be enabled */
  105626. enableBlending?: boolean | undefined);
  105627. /**
  105628. * Converts the animation to a string
  105629. * @param fullDetails support for multiple levels of logging within scene loading
  105630. * @returns String form of the animation
  105631. */
  105632. toString(fullDetails?: boolean): string;
  105633. /**
  105634. * Add an event to this animation
  105635. * @param event Event to add
  105636. */
  105637. addEvent(event: AnimationEvent): void;
  105638. /**
  105639. * Remove all events found at the given frame
  105640. * @param frame The frame to remove events from
  105641. */
  105642. removeEvents(frame: number): void;
  105643. /**
  105644. * Retrieves all the events from the animation
  105645. * @returns Events from the animation
  105646. */
  105647. getEvents(): AnimationEvent[];
  105648. /**
  105649. * Creates an animation range
  105650. * @param name Name of the animation range
  105651. * @param from Starting frame of the animation range
  105652. * @param to Ending frame of the animation
  105653. */
  105654. createRange(name: string, from: number, to: number): void;
  105655. /**
  105656. * Deletes an animation range by name
  105657. * @param name Name of the animation range to delete
  105658. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105659. */
  105660. deleteRange(name: string, deleteFrames?: boolean): void;
  105661. /**
  105662. * Gets the animation range by name, or null if not defined
  105663. * @param name Name of the animation range
  105664. * @returns Nullable animation range
  105665. */
  105666. getRange(name: string): Nullable<AnimationRange>;
  105667. /**
  105668. * Gets the key frames from the animation
  105669. * @returns The key frames of the animation
  105670. */
  105671. getKeys(): Array<IAnimationKey>;
  105672. /**
  105673. * Gets the highest frame rate of the animation
  105674. * @returns Highest frame rate of the animation
  105675. */
  105676. getHighestFrame(): number;
  105677. /**
  105678. * Gets the easing function of the animation
  105679. * @returns Easing function of the animation
  105680. */
  105681. getEasingFunction(): IEasingFunction;
  105682. /**
  105683. * Sets the easing function of the animation
  105684. * @param easingFunction A custom mathematical formula for animation
  105685. */
  105686. setEasingFunction(easingFunction: EasingFunction): void;
  105687. /**
  105688. * Interpolates a scalar linearly
  105689. * @param startValue Start value of the animation curve
  105690. * @param endValue End value of the animation curve
  105691. * @param gradient Scalar amount to interpolate
  105692. * @returns Interpolated scalar value
  105693. */
  105694. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105695. /**
  105696. * Interpolates a scalar cubically
  105697. * @param startValue Start value of the animation curve
  105698. * @param outTangent End tangent of the animation
  105699. * @param endValue End value of the animation curve
  105700. * @param inTangent Start tangent of the animation curve
  105701. * @param gradient Scalar amount to interpolate
  105702. * @returns Interpolated scalar value
  105703. */
  105704. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105705. /**
  105706. * Interpolates a quaternion using a spherical linear interpolation
  105707. * @param startValue Start value of the animation curve
  105708. * @param endValue End value of the animation curve
  105709. * @param gradient Scalar amount to interpolate
  105710. * @returns Interpolated quaternion value
  105711. */
  105712. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105713. /**
  105714. * Interpolates a quaternion cubically
  105715. * @param startValue Start value of the animation curve
  105716. * @param outTangent End tangent of the animation curve
  105717. * @param endValue End value of the animation curve
  105718. * @param inTangent Start tangent of the animation curve
  105719. * @param gradient Scalar amount to interpolate
  105720. * @returns Interpolated quaternion value
  105721. */
  105722. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105723. /**
  105724. * Interpolates a Vector3 linearl
  105725. * @param startValue Start value of the animation curve
  105726. * @param endValue End value of the animation curve
  105727. * @param gradient Scalar amount to interpolate
  105728. * @returns Interpolated scalar value
  105729. */
  105730. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105731. /**
  105732. * Interpolates a Vector3 cubically
  105733. * @param startValue Start value of the animation curve
  105734. * @param outTangent End tangent of the animation
  105735. * @param endValue End value of the animation curve
  105736. * @param inTangent Start tangent of the animation curve
  105737. * @param gradient Scalar amount to interpolate
  105738. * @returns InterpolatedVector3 value
  105739. */
  105740. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  105741. /**
  105742. * Interpolates a Vector2 linearly
  105743. * @param startValue Start value of the animation curve
  105744. * @param endValue End value of the animation curve
  105745. * @param gradient Scalar amount to interpolate
  105746. * @returns Interpolated Vector2 value
  105747. */
  105748. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  105749. /**
  105750. * Interpolates a Vector2 cubically
  105751. * @param startValue Start value of the animation curve
  105752. * @param outTangent End tangent of the animation
  105753. * @param endValue End value of the animation curve
  105754. * @param inTangent Start tangent of the animation curve
  105755. * @param gradient Scalar amount to interpolate
  105756. * @returns Interpolated Vector2 value
  105757. */
  105758. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  105759. /**
  105760. * Interpolates a size linearly
  105761. * @param startValue Start value of the animation curve
  105762. * @param endValue End value of the animation curve
  105763. * @param gradient Scalar amount to interpolate
  105764. * @returns Interpolated Size value
  105765. */
  105766. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  105767. /**
  105768. * Interpolates a Color3 linearly
  105769. * @param startValue Start value of the animation curve
  105770. * @param endValue End value of the animation curve
  105771. * @param gradient Scalar amount to interpolate
  105772. * @returns Interpolated Color3 value
  105773. */
  105774. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  105775. /**
  105776. * Interpolates a Color4 linearly
  105777. * @param startValue Start value of the animation curve
  105778. * @param endValue End value of the animation curve
  105779. * @param gradient Scalar amount to interpolate
  105780. * @returns Interpolated Color3 value
  105781. */
  105782. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  105783. /**
  105784. * @hidden Internal use only
  105785. */
  105786. _getKeyValue(value: any): any;
  105787. /**
  105788. * @hidden Internal use only
  105789. */
  105790. _interpolate(currentFrame: number, state: _IAnimationState): any;
  105791. /**
  105792. * Defines the function to use to interpolate matrices
  105793. * @param startValue defines the start matrix
  105794. * @param endValue defines the end matrix
  105795. * @param gradient defines the gradient between both matrices
  105796. * @param result defines an optional target matrix where to store the interpolation
  105797. * @returns the interpolated matrix
  105798. */
  105799. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  105800. /**
  105801. * Makes a copy of the animation
  105802. * @returns Cloned animation
  105803. */
  105804. clone(): Animation;
  105805. /**
  105806. * Sets the key frames of the animation
  105807. * @param values The animation key frames to set
  105808. */
  105809. setKeys(values: Array<IAnimationKey>): void;
  105810. /**
  105811. * Serializes the animation to an object
  105812. * @returns Serialized object
  105813. */
  105814. serialize(): any;
  105815. /**
  105816. * Float animation type
  105817. */
  105818. static readonly ANIMATIONTYPE_FLOAT: number;
  105819. /**
  105820. * Vector3 animation type
  105821. */
  105822. static readonly ANIMATIONTYPE_VECTOR3: number;
  105823. /**
  105824. * Quaternion animation type
  105825. */
  105826. static readonly ANIMATIONTYPE_QUATERNION: number;
  105827. /**
  105828. * Matrix animation type
  105829. */
  105830. static readonly ANIMATIONTYPE_MATRIX: number;
  105831. /**
  105832. * Color3 animation type
  105833. */
  105834. static readonly ANIMATIONTYPE_COLOR3: number;
  105835. /**
  105836. * Color3 animation type
  105837. */
  105838. static readonly ANIMATIONTYPE_COLOR4: number;
  105839. /**
  105840. * Vector2 animation type
  105841. */
  105842. static readonly ANIMATIONTYPE_VECTOR2: number;
  105843. /**
  105844. * Size animation type
  105845. */
  105846. static readonly ANIMATIONTYPE_SIZE: number;
  105847. /**
  105848. * Relative Loop Mode
  105849. */
  105850. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  105851. /**
  105852. * Cycle Loop Mode
  105853. */
  105854. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  105855. /**
  105856. * Constant Loop Mode
  105857. */
  105858. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  105859. /** @hidden */
  105860. static _UniversalLerp(left: any, right: any, amount: number): any;
  105861. /**
  105862. * Parses an animation object and creates an animation
  105863. * @param parsedAnimation Parsed animation object
  105864. * @returns Animation object
  105865. */
  105866. static Parse(parsedAnimation: any): Animation;
  105867. /**
  105868. * Appends the serialized animations from the source animations
  105869. * @param source Source containing the animations
  105870. * @param destination Target to store the animations
  105871. */
  105872. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105873. }
  105874. }
  105875. declare module BABYLON {
  105876. /**
  105877. * Interface containing an array of animations
  105878. */
  105879. export interface IAnimatable {
  105880. /**
  105881. * Array of animations
  105882. */
  105883. animations: Nullable<Array<Animation>>;
  105884. }
  105885. }
  105886. declare module BABYLON {
  105887. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  105888. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105889. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105890. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105891. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105892. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105893. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105894. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105895. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105896. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105897. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105898. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105899. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105900. /**
  105901. * Decorator used to define property that can be serialized as reference to a camera
  105902. * @param sourceName defines the name of the property to decorate
  105903. */
  105904. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105905. /**
  105906. * Class used to help serialization objects
  105907. */
  105908. export class SerializationHelper {
  105909. /** @hidden */
  105910. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  105911. /** @hidden */
  105912. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  105913. /** @hidden */
  105914. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  105915. /** @hidden */
  105916. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  105917. /**
  105918. * Appends the serialized animations from the source animations
  105919. * @param source Source containing the animations
  105920. * @param destination Target to store the animations
  105921. */
  105922. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105923. /**
  105924. * Static function used to serialized a specific entity
  105925. * @param entity defines the entity to serialize
  105926. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  105927. * @returns a JSON compatible object representing the serialization of the entity
  105928. */
  105929. static Serialize<T>(entity: T, serializationObject?: any): any;
  105930. /**
  105931. * Creates a new entity from a serialization data object
  105932. * @param creationFunction defines a function used to instanciated the new entity
  105933. * @param source defines the source serialization data
  105934. * @param scene defines the hosting scene
  105935. * @param rootUrl defines the root url for resources
  105936. * @returns a new entity
  105937. */
  105938. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  105939. /**
  105940. * Clones an object
  105941. * @param creationFunction defines the function used to instanciate the new object
  105942. * @param source defines the source object
  105943. * @returns the cloned object
  105944. */
  105945. static Clone<T>(creationFunction: () => T, source: T): T;
  105946. /**
  105947. * Instanciates a new object based on a source one (some data will be shared between both object)
  105948. * @param creationFunction defines the function used to instanciate the new object
  105949. * @param source defines the source object
  105950. * @returns the new object
  105951. */
  105952. static Instanciate<T>(creationFunction: () => T, source: T): T;
  105953. }
  105954. }
  105955. declare module BABYLON {
  105956. /**
  105957. * Base class of all the textures in babylon.
  105958. * It groups all the common properties the materials, post process, lights... might need
  105959. * in order to make a correct use of the texture.
  105960. */
  105961. export class BaseTexture implements IAnimatable {
  105962. /**
  105963. * Default anisotropic filtering level for the application.
  105964. * It is set to 4 as a good tradeoff between perf and quality.
  105965. */
  105966. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  105967. /**
  105968. * Gets or sets the unique id of the texture
  105969. */
  105970. uniqueId: number;
  105971. /**
  105972. * Define the name of the texture.
  105973. */
  105974. name: string;
  105975. /**
  105976. * Gets or sets an object used to store user defined information.
  105977. */
  105978. metadata: any;
  105979. /**
  105980. * For internal use only. Please do not use.
  105981. */
  105982. reservedDataStore: any;
  105983. private _hasAlpha;
  105984. /**
  105985. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  105986. */
  105987. set hasAlpha(value: boolean);
  105988. get hasAlpha(): boolean;
  105989. /**
  105990. * Defines if the alpha value should be determined via the rgb values.
  105991. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  105992. */
  105993. getAlphaFromRGB: boolean;
  105994. /**
  105995. * Intensity or strength of the texture.
  105996. * It is commonly used by materials to fine tune the intensity of the texture
  105997. */
  105998. level: number;
  105999. /**
  106000. * Define the UV chanel to use starting from 0 and defaulting to 0.
  106001. * This is part of the texture as textures usually maps to one uv set.
  106002. */
  106003. coordinatesIndex: number;
  106004. private _coordinatesMode;
  106005. /**
  106006. * How a texture is mapped.
  106007. *
  106008. * | Value | Type | Description |
  106009. * | ----- | ----------------------------------- | ----------- |
  106010. * | 0 | EXPLICIT_MODE | |
  106011. * | 1 | SPHERICAL_MODE | |
  106012. * | 2 | PLANAR_MODE | |
  106013. * | 3 | CUBIC_MODE | |
  106014. * | 4 | PROJECTION_MODE | |
  106015. * | 5 | SKYBOX_MODE | |
  106016. * | 6 | INVCUBIC_MODE | |
  106017. * | 7 | EQUIRECTANGULAR_MODE | |
  106018. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106019. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106020. */
  106021. set coordinatesMode(value: number);
  106022. get coordinatesMode(): number;
  106023. /**
  106024. * | Value | Type | Description |
  106025. * | ----- | ------------------ | ----------- |
  106026. * | 0 | CLAMP_ADDRESSMODE | |
  106027. * | 1 | WRAP_ADDRESSMODE | |
  106028. * | 2 | MIRROR_ADDRESSMODE | |
  106029. */
  106030. wrapU: number;
  106031. /**
  106032. * | Value | Type | Description |
  106033. * | ----- | ------------------ | ----------- |
  106034. * | 0 | CLAMP_ADDRESSMODE | |
  106035. * | 1 | WRAP_ADDRESSMODE | |
  106036. * | 2 | MIRROR_ADDRESSMODE | |
  106037. */
  106038. wrapV: number;
  106039. /**
  106040. * | Value | Type | Description |
  106041. * | ----- | ------------------ | ----------- |
  106042. * | 0 | CLAMP_ADDRESSMODE | |
  106043. * | 1 | WRAP_ADDRESSMODE | |
  106044. * | 2 | MIRROR_ADDRESSMODE | |
  106045. */
  106046. wrapR: number;
  106047. /**
  106048. * With compliant hardware and browser (supporting anisotropic filtering)
  106049. * this defines the level of anisotropic filtering in the texture.
  106050. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106051. */
  106052. anisotropicFilteringLevel: number;
  106053. /**
  106054. * Define if the texture is a cube texture or if false a 2d texture.
  106055. */
  106056. get isCube(): boolean;
  106057. set isCube(value: boolean);
  106058. /**
  106059. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106060. */
  106061. get is3D(): boolean;
  106062. set is3D(value: boolean);
  106063. /**
  106064. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106065. */
  106066. get is2DArray(): boolean;
  106067. set is2DArray(value: boolean);
  106068. /**
  106069. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106070. * HDR texture are usually stored in linear space.
  106071. * This only impacts the PBR and Background materials
  106072. */
  106073. gammaSpace: boolean;
  106074. /**
  106075. * Gets or sets whether or not the texture contains RGBD data.
  106076. */
  106077. get isRGBD(): boolean;
  106078. set isRGBD(value: boolean);
  106079. /**
  106080. * Is Z inverted in the texture (useful in a cube texture).
  106081. */
  106082. invertZ: boolean;
  106083. /**
  106084. * Are mip maps generated for this texture or not.
  106085. */
  106086. get noMipmap(): boolean;
  106087. /**
  106088. * @hidden
  106089. */
  106090. lodLevelInAlpha: boolean;
  106091. /**
  106092. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106093. */
  106094. get lodGenerationOffset(): number;
  106095. set lodGenerationOffset(value: number);
  106096. /**
  106097. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106098. */
  106099. get lodGenerationScale(): number;
  106100. set lodGenerationScale(value: number);
  106101. /**
  106102. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106103. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106104. * average roughness values.
  106105. */
  106106. get linearSpecularLOD(): boolean;
  106107. set linearSpecularLOD(value: boolean);
  106108. /**
  106109. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106110. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106111. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106112. */
  106113. get irradianceTexture(): Nullable<BaseTexture>;
  106114. set irradianceTexture(value: Nullable<BaseTexture>);
  106115. /**
  106116. * Define if the texture is a render target.
  106117. */
  106118. isRenderTarget: boolean;
  106119. /**
  106120. * Define the unique id of the texture in the scene.
  106121. */
  106122. get uid(): string;
  106123. /**
  106124. * Return a string representation of the texture.
  106125. * @returns the texture as a string
  106126. */
  106127. toString(): string;
  106128. /**
  106129. * Get the class name of the texture.
  106130. * @returns "BaseTexture"
  106131. */
  106132. getClassName(): string;
  106133. /**
  106134. * Define the list of animation attached to the texture.
  106135. */
  106136. animations: Animation[];
  106137. /**
  106138. * An event triggered when the texture is disposed.
  106139. */
  106140. onDisposeObservable: Observable<BaseTexture>;
  106141. private _onDisposeObserver;
  106142. /**
  106143. * Callback triggered when the texture has been disposed.
  106144. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106145. */
  106146. set onDispose(callback: () => void);
  106147. /**
  106148. * Define the current state of the loading sequence when in delayed load mode.
  106149. */
  106150. delayLoadState: number;
  106151. private _scene;
  106152. /** @hidden */
  106153. _texture: Nullable<InternalTexture>;
  106154. private _uid;
  106155. /**
  106156. * Define if the texture is preventinga material to render or not.
  106157. * If not and the texture is not ready, the engine will use a default black texture instead.
  106158. */
  106159. get isBlocking(): boolean;
  106160. /**
  106161. * Instantiates a new BaseTexture.
  106162. * Base class of all the textures in babylon.
  106163. * It groups all the common properties the materials, post process, lights... might need
  106164. * in order to make a correct use of the texture.
  106165. * @param scene Define the scene the texture blongs to
  106166. */
  106167. constructor(scene: Nullable<Scene>);
  106168. /**
  106169. * Get the scene the texture belongs to.
  106170. * @returns the scene or null if undefined
  106171. */
  106172. getScene(): Nullable<Scene>;
  106173. /**
  106174. * Get the texture transform matrix used to offset tile the texture for istance.
  106175. * @returns the transformation matrix
  106176. */
  106177. getTextureMatrix(): Matrix;
  106178. /**
  106179. * Get the texture reflection matrix used to rotate/transform the reflection.
  106180. * @returns the reflection matrix
  106181. */
  106182. getReflectionTextureMatrix(): Matrix;
  106183. /**
  106184. * Get the underlying lower level texture from Babylon.
  106185. * @returns the insternal texture
  106186. */
  106187. getInternalTexture(): Nullable<InternalTexture>;
  106188. /**
  106189. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106190. * @returns true if ready or not blocking
  106191. */
  106192. isReadyOrNotBlocking(): boolean;
  106193. /**
  106194. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106195. * @returns true if fully ready
  106196. */
  106197. isReady(): boolean;
  106198. private _cachedSize;
  106199. /**
  106200. * Get the size of the texture.
  106201. * @returns the texture size.
  106202. */
  106203. getSize(): ISize;
  106204. /**
  106205. * Get the base size of the texture.
  106206. * It can be different from the size if the texture has been resized for POT for instance
  106207. * @returns the base size
  106208. */
  106209. getBaseSize(): ISize;
  106210. /**
  106211. * Update the sampling mode of the texture.
  106212. * Default is Trilinear mode.
  106213. *
  106214. * | Value | Type | Description |
  106215. * | ----- | ------------------ | ----------- |
  106216. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106217. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106218. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106219. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106220. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106221. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106222. * | 7 | NEAREST_LINEAR | |
  106223. * | 8 | NEAREST_NEAREST | |
  106224. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106225. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106226. * | 11 | LINEAR_LINEAR | |
  106227. * | 12 | LINEAR_NEAREST | |
  106228. *
  106229. * > _mag_: magnification filter (close to the viewer)
  106230. * > _min_: minification filter (far from the viewer)
  106231. * > _mip_: filter used between mip map levels
  106232. *@param samplingMode Define the new sampling mode of the texture
  106233. */
  106234. updateSamplingMode(samplingMode: number): void;
  106235. /**
  106236. * Scales the texture if is `canRescale()`
  106237. * @param ratio the resize factor we want to use to rescale
  106238. */
  106239. scale(ratio: number): void;
  106240. /**
  106241. * Get if the texture can rescale.
  106242. */
  106243. get canRescale(): boolean;
  106244. /** @hidden */
  106245. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106246. /** @hidden */
  106247. _rebuild(): void;
  106248. /**
  106249. * Triggers the load sequence in delayed load mode.
  106250. */
  106251. delayLoad(): void;
  106252. /**
  106253. * Clones the texture.
  106254. * @returns the cloned texture
  106255. */
  106256. clone(): Nullable<BaseTexture>;
  106257. /**
  106258. * Get the texture underlying type (INT, FLOAT...)
  106259. */
  106260. get textureType(): number;
  106261. /**
  106262. * Get the texture underlying format (RGB, RGBA...)
  106263. */
  106264. get textureFormat(): number;
  106265. /**
  106266. * Indicates that textures need to be re-calculated for all materials
  106267. */
  106268. protected _markAllSubMeshesAsTexturesDirty(): void;
  106269. /**
  106270. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106271. * This will returns an RGBA array buffer containing either in values (0-255) or
  106272. * float values (0-1) depending of the underlying buffer type.
  106273. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106274. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106275. * @param buffer defines a user defined buffer to fill with data (can be null)
  106276. * @returns The Array buffer containing the pixels data.
  106277. */
  106278. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106279. /**
  106280. * Release and destroy the underlying lower level texture aka internalTexture.
  106281. */
  106282. releaseInternalTexture(): void;
  106283. /** @hidden */
  106284. get _lodTextureHigh(): Nullable<BaseTexture>;
  106285. /** @hidden */
  106286. get _lodTextureMid(): Nullable<BaseTexture>;
  106287. /** @hidden */
  106288. get _lodTextureLow(): Nullable<BaseTexture>;
  106289. /**
  106290. * Dispose the texture and release its associated resources.
  106291. */
  106292. dispose(): void;
  106293. /**
  106294. * Serialize the texture into a JSON representation that can be parsed later on.
  106295. * @returns the JSON representation of the texture
  106296. */
  106297. serialize(): any;
  106298. /**
  106299. * Helper function to be called back once a list of texture contains only ready textures.
  106300. * @param textures Define the list of textures to wait for
  106301. * @param callback Define the callback triggered once the entire list will be ready
  106302. */
  106303. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106304. }
  106305. }
  106306. declare module BABYLON {
  106307. /**
  106308. * Options to be used when creating an effect.
  106309. */
  106310. export interface IEffectCreationOptions {
  106311. /**
  106312. * Atrributes that will be used in the shader.
  106313. */
  106314. attributes: string[];
  106315. /**
  106316. * Uniform varible names that will be set in the shader.
  106317. */
  106318. uniformsNames: string[];
  106319. /**
  106320. * Uniform buffer variable names that will be set in the shader.
  106321. */
  106322. uniformBuffersNames: string[];
  106323. /**
  106324. * Sampler texture variable names that will be set in the shader.
  106325. */
  106326. samplers: string[];
  106327. /**
  106328. * Define statements that will be set in the shader.
  106329. */
  106330. defines: any;
  106331. /**
  106332. * Possible fallbacks for this effect to improve performance when needed.
  106333. */
  106334. fallbacks: Nullable<IEffectFallbacks>;
  106335. /**
  106336. * Callback that will be called when the shader is compiled.
  106337. */
  106338. onCompiled: Nullable<(effect: Effect) => void>;
  106339. /**
  106340. * Callback that will be called if an error occurs during shader compilation.
  106341. */
  106342. onError: Nullable<(effect: Effect, errors: string) => void>;
  106343. /**
  106344. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106345. */
  106346. indexParameters?: any;
  106347. /**
  106348. * Max number of lights that can be used in the shader.
  106349. */
  106350. maxSimultaneousLights?: number;
  106351. /**
  106352. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106353. */
  106354. transformFeedbackVaryings?: Nullable<string[]>;
  106355. }
  106356. /**
  106357. * Effect containing vertex and fragment shader that can be executed on an object.
  106358. */
  106359. export class Effect implements IDisposable {
  106360. /**
  106361. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106362. */
  106363. static ShadersRepository: string;
  106364. /**
  106365. * Enable logging of the shader code when a compilation error occurs
  106366. */
  106367. static LogShaderCodeOnCompilationError: boolean;
  106368. /**
  106369. * Name of the effect.
  106370. */
  106371. name: any;
  106372. /**
  106373. * String container all the define statements that should be set on the shader.
  106374. */
  106375. defines: string;
  106376. /**
  106377. * Callback that will be called when the shader is compiled.
  106378. */
  106379. onCompiled: Nullable<(effect: Effect) => void>;
  106380. /**
  106381. * Callback that will be called if an error occurs during shader compilation.
  106382. */
  106383. onError: Nullable<(effect: Effect, errors: string) => void>;
  106384. /**
  106385. * Callback that will be called when effect is bound.
  106386. */
  106387. onBind: Nullable<(effect: Effect) => void>;
  106388. /**
  106389. * Unique ID of the effect.
  106390. */
  106391. uniqueId: number;
  106392. /**
  106393. * Observable that will be called when the shader is compiled.
  106394. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106395. */
  106396. onCompileObservable: Observable<Effect>;
  106397. /**
  106398. * Observable that will be called if an error occurs during shader compilation.
  106399. */
  106400. onErrorObservable: Observable<Effect>;
  106401. /** @hidden */
  106402. _onBindObservable: Nullable<Observable<Effect>>;
  106403. /**
  106404. * @hidden
  106405. * Specifies if the effect was previously ready
  106406. */
  106407. _wasPreviouslyReady: boolean;
  106408. /**
  106409. * Observable that will be called when effect is bound.
  106410. */
  106411. get onBindObservable(): Observable<Effect>;
  106412. /** @hidden */
  106413. _bonesComputationForcedToCPU: boolean;
  106414. private static _uniqueIdSeed;
  106415. private _engine;
  106416. private _uniformBuffersNames;
  106417. private _uniformBuffersNamesList;
  106418. private _uniformsNames;
  106419. private _samplerList;
  106420. private _samplers;
  106421. private _isReady;
  106422. private _compilationError;
  106423. private _allFallbacksProcessed;
  106424. private _attributesNames;
  106425. private _attributes;
  106426. private _attributeLocationByName;
  106427. private _uniforms;
  106428. /**
  106429. * Key for the effect.
  106430. * @hidden
  106431. */
  106432. _key: string;
  106433. private _indexParameters;
  106434. private _fallbacks;
  106435. private _vertexSourceCode;
  106436. private _fragmentSourceCode;
  106437. private _vertexSourceCodeOverride;
  106438. private _fragmentSourceCodeOverride;
  106439. private _transformFeedbackVaryings;
  106440. /**
  106441. * Compiled shader to webGL program.
  106442. * @hidden
  106443. */
  106444. _pipelineContext: Nullable<IPipelineContext>;
  106445. private _valueCache;
  106446. private static _baseCache;
  106447. /**
  106448. * Instantiates an effect.
  106449. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106450. * @param baseName Name of the effect.
  106451. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106452. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106453. * @param samplers List of sampler variables that will be passed to the shader.
  106454. * @param engine Engine to be used to render the effect
  106455. * @param defines Define statements to be added to the shader.
  106456. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106457. * @param onCompiled Callback that will be called when the shader is compiled.
  106458. * @param onError Callback that will be called if an error occurs during shader compilation.
  106459. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106460. */
  106461. 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);
  106462. private _useFinalCode;
  106463. /**
  106464. * Unique key for this effect
  106465. */
  106466. get key(): string;
  106467. /**
  106468. * If the effect has been compiled and prepared.
  106469. * @returns if the effect is compiled and prepared.
  106470. */
  106471. isReady(): boolean;
  106472. private _isReadyInternal;
  106473. /**
  106474. * The engine the effect was initialized with.
  106475. * @returns the engine.
  106476. */
  106477. getEngine(): Engine;
  106478. /**
  106479. * The pipeline context for this effect
  106480. * @returns the associated pipeline context
  106481. */
  106482. getPipelineContext(): Nullable<IPipelineContext>;
  106483. /**
  106484. * The set of names of attribute variables for the shader.
  106485. * @returns An array of attribute names.
  106486. */
  106487. getAttributesNames(): string[];
  106488. /**
  106489. * Returns the attribute at the given index.
  106490. * @param index The index of the attribute.
  106491. * @returns The location of the attribute.
  106492. */
  106493. getAttributeLocation(index: number): number;
  106494. /**
  106495. * Returns the attribute based on the name of the variable.
  106496. * @param name of the attribute to look up.
  106497. * @returns the attribute location.
  106498. */
  106499. getAttributeLocationByName(name: string): number;
  106500. /**
  106501. * The number of attributes.
  106502. * @returns the numnber of attributes.
  106503. */
  106504. getAttributesCount(): number;
  106505. /**
  106506. * Gets the index of a uniform variable.
  106507. * @param uniformName of the uniform to look up.
  106508. * @returns the index.
  106509. */
  106510. getUniformIndex(uniformName: string): number;
  106511. /**
  106512. * Returns the attribute based on the name of the variable.
  106513. * @param uniformName of the uniform to look up.
  106514. * @returns the location of the uniform.
  106515. */
  106516. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106517. /**
  106518. * Returns an array of sampler variable names
  106519. * @returns The array of sampler variable names.
  106520. */
  106521. getSamplers(): string[];
  106522. /**
  106523. * Returns an array of uniform variable names
  106524. * @returns The array of uniform variable names.
  106525. */
  106526. getUniformNames(): string[];
  106527. /**
  106528. * Returns an array of uniform buffer variable names
  106529. * @returns The array of uniform buffer variable names.
  106530. */
  106531. getUniformBuffersNames(): string[];
  106532. /**
  106533. * Returns the index parameters used to create the effect
  106534. * @returns The index parameters object
  106535. */
  106536. getIndexParameters(): any;
  106537. /**
  106538. * The error from the last compilation.
  106539. * @returns the error string.
  106540. */
  106541. getCompilationError(): string;
  106542. /**
  106543. * Gets a boolean indicating that all fallbacks were used during compilation
  106544. * @returns true if all fallbacks were used
  106545. */
  106546. allFallbacksProcessed(): boolean;
  106547. /**
  106548. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106549. * @param func The callback to be used.
  106550. */
  106551. executeWhenCompiled(func: (effect: Effect) => void): void;
  106552. private _checkIsReady;
  106553. private _loadShader;
  106554. /**
  106555. * Gets the vertex shader source code of this effect
  106556. */
  106557. get vertexSourceCode(): string;
  106558. /**
  106559. * Gets the fragment shader source code of this effect
  106560. */
  106561. get fragmentSourceCode(): string;
  106562. /**
  106563. * Recompiles the webGL program
  106564. * @param vertexSourceCode The source code for the vertex shader.
  106565. * @param fragmentSourceCode The source code for the fragment shader.
  106566. * @param onCompiled Callback called when completed.
  106567. * @param onError Callback called on error.
  106568. * @hidden
  106569. */
  106570. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106571. /**
  106572. * Prepares the effect
  106573. * @hidden
  106574. */
  106575. _prepareEffect(): void;
  106576. private _getShaderCodeAndErrorLine;
  106577. private _processCompilationErrors;
  106578. /**
  106579. * Checks if the effect is supported. (Must be called after compilation)
  106580. */
  106581. get isSupported(): boolean;
  106582. /**
  106583. * Binds a texture to the engine to be used as output of the shader.
  106584. * @param channel Name of the output variable.
  106585. * @param texture Texture to bind.
  106586. * @hidden
  106587. */
  106588. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106589. /**
  106590. * Sets a texture on the engine to be used in the shader.
  106591. * @param channel Name of the sampler variable.
  106592. * @param texture Texture to set.
  106593. */
  106594. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106595. /**
  106596. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106597. * @param channel Name of the sampler variable.
  106598. * @param texture Texture to set.
  106599. */
  106600. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106601. /**
  106602. * Sets an array of textures on the engine to be used in the shader.
  106603. * @param channel Name of the variable.
  106604. * @param textures Textures to set.
  106605. */
  106606. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106607. /**
  106608. * 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)
  106609. * @param channel Name of the sampler variable.
  106610. * @param postProcess Post process to get the input texture from.
  106611. */
  106612. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106613. /**
  106614. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106615. * 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)
  106616. * @param channel Name of the sampler variable.
  106617. * @param postProcess Post process to get the output texture from.
  106618. */
  106619. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106620. /** @hidden */
  106621. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106622. /** @hidden */
  106623. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106624. /** @hidden */
  106625. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106626. /** @hidden */
  106627. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106628. /**
  106629. * Binds a buffer to a uniform.
  106630. * @param buffer Buffer to bind.
  106631. * @param name Name of the uniform variable to bind to.
  106632. */
  106633. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106634. /**
  106635. * Binds block to a uniform.
  106636. * @param blockName Name of the block to bind.
  106637. * @param index Index to bind.
  106638. */
  106639. bindUniformBlock(blockName: string, index: number): void;
  106640. /**
  106641. * Sets an interger value on a uniform variable.
  106642. * @param uniformName Name of the variable.
  106643. * @param value Value to be set.
  106644. * @returns this effect.
  106645. */
  106646. setInt(uniformName: string, value: number): Effect;
  106647. /**
  106648. * Sets an int array on a uniform variable.
  106649. * @param uniformName Name of the variable.
  106650. * @param array array to be set.
  106651. * @returns this effect.
  106652. */
  106653. setIntArray(uniformName: string, array: Int32Array): Effect;
  106654. /**
  106655. * 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)
  106656. * @param uniformName Name of the variable.
  106657. * @param array array to be set.
  106658. * @returns this effect.
  106659. */
  106660. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106661. /**
  106662. * 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)
  106663. * @param uniformName Name of the variable.
  106664. * @param array array to be set.
  106665. * @returns this effect.
  106666. */
  106667. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106668. /**
  106669. * 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)
  106670. * @param uniformName Name of the variable.
  106671. * @param array array to be set.
  106672. * @returns this effect.
  106673. */
  106674. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106675. /**
  106676. * Sets an float array on a uniform variable.
  106677. * @param uniformName Name of the variable.
  106678. * @param array array to be set.
  106679. * @returns this effect.
  106680. */
  106681. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106682. /**
  106683. * 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)
  106684. * @param uniformName Name of the variable.
  106685. * @param array array to be set.
  106686. * @returns this effect.
  106687. */
  106688. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106689. /**
  106690. * 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)
  106691. * @param uniformName Name of the variable.
  106692. * @param array array to be set.
  106693. * @returns this effect.
  106694. */
  106695. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106696. /**
  106697. * 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)
  106698. * @param uniformName Name of the variable.
  106699. * @param array array to be set.
  106700. * @returns this effect.
  106701. */
  106702. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106703. /**
  106704. * Sets an array on a uniform variable.
  106705. * @param uniformName Name of the variable.
  106706. * @param array array to be set.
  106707. * @returns this effect.
  106708. */
  106709. setArray(uniformName: string, array: number[]): Effect;
  106710. /**
  106711. * 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)
  106712. * @param uniformName Name of the variable.
  106713. * @param array array to be set.
  106714. * @returns this effect.
  106715. */
  106716. setArray2(uniformName: string, array: number[]): Effect;
  106717. /**
  106718. * 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)
  106719. * @param uniformName Name of the variable.
  106720. * @param array array to be set.
  106721. * @returns this effect.
  106722. */
  106723. setArray3(uniformName: string, array: number[]): Effect;
  106724. /**
  106725. * 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)
  106726. * @param uniformName Name of the variable.
  106727. * @param array array to be set.
  106728. * @returns this effect.
  106729. */
  106730. setArray4(uniformName: string, array: number[]): Effect;
  106731. /**
  106732. * Sets matrices on a uniform variable.
  106733. * @param uniformName Name of the variable.
  106734. * @param matrices matrices to be set.
  106735. * @returns this effect.
  106736. */
  106737. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  106738. /**
  106739. * Sets matrix on a uniform variable.
  106740. * @param uniformName Name of the variable.
  106741. * @param matrix matrix to be set.
  106742. * @returns this effect.
  106743. */
  106744. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  106745. /**
  106746. * 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)
  106747. * @param uniformName Name of the variable.
  106748. * @param matrix matrix to be set.
  106749. * @returns this effect.
  106750. */
  106751. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  106752. /**
  106753. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  106754. * @param uniformName Name of the variable.
  106755. * @param matrix matrix to be set.
  106756. * @returns this effect.
  106757. */
  106758. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  106759. /**
  106760. * Sets a float on a uniform variable.
  106761. * @param uniformName Name of the variable.
  106762. * @param value value to be set.
  106763. * @returns this effect.
  106764. */
  106765. setFloat(uniformName: string, value: number): Effect;
  106766. /**
  106767. * Sets a boolean on a uniform variable.
  106768. * @param uniformName Name of the variable.
  106769. * @param bool value to be set.
  106770. * @returns this effect.
  106771. */
  106772. setBool(uniformName: string, bool: boolean): Effect;
  106773. /**
  106774. * Sets a Vector2 on a uniform variable.
  106775. * @param uniformName Name of the variable.
  106776. * @param vector2 vector2 to be set.
  106777. * @returns this effect.
  106778. */
  106779. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  106780. /**
  106781. * Sets a float2 on a uniform variable.
  106782. * @param uniformName Name of the variable.
  106783. * @param x First float in float2.
  106784. * @param y Second float in float2.
  106785. * @returns this effect.
  106786. */
  106787. setFloat2(uniformName: string, x: number, y: number): Effect;
  106788. /**
  106789. * Sets a Vector3 on a uniform variable.
  106790. * @param uniformName Name of the variable.
  106791. * @param vector3 Value to be set.
  106792. * @returns this effect.
  106793. */
  106794. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  106795. /**
  106796. * Sets a float3 on a uniform variable.
  106797. * @param uniformName Name of the variable.
  106798. * @param x First float in float3.
  106799. * @param y Second float in float3.
  106800. * @param z Third float in float3.
  106801. * @returns this effect.
  106802. */
  106803. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  106804. /**
  106805. * Sets a Vector4 on a uniform variable.
  106806. * @param uniformName Name of the variable.
  106807. * @param vector4 Value to be set.
  106808. * @returns this effect.
  106809. */
  106810. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  106811. /**
  106812. * Sets a float4 on a uniform variable.
  106813. * @param uniformName Name of the variable.
  106814. * @param x First float in float4.
  106815. * @param y Second float in float4.
  106816. * @param z Third float in float4.
  106817. * @param w Fourth float in float4.
  106818. * @returns this effect.
  106819. */
  106820. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  106821. /**
  106822. * Sets a Color3 on a uniform variable.
  106823. * @param uniformName Name of the variable.
  106824. * @param color3 Value to be set.
  106825. * @returns this effect.
  106826. */
  106827. setColor3(uniformName: string, color3: IColor3Like): Effect;
  106828. /**
  106829. * Sets a Color4 on a uniform variable.
  106830. * @param uniformName Name of the variable.
  106831. * @param color3 Value to be set.
  106832. * @param alpha Alpha value to be set.
  106833. * @returns this effect.
  106834. */
  106835. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  106836. /**
  106837. * Sets a Color4 on a uniform variable
  106838. * @param uniformName defines the name of the variable
  106839. * @param color4 defines the value to be set
  106840. * @returns this effect.
  106841. */
  106842. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  106843. /** Release all associated resources */
  106844. dispose(): void;
  106845. /**
  106846. * This function will add a new shader to the shader store
  106847. * @param name the name of the shader
  106848. * @param pixelShader optional pixel shader content
  106849. * @param vertexShader optional vertex shader content
  106850. */
  106851. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  106852. /**
  106853. * Store of each shader (The can be looked up using effect.key)
  106854. */
  106855. static ShadersStore: {
  106856. [key: string]: string;
  106857. };
  106858. /**
  106859. * Store of each included file for a shader (The can be looked up using effect.key)
  106860. */
  106861. static IncludesShadersStore: {
  106862. [key: string]: string;
  106863. };
  106864. /**
  106865. * Resets the cache of effects.
  106866. */
  106867. static ResetCache(): void;
  106868. }
  106869. }
  106870. declare module BABYLON {
  106871. /**
  106872. * Interface used to describe the capabilities of the engine relatively to the current browser
  106873. */
  106874. export interface EngineCapabilities {
  106875. /** Maximum textures units per fragment shader */
  106876. maxTexturesImageUnits: number;
  106877. /** Maximum texture units per vertex shader */
  106878. maxVertexTextureImageUnits: number;
  106879. /** Maximum textures units in the entire pipeline */
  106880. maxCombinedTexturesImageUnits: number;
  106881. /** Maximum texture size */
  106882. maxTextureSize: number;
  106883. /** Maximum texture samples */
  106884. maxSamples?: number;
  106885. /** Maximum cube texture size */
  106886. maxCubemapTextureSize: number;
  106887. /** Maximum render texture size */
  106888. maxRenderTextureSize: number;
  106889. /** Maximum number of vertex attributes */
  106890. maxVertexAttribs: number;
  106891. /** Maximum number of varyings */
  106892. maxVaryingVectors: number;
  106893. /** Maximum number of uniforms per vertex shader */
  106894. maxVertexUniformVectors: number;
  106895. /** Maximum number of uniforms per fragment shader */
  106896. maxFragmentUniformVectors: number;
  106897. /** Defines if standard derivates (dx/dy) are supported */
  106898. standardDerivatives: boolean;
  106899. /** Defines if s3tc texture compression is supported */
  106900. s3tc?: WEBGL_compressed_texture_s3tc;
  106901. /** Defines if pvrtc texture compression is supported */
  106902. pvrtc: any;
  106903. /** Defines if etc1 texture compression is supported */
  106904. etc1: any;
  106905. /** Defines if etc2 texture compression is supported */
  106906. etc2: any;
  106907. /** Defines if astc texture compression is supported */
  106908. astc: any;
  106909. /** Defines if float textures are supported */
  106910. textureFloat: boolean;
  106911. /** Defines if vertex array objects are supported */
  106912. vertexArrayObject: boolean;
  106913. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  106914. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  106915. /** Gets the maximum level of anisotropy supported */
  106916. maxAnisotropy: number;
  106917. /** Defines if instancing is supported */
  106918. instancedArrays: boolean;
  106919. /** Defines if 32 bits indices are supported */
  106920. uintIndices: boolean;
  106921. /** Defines if high precision shaders are supported */
  106922. highPrecisionShaderSupported: boolean;
  106923. /** Defines if depth reading in the fragment shader is supported */
  106924. fragmentDepthSupported: boolean;
  106925. /** Defines if float texture linear filtering is supported*/
  106926. textureFloatLinearFiltering: boolean;
  106927. /** Defines if rendering to float textures is supported */
  106928. textureFloatRender: boolean;
  106929. /** Defines if half float textures are supported*/
  106930. textureHalfFloat: boolean;
  106931. /** Defines if half float texture linear filtering is supported*/
  106932. textureHalfFloatLinearFiltering: boolean;
  106933. /** Defines if rendering to half float textures is supported */
  106934. textureHalfFloatRender: boolean;
  106935. /** Defines if textureLOD shader command is supported */
  106936. textureLOD: boolean;
  106937. /** Defines if draw buffers extension is supported */
  106938. drawBuffersExtension: boolean;
  106939. /** Defines if depth textures are supported */
  106940. depthTextureExtension: boolean;
  106941. /** Defines if float color buffer are supported */
  106942. colorBufferFloat: boolean;
  106943. /** Gets disjoint timer query extension (null if not supported) */
  106944. timerQuery?: EXT_disjoint_timer_query;
  106945. /** Defines if timestamp can be used with timer query */
  106946. canUseTimestampForTimerQuery: boolean;
  106947. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  106948. multiview?: any;
  106949. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  106950. oculusMultiview?: any;
  106951. /** Function used to let the system compiles shaders in background */
  106952. parallelShaderCompile?: {
  106953. COMPLETION_STATUS_KHR: number;
  106954. };
  106955. /** Max number of texture samples for MSAA */
  106956. maxMSAASamples: number;
  106957. /** Defines if the blend min max extension is supported */
  106958. blendMinMax: boolean;
  106959. }
  106960. }
  106961. declare module BABYLON {
  106962. /**
  106963. * @hidden
  106964. **/
  106965. export class DepthCullingState {
  106966. private _isDepthTestDirty;
  106967. private _isDepthMaskDirty;
  106968. private _isDepthFuncDirty;
  106969. private _isCullFaceDirty;
  106970. private _isCullDirty;
  106971. private _isZOffsetDirty;
  106972. private _isFrontFaceDirty;
  106973. private _depthTest;
  106974. private _depthMask;
  106975. private _depthFunc;
  106976. private _cull;
  106977. private _cullFace;
  106978. private _zOffset;
  106979. private _frontFace;
  106980. /**
  106981. * Initializes the state.
  106982. */
  106983. constructor();
  106984. get isDirty(): boolean;
  106985. get zOffset(): number;
  106986. set zOffset(value: number);
  106987. get cullFace(): Nullable<number>;
  106988. set cullFace(value: Nullable<number>);
  106989. get cull(): Nullable<boolean>;
  106990. set cull(value: Nullable<boolean>);
  106991. get depthFunc(): Nullable<number>;
  106992. set depthFunc(value: Nullable<number>);
  106993. get depthMask(): boolean;
  106994. set depthMask(value: boolean);
  106995. get depthTest(): boolean;
  106996. set depthTest(value: boolean);
  106997. get frontFace(): Nullable<number>;
  106998. set frontFace(value: Nullable<number>);
  106999. reset(): void;
  107000. apply(gl: WebGLRenderingContext): void;
  107001. }
  107002. }
  107003. declare module BABYLON {
  107004. /**
  107005. * @hidden
  107006. **/
  107007. export class StencilState {
  107008. /** 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 */
  107009. static readonly ALWAYS: number;
  107010. /** Passed to stencilOperation to specify that stencil value must be kept */
  107011. static readonly KEEP: number;
  107012. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107013. static readonly REPLACE: number;
  107014. private _isStencilTestDirty;
  107015. private _isStencilMaskDirty;
  107016. private _isStencilFuncDirty;
  107017. private _isStencilOpDirty;
  107018. private _stencilTest;
  107019. private _stencilMask;
  107020. private _stencilFunc;
  107021. private _stencilFuncRef;
  107022. private _stencilFuncMask;
  107023. private _stencilOpStencilFail;
  107024. private _stencilOpDepthFail;
  107025. private _stencilOpStencilDepthPass;
  107026. get isDirty(): boolean;
  107027. get stencilFunc(): number;
  107028. set stencilFunc(value: number);
  107029. get stencilFuncRef(): number;
  107030. set stencilFuncRef(value: number);
  107031. get stencilFuncMask(): number;
  107032. set stencilFuncMask(value: number);
  107033. get stencilOpStencilFail(): number;
  107034. set stencilOpStencilFail(value: number);
  107035. get stencilOpDepthFail(): number;
  107036. set stencilOpDepthFail(value: number);
  107037. get stencilOpStencilDepthPass(): number;
  107038. set stencilOpStencilDepthPass(value: number);
  107039. get stencilMask(): number;
  107040. set stencilMask(value: number);
  107041. get stencilTest(): boolean;
  107042. set stencilTest(value: boolean);
  107043. constructor();
  107044. reset(): void;
  107045. apply(gl: WebGLRenderingContext): void;
  107046. }
  107047. }
  107048. declare module BABYLON {
  107049. /**
  107050. * @hidden
  107051. **/
  107052. export class AlphaState {
  107053. private _isAlphaBlendDirty;
  107054. private _isBlendFunctionParametersDirty;
  107055. private _isBlendEquationParametersDirty;
  107056. private _isBlendConstantsDirty;
  107057. private _alphaBlend;
  107058. private _blendFunctionParameters;
  107059. private _blendEquationParameters;
  107060. private _blendConstants;
  107061. /**
  107062. * Initializes the state.
  107063. */
  107064. constructor();
  107065. get isDirty(): boolean;
  107066. get alphaBlend(): boolean;
  107067. set alphaBlend(value: boolean);
  107068. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107069. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107070. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107071. reset(): void;
  107072. apply(gl: WebGLRenderingContext): void;
  107073. }
  107074. }
  107075. declare module BABYLON {
  107076. /** @hidden */
  107077. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107078. attributeProcessor(attribute: string): string;
  107079. varyingProcessor(varying: string, isFragment: boolean): string;
  107080. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107081. }
  107082. }
  107083. declare module BABYLON {
  107084. /**
  107085. * Interface for attribute information associated with buffer instanciation
  107086. */
  107087. export interface InstancingAttributeInfo {
  107088. /**
  107089. * Name of the GLSL attribute
  107090. * if attribute index is not specified, this is used to retrieve the index from the effect
  107091. */
  107092. attributeName: string;
  107093. /**
  107094. * Index/offset of the attribute in the vertex shader
  107095. * if not specified, this will be computes from the name.
  107096. */
  107097. index?: number;
  107098. /**
  107099. * size of the attribute, 1, 2, 3 or 4
  107100. */
  107101. attributeSize: number;
  107102. /**
  107103. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107104. */
  107105. offset: number;
  107106. /**
  107107. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107108. * default to 1
  107109. */
  107110. divisor?: number;
  107111. /**
  107112. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107113. * default is FLOAT
  107114. */
  107115. attributeType?: number;
  107116. /**
  107117. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107118. */
  107119. normalized?: boolean;
  107120. }
  107121. }
  107122. declare module BABYLON {
  107123. interface ThinEngine {
  107124. /**
  107125. * Update a video texture
  107126. * @param texture defines the texture to update
  107127. * @param video defines the video element to use
  107128. * @param invertY defines if data must be stored with Y axis inverted
  107129. */
  107130. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107131. }
  107132. }
  107133. declare module BABYLON {
  107134. /**
  107135. * Settings for finer control over video usage
  107136. */
  107137. export interface VideoTextureSettings {
  107138. /**
  107139. * Applies `autoplay` to video, if specified
  107140. */
  107141. autoPlay?: boolean;
  107142. /**
  107143. * Applies `loop` to video, if specified
  107144. */
  107145. loop?: boolean;
  107146. /**
  107147. * Automatically updates internal texture from video at every frame in the render loop
  107148. */
  107149. autoUpdateTexture: boolean;
  107150. /**
  107151. * Image src displayed during the video loading or until the user interacts with the video.
  107152. */
  107153. poster?: string;
  107154. }
  107155. /**
  107156. * If you want to display a video in your scene, this is the special texture for that.
  107157. * This special texture works similar to other textures, with the exception of a few parameters.
  107158. * @see https://doc.babylonjs.com/how_to/video_texture
  107159. */
  107160. export class VideoTexture extends Texture {
  107161. /**
  107162. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107163. */
  107164. readonly autoUpdateTexture: boolean;
  107165. /**
  107166. * The video instance used by the texture internally
  107167. */
  107168. readonly video: HTMLVideoElement;
  107169. private _onUserActionRequestedObservable;
  107170. /**
  107171. * Event triggerd when a dom action is required by the user to play the video.
  107172. * This happens due to recent changes in browser policies preventing video to auto start.
  107173. */
  107174. get onUserActionRequestedObservable(): Observable<Texture>;
  107175. private _generateMipMaps;
  107176. private _engine;
  107177. private _stillImageCaptured;
  107178. private _displayingPosterTexture;
  107179. private _settings;
  107180. private _createInternalTextureOnEvent;
  107181. private _frameId;
  107182. private _currentSrc;
  107183. /**
  107184. * Creates a video texture.
  107185. * If you want to display a video in your scene, this is the special texture for that.
  107186. * This special texture works similar to other textures, with the exception of a few parameters.
  107187. * @see https://doc.babylonjs.com/how_to/video_texture
  107188. * @param name optional name, will detect from video source, if not defined
  107189. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107190. * @param scene is obviously the current scene.
  107191. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107192. * @param invertY is false by default but can be used to invert video on Y axis
  107193. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107194. * @param settings allows finer control over video usage
  107195. */
  107196. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107197. private _getName;
  107198. private _getVideo;
  107199. private _createInternalTexture;
  107200. private reset;
  107201. /**
  107202. * @hidden Internal method to initiate `update`.
  107203. */
  107204. _rebuild(): void;
  107205. /**
  107206. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107207. */
  107208. update(): void;
  107209. /**
  107210. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107211. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107212. */
  107213. updateTexture(isVisible: boolean): void;
  107214. protected _updateInternalTexture: () => void;
  107215. /**
  107216. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107217. * @param url New url.
  107218. */
  107219. updateURL(url: string): void;
  107220. /**
  107221. * Clones the texture.
  107222. * @returns the cloned texture
  107223. */
  107224. clone(): VideoTexture;
  107225. /**
  107226. * Dispose the texture and release its associated resources.
  107227. */
  107228. dispose(): void;
  107229. /**
  107230. * Creates a video texture straight from a stream.
  107231. * @param scene Define the scene the texture should be created in
  107232. * @param stream Define the stream the texture should be created from
  107233. * @returns The created video texture as a promise
  107234. */
  107235. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107236. /**
  107237. * Creates a video texture straight from your WebCam video feed.
  107238. * @param scene Define the scene the texture should be created in
  107239. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107240. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107241. * @returns The created video texture as a promise
  107242. */
  107243. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107244. minWidth: number;
  107245. maxWidth: number;
  107246. minHeight: number;
  107247. maxHeight: number;
  107248. deviceId: string;
  107249. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107250. /**
  107251. * Creates a video texture straight from your WebCam video feed.
  107252. * @param scene Define the scene the texture should be created in
  107253. * @param onReady Define a callback to triggered once the texture will be ready
  107254. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107255. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107256. */
  107257. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107258. minWidth: number;
  107259. maxWidth: number;
  107260. minHeight: number;
  107261. maxHeight: number;
  107262. deviceId: string;
  107263. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107264. }
  107265. }
  107266. declare module BABYLON {
  107267. /**
  107268. * Defines the interface used by objects working like Scene
  107269. * @hidden
  107270. */
  107271. export interface ISceneLike {
  107272. _addPendingData(data: any): void;
  107273. _removePendingData(data: any): void;
  107274. offlineProvider: IOfflineProvider;
  107275. }
  107276. /** Interface defining initialization parameters for Engine class */
  107277. export interface EngineOptions extends WebGLContextAttributes {
  107278. /**
  107279. * Defines if the engine should no exceed a specified device ratio
  107280. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107281. */
  107282. limitDeviceRatio?: number;
  107283. /**
  107284. * Defines if webvr should be enabled automatically
  107285. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107286. */
  107287. autoEnableWebVR?: boolean;
  107288. /**
  107289. * Defines if webgl2 should be turned off even if supported
  107290. * @see http://doc.babylonjs.com/features/webgl2
  107291. */
  107292. disableWebGL2Support?: boolean;
  107293. /**
  107294. * Defines if webaudio should be initialized as well
  107295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107296. */
  107297. audioEngine?: boolean;
  107298. /**
  107299. * Defines if animations should run using a deterministic lock step
  107300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107301. */
  107302. deterministicLockstep?: boolean;
  107303. /** Defines the maximum steps to use with deterministic lock step mode */
  107304. lockstepMaxSteps?: number;
  107305. /** Defines the seconds between each deterministic lock step */
  107306. timeStep?: number;
  107307. /**
  107308. * Defines that engine should ignore context lost events
  107309. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107310. */
  107311. doNotHandleContextLost?: boolean;
  107312. /**
  107313. * Defines that engine should ignore modifying touch action attribute and style
  107314. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107315. */
  107316. doNotHandleTouchAction?: boolean;
  107317. /**
  107318. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107319. */
  107320. useHighPrecisionFloats?: boolean;
  107321. }
  107322. /**
  107323. * The base engine class (root of all engines)
  107324. */
  107325. export class ThinEngine {
  107326. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107327. static ExceptionList: ({
  107328. key: string;
  107329. capture: string;
  107330. captureConstraint: number;
  107331. targets: string[];
  107332. } | {
  107333. key: string;
  107334. capture: null;
  107335. captureConstraint: null;
  107336. targets: string[];
  107337. })[];
  107338. /** @hidden */
  107339. static _TextureLoaders: IInternalTextureLoader[];
  107340. /**
  107341. * Returns the current npm package of the sdk
  107342. */
  107343. static get NpmPackage(): string;
  107344. /**
  107345. * Returns the current version of the framework
  107346. */
  107347. static get Version(): string;
  107348. /**
  107349. * Returns a string describing the current engine
  107350. */
  107351. get description(): string;
  107352. /**
  107353. * Gets or sets the epsilon value used by collision engine
  107354. */
  107355. static CollisionsEpsilon: number;
  107356. /**
  107357. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107358. */
  107359. static get ShadersRepository(): string;
  107360. static set ShadersRepository(value: string);
  107361. /** @hidden */
  107362. _shaderProcessor: IShaderProcessor;
  107363. /**
  107364. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107365. */
  107366. forcePOTTextures: boolean;
  107367. /**
  107368. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107369. */
  107370. isFullscreen: boolean;
  107371. /**
  107372. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107373. */
  107374. cullBackFaces: boolean;
  107375. /**
  107376. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107377. */
  107378. renderEvenInBackground: boolean;
  107379. /**
  107380. * Gets or sets a boolean indicating that cache can be kept between frames
  107381. */
  107382. preventCacheWipeBetweenFrames: boolean;
  107383. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107384. validateShaderPrograms: boolean;
  107385. /**
  107386. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107387. * This can provide greater z depth for distant objects.
  107388. */
  107389. useReverseDepthBuffer: boolean;
  107390. /**
  107391. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107392. */
  107393. disableUniformBuffers: boolean;
  107394. /** @hidden */
  107395. _uniformBuffers: UniformBuffer[];
  107396. /**
  107397. * Gets a boolean indicating that the engine supports uniform buffers
  107398. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107399. */
  107400. get supportsUniformBuffers(): boolean;
  107401. /** @hidden */
  107402. _gl: WebGLRenderingContext;
  107403. /** @hidden */
  107404. _webGLVersion: number;
  107405. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107406. protected _windowIsBackground: boolean;
  107407. protected _creationOptions: EngineOptions;
  107408. protected _highPrecisionShadersAllowed: boolean;
  107409. /** @hidden */
  107410. get _shouldUseHighPrecisionShader(): boolean;
  107411. /**
  107412. * Gets a boolean indicating that only power of 2 textures are supported
  107413. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107414. */
  107415. get needPOTTextures(): boolean;
  107416. /** @hidden */
  107417. _badOS: boolean;
  107418. /** @hidden */
  107419. _badDesktopOS: boolean;
  107420. private _hardwareScalingLevel;
  107421. /** @hidden */
  107422. _caps: EngineCapabilities;
  107423. private _isStencilEnable;
  107424. private _glVersion;
  107425. private _glRenderer;
  107426. private _glVendor;
  107427. /** @hidden */
  107428. _videoTextureSupported: boolean;
  107429. protected _renderingQueueLaunched: boolean;
  107430. protected _activeRenderLoops: (() => void)[];
  107431. /**
  107432. * Observable signaled when a context lost event is raised
  107433. */
  107434. onContextLostObservable: Observable<ThinEngine>;
  107435. /**
  107436. * Observable signaled when a context restored event is raised
  107437. */
  107438. onContextRestoredObservable: Observable<ThinEngine>;
  107439. private _onContextLost;
  107440. private _onContextRestored;
  107441. protected _contextWasLost: boolean;
  107442. /** @hidden */
  107443. _doNotHandleContextLost: boolean;
  107444. /**
  107445. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107447. */
  107448. get doNotHandleContextLost(): boolean;
  107449. set doNotHandleContextLost(value: boolean);
  107450. /**
  107451. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107452. */
  107453. disableVertexArrayObjects: boolean;
  107454. /** @hidden */
  107455. protected _colorWrite: boolean;
  107456. /** @hidden */
  107457. protected _colorWriteChanged: boolean;
  107458. /** @hidden */
  107459. protected _depthCullingState: DepthCullingState;
  107460. /** @hidden */
  107461. protected _stencilState: StencilState;
  107462. /** @hidden */
  107463. _alphaState: AlphaState;
  107464. /** @hidden */
  107465. _alphaMode: number;
  107466. /** @hidden */
  107467. _alphaEquation: number;
  107468. /** @hidden */
  107469. _internalTexturesCache: InternalTexture[];
  107470. /** @hidden */
  107471. protected _activeChannel: number;
  107472. private _currentTextureChannel;
  107473. /** @hidden */
  107474. protected _boundTexturesCache: {
  107475. [key: string]: Nullable<InternalTexture>;
  107476. };
  107477. /** @hidden */
  107478. protected _currentEffect: Nullable<Effect>;
  107479. /** @hidden */
  107480. protected _currentProgram: Nullable<WebGLProgram>;
  107481. private _compiledEffects;
  107482. private _vertexAttribArraysEnabled;
  107483. /** @hidden */
  107484. protected _cachedViewport: Nullable<IViewportLike>;
  107485. private _cachedVertexArrayObject;
  107486. /** @hidden */
  107487. protected _cachedVertexBuffers: any;
  107488. /** @hidden */
  107489. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107490. /** @hidden */
  107491. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107492. /** @hidden */
  107493. _currentRenderTarget: Nullable<InternalTexture>;
  107494. private _uintIndicesCurrentlySet;
  107495. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107496. /** @hidden */
  107497. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107498. private _currentBufferPointers;
  107499. private _currentInstanceLocations;
  107500. private _currentInstanceBuffers;
  107501. private _textureUnits;
  107502. /** @hidden */
  107503. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107504. /** @hidden */
  107505. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107506. /** @hidden */
  107507. _boundRenderFunction: any;
  107508. private _vaoRecordInProgress;
  107509. private _mustWipeVertexAttributes;
  107510. private _emptyTexture;
  107511. private _emptyCubeTexture;
  107512. private _emptyTexture3D;
  107513. private _emptyTexture2DArray;
  107514. /** @hidden */
  107515. _frameHandler: number;
  107516. private _nextFreeTextureSlots;
  107517. private _maxSimultaneousTextures;
  107518. private _activeRequests;
  107519. /** @hidden */
  107520. _transformTextureUrl: Nullable<(url: string) => string>;
  107521. protected get _supportsHardwareTextureRescaling(): boolean;
  107522. private _framebufferDimensionsObject;
  107523. /**
  107524. * sets the object from which width and height will be taken from when getting render width and height
  107525. * Will fallback to the gl object
  107526. * @param dimensions the framebuffer width and height that will be used.
  107527. */
  107528. set framebufferDimensionsObject(dimensions: Nullable<{
  107529. framebufferWidth: number;
  107530. framebufferHeight: number;
  107531. }>);
  107532. /**
  107533. * Gets the current viewport
  107534. */
  107535. get currentViewport(): Nullable<IViewportLike>;
  107536. /**
  107537. * Gets the default empty texture
  107538. */
  107539. get emptyTexture(): InternalTexture;
  107540. /**
  107541. * Gets the default empty 3D texture
  107542. */
  107543. get emptyTexture3D(): InternalTexture;
  107544. /**
  107545. * Gets the default empty 2D array texture
  107546. */
  107547. get emptyTexture2DArray(): InternalTexture;
  107548. /**
  107549. * Gets the default empty cube texture
  107550. */
  107551. get emptyCubeTexture(): InternalTexture;
  107552. /**
  107553. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107554. */
  107555. readonly premultipliedAlpha: boolean;
  107556. /**
  107557. * Observable event triggered before each texture is initialized
  107558. */
  107559. onBeforeTextureInitObservable: Observable<Texture>;
  107560. /**
  107561. * Creates a new engine
  107562. * @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
  107563. * @param antialias defines enable antialiasing (default: false)
  107564. * @param options defines further options to be sent to the getContext() function
  107565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107566. */
  107567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107568. private _rebuildInternalTextures;
  107569. private _rebuildEffects;
  107570. /**
  107571. * Gets a boolean indicating if all created effects are ready
  107572. * @returns true if all effects are ready
  107573. */
  107574. areAllEffectsReady(): boolean;
  107575. protected _rebuildBuffers(): void;
  107576. protected _initGLContext(): void;
  107577. /**
  107578. * Gets version of the current webGL context
  107579. */
  107580. get webGLVersion(): number;
  107581. /**
  107582. * Gets a string idenfifying the name of the class
  107583. * @returns "Engine" string
  107584. */
  107585. getClassName(): string;
  107586. /**
  107587. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107588. */
  107589. get isStencilEnable(): boolean;
  107590. /** @hidden */
  107591. _prepareWorkingCanvas(): void;
  107592. /**
  107593. * Reset the texture cache to empty state
  107594. */
  107595. resetTextureCache(): void;
  107596. /**
  107597. * Gets an object containing information about the current webGL context
  107598. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107599. */
  107600. getGlInfo(): {
  107601. vendor: string;
  107602. renderer: string;
  107603. version: string;
  107604. };
  107605. /**
  107606. * Defines the hardware scaling level.
  107607. * By default the hardware scaling level is computed from the window device ratio.
  107608. * 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.
  107609. * @param level defines the level to use
  107610. */
  107611. setHardwareScalingLevel(level: number): void;
  107612. /**
  107613. * Gets the current hardware scaling level.
  107614. * By default the hardware scaling level is computed from the window device ratio.
  107615. * 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.
  107616. * @returns a number indicating the current hardware scaling level
  107617. */
  107618. getHardwareScalingLevel(): number;
  107619. /**
  107620. * Gets the list of loaded textures
  107621. * @returns an array containing all loaded textures
  107622. */
  107623. getLoadedTexturesCache(): InternalTexture[];
  107624. /**
  107625. * Gets the object containing all engine capabilities
  107626. * @returns the EngineCapabilities object
  107627. */
  107628. getCaps(): EngineCapabilities;
  107629. /**
  107630. * stop executing a render loop function and remove it from the execution array
  107631. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107632. */
  107633. stopRenderLoop(renderFunction?: () => void): void;
  107634. /** @hidden */
  107635. _renderLoop(): void;
  107636. /**
  107637. * Gets the HTML canvas attached with the current webGL context
  107638. * @returns a HTML canvas
  107639. */
  107640. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107641. /**
  107642. * Gets host window
  107643. * @returns the host window object
  107644. */
  107645. getHostWindow(): Nullable<Window>;
  107646. /**
  107647. * Gets the current render width
  107648. * @param useScreen defines if screen size must be used (or the current render target if any)
  107649. * @returns a number defining the current render width
  107650. */
  107651. getRenderWidth(useScreen?: boolean): number;
  107652. /**
  107653. * Gets the current render height
  107654. * @param useScreen defines if screen size must be used (or the current render target if any)
  107655. * @returns a number defining the current render height
  107656. */
  107657. getRenderHeight(useScreen?: boolean): number;
  107658. /**
  107659. * Can be used to override the current requestAnimationFrame requester.
  107660. * @hidden
  107661. */
  107662. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107663. /**
  107664. * Register and execute a render loop. The engine can have more than one render function
  107665. * @param renderFunction defines the function to continuously execute
  107666. */
  107667. runRenderLoop(renderFunction: () => void): void;
  107668. /**
  107669. * Clear the current render buffer or the current render target (if any is set up)
  107670. * @param color defines the color to use
  107671. * @param backBuffer defines if the back buffer must be cleared
  107672. * @param depth defines if the depth buffer must be cleared
  107673. * @param stencil defines if the stencil buffer must be cleared
  107674. */
  107675. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107676. private _viewportCached;
  107677. /** @hidden */
  107678. _viewport(x: number, y: number, width: number, height: number): void;
  107679. /**
  107680. * Set the WebGL's viewport
  107681. * @param viewport defines the viewport element to be used
  107682. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107683. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107684. */
  107685. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107686. /**
  107687. * Begin a new frame
  107688. */
  107689. beginFrame(): void;
  107690. /**
  107691. * Enf the current frame
  107692. */
  107693. endFrame(): void;
  107694. /**
  107695. * Resize the view according to the canvas' size
  107696. */
  107697. resize(): void;
  107698. /**
  107699. * Force a specific size of the canvas
  107700. * @param width defines the new canvas' width
  107701. * @param height defines the new canvas' height
  107702. */
  107703. setSize(width: number, height: number): void;
  107704. /**
  107705. * Binds the frame buffer to the specified texture.
  107706. * @param texture The texture to render to or null for the default canvas
  107707. * @param faceIndex The face of the texture to render to in case of cube texture
  107708. * @param requiredWidth The width of the target to render to
  107709. * @param requiredHeight The height of the target to render to
  107710. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107711. * @param lodLevel defines the lod level to bind to the frame buffer
  107712. * @param layer defines the 2d array index to bind to frame buffer to
  107713. */
  107714. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107715. /** @hidden */
  107716. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107717. /**
  107718. * Unbind the current render target texture from the webGL context
  107719. * @param texture defines the render target texture to unbind
  107720. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107721. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107722. */
  107723. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107724. /**
  107725. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107726. */
  107727. flushFramebuffer(): void;
  107728. /**
  107729. * Unbind the current render target and bind the default framebuffer
  107730. */
  107731. restoreDefaultFramebuffer(): void;
  107732. /** @hidden */
  107733. protected _resetVertexBufferBinding(): void;
  107734. /**
  107735. * Creates a vertex buffer
  107736. * @param data the data for the vertex buffer
  107737. * @returns the new WebGL static buffer
  107738. */
  107739. createVertexBuffer(data: DataArray): DataBuffer;
  107740. private _createVertexBuffer;
  107741. /**
  107742. * Creates a dynamic vertex buffer
  107743. * @param data the data for the dynamic vertex buffer
  107744. * @returns the new WebGL dynamic buffer
  107745. */
  107746. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  107747. protected _resetIndexBufferBinding(): void;
  107748. /**
  107749. * Creates a new index buffer
  107750. * @param indices defines the content of the index buffer
  107751. * @param updatable defines if the index buffer must be updatable
  107752. * @returns a new webGL buffer
  107753. */
  107754. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  107755. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  107756. /**
  107757. * Bind a webGL buffer to the webGL context
  107758. * @param buffer defines the buffer to bind
  107759. */
  107760. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  107761. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  107762. private bindBuffer;
  107763. /**
  107764. * update the bound buffer with the given data
  107765. * @param data defines the data to update
  107766. */
  107767. updateArrayBuffer(data: Float32Array): void;
  107768. private _vertexAttribPointer;
  107769. /** @hidden */
  107770. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  107771. private _bindVertexBuffersAttributes;
  107772. /**
  107773. * Records a vertex array object
  107774. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107775. * @param vertexBuffers defines the list of vertex buffers to store
  107776. * @param indexBuffer defines the index buffer to store
  107777. * @param effect defines the effect to store
  107778. * @returns the new vertex array object
  107779. */
  107780. recordVertexArrayObject(vertexBuffers: {
  107781. [key: string]: VertexBuffer;
  107782. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  107783. /**
  107784. * Bind a specific vertex array object
  107785. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107786. * @param vertexArrayObject defines the vertex array object to bind
  107787. * @param indexBuffer defines the index buffer to bind
  107788. */
  107789. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  107790. /**
  107791. * Bind webGl buffers directly to the webGL context
  107792. * @param vertexBuffer defines the vertex buffer to bind
  107793. * @param indexBuffer defines the index buffer to bind
  107794. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  107795. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  107796. * @param effect defines the effect associated with the vertex buffer
  107797. */
  107798. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  107799. private _unbindVertexArrayObject;
  107800. /**
  107801. * Bind a list of vertex buffers to the webGL context
  107802. * @param vertexBuffers defines the list of vertex buffers to bind
  107803. * @param indexBuffer defines the index buffer to bind
  107804. * @param effect defines the effect associated with the vertex buffers
  107805. */
  107806. bindBuffers(vertexBuffers: {
  107807. [key: string]: Nullable<VertexBuffer>;
  107808. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  107809. /**
  107810. * Unbind all instance attributes
  107811. */
  107812. unbindInstanceAttributes(): void;
  107813. /**
  107814. * Release and free the memory of a vertex array object
  107815. * @param vao defines the vertex array object to delete
  107816. */
  107817. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  107818. /** @hidden */
  107819. _releaseBuffer(buffer: DataBuffer): boolean;
  107820. protected _deleteBuffer(buffer: DataBuffer): void;
  107821. /**
  107822. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  107823. * @param instancesBuffer defines the webGL buffer to update and bind
  107824. * @param data defines the data to store in the buffer
  107825. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  107826. */
  107827. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  107828. /**
  107829. * Bind the content of a webGL buffer used with instantiation
  107830. * @param instancesBuffer defines the webGL buffer to bind
  107831. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  107832. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  107833. */
  107834. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  107835. /**
  107836. * Disable the instance attribute corresponding to the name in parameter
  107837. * @param name defines the name of the attribute to disable
  107838. */
  107839. disableInstanceAttributeByName(name: string): void;
  107840. /**
  107841. * Disable the instance attribute corresponding to the location in parameter
  107842. * @param attributeLocation defines the attribute location of the attribute to disable
  107843. */
  107844. disableInstanceAttribute(attributeLocation: number): void;
  107845. /**
  107846. * Disable the attribute corresponding to the location in parameter
  107847. * @param attributeLocation defines the attribute location of the attribute to disable
  107848. */
  107849. disableAttributeByIndex(attributeLocation: number): void;
  107850. /**
  107851. * Send a draw order
  107852. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107853. * @param indexStart defines the starting index
  107854. * @param indexCount defines the number of index to draw
  107855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107856. */
  107857. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107858. /**
  107859. * Draw a list of points
  107860. * @param verticesStart defines the index of first vertex to draw
  107861. * @param verticesCount defines the count of vertices to draw
  107862. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107863. */
  107864. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107865. /**
  107866. * Draw a list of unindexed primitives
  107867. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107868. * @param verticesStart defines the index of first vertex to draw
  107869. * @param verticesCount defines the count of vertices to draw
  107870. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107871. */
  107872. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107873. /**
  107874. * Draw a list of indexed primitives
  107875. * @param fillMode defines the primitive to use
  107876. * @param indexStart defines the starting index
  107877. * @param indexCount defines the number of index to draw
  107878. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107879. */
  107880. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107881. /**
  107882. * Draw a list of unindexed primitives
  107883. * @param fillMode defines the primitive to use
  107884. * @param verticesStart defines the index of first vertex to draw
  107885. * @param verticesCount defines the count of vertices to draw
  107886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107887. */
  107888. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107889. private _drawMode;
  107890. /** @hidden */
  107891. protected _reportDrawCall(): void;
  107892. /** @hidden */
  107893. _releaseEffect(effect: Effect): void;
  107894. /** @hidden */
  107895. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107896. /**
  107897. * Create a new effect (used to store vertex/fragment shaders)
  107898. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  107899. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  107900. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  107901. * @param samplers defines an array of string used to represent textures
  107902. * @param defines defines the string containing the defines to use to compile the shaders
  107903. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107904. * @param onCompiled defines a function to call when the effect creation is successful
  107905. * @param onError defines a function to call when the effect creation has failed
  107906. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  107907. * @returns the new Effect
  107908. */
  107909. 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;
  107910. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  107911. private _compileShader;
  107912. private _compileRawShader;
  107913. /** @hidden */
  107914. _getShaderSource(shader: WebGLShader): Nullable<string>;
  107915. /**
  107916. * Directly creates a webGL program
  107917. * @param pipelineContext defines the pipeline context to attach to
  107918. * @param vertexCode defines the vertex shader code to use
  107919. * @param fragmentCode defines the fragment shader code to use
  107920. * @param context defines the webGL context to use (if not set, the current one will be used)
  107921. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107922. * @returns the new webGL program
  107923. */
  107924. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107925. /**
  107926. * Creates a webGL program
  107927. * @param pipelineContext defines the pipeline context to attach to
  107928. * @param vertexCode defines the vertex shader code to use
  107929. * @param fragmentCode defines the fragment shader code to use
  107930. * @param defines defines the string containing the defines to use to compile the shaders
  107931. * @param context defines the webGL context to use (if not set, the current one will be used)
  107932. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107933. * @returns the new webGL program
  107934. */
  107935. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107936. /**
  107937. * Creates a new pipeline context
  107938. * @returns the new pipeline
  107939. */
  107940. createPipelineContext(): IPipelineContext;
  107941. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107942. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  107943. /** @hidden */
  107944. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  107945. /** @hidden */
  107946. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  107947. /** @hidden */
  107948. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  107949. /**
  107950. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  107951. * @param pipelineContext defines the pipeline context to use
  107952. * @param uniformsNames defines the list of uniform names
  107953. * @returns an array of webGL uniform locations
  107954. */
  107955. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107956. /**
  107957. * Gets the lsit of active attributes for a given webGL program
  107958. * @param pipelineContext defines the pipeline context to use
  107959. * @param attributesNames defines the list of attribute names to get
  107960. * @returns an array of indices indicating the offset of each attribute
  107961. */
  107962. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107963. /**
  107964. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  107965. * @param effect defines the effect to activate
  107966. */
  107967. enableEffect(effect: Nullable<Effect>): void;
  107968. /**
  107969. * Set the value of an uniform to a number (int)
  107970. * @param uniform defines the webGL uniform location where to store the value
  107971. * @param value defines the int number to store
  107972. */
  107973. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  107974. /**
  107975. * Set the value of an uniform to an array of int32
  107976. * @param uniform defines the webGL uniform location where to store the value
  107977. * @param array defines the array of int32 to store
  107978. */
  107979. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107980. /**
  107981. * Set the value of an uniform to an array of int32 (stored as vec2)
  107982. * @param uniform defines the webGL uniform location where to store the value
  107983. * @param array defines the array of int32 to store
  107984. */
  107985. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107986. /**
  107987. * Set the value of an uniform to an array of int32 (stored as vec3)
  107988. * @param uniform defines the webGL uniform location where to store the value
  107989. * @param array defines the array of int32 to store
  107990. */
  107991. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107992. /**
  107993. * Set the value of an uniform to an array of int32 (stored as vec4)
  107994. * @param uniform defines the webGL uniform location where to store the value
  107995. * @param array defines the array of int32 to store
  107996. */
  107997. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107998. /**
  107999. * Set the value of an uniform to an array of number
  108000. * @param uniform defines the webGL uniform location where to store the value
  108001. * @param array defines the array of number to store
  108002. */
  108003. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108004. /**
  108005. * Set the value of an uniform to an array of number (stored as vec2)
  108006. * @param uniform defines the webGL uniform location where to store the value
  108007. * @param array defines the array of number to store
  108008. */
  108009. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108010. /**
  108011. * Set the value of an uniform to an array of number (stored as vec3)
  108012. * @param uniform defines the webGL uniform location where to store the value
  108013. * @param array defines the array of number to store
  108014. */
  108015. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108016. /**
  108017. * Set the value of an uniform to an array of number (stored as vec4)
  108018. * @param uniform defines the webGL uniform location where to store the value
  108019. * @param array defines the array of number to store
  108020. */
  108021. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108022. /**
  108023. * Set the value of an uniform to an array of float32 (stored as matrices)
  108024. * @param uniform defines the webGL uniform location where to store the value
  108025. * @param matrices defines the array of float32 to store
  108026. */
  108027. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108028. /**
  108029. * Set the value of an uniform to a matrix (3x3)
  108030. * @param uniform defines the webGL uniform location where to store the value
  108031. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108032. */
  108033. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108034. /**
  108035. * Set the value of an uniform to a matrix (2x2)
  108036. * @param uniform defines the webGL uniform location where to store the value
  108037. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108038. */
  108039. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108040. /**
  108041. * Set the value of an uniform to a number (float)
  108042. * @param uniform defines the webGL uniform location where to store the value
  108043. * @param value defines the float number to store
  108044. */
  108045. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108046. /**
  108047. * Set the value of an uniform to a vec2
  108048. * @param uniform defines the webGL uniform location where to store the value
  108049. * @param x defines the 1st component of the value
  108050. * @param y defines the 2nd component of the value
  108051. */
  108052. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108053. /**
  108054. * Set the value of an uniform to a vec3
  108055. * @param uniform defines the webGL uniform location where to store the value
  108056. * @param x defines the 1st component of the value
  108057. * @param y defines the 2nd component of the value
  108058. * @param z defines the 3rd component of the value
  108059. */
  108060. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108061. /**
  108062. * Set the value of an uniform to a vec4
  108063. * @param uniform defines the webGL uniform location where to store the value
  108064. * @param x defines the 1st component of the value
  108065. * @param y defines the 2nd component of the value
  108066. * @param z defines the 3rd component of the value
  108067. * @param w defines the 4th component of the value
  108068. */
  108069. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108070. /**
  108071. * Apply all cached states (depth, culling, stencil and alpha)
  108072. */
  108073. applyStates(): void;
  108074. /**
  108075. * Enable or disable color writing
  108076. * @param enable defines the state to set
  108077. */
  108078. setColorWrite(enable: boolean): void;
  108079. /**
  108080. * Gets a boolean indicating if color writing is enabled
  108081. * @returns the current color writing state
  108082. */
  108083. getColorWrite(): boolean;
  108084. /**
  108085. * Gets the depth culling state manager
  108086. */
  108087. get depthCullingState(): DepthCullingState;
  108088. /**
  108089. * Gets the alpha state manager
  108090. */
  108091. get alphaState(): AlphaState;
  108092. /**
  108093. * Gets the stencil state manager
  108094. */
  108095. get stencilState(): StencilState;
  108096. /**
  108097. * Clears the list of texture accessible through engine.
  108098. * This can help preventing texture load conflict due to name collision.
  108099. */
  108100. clearInternalTexturesCache(): void;
  108101. /**
  108102. * Force the entire cache to be cleared
  108103. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108104. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108105. */
  108106. wipeCaches(bruteForce?: boolean): void;
  108107. /** @hidden */
  108108. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108109. min: number;
  108110. mag: number;
  108111. };
  108112. /** @hidden */
  108113. _createTexture(): WebGLTexture;
  108114. /**
  108115. * Usually called from Texture.ts.
  108116. * Passed information to create a WebGLTexture
  108117. * @param url defines a value which contains one of the following:
  108118. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108119. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108120. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108121. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108122. * @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)
  108123. * @param scene needed for loading to the correct scene
  108124. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108125. * @param onLoad optional callback to be called upon successful completion
  108126. * @param onError optional callback to be called upon failure
  108127. * @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
  108128. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108129. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108130. * @param forcedExtension defines the extension to use to pick the right loader
  108131. * @param mimeType defines an optional mime type
  108132. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108133. */
  108134. 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;
  108135. /**
  108136. * Loads an image as an HTMLImageElement.
  108137. * @param input url string, ArrayBuffer, or Blob to load
  108138. * @param onLoad callback called when the image successfully loads
  108139. * @param onError callback called when the image fails to load
  108140. * @param offlineProvider offline provider for caching
  108141. * @param mimeType optional mime type
  108142. * @returns the HTMLImageElement of the loaded image
  108143. * @hidden
  108144. */
  108145. 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>;
  108146. /**
  108147. * @hidden
  108148. */
  108149. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108150. private _unpackFlipYCached;
  108151. /**
  108152. * In case you are sharing the context with other applications, it might
  108153. * be interested to not cache the unpack flip y state to ensure a consistent
  108154. * value would be set.
  108155. */
  108156. enableUnpackFlipYCached: boolean;
  108157. /** @hidden */
  108158. _unpackFlipY(value: boolean): void;
  108159. /** @hidden */
  108160. _getUnpackAlignement(): number;
  108161. private _getTextureTarget;
  108162. /**
  108163. * Update the sampling mode of a given texture
  108164. * @param samplingMode defines the required sampling mode
  108165. * @param texture defines the texture to update
  108166. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108167. */
  108168. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108169. /**
  108170. * Update the sampling mode of a given texture
  108171. * @param texture defines the texture to update
  108172. * @param wrapU defines the texture wrap mode of the u coordinates
  108173. * @param wrapV defines the texture wrap mode of the v coordinates
  108174. * @param wrapR defines the texture wrap mode of the r coordinates
  108175. */
  108176. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108177. /** @hidden */
  108178. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108179. width: number;
  108180. height: number;
  108181. layers?: number;
  108182. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108183. /** @hidden */
  108184. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108185. /** @hidden */
  108186. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108187. /**
  108188. * Update a portion of an internal texture
  108189. * @param texture defines the texture to update
  108190. * @param imageData defines the data to store into the texture
  108191. * @param xOffset defines the x coordinates of the update rectangle
  108192. * @param yOffset defines the y coordinates of the update rectangle
  108193. * @param width defines the width of the update rectangle
  108194. * @param height defines the height of the update rectangle
  108195. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108196. * @param lod defines the lod level to update (0 by default)
  108197. */
  108198. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108199. /** @hidden */
  108200. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108201. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108202. private _prepareWebGLTexture;
  108203. /** @hidden */
  108204. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108205. private _getDepthStencilBuffer;
  108206. /** @hidden */
  108207. _releaseFramebufferObjects(texture: InternalTexture): void;
  108208. /** @hidden */
  108209. _releaseTexture(texture: InternalTexture): void;
  108210. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108211. protected _setProgram(program: WebGLProgram): void;
  108212. protected _boundUniforms: {
  108213. [key: number]: WebGLUniformLocation;
  108214. };
  108215. /**
  108216. * Binds an effect to the webGL context
  108217. * @param effect defines the effect to bind
  108218. */
  108219. bindSamplers(effect: Effect): void;
  108220. private _activateCurrentTexture;
  108221. /** @hidden */
  108222. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108223. /** @hidden */
  108224. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108225. /**
  108226. * Unbind all textures from the webGL context
  108227. */
  108228. unbindAllTextures(): void;
  108229. /**
  108230. * Sets a texture to the according uniform.
  108231. * @param channel The texture channel
  108232. * @param uniform The uniform to set
  108233. * @param texture The texture to apply
  108234. */
  108235. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108236. private _bindSamplerUniformToChannel;
  108237. private _getTextureWrapMode;
  108238. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108239. /**
  108240. * Sets an array of texture to the webGL context
  108241. * @param channel defines the channel where the texture array must be set
  108242. * @param uniform defines the associated uniform location
  108243. * @param textures defines the array of textures to bind
  108244. */
  108245. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108246. /** @hidden */
  108247. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108248. private _setTextureParameterFloat;
  108249. private _setTextureParameterInteger;
  108250. /**
  108251. * Unbind all vertex attributes from the webGL context
  108252. */
  108253. unbindAllAttributes(): void;
  108254. /**
  108255. * 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
  108256. */
  108257. releaseEffects(): void;
  108258. /**
  108259. * Dispose and release all associated resources
  108260. */
  108261. dispose(): void;
  108262. /**
  108263. * Attach a new callback raised when context lost event is fired
  108264. * @param callback defines the callback to call
  108265. */
  108266. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108267. /**
  108268. * Attach a new callback raised when context restored event is fired
  108269. * @param callback defines the callback to call
  108270. */
  108271. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108272. /**
  108273. * Get the current error code of the webGL context
  108274. * @returns the error code
  108275. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108276. */
  108277. getError(): number;
  108278. private _canRenderToFloatFramebuffer;
  108279. private _canRenderToHalfFloatFramebuffer;
  108280. private _canRenderToFramebuffer;
  108281. /** @hidden */
  108282. _getWebGLTextureType(type: number): number;
  108283. /** @hidden */
  108284. _getInternalFormat(format: number): number;
  108285. /** @hidden */
  108286. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108287. /** @hidden */
  108288. _getRGBAMultiSampleBufferFormat(type: number): number;
  108289. /** @hidden */
  108290. _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;
  108291. /**
  108292. * Loads a file from a url
  108293. * @param url url to load
  108294. * @param onSuccess callback called when the file successfully loads
  108295. * @param onProgress callback called while file is loading (if the server supports this mode)
  108296. * @param offlineProvider defines the offline provider for caching
  108297. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108298. * @param onError callback called when the file fails to load
  108299. * @returns a file request object
  108300. * @hidden
  108301. */
  108302. 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;
  108303. /**
  108304. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108305. * @param x defines the x coordinate of the rectangle where pixels must be read
  108306. * @param y defines the y coordinate of the rectangle where pixels must be read
  108307. * @param width defines the width of the rectangle where pixels must be read
  108308. * @param height defines the height of the rectangle where pixels must be read
  108309. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108310. * @returns a Uint8Array containing RGBA colors
  108311. */
  108312. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108313. private static _isSupported;
  108314. /**
  108315. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108316. * @returns true if the engine can be created
  108317. * @ignorenaming
  108318. */
  108319. static isSupported(): boolean;
  108320. /**
  108321. * Find the next highest power of two.
  108322. * @param x Number to start search from.
  108323. * @return Next highest power of two.
  108324. */
  108325. static CeilingPOT(x: number): number;
  108326. /**
  108327. * Find the next lowest power of two.
  108328. * @param x Number to start search from.
  108329. * @return Next lowest power of two.
  108330. */
  108331. static FloorPOT(x: number): number;
  108332. /**
  108333. * Find the nearest power of two.
  108334. * @param x Number to start search from.
  108335. * @return Next nearest power of two.
  108336. */
  108337. static NearestPOT(x: number): number;
  108338. /**
  108339. * Get the closest exponent of two
  108340. * @param value defines the value to approximate
  108341. * @param max defines the maximum value to return
  108342. * @param mode defines how to define the closest value
  108343. * @returns closest exponent of two of the given value
  108344. */
  108345. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108346. /**
  108347. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108348. * @param func - the function to be called
  108349. * @param requester - the object that will request the next frame. Falls back to window.
  108350. * @returns frame number
  108351. */
  108352. static QueueNewFrame(func: () => void, requester?: any): number;
  108353. /**
  108354. * Gets host document
  108355. * @returns the host document object
  108356. */
  108357. getHostDocument(): Nullable<Document>;
  108358. }
  108359. }
  108360. declare module BABYLON {
  108361. /**
  108362. * Class representing spherical harmonics coefficients to the 3rd degree
  108363. */
  108364. export class SphericalHarmonics {
  108365. /**
  108366. * Defines whether or not the harmonics have been prescaled for rendering.
  108367. */
  108368. preScaled: boolean;
  108369. /**
  108370. * The l0,0 coefficients of the spherical harmonics
  108371. */
  108372. l00: Vector3;
  108373. /**
  108374. * The l1,-1 coefficients of the spherical harmonics
  108375. */
  108376. l1_1: Vector3;
  108377. /**
  108378. * The l1,0 coefficients of the spherical harmonics
  108379. */
  108380. l10: Vector3;
  108381. /**
  108382. * The l1,1 coefficients of the spherical harmonics
  108383. */
  108384. l11: Vector3;
  108385. /**
  108386. * The l2,-2 coefficients of the spherical harmonics
  108387. */
  108388. l2_2: Vector3;
  108389. /**
  108390. * The l2,-1 coefficients of the spherical harmonics
  108391. */
  108392. l2_1: Vector3;
  108393. /**
  108394. * The l2,0 coefficients of the spherical harmonics
  108395. */
  108396. l20: Vector3;
  108397. /**
  108398. * The l2,1 coefficients of the spherical harmonics
  108399. */
  108400. l21: Vector3;
  108401. /**
  108402. * The l2,2 coefficients of the spherical harmonics
  108403. */
  108404. l22: Vector3;
  108405. /**
  108406. * Adds a light to the spherical harmonics
  108407. * @param direction the direction of the light
  108408. * @param color the color of the light
  108409. * @param deltaSolidAngle the delta solid angle of the light
  108410. */
  108411. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108412. /**
  108413. * Scales the spherical harmonics by the given amount
  108414. * @param scale the amount to scale
  108415. */
  108416. scaleInPlace(scale: number): void;
  108417. /**
  108418. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108419. *
  108420. * ```
  108421. * E_lm = A_l * L_lm
  108422. * ```
  108423. *
  108424. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108425. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108426. * the scaling factors are given in equation 9.
  108427. */
  108428. convertIncidentRadianceToIrradiance(): void;
  108429. /**
  108430. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108431. *
  108432. * ```
  108433. * L = (1/pi) * E * rho
  108434. * ```
  108435. *
  108436. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108437. */
  108438. convertIrradianceToLambertianRadiance(): void;
  108439. /**
  108440. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108441. * required operations at run time.
  108442. *
  108443. * This is simply done by scaling back the SH with Ylm constants parameter.
  108444. * The trigonometric part being applied by the shader at run time.
  108445. */
  108446. preScaleForRendering(): void;
  108447. /**
  108448. * Constructs a spherical harmonics from an array.
  108449. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108450. * @returns the spherical harmonics
  108451. */
  108452. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108453. /**
  108454. * Gets the spherical harmonics from polynomial
  108455. * @param polynomial the spherical polynomial
  108456. * @returns the spherical harmonics
  108457. */
  108458. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108459. }
  108460. /**
  108461. * Class representing spherical polynomial coefficients to the 3rd degree
  108462. */
  108463. export class SphericalPolynomial {
  108464. private _harmonics;
  108465. /**
  108466. * The spherical harmonics used to create the polynomials.
  108467. */
  108468. get preScaledHarmonics(): SphericalHarmonics;
  108469. /**
  108470. * The x coefficients of the spherical polynomial
  108471. */
  108472. x: Vector3;
  108473. /**
  108474. * The y coefficients of the spherical polynomial
  108475. */
  108476. y: Vector3;
  108477. /**
  108478. * The z coefficients of the spherical polynomial
  108479. */
  108480. z: Vector3;
  108481. /**
  108482. * The xx coefficients of the spherical polynomial
  108483. */
  108484. xx: Vector3;
  108485. /**
  108486. * The yy coefficients of the spherical polynomial
  108487. */
  108488. yy: Vector3;
  108489. /**
  108490. * The zz coefficients of the spherical polynomial
  108491. */
  108492. zz: Vector3;
  108493. /**
  108494. * The xy coefficients of the spherical polynomial
  108495. */
  108496. xy: Vector3;
  108497. /**
  108498. * The yz coefficients of the spherical polynomial
  108499. */
  108500. yz: Vector3;
  108501. /**
  108502. * The zx coefficients of the spherical polynomial
  108503. */
  108504. zx: Vector3;
  108505. /**
  108506. * Adds an ambient color to the spherical polynomial
  108507. * @param color the color to add
  108508. */
  108509. addAmbient(color: Color3): void;
  108510. /**
  108511. * Scales the spherical polynomial by the given amount
  108512. * @param scale the amount to scale
  108513. */
  108514. scaleInPlace(scale: number): void;
  108515. /**
  108516. * Gets the spherical polynomial from harmonics
  108517. * @param harmonics the spherical harmonics
  108518. * @returns the spherical polynomial
  108519. */
  108520. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108521. /**
  108522. * Constructs a spherical polynomial from an array.
  108523. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108524. * @returns the spherical polynomial
  108525. */
  108526. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /**
  108531. * Defines the source of the internal texture
  108532. */
  108533. export enum InternalTextureSource {
  108534. /**
  108535. * The source of the texture data is unknown
  108536. */
  108537. Unknown = 0,
  108538. /**
  108539. * Texture data comes from an URL
  108540. */
  108541. Url = 1,
  108542. /**
  108543. * Texture data is only used for temporary storage
  108544. */
  108545. Temp = 2,
  108546. /**
  108547. * Texture data comes from raw data (ArrayBuffer)
  108548. */
  108549. Raw = 3,
  108550. /**
  108551. * Texture content is dynamic (video or dynamic texture)
  108552. */
  108553. Dynamic = 4,
  108554. /**
  108555. * Texture content is generated by rendering to it
  108556. */
  108557. RenderTarget = 5,
  108558. /**
  108559. * Texture content is part of a multi render target process
  108560. */
  108561. MultiRenderTarget = 6,
  108562. /**
  108563. * Texture data comes from a cube data file
  108564. */
  108565. Cube = 7,
  108566. /**
  108567. * Texture data comes from a raw cube data
  108568. */
  108569. CubeRaw = 8,
  108570. /**
  108571. * Texture data come from a prefiltered cube data file
  108572. */
  108573. CubePrefiltered = 9,
  108574. /**
  108575. * Texture content is raw 3D data
  108576. */
  108577. Raw3D = 10,
  108578. /**
  108579. * Texture content is raw 2D array data
  108580. */
  108581. Raw2DArray = 11,
  108582. /**
  108583. * Texture content is a depth texture
  108584. */
  108585. Depth = 12,
  108586. /**
  108587. * Texture data comes from a raw cube data encoded with RGBD
  108588. */
  108589. CubeRawRGBD = 13
  108590. }
  108591. /**
  108592. * Class used to store data associated with WebGL texture data for the engine
  108593. * This class should not be used directly
  108594. */
  108595. export class InternalTexture {
  108596. /** @hidden */
  108597. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108598. /**
  108599. * Defines if the texture is ready
  108600. */
  108601. isReady: boolean;
  108602. /**
  108603. * Defines if the texture is a cube texture
  108604. */
  108605. isCube: boolean;
  108606. /**
  108607. * Defines if the texture contains 3D data
  108608. */
  108609. is3D: boolean;
  108610. /**
  108611. * Defines if the texture contains 2D array data
  108612. */
  108613. is2DArray: boolean;
  108614. /**
  108615. * Defines if the texture contains multiview data
  108616. */
  108617. isMultiview: boolean;
  108618. /**
  108619. * Gets the URL used to load this texture
  108620. */
  108621. url: string;
  108622. /**
  108623. * Gets the sampling mode of the texture
  108624. */
  108625. samplingMode: number;
  108626. /**
  108627. * Gets a boolean indicating if the texture needs mipmaps generation
  108628. */
  108629. generateMipMaps: boolean;
  108630. /**
  108631. * Gets the number of samples used by the texture (WebGL2+ only)
  108632. */
  108633. samples: number;
  108634. /**
  108635. * Gets the type of the texture (int, float...)
  108636. */
  108637. type: number;
  108638. /**
  108639. * Gets the format of the texture (RGB, RGBA...)
  108640. */
  108641. format: number;
  108642. /**
  108643. * Observable called when the texture is loaded
  108644. */
  108645. onLoadedObservable: Observable<InternalTexture>;
  108646. /**
  108647. * Gets the width of the texture
  108648. */
  108649. width: number;
  108650. /**
  108651. * Gets the height of the texture
  108652. */
  108653. height: number;
  108654. /**
  108655. * Gets the depth of the texture
  108656. */
  108657. depth: number;
  108658. /**
  108659. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108660. */
  108661. baseWidth: number;
  108662. /**
  108663. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108664. */
  108665. baseHeight: number;
  108666. /**
  108667. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108668. */
  108669. baseDepth: number;
  108670. /**
  108671. * Gets a boolean indicating if the texture is inverted on Y axis
  108672. */
  108673. invertY: boolean;
  108674. /** @hidden */
  108675. _invertVScale: boolean;
  108676. /** @hidden */
  108677. _associatedChannel: number;
  108678. /** @hidden */
  108679. _source: InternalTextureSource;
  108680. /** @hidden */
  108681. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108682. /** @hidden */
  108683. _bufferView: Nullable<ArrayBufferView>;
  108684. /** @hidden */
  108685. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108686. /** @hidden */
  108687. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108688. /** @hidden */
  108689. _size: number;
  108690. /** @hidden */
  108691. _extension: string;
  108692. /** @hidden */
  108693. _files: Nullable<string[]>;
  108694. /** @hidden */
  108695. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108696. /** @hidden */
  108697. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108698. /** @hidden */
  108699. _framebuffer: Nullable<WebGLFramebuffer>;
  108700. /** @hidden */
  108701. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108702. /** @hidden */
  108703. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108704. /** @hidden */
  108705. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108706. /** @hidden */
  108707. _attachments: Nullable<number[]>;
  108708. /** @hidden */
  108709. _cachedCoordinatesMode: Nullable<number>;
  108710. /** @hidden */
  108711. _cachedWrapU: Nullable<number>;
  108712. /** @hidden */
  108713. _cachedWrapV: Nullable<number>;
  108714. /** @hidden */
  108715. _cachedWrapR: Nullable<number>;
  108716. /** @hidden */
  108717. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108718. /** @hidden */
  108719. _isDisabled: boolean;
  108720. /** @hidden */
  108721. _compression: Nullable<string>;
  108722. /** @hidden */
  108723. _generateStencilBuffer: boolean;
  108724. /** @hidden */
  108725. _generateDepthBuffer: boolean;
  108726. /** @hidden */
  108727. _comparisonFunction: number;
  108728. /** @hidden */
  108729. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108730. /** @hidden */
  108731. _lodGenerationScale: number;
  108732. /** @hidden */
  108733. _lodGenerationOffset: number;
  108734. /** @hidden */
  108735. _depthStencilTexture: Nullable<InternalTexture>;
  108736. /** @hidden */
  108737. _colorTextureArray: Nullable<WebGLTexture>;
  108738. /** @hidden */
  108739. _depthStencilTextureArray: Nullable<WebGLTexture>;
  108740. /** @hidden */
  108741. _lodTextureHigh: Nullable<BaseTexture>;
  108742. /** @hidden */
  108743. _lodTextureMid: Nullable<BaseTexture>;
  108744. /** @hidden */
  108745. _lodTextureLow: Nullable<BaseTexture>;
  108746. /** @hidden */
  108747. _isRGBD: boolean;
  108748. /** @hidden */
  108749. _linearSpecularLOD: boolean;
  108750. /** @hidden */
  108751. _irradianceTexture: Nullable<BaseTexture>;
  108752. /** @hidden */
  108753. _webGLTexture: Nullable<WebGLTexture>;
  108754. /** @hidden */
  108755. _references: number;
  108756. private _engine;
  108757. /**
  108758. * Gets the Engine the texture belongs to.
  108759. * @returns The babylon engine
  108760. */
  108761. getEngine(): ThinEngine;
  108762. /**
  108763. * Gets the data source type of the texture
  108764. */
  108765. get source(): InternalTextureSource;
  108766. /**
  108767. * Creates a new InternalTexture
  108768. * @param engine defines the engine to use
  108769. * @param source defines the type of data that will be used
  108770. * @param delayAllocation if the texture allocation should be delayed (default: false)
  108771. */
  108772. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  108773. /**
  108774. * Increments the number of references (ie. the number of Texture that point to it)
  108775. */
  108776. incrementReferences(): void;
  108777. /**
  108778. * Change the size of the texture (not the size of the content)
  108779. * @param width defines the new width
  108780. * @param height defines the new height
  108781. * @param depth defines the new depth (1 by default)
  108782. */
  108783. updateSize(width: int, height: int, depth?: int): void;
  108784. /** @hidden */
  108785. _rebuild(): void;
  108786. /** @hidden */
  108787. _swapAndDie(target: InternalTexture): void;
  108788. /**
  108789. * Dispose the current allocated resources
  108790. */
  108791. dispose(): void;
  108792. }
  108793. }
  108794. declare module BABYLON {
  108795. /**
  108796. * Class used to work with sound analyzer using fast fourier transform (FFT)
  108797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108798. */
  108799. export class Analyser {
  108800. /**
  108801. * Gets or sets the smoothing
  108802. * @ignorenaming
  108803. */
  108804. SMOOTHING: number;
  108805. /**
  108806. * Gets or sets the FFT table size
  108807. * @ignorenaming
  108808. */
  108809. FFT_SIZE: number;
  108810. /**
  108811. * Gets or sets the bar graph amplitude
  108812. * @ignorenaming
  108813. */
  108814. BARGRAPHAMPLITUDE: number;
  108815. /**
  108816. * Gets or sets the position of the debug canvas
  108817. * @ignorenaming
  108818. */
  108819. DEBUGCANVASPOS: {
  108820. x: number;
  108821. y: number;
  108822. };
  108823. /**
  108824. * Gets or sets the debug canvas size
  108825. * @ignorenaming
  108826. */
  108827. DEBUGCANVASSIZE: {
  108828. width: number;
  108829. height: number;
  108830. };
  108831. private _byteFreqs;
  108832. private _byteTime;
  108833. private _floatFreqs;
  108834. private _webAudioAnalyser;
  108835. private _debugCanvas;
  108836. private _debugCanvasContext;
  108837. private _scene;
  108838. private _registerFunc;
  108839. private _audioEngine;
  108840. /**
  108841. * Creates a new analyser
  108842. * @param scene defines hosting scene
  108843. */
  108844. constructor(scene: Scene);
  108845. /**
  108846. * Get the number of data values you will have to play with for the visualization
  108847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  108848. * @returns a number
  108849. */
  108850. getFrequencyBinCount(): number;
  108851. /**
  108852. * Gets the current frequency data as a byte array
  108853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108854. * @returns a Uint8Array
  108855. */
  108856. getByteFrequencyData(): Uint8Array;
  108857. /**
  108858. * Gets the current waveform as a byte array
  108859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  108860. * @returns a Uint8Array
  108861. */
  108862. getByteTimeDomainData(): Uint8Array;
  108863. /**
  108864. * Gets the current frequency data as a float array
  108865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108866. * @returns a Float32Array
  108867. */
  108868. getFloatFrequencyData(): Float32Array;
  108869. /**
  108870. * Renders the debug canvas
  108871. */
  108872. drawDebugCanvas(): void;
  108873. /**
  108874. * Stops rendering the debug canvas and removes it
  108875. */
  108876. stopDebugCanvas(): void;
  108877. /**
  108878. * Connects two audio nodes
  108879. * @param inputAudioNode defines first node to connect
  108880. * @param outputAudioNode defines second node to connect
  108881. */
  108882. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  108883. /**
  108884. * Releases all associated resources
  108885. */
  108886. dispose(): void;
  108887. }
  108888. }
  108889. declare module BABYLON {
  108890. /**
  108891. * This represents an audio engine and it is responsible
  108892. * to play, synchronize and analyse sounds throughout the application.
  108893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108894. */
  108895. export interface IAudioEngine extends IDisposable {
  108896. /**
  108897. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108898. */
  108899. readonly canUseWebAudio: boolean;
  108900. /**
  108901. * Gets the current AudioContext if available.
  108902. */
  108903. readonly audioContext: Nullable<AudioContext>;
  108904. /**
  108905. * The master gain node defines the global audio volume of your audio engine.
  108906. */
  108907. readonly masterGain: GainNode;
  108908. /**
  108909. * Gets whether or not mp3 are supported by your browser.
  108910. */
  108911. readonly isMP3supported: boolean;
  108912. /**
  108913. * Gets whether or not ogg are supported by your browser.
  108914. */
  108915. readonly isOGGsupported: boolean;
  108916. /**
  108917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108918. * @ignoreNaming
  108919. */
  108920. WarnedWebAudioUnsupported: boolean;
  108921. /**
  108922. * Defines if the audio engine relies on a custom unlocked button.
  108923. * In this case, the embedded button will not be displayed.
  108924. */
  108925. useCustomUnlockedButton: boolean;
  108926. /**
  108927. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  108928. */
  108929. readonly unlocked: boolean;
  108930. /**
  108931. * Event raised when audio has been unlocked on the browser.
  108932. */
  108933. onAudioUnlockedObservable: Observable<AudioEngine>;
  108934. /**
  108935. * Event raised when audio has been locked on the browser.
  108936. */
  108937. onAudioLockedObservable: Observable<AudioEngine>;
  108938. /**
  108939. * Flags the audio engine in Locked state.
  108940. * This happens due to new browser policies preventing audio to autoplay.
  108941. */
  108942. lock(): void;
  108943. /**
  108944. * Unlocks the audio engine once a user action has been done on the dom.
  108945. * This is helpful to resume play once browser policies have been satisfied.
  108946. */
  108947. unlock(): void;
  108948. /**
  108949. * Gets the global volume sets on the master gain.
  108950. * @returns the global volume if set or -1 otherwise
  108951. */
  108952. getGlobalVolume(): number;
  108953. /**
  108954. * Sets the global volume of your experience (sets on the master gain).
  108955. * @param newVolume Defines the new global volume of the application
  108956. */
  108957. setGlobalVolume(newVolume: number): void;
  108958. /**
  108959. * Connect the audio engine to an audio analyser allowing some amazing
  108960. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108962. * @param analyser The analyser to connect to the engine
  108963. */
  108964. connectToAnalyser(analyser: Analyser): void;
  108965. }
  108966. /**
  108967. * This represents the default audio engine used in babylon.
  108968. * It is responsible to play, synchronize and analyse sounds throughout the application.
  108969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108970. */
  108971. export class AudioEngine implements IAudioEngine {
  108972. private _audioContext;
  108973. private _audioContextInitialized;
  108974. private _muteButton;
  108975. private _hostElement;
  108976. /**
  108977. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108978. */
  108979. canUseWebAudio: boolean;
  108980. /**
  108981. * The master gain node defines the global audio volume of your audio engine.
  108982. */
  108983. masterGain: GainNode;
  108984. /**
  108985. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108986. * @ignoreNaming
  108987. */
  108988. WarnedWebAudioUnsupported: boolean;
  108989. /**
  108990. * Gets whether or not mp3 are supported by your browser.
  108991. */
  108992. isMP3supported: boolean;
  108993. /**
  108994. * Gets whether or not ogg are supported by your browser.
  108995. */
  108996. isOGGsupported: boolean;
  108997. /**
  108998. * Gets whether audio has been unlocked on the device.
  108999. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  109000. * a user interaction has happened.
  109001. */
  109002. unlocked: boolean;
  109003. /**
  109004. * Defines if the audio engine relies on a custom unlocked button.
  109005. * In this case, the embedded button will not be displayed.
  109006. */
  109007. useCustomUnlockedButton: boolean;
  109008. /**
  109009. * Event raised when audio has been unlocked on the browser.
  109010. */
  109011. onAudioUnlockedObservable: Observable<AudioEngine>;
  109012. /**
  109013. * Event raised when audio has been locked on the browser.
  109014. */
  109015. onAudioLockedObservable: Observable<AudioEngine>;
  109016. /**
  109017. * Gets the current AudioContext if available.
  109018. */
  109019. get audioContext(): Nullable<AudioContext>;
  109020. private _connectedAnalyser;
  109021. /**
  109022. * Instantiates a new audio engine.
  109023. *
  109024. * There should be only one per page as some browsers restrict the number
  109025. * of audio contexts you can create.
  109026. * @param hostElement defines the host element where to display the mute icon if necessary
  109027. */
  109028. constructor(hostElement?: Nullable<HTMLElement>);
  109029. /**
  109030. * Flags the audio engine in Locked state.
  109031. * This happens due to new browser policies preventing audio to autoplay.
  109032. */
  109033. lock(): void;
  109034. /**
  109035. * Unlocks the audio engine once a user action has been done on the dom.
  109036. * This is helpful to resume play once browser policies have been satisfied.
  109037. */
  109038. unlock(): void;
  109039. private _resumeAudioContext;
  109040. private _initializeAudioContext;
  109041. private _tryToRun;
  109042. private _triggerRunningState;
  109043. private _triggerSuspendedState;
  109044. private _displayMuteButton;
  109045. private _moveButtonToTopLeft;
  109046. private _onResize;
  109047. private _hideMuteButton;
  109048. /**
  109049. * Destroy and release the resources associated with the audio ccontext.
  109050. */
  109051. dispose(): void;
  109052. /**
  109053. * Gets the global volume sets on the master gain.
  109054. * @returns the global volume if set or -1 otherwise
  109055. */
  109056. getGlobalVolume(): number;
  109057. /**
  109058. * Sets the global volume of your experience (sets on the master gain).
  109059. * @param newVolume Defines the new global volume of the application
  109060. */
  109061. setGlobalVolume(newVolume: number): void;
  109062. /**
  109063. * Connect the audio engine to an audio analyser allowing some amazing
  109064. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109066. * @param analyser The analyser to connect to the engine
  109067. */
  109068. connectToAnalyser(analyser: Analyser): void;
  109069. }
  109070. }
  109071. declare module BABYLON {
  109072. /**
  109073. * Interface used to present a loading screen while loading a scene
  109074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109075. */
  109076. export interface ILoadingScreen {
  109077. /**
  109078. * Function called to display the loading screen
  109079. */
  109080. displayLoadingUI: () => void;
  109081. /**
  109082. * Function called to hide the loading screen
  109083. */
  109084. hideLoadingUI: () => void;
  109085. /**
  109086. * Gets or sets the color to use for the background
  109087. */
  109088. loadingUIBackgroundColor: string;
  109089. /**
  109090. * Gets or sets the text to display while loading
  109091. */
  109092. loadingUIText: string;
  109093. }
  109094. /**
  109095. * Class used for the default loading screen
  109096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109097. */
  109098. export class DefaultLoadingScreen implements ILoadingScreen {
  109099. private _renderingCanvas;
  109100. private _loadingText;
  109101. private _loadingDivBackgroundColor;
  109102. private _loadingDiv;
  109103. private _loadingTextDiv;
  109104. /** Gets or sets the logo url to use for the default loading screen */
  109105. static DefaultLogoUrl: string;
  109106. /** Gets or sets the spinner url to use for the default loading screen */
  109107. static DefaultSpinnerUrl: string;
  109108. /**
  109109. * Creates a new default loading screen
  109110. * @param _renderingCanvas defines the canvas used to render the scene
  109111. * @param _loadingText defines the default text to display
  109112. * @param _loadingDivBackgroundColor defines the default background color
  109113. */
  109114. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109115. /**
  109116. * Function called to display the loading screen
  109117. */
  109118. displayLoadingUI(): void;
  109119. /**
  109120. * Function called to hide the loading screen
  109121. */
  109122. hideLoadingUI(): void;
  109123. /**
  109124. * Gets or sets the text to display while loading
  109125. */
  109126. set loadingUIText(text: string);
  109127. get loadingUIText(): string;
  109128. /**
  109129. * Gets or sets the color to use for the background
  109130. */
  109131. get loadingUIBackgroundColor(): string;
  109132. set loadingUIBackgroundColor(color: string);
  109133. private _resizeLoadingUI;
  109134. }
  109135. }
  109136. declare module BABYLON {
  109137. /**
  109138. * Interface for any object that can request an animation frame
  109139. */
  109140. export interface ICustomAnimationFrameRequester {
  109141. /**
  109142. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109143. */
  109144. renderFunction?: Function;
  109145. /**
  109146. * Called to request the next frame to render to
  109147. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109148. */
  109149. requestAnimationFrame: Function;
  109150. /**
  109151. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109152. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109153. */
  109154. requestID?: number;
  109155. }
  109156. }
  109157. declare module BABYLON {
  109158. /**
  109159. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109160. */
  109161. export class PerformanceMonitor {
  109162. private _enabled;
  109163. private _rollingFrameTime;
  109164. private _lastFrameTimeMs;
  109165. /**
  109166. * constructor
  109167. * @param frameSampleSize The number of samples required to saturate the sliding window
  109168. */
  109169. constructor(frameSampleSize?: number);
  109170. /**
  109171. * Samples current frame
  109172. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109173. */
  109174. sampleFrame(timeMs?: number): void;
  109175. /**
  109176. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109177. */
  109178. get averageFrameTime(): number;
  109179. /**
  109180. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109181. */
  109182. get averageFrameTimeVariance(): number;
  109183. /**
  109184. * Returns the frame time of the most recent frame
  109185. */
  109186. get instantaneousFrameTime(): number;
  109187. /**
  109188. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109189. */
  109190. get averageFPS(): number;
  109191. /**
  109192. * Returns the average framerate in frames per second using the most recent frame time
  109193. */
  109194. get instantaneousFPS(): number;
  109195. /**
  109196. * Returns true if enough samples have been taken to completely fill the sliding window
  109197. */
  109198. get isSaturated(): boolean;
  109199. /**
  109200. * Enables contributions to the sliding window sample set
  109201. */
  109202. enable(): void;
  109203. /**
  109204. * Disables contributions to the sliding window sample set
  109205. * Samples will not be interpolated over the disabled period
  109206. */
  109207. disable(): void;
  109208. /**
  109209. * Returns true if sampling is enabled
  109210. */
  109211. get isEnabled(): boolean;
  109212. /**
  109213. * Resets performance monitor
  109214. */
  109215. reset(): void;
  109216. }
  109217. /**
  109218. * RollingAverage
  109219. *
  109220. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109221. */
  109222. export class RollingAverage {
  109223. /**
  109224. * Current average
  109225. */
  109226. average: number;
  109227. /**
  109228. * Current variance
  109229. */
  109230. variance: number;
  109231. protected _samples: Array<number>;
  109232. protected _sampleCount: number;
  109233. protected _pos: number;
  109234. protected _m2: number;
  109235. /**
  109236. * constructor
  109237. * @param length The number of samples required to saturate the sliding window
  109238. */
  109239. constructor(length: number);
  109240. /**
  109241. * Adds a sample to the sample set
  109242. * @param v The sample value
  109243. */
  109244. add(v: number): void;
  109245. /**
  109246. * Returns previously added values or null if outside of history or outside the sliding window domain
  109247. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109248. * @return Value previously recorded with add() or null if outside of range
  109249. */
  109250. history(i: number): number;
  109251. /**
  109252. * Returns true if enough samples have been taken to completely fill the sliding window
  109253. * @return true if sample-set saturated
  109254. */
  109255. isSaturated(): boolean;
  109256. /**
  109257. * Resets the rolling average (equivalent to 0 samples taken so far)
  109258. */
  109259. reset(): void;
  109260. /**
  109261. * Wraps a value around the sample range boundaries
  109262. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109263. * @return Wrapped position in sample range
  109264. */
  109265. protected _wrapPosition(i: number): number;
  109266. }
  109267. }
  109268. declare module BABYLON {
  109269. /**
  109270. * This class is used to track a performance counter which is number based.
  109271. * The user has access to many properties which give statistics of different nature.
  109272. *
  109273. * The implementer can track two kinds of Performance Counter: time and count.
  109274. * 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.
  109275. * 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.
  109276. */
  109277. export class PerfCounter {
  109278. /**
  109279. * Gets or sets a global boolean to turn on and off all the counters
  109280. */
  109281. static Enabled: boolean;
  109282. /**
  109283. * Returns the smallest value ever
  109284. */
  109285. get min(): number;
  109286. /**
  109287. * Returns the biggest value ever
  109288. */
  109289. get max(): number;
  109290. /**
  109291. * Returns the average value since the performance counter is running
  109292. */
  109293. get average(): number;
  109294. /**
  109295. * Returns the average value of the last second the counter was monitored
  109296. */
  109297. get lastSecAverage(): number;
  109298. /**
  109299. * Returns the current value
  109300. */
  109301. get current(): number;
  109302. /**
  109303. * Gets the accumulated total
  109304. */
  109305. get total(): number;
  109306. /**
  109307. * Gets the total value count
  109308. */
  109309. get count(): number;
  109310. /**
  109311. * Creates a new counter
  109312. */
  109313. constructor();
  109314. /**
  109315. * Call this method to start monitoring a new frame.
  109316. * 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.
  109317. */
  109318. fetchNewFrame(): void;
  109319. /**
  109320. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109321. * @param newCount the count value to add to the monitored count
  109322. * @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.
  109323. */
  109324. addCount(newCount: number, fetchResult: boolean): void;
  109325. /**
  109326. * Start monitoring this performance counter
  109327. */
  109328. beginMonitoring(): void;
  109329. /**
  109330. * Compute the time lapsed since the previous beginMonitoring() call.
  109331. * @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
  109332. */
  109333. endMonitoring(newFrame?: boolean): void;
  109334. private _fetchResult;
  109335. private _startMonitoringTime;
  109336. private _min;
  109337. private _max;
  109338. private _average;
  109339. private _current;
  109340. private _totalValueCount;
  109341. private _totalAccumulated;
  109342. private _lastSecAverage;
  109343. private _lastSecAccumulated;
  109344. private _lastSecTime;
  109345. private _lastSecValueCount;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. interface ThinEngine {
  109350. /**
  109351. * Sets alpha constants used by some alpha blending modes
  109352. * @param r defines the red component
  109353. * @param g defines the green component
  109354. * @param b defines the blue component
  109355. * @param a defines the alpha component
  109356. */
  109357. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109358. /**
  109359. * Sets the current alpha mode
  109360. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109361. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109362. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109363. */
  109364. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109365. /**
  109366. * Gets the current alpha mode
  109367. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109368. * @returns the current alpha mode
  109369. */
  109370. getAlphaMode(): number;
  109371. /**
  109372. * Sets the current alpha equation
  109373. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109374. */
  109375. setAlphaEquation(equation: number): void;
  109376. /**
  109377. * Gets the current alpha equation.
  109378. * @returns the current alpha equation
  109379. */
  109380. getAlphaEquation(): number;
  109381. }
  109382. }
  109383. declare module BABYLON {
  109384. /**
  109385. * Defines the interface used by display changed events
  109386. */
  109387. export interface IDisplayChangedEventArgs {
  109388. /** Gets the vrDisplay object (if any) */
  109389. vrDisplay: Nullable<any>;
  109390. /** Gets a boolean indicating if webVR is supported */
  109391. vrSupported: boolean;
  109392. }
  109393. /**
  109394. * Defines the interface used by objects containing a viewport (like a camera)
  109395. */
  109396. interface IViewportOwnerLike {
  109397. /**
  109398. * Gets or sets the viewport
  109399. */
  109400. viewport: IViewportLike;
  109401. }
  109402. /**
  109403. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109404. */
  109405. export class Engine extends ThinEngine {
  109406. /** Defines that alpha blending is disabled */
  109407. static readonly ALPHA_DISABLE: number;
  109408. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109409. static readonly ALPHA_ADD: number;
  109410. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109411. static readonly ALPHA_COMBINE: number;
  109412. /** Defines that alpha blending to DEST - SRC * DEST */
  109413. static readonly ALPHA_SUBTRACT: number;
  109414. /** Defines that alpha blending to SRC * DEST */
  109415. static readonly ALPHA_MULTIPLY: number;
  109416. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109417. static readonly ALPHA_MAXIMIZED: number;
  109418. /** Defines that alpha blending to SRC + DEST */
  109419. static readonly ALPHA_ONEONE: number;
  109420. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109421. static readonly ALPHA_PREMULTIPLIED: number;
  109422. /**
  109423. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109424. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109425. */
  109426. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109427. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109428. static readonly ALPHA_INTERPOLATE: number;
  109429. /**
  109430. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109431. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109432. */
  109433. static readonly ALPHA_SCREENMODE: number;
  109434. /** Defines that the ressource is not delayed*/
  109435. static readonly DELAYLOADSTATE_NONE: number;
  109436. /** Defines that the ressource was successfully delay loaded */
  109437. static readonly DELAYLOADSTATE_LOADED: number;
  109438. /** Defines that the ressource is currently delay loading */
  109439. static readonly DELAYLOADSTATE_LOADING: number;
  109440. /** Defines that the ressource is delayed and has not started loading */
  109441. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109443. static readonly NEVER: number;
  109444. /** 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 */
  109445. static readonly ALWAYS: number;
  109446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109447. static readonly LESS: number;
  109448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109449. static readonly EQUAL: number;
  109450. /** 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 */
  109451. static readonly LEQUAL: number;
  109452. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109453. static readonly GREATER: number;
  109454. /** 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 */
  109455. static readonly GEQUAL: number;
  109456. /** 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 */
  109457. static readonly NOTEQUAL: number;
  109458. /** Passed to stencilOperation to specify that stencil value must be kept */
  109459. static readonly KEEP: number;
  109460. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109461. static readonly REPLACE: number;
  109462. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109463. static readonly INCR: number;
  109464. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109465. static readonly DECR: number;
  109466. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109467. static readonly INVERT: number;
  109468. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109469. static readonly INCR_WRAP: number;
  109470. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109471. static readonly DECR_WRAP: number;
  109472. /** Texture is not repeating outside of 0..1 UVs */
  109473. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109474. /** Texture is repeating outside of 0..1 UVs */
  109475. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109476. /** Texture is repeating and mirrored */
  109477. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109478. /** ALPHA */
  109479. static readonly TEXTUREFORMAT_ALPHA: number;
  109480. /** LUMINANCE */
  109481. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109482. /** LUMINANCE_ALPHA */
  109483. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109484. /** RGB */
  109485. static readonly TEXTUREFORMAT_RGB: number;
  109486. /** RGBA */
  109487. static readonly TEXTUREFORMAT_RGBA: number;
  109488. /** RED */
  109489. static readonly TEXTUREFORMAT_RED: number;
  109490. /** RED (2nd reference) */
  109491. static readonly TEXTUREFORMAT_R: number;
  109492. /** RG */
  109493. static readonly TEXTUREFORMAT_RG: number;
  109494. /** RED_INTEGER */
  109495. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109496. /** RED_INTEGER (2nd reference) */
  109497. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109498. /** RG_INTEGER */
  109499. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109500. /** RGB_INTEGER */
  109501. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109502. /** RGBA_INTEGER */
  109503. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109504. /** UNSIGNED_BYTE */
  109505. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109506. /** UNSIGNED_BYTE (2nd reference) */
  109507. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109508. /** FLOAT */
  109509. static readonly TEXTURETYPE_FLOAT: number;
  109510. /** HALF_FLOAT */
  109511. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109512. /** BYTE */
  109513. static readonly TEXTURETYPE_BYTE: number;
  109514. /** SHORT */
  109515. static readonly TEXTURETYPE_SHORT: number;
  109516. /** UNSIGNED_SHORT */
  109517. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109518. /** INT */
  109519. static readonly TEXTURETYPE_INT: number;
  109520. /** UNSIGNED_INT */
  109521. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109522. /** UNSIGNED_SHORT_4_4_4_4 */
  109523. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109524. /** UNSIGNED_SHORT_5_5_5_1 */
  109525. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109526. /** UNSIGNED_SHORT_5_6_5 */
  109527. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109528. /** UNSIGNED_INT_2_10_10_10_REV */
  109529. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109530. /** UNSIGNED_INT_24_8 */
  109531. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109532. /** UNSIGNED_INT_10F_11F_11F_REV */
  109533. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109534. /** UNSIGNED_INT_5_9_9_9_REV */
  109535. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109536. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109537. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109538. /** nearest is mag = nearest and min = nearest and mip = linear */
  109539. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109541. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109542. /** Trilinear is mag = linear and min = linear and mip = linear */
  109543. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109544. /** nearest is mag = nearest and min = nearest and mip = linear */
  109545. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109546. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109547. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109548. /** Trilinear is mag = linear and min = linear and mip = linear */
  109549. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109550. /** mag = nearest and min = nearest and mip = nearest */
  109551. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109552. /** mag = nearest and min = linear and mip = nearest */
  109553. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109554. /** mag = nearest and min = linear and mip = linear */
  109555. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109556. /** mag = nearest and min = linear and mip = none */
  109557. static readonly TEXTURE_NEAREST_LINEAR: number;
  109558. /** mag = nearest and min = nearest and mip = none */
  109559. static readonly TEXTURE_NEAREST_NEAREST: number;
  109560. /** mag = linear and min = nearest and mip = nearest */
  109561. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109562. /** mag = linear and min = nearest and mip = linear */
  109563. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109564. /** mag = linear and min = linear and mip = none */
  109565. static readonly TEXTURE_LINEAR_LINEAR: number;
  109566. /** mag = linear and min = nearest and mip = none */
  109567. static readonly TEXTURE_LINEAR_NEAREST: number;
  109568. /** Explicit coordinates mode */
  109569. static readonly TEXTURE_EXPLICIT_MODE: number;
  109570. /** Spherical coordinates mode */
  109571. static readonly TEXTURE_SPHERICAL_MODE: number;
  109572. /** Planar coordinates mode */
  109573. static readonly TEXTURE_PLANAR_MODE: number;
  109574. /** Cubic coordinates mode */
  109575. static readonly TEXTURE_CUBIC_MODE: number;
  109576. /** Projection coordinates mode */
  109577. static readonly TEXTURE_PROJECTION_MODE: number;
  109578. /** Skybox coordinates mode */
  109579. static readonly TEXTURE_SKYBOX_MODE: number;
  109580. /** Inverse Cubic coordinates mode */
  109581. static readonly TEXTURE_INVCUBIC_MODE: number;
  109582. /** Equirectangular coordinates mode */
  109583. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109584. /** Equirectangular Fixed coordinates mode */
  109585. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109586. /** Equirectangular Fixed Mirrored coordinates mode */
  109587. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109588. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109589. static readonly SCALEMODE_FLOOR: number;
  109590. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109591. static readonly SCALEMODE_NEAREST: number;
  109592. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109593. static readonly SCALEMODE_CEILING: number;
  109594. /**
  109595. * Returns the current npm package of the sdk
  109596. */
  109597. static get NpmPackage(): string;
  109598. /**
  109599. * Returns the current version of the framework
  109600. */
  109601. static get Version(): string;
  109602. /** Gets the list of created engines */
  109603. static get Instances(): Engine[];
  109604. /**
  109605. * Gets the latest created engine
  109606. */
  109607. static get LastCreatedEngine(): Nullable<Engine>;
  109608. /**
  109609. * Gets the latest created scene
  109610. */
  109611. static get LastCreatedScene(): Nullable<Scene>;
  109612. /**
  109613. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109614. * @param flag defines which part of the materials must be marked as dirty
  109615. * @param predicate defines a predicate used to filter which materials should be affected
  109616. */
  109617. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109618. /**
  109619. * Method called to create the default loading screen.
  109620. * This can be overriden in your own app.
  109621. * @param canvas The rendering canvas element
  109622. * @returns The loading screen
  109623. */
  109624. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109625. /**
  109626. * Method called to create the default rescale post process on each engine.
  109627. */
  109628. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109629. /**
  109630. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109631. **/
  109632. enableOfflineSupport: boolean;
  109633. /**
  109634. * 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)
  109635. **/
  109636. disableManifestCheck: boolean;
  109637. /**
  109638. * Gets the list of created scenes
  109639. */
  109640. scenes: Scene[];
  109641. /**
  109642. * Event raised when a new scene is created
  109643. */
  109644. onNewSceneAddedObservable: Observable<Scene>;
  109645. /**
  109646. * Gets the list of created postprocesses
  109647. */
  109648. postProcesses: PostProcess[];
  109649. /**
  109650. * Gets a boolean indicating if the pointer is currently locked
  109651. */
  109652. isPointerLock: boolean;
  109653. /**
  109654. * Observable event triggered each time the rendering canvas is resized
  109655. */
  109656. onResizeObservable: Observable<Engine>;
  109657. /**
  109658. * Observable event triggered each time the canvas loses focus
  109659. */
  109660. onCanvasBlurObservable: Observable<Engine>;
  109661. /**
  109662. * Observable event triggered each time the canvas gains focus
  109663. */
  109664. onCanvasFocusObservable: Observable<Engine>;
  109665. /**
  109666. * Observable event triggered each time the canvas receives pointerout event
  109667. */
  109668. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109669. /**
  109670. * Observable raised when the engine begins a new frame
  109671. */
  109672. onBeginFrameObservable: Observable<Engine>;
  109673. /**
  109674. * If set, will be used to request the next animation frame for the render loop
  109675. */
  109676. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109677. /**
  109678. * Observable raised when the engine ends the current frame
  109679. */
  109680. onEndFrameObservable: Observable<Engine>;
  109681. /**
  109682. * Observable raised when the engine is about to compile a shader
  109683. */
  109684. onBeforeShaderCompilationObservable: Observable<Engine>;
  109685. /**
  109686. * Observable raised when the engine has jsut compiled a shader
  109687. */
  109688. onAfterShaderCompilationObservable: Observable<Engine>;
  109689. /**
  109690. * Gets the audio engine
  109691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109692. * @ignorenaming
  109693. */
  109694. static audioEngine: IAudioEngine;
  109695. /**
  109696. * Default AudioEngine factory responsible of creating the Audio Engine.
  109697. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109698. */
  109699. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109700. /**
  109701. * Default offline support factory responsible of creating a tool used to store data locally.
  109702. * By default, this will create a Database object if the workload has been embedded.
  109703. */
  109704. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109705. private _loadingScreen;
  109706. private _pointerLockRequested;
  109707. private _dummyFramebuffer;
  109708. private _rescalePostProcess;
  109709. private _deterministicLockstep;
  109710. private _lockstepMaxSteps;
  109711. private _timeStep;
  109712. protected get _supportsHardwareTextureRescaling(): boolean;
  109713. private _fps;
  109714. private _deltaTime;
  109715. /** @hidden */
  109716. _drawCalls: PerfCounter;
  109717. /** 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 */
  109718. canvasTabIndex: number;
  109719. /**
  109720. * Turn this value on if you want to pause FPS computation when in background
  109721. */
  109722. disablePerformanceMonitorInBackground: boolean;
  109723. private _performanceMonitor;
  109724. /**
  109725. * Gets the performance monitor attached to this engine
  109726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109727. */
  109728. get performanceMonitor(): PerformanceMonitor;
  109729. private _onFocus;
  109730. private _onBlur;
  109731. private _onCanvasPointerOut;
  109732. private _onCanvasBlur;
  109733. private _onCanvasFocus;
  109734. private _onFullscreenChange;
  109735. private _onPointerLockChange;
  109736. /**
  109737. * Gets the HTML element used to attach event listeners
  109738. * @returns a HTML element
  109739. */
  109740. getInputElement(): Nullable<HTMLElement>;
  109741. /**
  109742. * Creates a new engine
  109743. * @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
  109744. * @param antialias defines enable antialiasing (default: false)
  109745. * @param options defines further options to be sent to the getContext() function
  109746. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  109747. */
  109748. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  109749. /**
  109750. * Gets current aspect ratio
  109751. * @param viewportOwner defines the camera to use to get the aspect ratio
  109752. * @param useScreen defines if screen size must be used (or the current render target if any)
  109753. * @returns a number defining the aspect ratio
  109754. */
  109755. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  109756. /**
  109757. * Gets current screen aspect ratio
  109758. * @returns a number defining the aspect ratio
  109759. */
  109760. getScreenAspectRatio(): number;
  109761. /**
  109762. * Gets the client rect of the HTML canvas attached with the current webGL context
  109763. * @returns a client rectanglee
  109764. */
  109765. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  109766. /**
  109767. * Gets the client rect of the HTML element used for events
  109768. * @returns a client rectanglee
  109769. */
  109770. getInputElementClientRect(): Nullable<ClientRect>;
  109771. /**
  109772. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109774. * @returns true if engine is in deterministic lock step mode
  109775. */
  109776. isDeterministicLockStep(): boolean;
  109777. /**
  109778. * Gets the max steps when engine is running in deterministic lock step
  109779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109780. * @returns the max steps
  109781. */
  109782. getLockstepMaxSteps(): number;
  109783. /**
  109784. * Returns the time in ms between steps when using deterministic lock step.
  109785. * @returns time step in (ms)
  109786. */
  109787. getTimeStep(): number;
  109788. /**
  109789. * Force the mipmap generation for the given render target texture
  109790. * @param texture defines the render target texture to use
  109791. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  109792. */
  109793. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  109794. /** States */
  109795. /**
  109796. * Set various states to the webGL context
  109797. * @param culling defines backface culling state
  109798. * @param zOffset defines the value to apply to zOffset (0 by default)
  109799. * @param force defines if states must be applied even if cache is up to date
  109800. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  109801. */
  109802. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109803. /**
  109804. * Set the z offset to apply to current rendering
  109805. * @param value defines the offset to apply
  109806. */
  109807. setZOffset(value: number): void;
  109808. /**
  109809. * Gets the current value of the zOffset
  109810. * @returns the current zOffset state
  109811. */
  109812. getZOffset(): number;
  109813. /**
  109814. * Enable or disable depth buffering
  109815. * @param enable defines the state to set
  109816. */
  109817. setDepthBuffer(enable: boolean): void;
  109818. /**
  109819. * Gets a boolean indicating if depth writing is enabled
  109820. * @returns the current depth writing state
  109821. */
  109822. getDepthWrite(): boolean;
  109823. /**
  109824. * Enable or disable depth writing
  109825. * @param enable defines the state to set
  109826. */
  109827. setDepthWrite(enable: boolean): void;
  109828. /**
  109829. * Gets a boolean indicating if stencil buffer is enabled
  109830. * @returns the current stencil buffer state
  109831. */
  109832. getStencilBuffer(): boolean;
  109833. /**
  109834. * Enable or disable the stencil buffer
  109835. * @param enable defines if the stencil buffer must be enabled or disabled
  109836. */
  109837. setStencilBuffer(enable: boolean): void;
  109838. /**
  109839. * Gets the current stencil mask
  109840. * @returns a number defining the new stencil mask to use
  109841. */
  109842. getStencilMask(): number;
  109843. /**
  109844. * Sets the current stencil mask
  109845. * @param mask defines the new stencil mask to use
  109846. */
  109847. setStencilMask(mask: number): void;
  109848. /**
  109849. * Gets the current stencil function
  109850. * @returns a number defining the stencil function to use
  109851. */
  109852. getStencilFunction(): number;
  109853. /**
  109854. * Gets the current stencil reference value
  109855. * @returns a number defining the stencil reference value to use
  109856. */
  109857. getStencilFunctionReference(): number;
  109858. /**
  109859. * Gets the current stencil mask
  109860. * @returns a number defining the stencil mask to use
  109861. */
  109862. getStencilFunctionMask(): number;
  109863. /**
  109864. * Sets the current stencil function
  109865. * @param stencilFunc defines the new stencil function to use
  109866. */
  109867. setStencilFunction(stencilFunc: number): void;
  109868. /**
  109869. * Sets the current stencil reference
  109870. * @param reference defines the new stencil reference to use
  109871. */
  109872. setStencilFunctionReference(reference: number): void;
  109873. /**
  109874. * Sets the current stencil mask
  109875. * @param mask defines the new stencil mask to use
  109876. */
  109877. setStencilFunctionMask(mask: number): void;
  109878. /**
  109879. * Gets the current stencil operation when stencil fails
  109880. * @returns a number defining stencil operation to use when stencil fails
  109881. */
  109882. getStencilOperationFail(): number;
  109883. /**
  109884. * Gets the current stencil operation when depth fails
  109885. * @returns a number defining stencil operation to use when depth fails
  109886. */
  109887. getStencilOperationDepthFail(): number;
  109888. /**
  109889. * Gets the current stencil operation when stencil passes
  109890. * @returns a number defining stencil operation to use when stencil passes
  109891. */
  109892. getStencilOperationPass(): number;
  109893. /**
  109894. * Sets the stencil operation to use when stencil fails
  109895. * @param operation defines the stencil operation to use when stencil fails
  109896. */
  109897. setStencilOperationFail(operation: number): void;
  109898. /**
  109899. * Sets the stencil operation to use when depth fails
  109900. * @param operation defines the stencil operation to use when depth fails
  109901. */
  109902. setStencilOperationDepthFail(operation: number): void;
  109903. /**
  109904. * Sets the stencil operation to use when stencil passes
  109905. * @param operation defines the stencil operation to use when stencil passes
  109906. */
  109907. setStencilOperationPass(operation: number): void;
  109908. /**
  109909. * Sets a boolean indicating if the dithering state is enabled or disabled
  109910. * @param value defines the dithering state
  109911. */
  109912. setDitheringState(value: boolean): void;
  109913. /**
  109914. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  109915. * @param value defines the rasterizer state
  109916. */
  109917. setRasterizerState(value: boolean): void;
  109918. /**
  109919. * Gets the current depth function
  109920. * @returns a number defining the depth function
  109921. */
  109922. getDepthFunction(): Nullable<number>;
  109923. /**
  109924. * Sets the current depth function
  109925. * @param depthFunc defines the function to use
  109926. */
  109927. setDepthFunction(depthFunc: number): void;
  109928. /**
  109929. * Sets the current depth function to GREATER
  109930. */
  109931. setDepthFunctionToGreater(): void;
  109932. /**
  109933. * Sets the current depth function to GEQUAL
  109934. */
  109935. setDepthFunctionToGreaterOrEqual(): void;
  109936. /**
  109937. * Sets the current depth function to LESS
  109938. */
  109939. setDepthFunctionToLess(): void;
  109940. /**
  109941. * Sets the current depth function to LEQUAL
  109942. */
  109943. setDepthFunctionToLessOrEqual(): void;
  109944. private _cachedStencilBuffer;
  109945. private _cachedStencilFunction;
  109946. private _cachedStencilMask;
  109947. private _cachedStencilOperationPass;
  109948. private _cachedStencilOperationFail;
  109949. private _cachedStencilOperationDepthFail;
  109950. private _cachedStencilReference;
  109951. /**
  109952. * Caches the the state of the stencil buffer
  109953. */
  109954. cacheStencilState(): void;
  109955. /**
  109956. * Restores the state of the stencil buffer
  109957. */
  109958. restoreStencilState(): void;
  109959. /**
  109960. * Directly set the WebGL Viewport
  109961. * @param x defines the x coordinate of the viewport (in screen space)
  109962. * @param y defines the y coordinate of the viewport (in screen space)
  109963. * @param width defines the width of the viewport (in screen space)
  109964. * @param height defines the height of the viewport (in screen space)
  109965. * @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
  109966. */
  109967. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  109968. /**
  109969. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  109970. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109971. * @param y defines the y-coordinate of the corner of the clear rectangle
  109972. * @param width defines the width of the clear rectangle
  109973. * @param height defines the height of the clear rectangle
  109974. * @param clearColor defines the clear color
  109975. */
  109976. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  109977. /**
  109978. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  109979. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109980. * @param y defines the y-coordinate of the corner of the clear rectangle
  109981. * @param width defines the width of the clear rectangle
  109982. * @param height defines the height of the clear rectangle
  109983. */
  109984. enableScissor(x: number, y: number, width: number, height: number): void;
  109985. /**
  109986. * Disable previously set scissor test rectangle
  109987. */
  109988. disableScissor(): void;
  109989. protected _reportDrawCall(): void;
  109990. /**
  109991. * Initializes a webVR display and starts listening to display change events
  109992. * The onVRDisplayChangedObservable will be notified upon these changes
  109993. * @returns The onVRDisplayChangedObservable
  109994. */
  109995. initWebVR(): Observable<IDisplayChangedEventArgs>;
  109996. /** @hidden */
  109997. _prepareVRComponent(): void;
  109998. /** @hidden */
  109999. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  110000. /** @hidden */
  110001. _submitVRFrame(): void;
  110002. /**
  110003. * Call this function to leave webVR mode
  110004. * Will do nothing if webVR is not supported or if there is no webVR device
  110005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  110006. */
  110007. disableVR(): void;
  110008. /**
  110009. * Gets a boolean indicating that the system is in VR mode and is presenting
  110010. * @returns true if VR mode is engaged
  110011. */
  110012. isVRPresenting(): boolean;
  110013. /** @hidden */
  110014. _requestVRFrame(): void;
  110015. /** @hidden */
  110016. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110017. /**
  110018. * Gets the source code of the vertex shader associated with a specific webGL program
  110019. * @param program defines the program to use
  110020. * @returns a string containing the source code of the vertex shader associated with the program
  110021. */
  110022. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110023. /**
  110024. * Gets the source code of the fragment shader associated with a specific webGL program
  110025. * @param program defines the program to use
  110026. * @returns a string containing the source code of the fragment shader associated with the program
  110027. */
  110028. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110029. /**
  110030. * Sets a depth stencil texture from a render target to the according uniform.
  110031. * @param channel The texture channel
  110032. * @param uniform The uniform to set
  110033. * @param texture The render target texture containing the depth stencil texture to apply
  110034. */
  110035. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110036. /**
  110037. * Sets a texture to the webGL context from a postprocess
  110038. * @param channel defines the channel to use
  110039. * @param postProcess defines the source postprocess
  110040. */
  110041. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110042. /**
  110043. * Binds the output of the passed in post process to the texture channel specified
  110044. * @param channel The channel the texture should be bound to
  110045. * @param postProcess The post process which's output should be bound
  110046. */
  110047. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110048. protected _rebuildBuffers(): void;
  110049. /** @hidden */
  110050. _renderFrame(): void;
  110051. _renderLoop(): void;
  110052. /** @hidden */
  110053. _renderViews(): boolean;
  110054. /**
  110055. * Toggle full screen mode
  110056. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110057. */
  110058. switchFullscreen(requestPointerLock: boolean): void;
  110059. /**
  110060. * Enters full screen mode
  110061. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110062. */
  110063. enterFullscreen(requestPointerLock: boolean): void;
  110064. /**
  110065. * Exits full screen mode
  110066. */
  110067. exitFullscreen(): void;
  110068. /**
  110069. * Enters Pointerlock mode
  110070. */
  110071. enterPointerlock(): void;
  110072. /**
  110073. * Exits Pointerlock mode
  110074. */
  110075. exitPointerlock(): void;
  110076. /**
  110077. * Begin a new frame
  110078. */
  110079. beginFrame(): void;
  110080. /**
  110081. * Enf the current frame
  110082. */
  110083. endFrame(): void;
  110084. resize(): void;
  110085. /**
  110086. * Force a specific size of the canvas
  110087. * @param width defines the new canvas' width
  110088. * @param height defines the new canvas' height
  110089. */
  110090. setSize(width: number, height: number): void;
  110091. /**
  110092. * Updates a dynamic vertex buffer.
  110093. * @param vertexBuffer the vertex buffer to update
  110094. * @param data the data used to update the vertex buffer
  110095. * @param byteOffset the byte offset of the data
  110096. * @param byteLength the byte length of the data
  110097. */
  110098. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110099. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110101. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110102. _releaseTexture(texture: InternalTexture): void;
  110103. /**
  110104. * @hidden
  110105. * Rescales a texture
  110106. * @param source input texutre
  110107. * @param destination destination texture
  110108. * @param scene scene to use to render the resize
  110109. * @param internalFormat format to use when resizing
  110110. * @param onComplete callback to be called when resize has completed
  110111. */
  110112. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110113. /**
  110114. * Gets the current framerate
  110115. * @returns a number representing the framerate
  110116. */
  110117. getFps(): number;
  110118. /**
  110119. * Gets the time spent between current and previous frame
  110120. * @returns a number representing the delta time in ms
  110121. */
  110122. getDeltaTime(): number;
  110123. private _measureFps;
  110124. /** @hidden */
  110125. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110126. /**
  110127. * Update a dynamic index buffer
  110128. * @param indexBuffer defines the target index buffer
  110129. * @param indices defines the data to update
  110130. * @param offset defines the offset in the target index buffer where update should start
  110131. */
  110132. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110133. /**
  110134. * Updates the sample count of a render target texture
  110135. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110136. * @param texture defines the texture to update
  110137. * @param samples defines the sample count to set
  110138. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110139. */
  110140. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110141. /**
  110142. * Updates a depth texture Comparison Mode and Function.
  110143. * If the comparison Function is equal to 0, the mode will be set to none.
  110144. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110145. * @param texture The texture to set the comparison function for
  110146. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110147. */
  110148. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110149. /**
  110150. * Creates a webGL buffer to use with instanciation
  110151. * @param capacity defines the size of the buffer
  110152. * @returns the webGL buffer
  110153. */
  110154. createInstancesBuffer(capacity: number): DataBuffer;
  110155. /**
  110156. * Delete a webGL buffer used with instanciation
  110157. * @param buffer defines the webGL buffer to delete
  110158. */
  110159. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110160. private _clientWaitAsync;
  110161. /** @hidden */
  110162. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110163. /** @hidden */
  110164. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  110165. dispose(): void;
  110166. private _disableTouchAction;
  110167. /**
  110168. * Display the loading screen
  110169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110170. */
  110171. displayLoadingUI(): void;
  110172. /**
  110173. * Hide the loading screen
  110174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110175. */
  110176. hideLoadingUI(): void;
  110177. /**
  110178. * Gets the current loading screen object
  110179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110180. */
  110181. get loadingScreen(): ILoadingScreen;
  110182. /**
  110183. * Sets the current loading screen object
  110184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110185. */
  110186. set loadingScreen(loadingScreen: ILoadingScreen);
  110187. /**
  110188. * Sets the current loading screen text
  110189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110190. */
  110191. set loadingUIText(text: string);
  110192. /**
  110193. * Sets the current loading screen background color
  110194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110195. */
  110196. set loadingUIBackgroundColor(color: string);
  110197. /** Pointerlock and fullscreen */
  110198. /**
  110199. * Ask the browser to promote the current element to pointerlock mode
  110200. * @param element defines the DOM element to promote
  110201. */
  110202. static _RequestPointerlock(element: HTMLElement): void;
  110203. /**
  110204. * Asks the browser to exit pointerlock mode
  110205. */
  110206. static _ExitPointerlock(): void;
  110207. /**
  110208. * Ask the browser to promote the current element to fullscreen rendering mode
  110209. * @param element defines the DOM element to promote
  110210. */
  110211. static _RequestFullscreen(element: HTMLElement): void;
  110212. /**
  110213. * Asks the browser to exit fullscreen mode
  110214. */
  110215. static _ExitFullscreen(): void;
  110216. }
  110217. }
  110218. declare module BABYLON {
  110219. /**
  110220. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110221. * during the life time of the application.
  110222. */
  110223. export class EngineStore {
  110224. /** Gets the list of created engines */
  110225. static Instances: Engine[];
  110226. /** @hidden */
  110227. static _LastCreatedScene: Nullable<Scene>;
  110228. /**
  110229. * Gets the latest created engine
  110230. */
  110231. static get LastCreatedEngine(): Nullable<Engine>;
  110232. /**
  110233. * Gets the latest created scene
  110234. */
  110235. static get LastCreatedScene(): Nullable<Scene>;
  110236. /**
  110237. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110238. * @ignorenaming
  110239. */
  110240. static UseFallbackTexture: boolean;
  110241. /**
  110242. * Texture content used if a texture cannot loaded
  110243. * @ignorenaming
  110244. */
  110245. static FallbackTexture: string;
  110246. }
  110247. }
  110248. declare module BABYLON {
  110249. /**
  110250. * Helper class that provides a small promise polyfill
  110251. */
  110252. export class PromisePolyfill {
  110253. /**
  110254. * Static function used to check if the polyfill is required
  110255. * If this is the case then the function will inject the polyfill to window.Promise
  110256. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110257. */
  110258. static Apply(force?: boolean): void;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Interface for screenshot methods with describe argument called `size` as object with options
  110264. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110265. */
  110266. export interface IScreenshotSize {
  110267. /**
  110268. * number in pixels for canvas height
  110269. */
  110270. height?: number;
  110271. /**
  110272. * multiplier allowing render at a higher or lower resolution
  110273. * If value is defined then height and width will be ignored and taken from camera
  110274. */
  110275. precision?: number;
  110276. /**
  110277. * number in pixels for canvas width
  110278. */
  110279. width?: number;
  110280. }
  110281. }
  110282. declare module BABYLON {
  110283. interface IColor4Like {
  110284. r: float;
  110285. g: float;
  110286. b: float;
  110287. a: float;
  110288. }
  110289. /**
  110290. * Class containing a set of static utilities functions
  110291. */
  110292. export class Tools {
  110293. /**
  110294. * Gets or sets the base URL to use to load assets
  110295. */
  110296. static get BaseUrl(): string;
  110297. static set BaseUrl(value: string);
  110298. /**
  110299. * Enable/Disable Custom HTTP Request Headers globally.
  110300. * default = false
  110301. * @see CustomRequestHeaders
  110302. */
  110303. static UseCustomRequestHeaders: boolean;
  110304. /**
  110305. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110306. * i.e. when loading files, where the server/service expects an Authorization header
  110307. */
  110308. static CustomRequestHeaders: {
  110309. [key: string]: string;
  110310. };
  110311. /**
  110312. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110313. */
  110314. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110315. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110316. /**
  110317. * Default behaviour for cors in the application.
  110318. * It can be a string if the expected behavior is identical in the entire app.
  110319. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110320. */
  110321. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110322. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110323. /**
  110324. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110325. * @ignorenaming
  110326. */
  110327. static get UseFallbackTexture(): boolean;
  110328. static set UseFallbackTexture(value: boolean);
  110329. /**
  110330. * Use this object to register external classes like custom textures or material
  110331. * to allow the laoders to instantiate them
  110332. */
  110333. static get RegisteredExternalClasses(): {
  110334. [key: string]: Object;
  110335. };
  110336. static set RegisteredExternalClasses(classes: {
  110337. [key: string]: Object;
  110338. });
  110339. /**
  110340. * Texture content used if a texture cannot loaded
  110341. * @ignorenaming
  110342. */
  110343. static get fallbackTexture(): string;
  110344. static set fallbackTexture(value: string);
  110345. /**
  110346. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110347. * @param u defines the coordinate on X axis
  110348. * @param v defines the coordinate on Y axis
  110349. * @param width defines the width of the source data
  110350. * @param height defines the height of the source data
  110351. * @param pixels defines the source byte array
  110352. * @param color defines the output color
  110353. */
  110354. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110355. /**
  110356. * Interpolates between a and b via alpha
  110357. * @param a The lower value (returned when alpha = 0)
  110358. * @param b The upper value (returned when alpha = 1)
  110359. * @param alpha The interpolation-factor
  110360. * @return The mixed value
  110361. */
  110362. static Mix(a: number, b: number, alpha: number): number;
  110363. /**
  110364. * Tries to instantiate a new object from a given class name
  110365. * @param className defines the class name to instantiate
  110366. * @returns the new object or null if the system was not able to do the instantiation
  110367. */
  110368. static Instantiate(className: string): any;
  110369. /**
  110370. * Provides a slice function that will work even on IE
  110371. * @param data defines the array to slice
  110372. * @param start defines the start of the data (optional)
  110373. * @param end defines the end of the data (optional)
  110374. * @returns the new sliced array
  110375. */
  110376. static Slice<T>(data: T, start?: number, end?: number): T;
  110377. /**
  110378. * Polyfill for setImmediate
  110379. * @param action defines the action to execute after the current execution block
  110380. */
  110381. static SetImmediate(action: () => void): void;
  110382. /**
  110383. * Function indicating if a number is an exponent of 2
  110384. * @param value defines the value to test
  110385. * @returns true if the value is an exponent of 2
  110386. */
  110387. static IsExponentOfTwo(value: number): boolean;
  110388. private static _tmpFloatArray;
  110389. /**
  110390. * Returns the nearest 32-bit single precision float representation of a Number
  110391. * @param value A Number. If the parameter is of a different type, it will get converted
  110392. * to a number or to NaN if it cannot be converted
  110393. * @returns number
  110394. */
  110395. static FloatRound(value: number): number;
  110396. /**
  110397. * Extracts the filename from a path
  110398. * @param path defines the path to use
  110399. * @returns the filename
  110400. */
  110401. static GetFilename(path: string): string;
  110402. /**
  110403. * Extracts the "folder" part of a path (everything before the filename).
  110404. * @param uri The URI to extract the info from
  110405. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110406. * @returns The "folder" part of the path
  110407. */
  110408. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110409. /**
  110410. * Extracts text content from a DOM element hierarchy
  110411. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110412. */
  110413. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110414. /**
  110415. * Convert an angle in radians to degrees
  110416. * @param angle defines the angle to convert
  110417. * @returns the angle in degrees
  110418. */
  110419. static ToDegrees(angle: number): number;
  110420. /**
  110421. * Convert an angle in degrees to radians
  110422. * @param angle defines the angle to convert
  110423. * @returns the angle in radians
  110424. */
  110425. static ToRadians(angle: number): number;
  110426. /**
  110427. * Returns an array if obj is not an array
  110428. * @param obj defines the object to evaluate as an array
  110429. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110430. * @returns either obj directly if obj is an array or a new array containing obj
  110431. */
  110432. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110433. /**
  110434. * Gets the pointer prefix to use
  110435. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110436. */
  110437. static GetPointerPrefix(): string;
  110438. /**
  110439. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110440. * @param url define the url we are trying
  110441. * @param element define the dom element where to configure the cors policy
  110442. */
  110443. static SetCorsBehavior(url: string | string[], element: {
  110444. crossOrigin: string | null;
  110445. }): void;
  110446. /**
  110447. * Removes unwanted characters from an url
  110448. * @param url defines the url to clean
  110449. * @returns the cleaned url
  110450. */
  110451. static CleanUrl(url: string): string;
  110452. /**
  110453. * Gets or sets a function used to pre-process url before using them to load assets
  110454. */
  110455. static get PreprocessUrl(): (url: string) => string;
  110456. static set PreprocessUrl(processor: (url: string) => string);
  110457. /**
  110458. * Loads an image as an HTMLImageElement.
  110459. * @param input url string, ArrayBuffer, or Blob to load
  110460. * @param onLoad callback called when the image successfully loads
  110461. * @param onError callback called when the image fails to load
  110462. * @param offlineProvider offline provider for caching
  110463. * @param mimeType optional mime type
  110464. * @returns the HTMLImageElement of the loaded image
  110465. */
  110466. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110467. /**
  110468. * Loads a file from a url
  110469. * @param url url string, ArrayBuffer, or Blob to load
  110470. * @param onSuccess callback called when the file successfully loads
  110471. * @param onProgress callback called while file is loading (if the server supports this mode)
  110472. * @param offlineProvider defines the offline provider for caching
  110473. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110474. * @param onError callback called when the file fails to load
  110475. * @returns a file request object
  110476. */
  110477. 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;
  110478. /**
  110479. * Loads a file from a url
  110480. * @param url the file url to load
  110481. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110482. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110483. */
  110484. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110485. /**
  110486. * Load a script (identified by an url). When the url returns, the
  110487. * content of this file is added into a new script element, attached to the DOM (body element)
  110488. * @param scriptUrl defines the url of the script to laod
  110489. * @param onSuccess defines the callback called when the script is loaded
  110490. * @param onError defines the callback to call if an error occurs
  110491. * @param scriptId defines the id of the script element
  110492. */
  110493. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110494. /**
  110495. * Load an asynchronous script (identified by an url). When the url returns, the
  110496. * content of this file is added into a new script element, attached to the DOM (body element)
  110497. * @param scriptUrl defines the url of the script to laod
  110498. * @param scriptId defines the id of the script element
  110499. * @returns a promise request object
  110500. */
  110501. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110502. /**
  110503. * Loads a file from a blob
  110504. * @param fileToLoad defines the blob to use
  110505. * @param callback defines the callback to call when data is loaded
  110506. * @param progressCallback defines the callback to call during loading process
  110507. * @returns a file request object
  110508. */
  110509. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110510. /**
  110511. * Reads a file from a File object
  110512. * @param file defines the file to load
  110513. * @param onSuccess defines the callback to call when data is loaded
  110514. * @param onProgress defines the callback to call during loading process
  110515. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110516. * @param onError defines the callback to call when an error occurs
  110517. * @returns a file request object
  110518. */
  110519. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110520. /**
  110521. * Creates a data url from a given string content
  110522. * @param content defines the content to convert
  110523. * @returns the new data url link
  110524. */
  110525. static FileAsURL(content: string): string;
  110526. /**
  110527. * Format the given number to a specific decimal format
  110528. * @param value defines the number to format
  110529. * @param decimals defines the number of decimals to use
  110530. * @returns the formatted string
  110531. */
  110532. static Format(value: number, decimals?: number): string;
  110533. /**
  110534. * Tries to copy an object by duplicating every property
  110535. * @param source defines the source object
  110536. * @param destination defines the target object
  110537. * @param doNotCopyList defines a list of properties to avoid
  110538. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110539. */
  110540. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110541. /**
  110542. * Gets a boolean indicating if the given object has no own property
  110543. * @param obj defines the object to test
  110544. * @returns true if object has no own property
  110545. */
  110546. static IsEmpty(obj: any): boolean;
  110547. /**
  110548. * Function used to register events at window level
  110549. * @param windowElement defines the Window object to use
  110550. * @param events defines the events to register
  110551. */
  110552. static RegisterTopRootEvents(windowElement: Window, events: {
  110553. name: string;
  110554. handler: Nullable<(e: FocusEvent) => any>;
  110555. }[]): void;
  110556. /**
  110557. * Function used to unregister events from window level
  110558. * @param windowElement defines the Window object to use
  110559. * @param events defines the events to unregister
  110560. */
  110561. static UnregisterTopRootEvents(windowElement: Window, events: {
  110562. name: string;
  110563. handler: Nullable<(e: FocusEvent) => any>;
  110564. }[]): void;
  110565. /**
  110566. * @ignore
  110567. */
  110568. static _ScreenshotCanvas: HTMLCanvasElement;
  110569. /**
  110570. * Dumps the current bound framebuffer
  110571. * @param width defines the rendering width
  110572. * @param height defines the rendering height
  110573. * @param engine defines the hosting engine
  110574. * @param successCallback defines the callback triggered once the data are available
  110575. * @param mimeType defines the mime type of the result
  110576. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110577. */
  110578. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110579. /**
  110580. * Converts the canvas data to blob.
  110581. * This acts as a polyfill for browsers not supporting the to blob function.
  110582. * @param canvas Defines the canvas to extract the data from
  110583. * @param successCallback Defines the callback triggered once the data are available
  110584. * @param mimeType Defines the mime type of the result
  110585. */
  110586. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110587. /**
  110588. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110589. * @param successCallback defines the callback triggered once the data are available
  110590. * @param mimeType defines the mime type of the result
  110591. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110592. */
  110593. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110594. /**
  110595. * Downloads a blob in the browser
  110596. * @param blob defines the blob to download
  110597. * @param fileName defines the name of the downloaded file
  110598. */
  110599. static Download(blob: Blob, fileName: string): void;
  110600. /**
  110601. * Captures a screenshot of the current rendering
  110602. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110603. * @param engine defines the rendering engine
  110604. * @param camera defines the source camera
  110605. * @param size This parameter can be set to a single number or to an object with the
  110606. * following (optional) properties: precision, width, height. If a single number is passed,
  110607. * it will be used for both width and height. If an object is passed, the screenshot size
  110608. * will be derived from the parameters. The precision property is a multiplier allowing
  110609. * rendering at a higher or lower resolution
  110610. * @param successCallback defines the callback receives a single parameter which contains the
  110611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110612. * src parameter of an <img> to display it
  110613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110614. * Check your browser for supported MIME types
  110615. */
  110616. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110617. /**
  110618. * Captures a screenshot of the current rendering
  110619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110620. * @param engine defines the rendering engine
  110621. * @param camera defines the source camera
  110622. * @param size This parameter can be set to a single number or to an object with the
  110623. * following (optional) properties: precision, width, height. If a single number is passed,
  110624. * it will be used for both width and height. If an object is passed, the screenshot size
  110625. * will be derived from the parameters. The precision property is a multiplier allowing
  110626. * rendering at a higher or lower resolution
  110627. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110628. * Check your browser for supported MIME types
  110629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110630. * to the src parameter of an <img> to display it
  110631. */
  110632. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110633. /**
  110634. * Generates an image screenshot from the specified camera.
  110635. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110636. * @param engine The engine to use for rendering
  110637. * @param camera The camera to use for rendering
  110638. * @param size This parameter can be set to a single number or to an object with the
  110639. * following (optional) properties: precision, width, height. If a single number is passed,
  110640. * it will be used for both width and height. If an object is passed, the screenshot size
  110641. * will be derived from the parameters. The precision property is a multiplier allowing
  110642. * rendering at a higher or lower resolution
  110643. * @param successCallback The callback receives a single parameter which contains the
  110644. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110645. * src parameter of an <img> to display it
  110646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110647. * Check your browser for supported MIME types
  110648. * @param samples Texture samples (default: 1)
  110649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110650. * @param fileName A name for for the downloaded file.
  110651. */
  110652. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110653. /**
  110654. * Generates an image screenshot from the specified camera.
  110655. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110656. * @param engine The engine to use for rendering
  110657. * @param camera The camera to use for rendering
  110658. * @param size This parameter can be set to a single number or to an object with the
  110659. * following (optional) properties: precision, width, height. If a single number is passed,
  110660. * it will be used for both width and height. If an object is passed, the screenshot size
  110661. * will be derived from the parameters. The precision property is a multiplier allowing
  110662. * rendering at a higher or lower resolution
  110663. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110664. * Check your browser for supported MIME types
  110665. * @param samples Texture samples (default: 1)
  110666. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110667. * @param fileName A name for for the downloaded file.
  110668. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110669. * to the src parameter of an <img> to display it
  110670. */
  110671. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110672. /**
  110673. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110674. * Be aware Math.random() could cause collisions, but:
  110675. * "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"
  110676. * @returns a pseudo random id
  110677. */
  110678. static RandomId(): string;
  110679. /**
  110680. * Test if the given uri is a base64 string
  110681. * @param uri The uri to test
  110682. * @return True if the uri is a base64 string or false otherwise
  110683. */
  110684. static IsBase64(uri: string): boolean;
  110685. /**
  110686. * Decode the given base64 uri.
  110687. * @param uri The uri to decode
  110688. * @return The decoded base64 data.
  110689. */
  110690. static DecodeBase64(uri: string): ArrayBuffer;
  110691. /**
  110692. * Gets the absolute url.
  110693. * @param url the input url
  110694. * @return the absolute url
  110695. */
  110696. static GetAbsoluteUrl(url: string): string;
  110697. /**
  110698. * No log
  110699. */
  110700. static readonly NoneLogLevel: number;
  110701. /**
  110702. * Only message logs
  110703. */
  110704. static readonly MessageLogLevel: number;
  110705. /**
  110706. * Only warning logs
  110707. */
  110708. static readonly WarningLogLevel: number;
  110709. /**
  110710. * Only error logs
  110711. */
  110712. static readonly ErrorLogLevel: number;
  110713. /**
  110714. * All logs
  110715. */
  110716. static readonly AllLogLevel: number;
  110717. /**
  110718. * Gets a value indicating the number of loading errors
  110719. * @ignorenaming
  110720. */
  110721. static get errorsCount(): number;
  110722. /**
  110723. * Callback called when a new log is added
  110724. */
  110725. static OnNewCacheEntry: (entry: string) => void;
  110726. /**
  110727. * Log a message to the console
  110728. * @param message defines the message to log
  110729. */
  110730. static Log(message: string): void;
  110731. /**
  110732. * Write a warning message to the console
  110733. * @param message defines the message to log
  110734. */
  110735. static Warn(message: string): void;
  110736. /**
  110737. * Write an error message to the console
  110738. * @param message defines the message to log
  110739. */
  110740. static Error(message: string): void;
  110741. /**
  110742. * Gets current log cache (list of logs)
  110743. */
  110744. static get LogCache(): string;
  110745. /**
  110746. * Clears the log cache
  110747. */
  110748. static ClearLogCache(): void;
  110749. /**
  110750. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  110751. */
  110752. static set LogLevels(level: number);
  110753. /**
  110754. * Checks if the window object exists
  110755. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  110756. */
  110757. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  110758. /**
  110759. * No performance log
  110760. */
  110761. static readonly PerformanceNoneLogLevel: number;
  110762. /**
  110763. * Use user marks to log performance
  110764. */
  110765. static readonly PerformanceUserMarkLogLevel: number;
  110766. /**
  110767. * Log performance to the console
  110768. */
  110769. static readonly PerformanceConsoleLogLevel: number;
  110770. private static _performance;
  110771. /**
  110772. * Sets the current performance log level
  110773. */
  110774. static set PerformanceLogLevel(level: number);
  110775. private static _StartPerformanceCounterDisabled;
  110776. private static _EndPerformanceCounterDisabled;
  110777. private static _StartUserMark;
  110778. private static _EndUserMark;
  110779. private static _StartPerformanceConsole;
  110780. private static _EndPerformanceConsole;
  110781. /**
  110782. * Starts a performance counter
  110783. */
  110784. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110785. /**
  110786. * Ends a specific performance coutner
  110787. */
  110788. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110789. /**
  110790. * Gets either window.performance.now() if supported or Date.now() else
  110791. */
  110792. static get Now(): number;
  110793. /**
  110794. * This method will return the name of the class used to create the instance of the given object.
  110795. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  110796. * @param object the object to get the class name from
  110797. * @param isType defines if the object is actually a type
  110798. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  110799. */
  110800. static GetClassName(object: any, isType?: boolean): string;
  110801. /**
  110802. * Gets the first element of an array satisfying a given predicate
  110803. * @param array defines the array to browse
  110804. * @param predicate defines the predicate to use
  110805. * @returns null if not found or the element
  110806. */
  110807. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  110808. /**
  110809. * This method will return the name of the full name of the class, including its owning module (if any).
  110810. * 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).
  110811. * @param object the object to get the class name from
  110812. * @param isType defines if the object is actually a type
  110813. * @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.
  110814. * @ignorenaming
  110815. */
  110816. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  110817. /**
  110818. * Returns a promise that resolves after the given amount of time.
  110819. * @param delay Number of milliseconds to delay
  110820. * @returns Promise that resolves after the given amount of time
  110821. */
  110822. static DelayAsync(delay: number): Promise<void>;
  110823. /**
  110824. * Utility function to detect if the current user agent is Safari
  110825. * @returns whether or not the current user agent is safari
  110826. */
  110827. static IsSafari(): boolean;
  110828. }
  110829. /**
  110830. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  110831. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  110832. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  110833. * @param name The name of the class, case should be preserved
  110834. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  110835. */
  110836. export function className(name: string, module?: string): (target: Object) => void;
  110837. /**
  110838. * An implementation of a loop for asynchronous functions.
  110839. */
  110840. export class AsyncLoop {
  110841. /**
  110842. * Defines the number of iterations for the loop
  110843. */
  110844. iterations: number;
  110845. /**
  110846. * Defines the current index of the loop.
  110847. */
  110848. index: number;
  110849. private _done;
  110850. private _fn;
  110851. private _successCallback;
  110852. /**
  110853. * Constructor.
  110854. * @param iterations the number of iterations.
  110855. * @param func the function to run each iteration
  110856. * @param successCallback the callback that will be called upon succesful execution
  110857. * @param offset starting offset.
  110858. */
  110859. constructor(
  110860. /**
  110861. * Defines the number of iterations for the loop
  110862. */
  110863. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  110864. /**
  110865. * Execute the next iteration. Must be called after the last iteration was finished.
  110866. */
  110867. executeNext(): void;
  110868. /**
  110869. * Break the loop and run the success callback.
  110870. */
  110871. breakLoop(): void;
  110872. /**
  110873. * Create and run an async loop.
  110874. * @param iterations the number of iterations.
  110875. * @param fn the function to run each iteration
  110876. * @param successCallback the callback that will be called upon succesful execution
  110877. * @param offset starting offset.
  110878. * @returns the created async loop object
  110879. */
  110880. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  110881. /**
  110882. * A for-loop that will run a given number of iterations synchronous and the rest async.
  110883. * @param iterations total number of iterations
  110884. * @param syncedIterations number of synchronous iterations in each async iteration.
  110885. * @param fn the function to call each iteration.
  110886. * @param callback a success call back that will be called when iterating stops.
  110887. * @param breakFunction a break condition (optional)
  110888. * @param timeout timeout settings for the setTimeout function. default - 0.
  110889. * @returns the created async loop object
  110890. */
  110891. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  110892. }
  110893. }
  110894. declare module BABYLON {
  110895. /**
  110896. * This class implement a typical dictionary using a string as key and the generic type T as value.
  110897. * The underlying implementation relies on an associative array to ensure the best performances.
  110898. * The value can be anything including 'null' but except 'undefined'
  110899. */
  110900. export class StringDictionary<T> {
  110901. /**
  110902. * This will clear this dictionary and copy the content from the 'source' one.
  110903. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  110904. * @param source the dictionary to take the content from and copy to this dictionary
  110905. */
  110906. copyFrom(source: StringDictionary<T>): void;
  110907. /**
  110908. * Get a value based from its key
  110909. * @param key the given key to get the matching value from
  110910. * @return the value if found, otherwise undefined is returned
  110911. */
  110912. get(key: string): T | undefined;
  110913. /**
  110914. * Get a value from its key or add it if it doesn't exist.
  110915. * This method will ensure you that a given key/data will be present in the dictionary.
  110916. * @param key the given key to get the matching value from
  110917. * @param factory the factory that will create the value if the key is not present in the dictionary.
  110918. * The factory will only be invoked if there's no data for the given key.
  110919. * @return the value corresponding to the key.
  110920. */
  110921. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  110922. /**
  110923. * Get a value from its key if present in the dictionary otherwise add it
  110924. * @param key the key to get the value from
  110925. * @param val if there's no such key/value pair in the dictionary add it with this value
  110926. * @return the value corresponding to the key
  110927. */
  110928. getOrAdd(key: string, val: T): T;
  110929. /**
  110930. * Check if there's a given key in the dictionary
  110931. * @param key the key to check for
  110932. * @return true if the key is present, false otherwise
  110933. */
  110934. contains(key: string): boolean;
  110935. /**
  110936. * Add a new key and its corresponding value
  110937. * @param key the key to add
  110938. * @param value the value corresponding to the key
  110939. * @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
  110940. */
  110941. add(key: string, value: T): boolean;
  110942. /**
  110943. * Update a specific value associated to a key
  110944. * @param key defines the key to use
  110945. * @param value defines the value to store
  110946. * @returns true if the value was updated (or false if the key was not found)
  110947. */
  110948. set(key: string, value: T): boolean;
  110949. /**
  110950. * Get the element of the given key and remove it from the dictionary
  110951. * @param key defines the key to search
  110952. * @returns the value associated with the key or null if not found
  110953. */
  110954. getAndRemove(key: string): Nullable<T>;
  110955. /**
  110956. * Remove a key/value from the dictionary.
  110957. * @param key the key to remove
  110958. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  110959. */
  110960. remove(key: string): boolean;
  110961. /**
  110962. * Clear the whole content of the dictionary
  110963. */
  110964. clear(): void;
  110965. /**
  110966. * Gets the current count
  110967. */
  110968. get count(): number;
  110969. /**
  110970. * Execute a callback on each key/val of the dictionary.
  110971. * Note that you can remove any element in this dictionary in the callback implementation
  110972. * @param callback the callback to execute on a given key/value pair
  110973. */
  110974. forEach(callback: (key: string, val: T) => void): void;
  110975. /**
  110976. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  110977. * If the callback returns null or undefined the method will iterate to the next key/value pair
  110978. * Note that you can remove any element in this dictionary in the callback implementation
  110979. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  110980. * @returns the first item
  110981. */
  110982. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  110983. private _count;
  110984. private _data;
  110985. }
  110986. }
  110987. declare module BABYLON {
  110988. /** @hidden */
  110989. export interface ICollisionCoordinator {
  110990. createCollider(): Collider;
  110991. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  110992. init(scene: Scene): void;
  110993. }
  110994. /** @hidden */
  110995. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  110996. private _scene;
  110997. private _scaledPosition;
  110998. private _scaledVelocity;
  110999. private _finalPosition;
  111000. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  111001. createCollider(): Collider;
  111002. init(scene: Scene): void;
  111003. private _collideWithWorld;
  111004. }
  111005. }
  111006. declare module BABYLON {
  111007. /**
  111008. * Class used to manage all inputs for the scene.
  111009. */
  111010. export class InputManager {
  111011. /** The distance in pixel that you have to move to prevent some events */
  111012. static DragMovementThreshold: number;
  111013. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111014. static LongPressDelay: number;
  111015. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111016. static DoubleClickDelay: number;
  111017. /** If you need to check double click without raising a single click at first click, enable this flag */
  111018. static ExclusiveDoubleClickMode: boolean;
  111019. private _wheelEventName;
  111020. private _onPointerMove;
  111021. private _onPointerDown;
  111022. private _onPointerUp;
  111023. private _initClickEvent;
  111024. private _initActionManager;
  111025. private _delayedSimpleClick;
  111026. private _delayedSimpleClickTimeout;
  111027. private _previousDelayedSimpleClickTimeout;
  111028. private _meshPickProceed;
  111029. private _previousButtonPressed;
  111030. private _currentPickResult;
  111031. private _previousPickResult;
  111032. private _totalPointersPressed;
  111033. private _doubleClickOccured;
  111034. private _pointerOverMesh;
  111035. private _pickedDownMesh;
  111036. private _pickedUpMesh;
  111037. private _pointerX;
  111038. private _pointerY;
  111039. private _unTranslatedPointerX;
  111040. private _unTranslatedPointerY;
  111041. private _startingPointerPosition;
  111042. private _previousStartingPointerPosition;
  111043. private _startingPointerTime;
  111044. private _previousStartingPointerTime;
  111045. private _pointerCaptures;
  111046. private _onKeyDown;
  111047. private _onKeyUp;
  111048. private _onCanvasFocusObserver;
  111049. private _onCanvasBlurObserver;
  111050. private _scene;
  111051. /**
  111052. * Creates a new InputManager
  111053. * @param scene defines the hosting scene
  111054. */
  111055. constructor(scene: Scene);
  111056. /**
  111057. * Gets the mesh that is currently under the pointer
  111058. */
  111059. get meshUnderPointer(): Nullable<AbstractMesh>;
  111060. /**
  111061. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111062. */
  111063. get unTranslatedPointer(): Vector2;
  111064. /**
  111065. * Gets or sets the current on-screen X position of the pointer
  111066. */
  111067. get pointerX(): number;
  111068. set pointerX(value: number);
  111069. /**
  111070. * Gets or sets the current on-screen Y position of the pointer
  111071. */
  111072. get pointerY(): number;
  111073. set pointerY(value: number);
  111074. private _updatePointerPosition;
  111075. private _processPointerMove;
  111076. private _setRayOnPointerInfo;
  111077. private _checkPrePointerObservable;
  111078. /**
  111079. * Use this method to simulate a pointer move on a mesh
  111080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111083. */
  111084. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111085. /**
  111086. * Use this method to simulate a pointer down on a mesh
  111087. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111088. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111089. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111090. */
  111091. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111092. private _processPointerDown;
  111093. /** @hidden */
  111094. _isPointerSwiping(): boolean;
  111095. /**
  111096. * Use this method to simulate a pointer up on a mesh
  111097. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111098. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111099. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111100. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111101. */
  111102. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111103. private _processPointerUp;
  111104. /**
  111105. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111106. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111107. * @returns true if the pointer was captured
  111108. */
  111109. isPointerCaptured(pointerId?: number): boolean;
  111110. /**
  111111. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111112. * @param attachUp defines if you want to attach events to pointerup
  111113. * @param attachDown defines if you want to attach events to pointerdown
  111114. * @param attachMove defines if you want to attach events to pointermove
  111115. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111116. */
  111117. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111118. /**
  111119. * Detaches all event handlers
  111120. */
  111121. detachControl(): void;
  111122. /**
  111123. * Force the value of meshUnderPointer
  111124. * @param mesh defines the mesh to use
  111125. */
  111126. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111127. /**
  111128. * Gets the mesh under the pointer
  111129. * @returns a Mesh or null if no mesh is under the pointer
  111130. */
  111131. getPointerOverMesh(): Nullable<AbstractMesh>;
  111132. }
  111133. }
  111134. declare module BABYLON {
  111135. /**
  111136. * Helper class used to generate session unique ID
  111137. */
  111138. export class UniqueIdGenerator {
  111139. private static _UniqueIdCounter;
  111140. /**
  111141. * Gets an unique (relatively to the current scene) Id
  111142. */
  111143. static get UniqueId(): number;
  111144. }
  111145. }
  111146. declare module BABYLON {
  111147. /**
  111148. * This class defines the direct association between an animation and a target
  111149. */
  111150. export class TargetedAnimation {
  111151. /**
  111152. * Animation to perform
  111153. */
  111154. animation: Animation;
  111155. /**
  111156. * Target to animate
  111157. */
  111158. target: any;
  111159. /**
  111160. * Serialize the object
  111161. * @returns the JSON object representing the current entity
  111162. */
  111163. serialize(): any;
  111164. }
  111165. /**
  111166. * Use this class to create coordinated animations on multiple targets
  111167. */
  111168. export class AnimationGroup implements IDisposable {
  111169. /** The name of the animation group */
  111170. name: string;
  111171. private _scene;
  111172. private _targetedAnimations;
  111173. private _animatables;
  111174. private _from;
  111175. private _to;
  111176. private _isStarted;
  111177. private _isPaused;
  111178. private _speedRatio;
  111179. private _loopAnimation;
  111180. private _isAdditive;
  111181. /**
  111182. * Gets or sets the unique id of the node
  111183. */
  111184. uniqueId: number;
  111185. /**
  111186. * This observable will notify when one animation have ended
  111187. */
  111188. onAnimationEndObservable: Observable<TargetedAnimation>;
  111189. /**
  111190. * Observer raised when one animation loops
  111191. */
  111192. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111193. /**
  111194. * Observer raised when all animations have looped
  111195. */
  111196. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111197. /**
  111198. * This observable will notify when all animations have ended.
  111199. */
  111200. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111201. /**
  111202. * This observable will notify when all animations have paused.
  111203. */
  111204. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111205. /**
  111206. * This observable will notify when all animations are playing.
  111207. */
  111208. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111209. /**
  111210. * Gets the first frame
  111211. */
  111212. get from(): number;
  111213. /**
  111214. * Gets the last frame
  111215. */
  111216. get to(): number;
  111217. /**
  111218. * Define if the animations are started
  111219. */
  111220. get isStarted(): boolean;
  111221. /**
  111222. * Gets a value indicating that the current group is playing
  111223. */
  111224. get isPlaying(): boolean;
  111225. /**
  111226. * Gets or sets the speed ratio to use for all animations
  111227. */
  111228. get speedRatio(): number;
  111229. /**
  111230. * Gets or sets the speed ratio to use for all animations
  111231. */
  111232. set speedRatio(value: number);
  111233. /**
  111234. * Gets or sets if all animations should loop or not
  111235. */
  111236. get loopAnimation(): boolean;
  111237. set loopAnimation(value: boolean);
  111238. /**
  111239. * Gets or sets if all animations should be evaluated additively
  111240. */
  111241. get isAdditive(): boolean;
  111242. set isAdditive(value: boolean);
  111243. /**
  111244. * Gets the targeted animations for this animation group
  111245. */
  111246. get targetedAnimations(): Array<TargetedAnimation>;
  111247. /**
  111248. * returning the list of animatables controlled by this animation group.
  111249. */
  111250. get animatables(): Array<Animatable>;
  111251. /**
  111252. * Instantiates a new Animation Group.
  111253. * This helps managing several animations at once.
  111254. * @see http://doc.babylonjs.com/how_to/group
  111255. * @param name Defines the name of the group
  111256. * @param scene Defines the scene the group belongs to
  111257. */
  111258. constructor(
  111259. /** The name of the animation group */
  111260. name: string, scene?: Nullable<Scene>);
  111261. /**
  111262. * Add an animation (with its target) in the group
  111263. * @param animation defines the animation we want to add
  111264. * @param target defines the target of the animation
  111265. * @returns the TargetedAnimation object
  111266. */
  111267. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111268. /**
  111269. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111270. * It can add constant keys at begin or end
  111271. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111272. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111273. * @returns the animation group
  111274. */
  111275. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111276. private _animationLoopCount;
  111277. private _animationLoopFlags;
  111278. private _processLoop;
  111279. /**
  111280. * Start all animations on given targets
  111281. * @param loop defines if animations must loop
  111282. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111283. * @param from defines the from key (optional)
  111284. * @param to defines the to key (optional)
  111285. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111286. * @returns the current animation group
  111287. */
  111288. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111289. /**
  111290. * Pause all animations
  111291. * @returns the animation group
  111292. */
  111293. pause(): AnimationGroup;
  111294. /**
  111295. * Play all animations to initial state
  111296. * This function will start() the animations if they were not started or will restart() them if they were paused
  111297. * @param loop defines if animations must loop
  111298. * @returns the animation group
  111299. */
  111300. play(loop?: boolean): AnimationGroup;
  111301. /**
  111302. * Reset all animations to initial state
  111303. * @returns the animation group
  111304. */
  111305. reset(): AnimationGroup;
  111306. /**
  111307. * Restart animations from key 0
  111308. * @returns the animation group
  111309. */
  111310. restart(): AnimationGroup;
  111311. /**
  111312. * Stop all animations
  111313. * @returns the animation group
  111314. */
  111315. stop(): AnimationGroup;
  111316. /**
  111317. * Set animation weight for all animatables
  111318. * @param weight defines the weight to use
  111319. * @return the animationGroup
  111320. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111321. */
  111322. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111323. /**
  111324. * Synchronize and normalize all animatables with a source animatable
  111325. * @param root defines the root animatable to synchronize with
  111326. * @return the animationGroup
  111327. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111328. */
  111329. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111330. /**
  111331. * Goes to a specific frame in this animation group
  111332. * @param frame the frame number to go to
  111333. * @return the animationGroup
  111334. */
  111335. goToFrame(frame: number): AnimationGroup;
  111336. /**
  111337. * Dispose all associated resources
  111338. */
  111339. dispose(): void;
  111340. private _checkAnimationGroupEnded;
  111341. /**
  111342. * Clone the current animation group and returns a copy
  111343. * @param newName defines the name of the new group
  111344. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111345. * @returns the new aniamtion group
  111346. */
  111347. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111348. /**
  111349. * Serializes the animationGroup to an object
  111350. * @returns Serialized object
  111351. */
  111352. serialize(): any;
  111353. /**
  111354. * Returns a new AnimationGroup object parsed from the source provided.
  111355. * @param parsedAnimationGroup defines the source
  111356. * @param scene defines the scene that will receive the animationGroup
  111357. * @returns a new AnimationGroup
  111358. */
  111359. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111360. /**
  111361. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111362. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111363. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111364. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111365. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111366. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111367. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111368. */
  111369. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111370. /**
  111371. * Returns the string "AnimationGroup"
  111372. * @returns "AnimationGroup"
  111373. */
  111374. getClassName(): string;
  111375. /**
  111376. * Creates a detailled string about the object
  111377. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111378. * @returns a string representing the object
  111379. */
  111380. toString(fullDetails?: boolean): string;
  111381. }
  111382. }
  111383. declare module BABYLON {
  111384. /**
  111385. * Define an interface for all classes that will hold resources
  111386. */
  111387. export interface IDisposable {
  111388. /**
  111389. * Releases all held resources
  111390. */
  111391. dispose(): void;
  111392. }
  111393. /** Interface defining initialization parameters for Scene class */
  111394. export interface SceneOptions {
  111395. /**
  111396. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111397. * It will improve performance when the number of geometries becomes important.
  111398. */
  111399. useGeometryUniqueIdsMap?: boolean;
  111400. /**
  111401. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111402. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111403. */
  111404. useMaterialMeshMap?: boolean;
  111405. /**
  111406. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111407. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111408. */
  111409. useClonedMeshMap?: boolean;
  111410. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111411. virtual?: boolean;
  111412. }
  111413. /**
  111414. * Represents a scene to be rendered by the engine.
  111415. * @see http://doc.babylonjs.com/features/scene
  111416. */
  111417. export class Scene extends AbstractScene implements IAnimatable {
  111418. /** The fog is deactivated */
  111419. static readonly FOGMODE_NONE: number;
  111420. /** The fog density is following an exponential function */
  111421. static readonly FOGMODE_EXP: number;
  111422. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111423. static readonly FOGMODE_EXP2: number;
  111424. /** The fog density is following a linear function. */
  111425. static readonly FOGMODE_LINEAR: number;
  111426. /**
  111427. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111429. */
  111430. static MinDeltaTime: number;
  111431. /**
  111432. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111434. */
  111435. static MaxDeltaTime: number;
  111436. /**
  111437. * Factory used to create the default material.
  111438. * @param name The name of the material to create
  111439. * @param scene The scene to create the material for
  111440. * @returns The default material
  111441. */
  111442. static DefaultMaterialFactory(scene: Scene): Material;
  111443. /**
  111444. * Factory used to create the a collision coordinator.
  111445. * @returns The collision coordinator
  111446. */
  111447. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111448. /** @hidden */
  111449. _inputManager: InputManager;
  111450. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111451. cameraToUseForPointers: Nullable<Camera>;
  111452. /** @hidden */
  111453. readonly _isScene: boolean;
  111454. /** @hidden */
  111455. _blockEntityCollection: boolean;
  111456. /**
  111457. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111458. */
  111459. autoClear: boolean;
  111460. /**
  111461. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111462. */
  111463. autoClearDepthAndStencil: boolean;
  111464. /**
  111465. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111466. */
  111467. clearColor: Color4;
  111468. /**
  111469. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111470. */
  111471. ambientColor: Color3;
  111472. /**
  111473. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111474. * It should only be one of the following (if not the default embedded one):
  111475. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111476. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111477. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111478. * The material properties need to be setup according to the type of texture in use.
  111479. */
  111480. environmentBRDFTexture: BaseTexture;
  111481. /** @hidden */
  111482. protected _environmentTexture: Nullable<BaseTexture>;
  111483. /**
  111484. * Texture used in all pbr material as the reflection texture.
  111485. * As in the majority of the scene they are the same (exception for multi room and so on),
  111486. * this is easier to reference from here than from all the materials.
  111487. */
  111488. get environmentTexture(): Nullable<BaseTexture>;
  111489. /**
  111490. * Texture used in all pbr material as the reflection texture.
  111491. * As in the majority of the scene they are the same (exception for multi room and so on),
  111492. * this is easier to set here than in all the materials.
  111493. */
  111494. set environmentTexture(value: Nullable<BaseTexture>);
  111495. /** @hidden */
  111496. protected _environmentIntensity: number;
  111497. /**
  111498. * Intensity of the environment in all pbr material.
  111499. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111500. * As in the majority of the scene they are the same (exception for multi room and so on),
  111501. * this is easier to reference from here than from all the materials.
  111502. */
  111503. get environmentIntensity(): number;
  111504. /**
  111505. * Intensity of the environment in all pbr material.
  111506. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111507. * As in the majority of the scene they are the same (exception for multi room and so on),
  111508. * this is easier to set here than in all the materials.
  111509. */
  111510. set environmentIntensity(value: number);
  111511. /** @hidden */
  111512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111513. /**
  111514. * Default image processing configuration used either in the rendering
  111515. * Forward main pass or through the imageProcessingPostProcess if present.
  111516. * As in the majority of the scene they are the same (exception for multi camera),
  111517. * this is easier to reference from here than from all the materials and post process.
  111518. *
  111519. * No setter as we it is a shared configuration, you can set the values instead.
  111520. */
  111521. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111522. private _forceWireframe;
  111523. /**
  111524. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111525. */
  111526. set forceWireframe(value: boolean);
  111527. get forceWireframe(): boolean;
  111528. private _skipFrustumClipping;
  111529. /**
  111530. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111531. */
  111532. set skipFrustumClipping(value: boolean);
  111533. get skipFrustumClipping(): boolean;
  111534. private _forcePointsCloud;
  111535. /**
  111536. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111537. */
  111538. set forcePointsCloud(value: boolean);
  111539. get forcePointsCloud(): boolean;
  111540. /**
  111541. * Gets or sets the active clipplane 1
  111542. */
  111543. clipPlane: Nullable<Plane>;
  111544. /**
  111545. * Gets or sets the active clipplane 2
  111546. */
  111547. clipPlane2: Nullable<Plane>;
  111548. /**
  111549. * Gets or sets the active clipplane 3
  111550. */
  111551. clipPlane3: Nullable<Plane>;
  111552. /**
  111553. * Gets or sets the active clipplane 4
  111554. */
  111555. clipPlane4: Nullable<Plane>;
  111556. /**
  111557. * Gets or sets the active clipplane 5
  111558. */
  111559. clipPlane5: Nullable<Plane>;
  111560. /**
  111561. * Gets or sets the active clipplane 6
  111562. */
  111563. clipPlane6: Nullable<Plane>;
  111564. /**
  111565. * Gets or sets a boolean indicating if animations are enabled
  111566. */
  111567. animationsEnabled: boolean;
  111568. private _animationPropertiesOverride;
  111569. /**
  111570. * Gets or sets the animation properties override
  111571. */
  111572. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111573. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111574. /**
  111575. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111576. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111577. */
  111578. useConstantAnimationDeltaTime: boolean;
  111579. /**
  111580. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111581. * Please note that it requires to run a ray cast through the scene on every frame
  111582. */
  111583. constantlyUpdateMeshUnderPointer: boolean;
  111584. /**
  111585. * Defines the HTML cursor to use when hovering over interactive elements
  111586. */
  111587. hoverCursor: string;
  111588. /**
  111589. * Defines the HTML default cursor to use (empty by default)
  111590. */
  111591. defaultCursor: string;
  111592. /**
  111593. * Defines whether cursors are handled by the scene.
  111594. */
  111595. doNotHandleCursors: boolean;
  111596. /**
  111597. * This is used to call preventDefault() on pointer down
  111598. * in order to block unwanted artifacts like system double clicks
  111599. */
  111600. preventDefaultOnPointerDown: boolean;
  111601. /**
  111602. * This is used to call preventDefault() on pointer up
  111603. * in order to block unwanted artifacts like system double clicks
  111604. */
  111605. preventDefaultOnPointerUp: boolean;
  111606. /**
  111607. * Gets or sets user defined metadata
  111608. */
  111609. metadata: any;
  111610. /**
  111611. * For internal use only. Please do not use.
  111612. */
  111613. reservedDataStore: any;
  111614. /**
  111615. * Gets the name of the plugin used to load this scene (null by default)
  111616. */
  111617. loadingPluginName: string;
  111618. /**
  111619. * Use this array to add regular expressions used to disable offline support for specific urls
  111620. */
  111621. disableOfflineSupportExceptionRules: RegExp[];
  111622. /**
  111623. * An event triggered when the scene is disposed.
  111624. */
  111625. onDisposeObservable: Observable<Scene>;
  111626. private _onDisposeObserver;
  111627. /** Sets a function to be executed when this scene is disposed. */
  111628. set onDispose(callback: () => void);
  111629. /**
  111630. * An event triggered before rendering the scene (right after animations and physics)
  111631. */
  111632. onBeforeRenderObservable: Observable<Scene>;
  111633. private _onBeforeRenderObserver;
  111634. /** Sets a function to be executed before rendering this scene */
  111635. set beforeRender(callback: Nullable<() => void>);
  111636. /**
  111637. * An event triggered after rendering the scene
  111638. */
  111639. onAfterRenderObservable: Observable<Scene>;
  111640. /**
  111641. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111642. */
  111643. onAfterRenderCameraObservable: Observable<Camera>;
  111644. private _onAfterRenderObserver;
  111645. /** Sets a function to be executed after rendering this scene */
  111646. set afterRender(callback: Nullable<() => void>);
  111647. /**
  111648. * An event triggered before animating the scene
  111649. */
  111650. onBeforeAnimationsObservable: Observable<Scene>;
  111651. /**
  111652. * An event triggered after animations processing
  111653. */
  111654. onAfterAnimationsObservable: Observable<Scene>;
  111655. /**
  111656. * An event triggered before draw calls are ready to be sent
  111657. */
  111658. onBeforeDrawPhaseObservable: Observable<Scene>;
  111659. /**
  111660. * An event triggered after draw calls have been sent
  111661. */
  111662. onAfterDrawPhaseObservable: Observable<Scene>;
  111663. /**
  111664. * An event triggered when the scene is ready
  111665. */
  111666. onReadyObservable: Observable<Scene>;
  111667. /**
  111668. * An event triggered before rendering a camera
  111669. */
  111670. onBeforeCameraRenderObservable: Observable<Camera>;
  111671. private _onBeforeCameraRenderObserver;
  111672. /** Sets a function to be executed before rendering a camera*/
  111673. set beforeCameraRender(callback: () => void);
  111674. /**
  111675. * An event triggered after rendering a camera
  111676. */
  111677. onAfterCameraRenderObservable: Observable<Camera>;
  111678. private _onAfterCameraRenderObserver;
  111679. /** Sets a function to be executed after rendering a camera*/
  111680. set afterCameraRender(callback: () => void);
  111681. /**
  111682. * An event triggered when active meshes evaluation is about to start
  111683. */
  111684. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111685. /**
  111686. * An event triggered when active meshes evaluation is done
  111687. */
  111688. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111689. /**
  111690. * An event triggered when particles rendering is about to start
  111691. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111692. */
  111693. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111694. /**
  111695. * An event triggered when particles rendering is done
  111696. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111697. */
  111698. onAfterParticlesRenderingObservable: Observable<Scene>;
  111699. /**
  111700. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111701. */
  111702. onDataLoadedObservable: Observable<Scene>;
  111703. /**
  111704. * An event triggered when a camera is created
  111705. */
  111706. onNewCameraAddedObservable: Observable<Camera>;
  111707. /**
  111708. * An event triggered when a camera is removed
  111709. */
  111710. onCameraRemovedObservable: Observable<Camera>;
  111711. /**
  111712. * An event triggered when a light is created
  111713. */
  111714. onNewLightAddedObservable: Observable<Light>;
  111715. /**
  111716. * An event triggered when a light is removed
  111717. */
  111718. onLightRemovedObservable: Observable<Light>;
  111719. /**
  111720. * An event triggered when a geometry is created
  111721. */
  111722. onNewGeometryAddedObservable: Observable<Geometry>;
  111723. /**
  111724. * An event triggered when a geometry is removed
  111725. */
  111726. onGeometryRemovedObservable: Observable<Geometry>;
  111727. /**
  111728. * An event triggered when a transform node is created
  111729. */
  111730. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  111731. /**
  111732. * An event triggered when a transform node is removed
  111733. */
  111734. onTransformNodeRemovedObservable: Observable<TransformNode>;
  111735. /**
  111736. * An event triggered when a mesh is created
  111737. */
  111738. onNewMeshAddedObservable: Observable<AbstractMesh>;
  111739. /**
  111740. * An event triggered when a mesh is removed
  111741. */
  111742. onMeshRemovedObservable: Observable<AbstractMesh>;
  111743. /**
  111744. * An event triggered when a skeleton is created
  111745. */
  111746. onNewSkeletonAddedObservable: Observable<Skeleton>;
  111747. /**
  111748. * An event triggered when a skeleton is removed
  111749. */
  111750. onSkeletonRemovedObservable: Observable<Skeleton>;
  111751. /**
  111752. * An event triggered when a material is created
  111753. */
  111754. onNewMaterialAddedObservable: Observable<Material>;
  111755. /**
  111756. * An event triggered when a material is removed
  111757. */
  111758. onMaterialRemovedObservable: Observable<Material>;
  111759. /**
  111760. * An event triggered when a texture is created
  111761. */
  111762. onNewTextureAddedObservable: Observable<BaseTexture>;
  111763. /**
  111764. * An event triggered when a texture is removed
  111765. */
  111766. onTextureRemovedObservable: Observable<BaseTexture>;
  111767. /**
  111768. * An event triggered when render targets are about to be rendered
  111769. * Can happen multiple times per frame.
  111770. */
  111771. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  111772. /**
  111773. * An event triggered when render targets were rendered.
  111774. * Can happen multiple times per frame.
  111775. */
  111776. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  111777. /**
  111778. * An event triggered before calculating deterministic simulation step
  111779. */
  111780. onBeforeStepObservable: Observable<Scene>;
  111781. /**
  111782. * An event triggered after calculating deterministic simulation step
  111783. */
  111784. onAfterStepObservable: Observable<Scene>;
  111785. /**
  111786. * An event triggered when the activeCamera property is updated
  111787. */
  111788. onActiveCameraChanged: Observable<Scene>;
  111789. /**
  111790. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  111791. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111792. * 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)
  111793. */
  111794. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111795. /**
  111796. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  111797. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111798. * 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)
  111799. */
  111800. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111801. /**
  111802. * This Observable will when a mesh has been imported into the scene.
  111803. */
  111804. onMeshImportedObservable: Observable<AbstractMesh>;
  111805. /**
  111806. * This Observable will when an animation file has been imported into the scene.
  111807. */
  111808. onAnimationFileImportedObservable: Observable<Scene>;
  111809. /**
  111810. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  111811. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  111812. */
  111813. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  111814. /** @hidden */
  111815. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  111816. /**
  111817. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  111818. */
  111819. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  111820. /**
  111821. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  111822. */
  111823. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  111824. /**
  111825. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  111826. */
  111827. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  111828. /** Callback called when a pointer move is detected */
  111829. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111830. /** Callback called when a pointer down is detected */
  111831. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111832. /** Callback called when a pointer up is detected */
  111833. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  111834. /** Callback called when a pointer pick is detected */
  111835. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  111836. /**
  111837. * 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).
  111838. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  111839. */
  111840. onPrePointerObservable: Observable<PointerInfoPre>;
  111841. /**
  111842. * Observable event triggered each time an input event is received from the rendering canvas
  111843. */
  111844. onPointerObservable: Observable<PointerInfo>;
  111845. /**
  111846. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  111847. */
  111848. get unTranslatedPointer(): Vector2;
  111849. /**
  111850. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  111851. */
  111852. static get DragMovementThreshold(): number;
  111853. static set DragMovementThreshold(value: number);
  111854. /**
  111855. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  111856. */
  111857. static get LongPressDelay(): number;
  111858. static set LongPressDelay(value: number);
  111859. /**
  111860. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  111861. */
  111862. static get DoubleClickDelay(): number;
  111863. static set DoubleClickDelay(value: number);
  111864. /** If you need to check double click without raising a single click at first click, enable this flag */
  111865. static get ExclusiveDoubleClickMode(): boolean;
  111866. static set ExclusiveDoubleClickMode(value: boolean);
  111867. /** @hidden */
  111868. _mirroredCameraPosition: Nullable<Vector3>;
  111869. /**
  111870. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  111871. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  111872. */
  111873. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  111874. /**
  111875. * Observable event triggered each time an keyboard event is received from the hosting window
  111876. */
  111877. onKeyboardObservable: Observable<KeyboardInfo>;
  111878. private _useRightHandedSystem;
  111879. /**
  111880. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  111881. */
  111882. set useRightHandedSystem(value: boolean);
  111883. get useRightHandedSystem(): boolean;
  111884. private _timeAccumulator;
  111885. private _currentStepId;
  111886. private _currentInternalStep;
  111887. /**
  111888. * Sets the step Id used by deterministic lock step
  111889. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111890. * @param newStepId defines the step Id
  111891. */
  111892. setStepId(newStepId: number): void;
  111893. /**
  111894. * Gets the step Id used by deterministic lock step
  111895. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111896. * @returns the step Id
  111897. */
  111898. getStepId(): number;
  111899. /**
  111900. * Gets the internal step used by deterministic lock step
  111901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111902. * @returns the internal step
  111903. */
  111904. getInternalStep(): number;
  111905. private _fogEnabled;
  111906. /**
  111907. * Gets or sets a boolean indicating if fog is enabled on this scene
  111908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111909. * (Default is true)
  111910. */
  111911. set fogEnabled(value: boolean);
  111912. get fogEnabled(): boolean;
  111913. private _fogMode;
  111914. /**
  111915. * Gets or sets the fog mode to use
  111916. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111917. * | mode | value |
  111918. * | --- | --- |
  111919. * | FOGMODE_NONE | 0 |
  111920. * | FOGMODE_EXP | 1 |
  111921. * | FOGMODE_EXP2 | 2 |
  111922. * | FOGMODE_LINEAR | 3 |
  111923. */
  111924. set fogMode(value: number);
  111925. get fogMode(): number;
  111926. /**
  111927. * Gets or sets the fog color to use
  111928. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111929. * (Default is Color3(0.2, 0.2, 0.3))
  111930. */
  111931. fogColor: Color3;
  111932. /**
  111933. * Gets or sets the fog density to use
  111934. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111935. * (Default is 0.1)
  111936. */
  111937. fogDensity: number;
  111938. /**
  111939. * Gets or sets the fog start distance to use
  111940. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111941. * (Default is 0)
  111942. */
  111943. fogStart: number;
  111944. /**
  111945. * Gets or sets the fog end distance to use
  111946. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111947. * (Default is 1000)
  111948. */
  111949. fogEnd: number;
  111950. private _shadowsEnabled;
  111951. /**
  111952. * Gets or sets a boolean indicating if shadows are enabled on this scene
  111953. */
  111954. set shadowsEnabled(value: boolean);
  111955. get shadowsEnabled(): boolean;
  111956. private _lightsEnabled;
  111957. /**
  111958. * Gets or sets a boolean indicating if lights are enabled on this scene
  111959. */
  111960. set lightsEnabled(value: boolean);
  111961. get lightsEnabled(): boolean;
  111962. /** All of the active cameras added to this scene. */
  111963. activeCameras: Camera[];
  111964. /** @hidden */
  111965. _activeCamera: Nullable<Camera>;
  111966. /** Gets or sets the current active camera */
  111967. get activeCamera(): Nullable<Camera>;
  111968. set activeCamera(value: Nullable<Camera>);
  111969. private _defaultMaterial;
  111970. /** The default material used on meshes when no material is affected */
  111971. get defaultMaterial(): Material;
  111972. /** The default material used on meshes when no material is affected */
  111973. set defaultMaterial(value: Material);
  111974. private _texturesEnabled;
  111975. /**
  111976. * Gets or sets a boolean indicating if textures are enabled on this scene
  111977. */
  111978. set texturesEnabled(value: boolean);
  111979. get texturesEnabled(): boolean;
  111980. /**
  111981. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  111982. */
  111983. physicsEnabled: boolean;
  111984. /**
  111985. * Gets or sets a boolean indicating if particles are enabled on this scene
  111986. */
  111987. particlesEnabled: boolean;
  111988. /**
  111989. * Gets or sets a boolean indicating if sprites are enabled on this scene
  111990. */
  111991. spritesEnabled: boolean;
  111992. private _skeletonsEnabled;
  111993. /**
  111994. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  111995. */
  111996. set skeletonsEnabled(value: boolean);
  111997. get skeletonsEnabled(): boolean;
  111998. /**
  111999. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  112000. */
  112001. lensFlaresEnabled: boolean;
  112002. /**
  112003. * Gets or sets a boolean indicating if collisions are enabled on this scene
  112004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112005. */
  112006. collisionsEnabled: boolean;
  112007. private _collisionCoordinator;
  112008. /** @hidden */
  112009. get collisionCoordinator(): ICollisionCoordinator;
  112010. /**
  112011. * Defines the gravity applied to this scene (used only for collisions)
  112012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112013. */
  112014. gravity: Vector3;
  112015. /**
  112016. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112017. */
  112018. postProcessesEnabled: boolean;
  112019. /**
  112020. * The list of postprocesses added to the scene
  112021. */
  112022. postProcesses: PostProcess[];
  112023. /**
  112024. * Gets the current postprocess manager
  112025. */
  112026. postProcessManager: PostProcessManager;
  112027. /**
  112028. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112029. */
  112030. renderTargetsEnabled: boolean;
  112031. /**
  112032. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112033. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112034. */
  112035. dumpNextRenderTargets: boolean;
  112036. /**
  112037. * The list of user defined render targets added to the scene
  112038. */
  112039. customRenderTargets: RenderTargetTexture[];
  112040. /**
  112041. * Defines if texture loading must be delayed
  112042. * If true, textures will only be loaded when they need to be rendered
  112043. */
  112044. useDelayedTextureLoading: boolean;
  112045. /**
  112046. * Gets the list of meshes imported to the scene through SceneLoader
  112047. */
  112048. importedMeshesFiles: String[];
  112049. /**
  112050. * Gets or sets a boolean indicating if probes are enabled on this scene
  112051. */
  112052. probesEnabled: boolean;
  112053. /**
  112054. * Gets or sets the current offline provider to use to store scene data
  112055. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112056. */
  112057. offlineProvider: IOfflineProvider;
  112058. /**
  112059. * Gets or sets the action manager associated with the scene
  112060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112061. */
  112062. actionManager: AbstractActionManager;
  112063. private _meshesForIntersections;
  112064. /**
  112065. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112066. */
  112067. proceduralTexturesEnabled: boolean;
  112068. private _engine;
  112069. private _totalVertices;
  112070. /** @hidden */
  112071. _activeIndices: PerfCounter;
  112072. /** @hidden */
  112073. _activeParticles: PerfCounter;
  112074. /** @hidden */
  112075. _activeBones: PerfCounter;
  112076. private _animationRatio;
  112077. /** @hidden */
  112078. _animationTimeLast: number;
  112079. /** @hidden */
  112080. _animationTime: number;
  112081. /**
  112082. * Gets or sets a general scale for animation speed
  112083. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112084. */
  112085. animationTimeScale: number;
  112086. /** @hidden */
  112087. _cachedMaterial: Nullable<Material>;
  112088. /** @hidden */
  112089. _cachedEffect: Nullable<Effect>;
  112090. /** @hidden */
  112091. _cachedVisibility: Nullable<number>;
  112092. private _renderId;
  112093. private _frameId;
  112094. private _executeWhenReadyTimeoutId;
  112095. private _intermediateRendering;
  112096. private _viewUpdateFlag;
  112097. private _projectionUpdateFlag;
  112098. /** @hidden */
  112099. _toBeDisposed: Nullable<IDisposable>[];
  112100. private _activeRequests;
  112101. /** @hidden */
  112102. _pendingData: any[];
  112103. private _isDisposed;
  112104. /**
  112105. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112106. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112107. */
  112108. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112109. private _activeMeshes;
  112110. private _processedMaterials;
  112111. private _renderTargets;
  112112. /** @hidden */
  112113. _activeParticleSystems: SmartArray<IParticleSystem>;
  112114. private _activeSkeletons;
  112115. private _softwareSkinnedMeshes;
  112116. private _renderingManager;
  112117. /** @hidden */
  112118. _activeAnimatables: Animatable[];
  112119. private _transformMatrix;
  112120. private _sceneUbo;
  112121. /** @hidden */
  112122. _viewMatrix: Matrix;
  112123. private _projectionMatrix;
  112124. /** @hidden */
  112125. _forcedViewPosition: Nullable<Vector3>;
  112126. /** @hidden */
  112127. _frustumPlanes: Plane[];
  112128. /**
  112129. * Gets the list of frustum planes (built from the active camera)
  112130. */
  112131. get frustumPlanes(): Plane[];
  112132. /**
  112133. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112134. * This is useful if there are more lights that the maximum simulteanous authorized
  112135. */
  112136. requireLightSorting: boolean;
  112137. /** @hidden */
  112138. readonly useMaterialMeshMap: boolean;
  112139. /** @hidden */
  112140. readonly useClonedMeshMap: boolean;
  112141. private _externalData;
  112142. private _uid;
  112143. /**
  112144. * @hidden
  112145. * Backing store of defined scene components.
  112146. */
  112147. _components: ISceneComponent[];
  112148. /**
  112149. * @hidden
  112150. * Backing store of defined scene components.
  112151. */
  112152. _serializableComponents: ISceneSerializableComponent[];
  112153. /**
  112154. * List of components to register on the next registration step.
  112155. */
  112156. private _transientComponents;
  112157. /**
  112158. * Registers the transient components if needed.
  112159. */
  112160. private _registerTransientComponents;
  112161. /**
  112162. * @hidden
  112163. * Add a component to the scene.
  112164. * Note that the ccomponent could be registered on th next frame if this is called after
  112165. * the register component stage.
  112166. * @param component Defines the component to add to the scene
  112167. */
  112168. _addComponent(component: ISceneComponent): void;
  112169. /**
  112170. * @hidden
  112171. * Gets a component from the scene.
  112172. * @param name defines the name of the component to retrieve
  112173. * @returns the component or null if not present
  112174. */
  112175. _getComponent(name: string): Nullable<ISceneComponent>;
  112176. /**
  112177. * @hidden
  112178. * Defines the actions happening before camera updates.
  112179. */
  112180. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112181. /**
  112182. * @hidden
  112183. * Defines the actions happening before clear the canvas.
  112184. */
  112185. _beforeClearStage: Stage<SimpleStageAction>;
  112186. /**
  112187. * @hidden
  112188. * Defines the actions when collecting render targets for the frame.
  112189. */
  112190. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112191. /**
  112192. * @hidden
  112193. * Defines the actions happening for one camera in the frame.
  112194. */
  112195. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112196. /**
  112197. * @hidden
  112198. * Defines the actions happening during the per mesh ready checks.
  112199. */
  112200. _isReadyForMeshStage: Stage<MeshStageAction>;
  112201. /**
  112202. * @hidden
  112203. * Defines the actions happening before evaluate active mesh checks.
  112204. */
  112205. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112206. /**
  112207. * @hidden
  112208. * Defines the actions happening during the evaluate sub mesh checks.
  112209. */
  112210. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112211. /**
  112212. * @hidden
  112213. * Defines the actions happening during the active mesh stage.
  112214. */
  112215. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112216. /**
  112217. * @hidden
  112218. * Defines the actions happening during the per camera render target step.
  112219. */
  112220. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112221. /**
  112222. * @hidden
  112223. * Defines the actions happening just before the active camera is drawing.
  112224. */
  112225. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112226. /**
  112227. * @hidden
  112228. * Defines the actions happening just before a render target is drawing.
  112229. */
  112230. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112231. /**
  112232. * @hidden
  112233. * Defines the actions happening just before a rendering group is drawing.
  112234. */
  112235. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112236. /**
  112237. * @hidden
  112238. * Defines the actions happening just before a mesh is drawing.
  112239. */
  112240. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112241. /**
  112242. * @hidden
  112243. * Defines the actions happening just after a mesh has been drawn.
  112244. */
  112245. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112246. /**
  112247. * @hidden
  112248. * Defines the actions happening just after a rendering group has been drawn.
  112249. */
  112250. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112251. /**
  112252. * @hidden
  112253. * Defines the actions happening just after the active camera has been drawn.
  112254. */
  112255. _afterCameraDrawStage: Stage<CameraStageAction>;
  112256. /**
  112257. * @hidden
  112258. * Defines the actions happening just after a render target has been drawn.
  112259. */
  112260. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112261. /**
  112262. * @hidden
  112263. * Defines the actions happening just after rendering all cameras and computing intersections.
  112264. */
  112265. _afterRenderStage: Stage<SimpleStageAction>;
  112266. /**
  112267. * @hidden
  112268. * Defines the actions happening when a pointer move event happens.
  112269. */
  112270. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112271. /**
  112272. * @hidden
  112273. * Defines the actions happening when a pointer down event happens.
  112274. */
  112275. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112276. /**
  112277. * @hidden
  112278. * Defines the actions happening when a pointer up event happens.
  112279. */
  112280. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112281. /**
  112282. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112283. */
  112284. private geometriesByUniqueId;
  112285. /**
  112286. * Creates a new Scene
  112287. * @param engine defines the engine to use to render this scene
  112288. * @param options defines the scene options
  112289. */
  112290. constructor(engine: Engine, options?: SceneOptions);
  112291. /**
  112292. * Gets a string idenfifying the name of the class
  112293. * @returns "Scene" string
  112294. */
  112295. getClassName(): string;
  112296. private _defaultMeshCandidates;
  112297. /**
  112298. * @hidden
  112299. */
  112300. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112301. private _defaultSubMeshCandidates;
  112302. /**
  112303. * @hidden
  112304. */
  112305. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112306. /**
  112307. * Sets the default candidate providers for the scene.
  112308. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112309. * and getCollidingSubMeshCandidates to their default function
  112310. */
  112311. setDefaultCandidateProviders(): void;
  112312. /**
  112313. * Gets the mesh that is currently under the pointer
  112314. */
  112315. get meshUnderPointer(): Nullable<AbstractMesh>;
  112316. /**
  112317. * Gets or sets the current on-screen X position of the pointer
  112318. */
  112319. get pointerX(): number;
  112320. set pointerX(value: number);
  112321. /**
  112322. * Gets or sets the current on-screen Y position of the pointer
  112323. */
  112324. get pointerY(): number;
  112325. set pointerY(value: number);
  112326. /**
  112327. * Gets the cached material (ie. the latest rendered one)
  112328. * @returns the cached material
  112329. */
  112330. getCachedMaterial(): Nullable<Material>;
  112331. /**
  112332. * Gets the cached effect (ie. the latest rendered one)
  112333. * @returns the cached effect
  112334. */
  112335. getCachedEffect(): Nullable<Effect>;
  112336. /**
  112337. * Gets the cached visibility state (ie. the latest rendered one)
  112338. * @returns the cached visibility state
  112339. */
  112340. getCachedVisibility(): Nullable<number>;
  112341. /**
  112342. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112343. * @param material defines the current material
  112344. * @param effect defines the current effect
  112345. * @param visibility defines the current visibility state
  112346. * @returns true if one parameter is not cached
  112347. */
  112348. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112349. /**
  112350. * Gets the engine associated with the scene
  112351. * @returns an Engine
  112352. */
  112353. getEngine(): Engine;
  112354. /**
  112355. * Gets the total number of vertices rendered per frame
  112356. * @returns the total number of vertices rendered per frame
  112357. */
  112358. getTotalVertices(): number;
  112359. /**
  112360. * Gets the performance counter for total vertices
  112361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112362. */
  112363. get totalVerticesPerfCounter(): PerfCounter;
  112364. /**
  112365. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112366. * @returns the total number of active indices rendered per frame
  112367. */
  112368. getActiveIndices(): number;
  112369. /**
  112370. * Gets the performance counter for active indices
  112371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112372. */
  112373. get totalActiveIndicesPerfCounter(): PerfCounter;
  112374. /**
  112375. * Gets the total number of active particles rendered per frame
  112376. * @returns the total number of active particles rendered per frame
  112377. */
  112378. getActiveParticles(): number;
  112379. /**
  112380. * Gets the performance counter for active particles
  112381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112382. */
  112383. get activeParticlesPerfCounter(): PerfCounter;
  112384. /**
  112385. * Gets the total number of active bones rendered per frame
  112386. * @returns the total number of active bones rendered per frame
  112387. */
  112388. getActiveBones(): number;
  112389. /**
  112390. * Gets the performance counter for active bones
  112391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112392. */
  112393. get activeBonesPerfCounter(): PerfCounter;
  112394. /**
  112395. * Gets the array of active meshes
  112396. * @returns an array of AbstractMesh
  112397. */
  112398. getActiveMeshes(): SmartArray<AbstractMesh>;
  112399. /**
  112400. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112401. * @returns a number
  112402. */
  112403. getAnimationRatio(): number;
  112404. /**
  112405. * Gets an unique Id for the current render phase
  112406. * @returns a number
  112407. */
  112408. getRenderId(): number;
  112409. /**
  112410. * Gets an unique Id for the current frame
  112411. * @returns a number
  112412. */
  112413. getFrameId(): number;
  112414. /** Call this function if you want to manually increment the render Id*/
  112415. incrementRenderId(): void;
  112416. private _createUbo;
  112417. /**
  112418. * Use this method to simulate a pointer move on a mesh
  112419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112422. * @returns the current scene
  112423. */
  112424. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112425. /**
  112426. * Use this method to simulate a pointer down on a mesh
  112427. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112428. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112429. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112430. * @returns the current scene
  112431. */
  112432. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112433. /**
  112434. * Use this method to simulate a pointer up on a mesh
  112435. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112436. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112437. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112438. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112439. * @returns the current scene
  112440. */
  112441. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112442. /**
  112443. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112444. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112445. * @returns true if the pointer was captured
  112446. */
  112447. isPointerCaptured(pointerId?: number): boolean;
  112448. /**
  112449. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112450. * @param attachUp defines if you want to attach events to pointerup
  112451. * @param attachDown defines if you want to attach events to pointerdown
  112452. * @param attachMove defines if you want to attach events to pointermove
  112453. */
  112454. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112455. /** Detaches all event handlers*/
  112456. detachControl(): void;
  112457. /**
  112458. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112459. * Delay loaded resources are not taking in account
  112460. * @return true if all required resources are ready
  112461. */
  112462. isReady(): boolean;
  112463. /** Resets all cached information relative to material (including effect and visibility) */
  112464. resetCachedMaterial(): void;
  112465. /**
  112466. * Registers a function to be called before every frame render
  112467. * @param func defines the function to register
  112468. */
  112469. registerBeforeRender(func: () => void): void;
  112470. /**
  112471. * Unregisters a function called before every frame render
  112472. * @param func defines the function to unregister
  112473. */
  112474. unregisterBeforeRender(func: () => void): void;
  112475. /**
  112476. * Registers a function to be called after every frame render
  112477. * @param func defines the function to register
  112478. */
  112479. registerAfterRender(func: () => void): void;
  112480. /**
  112481. * Unregisters a function called after every frame render
  112482. * @param func defines the function to unregister
  112483. */
  112484. unregisterAfterRender(func: () => void): void;
  112485. private _executeOnceBeforeRender;
  112486. /**
  112487. * The provided function will run before render once and will be disposed afterwards.
  112488. * A timeout delay can be provided so that the function will be executed in N ms.
  112489. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112490. * @param func The function to be executed.
  112491. * @param timeout optional delay in ms
  112492. */
  112493. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112494. /** @hidden */
  112495. _addPendingData(data: any): void;
  112496. /** @hidden */
  112497. _removePendingData(data: any): void;
  112498. /**
  112499. * Returns the number of items waiting to be loaded
  112500. * @returns the number of items waiting to be loaded
  112501. */
  112502. getWaitingItemsCount(): number;
  112503. /**
  112504. * Returns a boolean indicating if the scene is still loading data
  112505. */
  112506. get isLoading(): boolean;
  112507. /**
  112508. * Registers a function to be executed when the scene is ready
  112509. * @param {Function} func - the function to be executed
  112510. */
  112511. executeWhenReady(func: () => void): void;
  112512. /**
  112513. * Returns a promise that resolves when the scene is ready
  112514. * @returns A promise that resolves when the scene is ready
  112515. */
  112516. whenReadyAsync(): Promise<void>;
  112517. /** @hidden */
  112518. _checkIsReady(): void;
  112519. /**
  112520. * Gets all animatable attached to the scene
  112521. */
  112522. get animatables(): Animatable[];
  112523. /**
  112524. * Resets the last animation time frame.
  112525. * Useful to override when animations start running when loading a scene for the first time.
  112526. */
  112527. resetLastAnimationTimeFrame(): void;
  112528. /**
  112529. * Gets the current view matrix
  112530. * @returns a Matrix
  112531. */
  112532. getViewMatrix(): Matrix;
  112533. /**
  112534. * Gets the current projection matrix
  112535. * @returns a Matrix
  112536. */
  112537. getProjectionMatrix(): Matrix;
  112538. /**
  112539. * Gets the current transform matrix
  112540. * @returns a Matrix made of View * Projection
  112541. */
  112542. getTransformMatrix(): Matrix;
  112543. /**
  112544. * Sets the current transform matrix
  112545. * @param viewL defines the View matrix to use
  112546. * @param projectionL defines the Projection matrix to use
  112547. * @param viewR defines the right View matrix to use (if provided)
  112548. * @param projectionR defines the right Projection matrix to use (if provided)
  112549. */
  112550. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112551. /**
  112552. * Gets the uniform buffer used to store scene data
  112553. * @returns a UniformBuffer
  112554. */
  112555. getSceneUniformBuffer(): UniformBuffer;
  112556. /**
  112557. * Gets an unique (relatively to the current scene) Id
  112558. * @returns an unique number for the scene
  112559. */
  112560. getUniqueId(): number;
  112561. /**
  112562. * Add a mesh to the list of scene's meshes
  112563. * @param newMesh defines the mesh to add
  112564. * @param recursive if all child meshes should also be added to the scene
  112565. */
  112566. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112567. /**
  112568. * Remove a mesh for the list of scene's meshes
  112569. * @param toRemove defines the mesh to remove
  112570. * @param recursive if all child meshes should also be removed from the scene
  112571. * @returns the index where the mesh was in the mesh list
  112572. */
  112573. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112574. /**
  112575. * Add a transform node to the list of scene's transform nodes
  112576. * @param newTransformNode defines the transform node to add
  112577. */
  112578. addTransformNode(newTransformNode: TransformNode): void;
  112579. /**
  112580. * Remove a transform node for the list of scene's transform nodes
  112581. * @param toRemove defines the transform node to remove
  112582. * @returns the index where the transform node was in the transform node list
  112583. */
  112584. removeTransformNode(toRemove: TransformNode): number;
  112585. /**
  112586. * Remove a skeleton for the list of scene's skeletons
  112587. * @param toRemove defines the skeleton to remove
  112588. * @returns the index where the skeleton was in the skeleton list
  112589. */
  112590. removeSkeleton(toRemove: Skeleton): number;
  112591. /**
  112592. * Remove a morph target for the list of scene's morph targets
  112593. * @param toRemove defines the morph target to remove
  112594. * @returns the index where the morph target was in the morph target list
  112595. */
  112596. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112597. /**
  112598. * Remove a light for the list of scene's lights
  112599. * @param toRemove defines the light to remove
  112600. * @returns the index where the light was in the light list
  112601. */
  112602. removeLight(toRemove: Light): number;
  112603. /**
  112604. * Remove a camera for the list of scene's cameras
  112605. * @param toRemove defines the camera to remove
  112606. * @returns the index where the camera was in the camera list
  112607. */
  112608. removeCamera(toRemove: Camera): number;
  112609. /**
  112610. * Remove a particle system for the list of scene's particle systems
  112611. * @param toRemove defines the particle system to remove
  112612. * @returns the index where the particle system was in the particle system list
  112613. */
  112614. removeParticleSystem(toRemove: IParticleSystem): number;
  112615. /**
  112616. * Remove a animation for the list of scene's animations
  112617. * @param toRemove defines the animation to remove
  112618. * @returns the index where the animation was in the animation list
  112619. */
  112620. removeAnimation(toRemove: Animation): number;
  112621. /**
  112622. * Will stop the animation of the given target
  112623. * @param target - the target
  112624. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112625. * @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)
  112626. */
  112627. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112628. /**
  112629. * Removes the given animation group from this scene.
  112630. * @param toRemove The animation group to remove
  112631. * @returns The index of the removed animation group
  112632. */
  112633. removeAnimationGroup(toRemove: AnimationGroup): number;
  112634. /**
  112635. * Removes the given multi-material from this scene.
  112636. * @param toRemove The multi-material to remove
  112637. * @returns The index of the removed multi-material
  112638. */
  112639. removeMultiMaterial(toRemove: MultiMaterial): number;
  112640. /**
  112641. * Removes the given material from this scene.
  112642. * @param toRemove The material to remove
  112643. * @returns The index of the removed material
  112644. */
  112645. removeMaterial(toRemove: Material): number;
  112646. /**
  112647. * Removes the given action manager from this scene.
  112648. * @param toRemove The action manager to remove
  112649. * @returns The index of the removed action manager
  112650. */
  112651. removeActionManager(toRemove: AbstractActionManager): number;
  112652. /**
  112653. * Removes the given texture from this scene.
  112654. * @param toRemove The texture to remove
  112655. * @returns The index of the removed texture
  112656. */
  112657. removeTexture(toRemove: BaseTexture): number;
  112658. /**
  112659. * Adds the given light to this scene
  112660. * @param newLight The light to add
  112661. */
  112662. addLight(newLight: Light): void;
  112663. /**
  112664. * Sorts the list list based on light priorities
  112665. */
  112666. sortLightsByPriority(): void;
  112667. /**
  112668. * Adds the given camera to this scene
  112669. * @param newCamera The camera to add
  112670. */
  112671. addCamera(newCamera: Camera): void;
  112672. /**
  112673. * Adds the given skeleton to this scene
  112674. * @param newSkeleton The skeleton to add
  112675. */
  112676. addSkeleton(newSkeleton: Skeleton): void;
  112677. /**
  112678. * Adds the given particle system to this scene
  112679. * @param newParticleSystem The particle system to add
  112680. */
  112681. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112682. /**
  112683. * Adds the given animation to this scene
  112684. * @param newAnimation The animation to add
  112685. */
  112686. addAnimation(newAnimation: Animation): void;
  112687. /**
  112688. * Adds the given animation group to this scene.
  112689. * @param newAnimationGroup The animation group to add
  112690. */
  112691. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112692. /**
  112693. * Adds the given multi-material to this scene
  112694. * @param newMultiMaterial The multi-material to add
  112695. */
  112696. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112697. /**
  112698. * Adds the given material to this scene
  112699. * @param newMaterial The material to add
  112700. */
  112701. addMaterial(newMaterial: Material): void;
  112702. /**
  112703. * Adds the given morph target to this scene
  112704. * @param newMorphTargetManager The morph target to add
  112705. */
  112706. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112707. /**
  112708. * Adds the given geometry to this scene
  112709. * @param newGeometry The geometry to add
  112710. */
  112711. addGeometry(newGeometry: Geometry): void;
  112712. /**
  112713. * Adds the given action manager to this scene
  112714. * @param newActionManager The action manager to add
  112715. */
  112716. addActionManager(newActionManager: AbstractActionManager): void;
  112717. /**
  112718. * Adds the given texture to this scene.
  112719. * @param newTexture The texture to add
  112720. */
  112721. addTexture(newTexture: BaseTexture): void;
  112722. /**
  112723. * Switch active camera
  112724. * @param newCamera defines the new active camera
  112725. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112726. */
  112727. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  112728. /**
  112729. * sets the active camera of the scene using its ID
  112730. * @param id defines the camera's ID
  112731. * @return the new active camera or null if none found.
  112732. */
  112733. setActiveCameraByID(id: string): Nullable<Camera>;
  112734. /**
  112735. * sets the active camera of the scene using its name
  112736. * @param name defines the camera's name
  112737. * @returns the new active camera or null if none found.
  112738. */
  112739. setActiveCameraByName(name: string): Nullable<Camera>;
  112740. /**
  112741. * get an animation group using its name
  112742. * @param name defines the material's name
  112743. * @return the animation group or null if none found.
  112744. */
  112745. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  112746. /**
  112747. * Get a material using its unique id
  112748. * @param uniqueId defines the material's unique id
  112749. * @return the material or null if none found.
  112750. */
  112751. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  112752. /**
  112753. * get a material using its id
  112754. * @param id defines the material's ID
  112755. * @return the material or null if none found.
  112756. */
  112757. getMaterialByID(id: string): Nullable<Material>;
  112758. /**
  112759. * Gets a the last added material using a given id
  112760. * @param id defines the material's ID
  112761. * @return the last material with the given id or null if none found.
  112762. */
  112763. getLastMaterialByID(id: string): Nullable<Material>;
  112764. /**
  112765. * Gets a material using its name
  112766. * @param name defines the material's name
  112767. * @return the material or null if none found.
  112768. */
  112769. getMaterialByName(name: string): Nullable<Material>;
  112770. /**
  112771. * Get a texture using its unique id
  112772. * @param uniqueId defines the texture's unique id
  112773. * @return the texture or null if none found.
  112774. */
  112775. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  112776. /**
  112777. * Gets a camera using its id
  112778. * @param id defines the id to look for
  112779. * @returns the camera or null if not found
  112780. */
  112781. getCameraByID(id: string): Nullable<Camera>;
  112782. /**
  112783. * Gets a camera using its unique id
  112784. * @param uniqueId defines the unique id to look for
  112785. * @returns the camera or null if not found
  112786. */
  112787. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  112788. /**
  112789. * Gets a camera using its name
  112790. * @param name defines the camera's name
  112791. * @return the camera or null if none found.
  112792. */
  112793. getCameraByName(name: string): Nullable<Camera>;
  112794. /**
  112795. * Gets a bone using its id
  112796. * @param id defines the bone's id
  112797. * @return the bone or null if not found
  112798. */
  112799. getBoneByID(id: string): Nullable<Bone>;
  112800. /**
  112801. * Gets a bone using its id
  112802. * @param name defines the bone's name
  112803. * @return the bone or null if not found
  112804. */
  112805. getBoneByName(name: string): Nullable<Bone>;
  112806. /**
  112807. * Gets a light node using its name
  112808. * @param name defines the the light's name
  112809. * @return the light or null if none found.
  112810. */
  112811. getLightByName(name: string): Nullable<Light>;
  112812. /**
  112813. * Gets a light node using its id
  112814. * @param id defines the light's id
  112815. * @return the light or null if none found.
  112816. */
  112817. getLightByID(id: string): Nullable<Light>;
  112818. /**
  112819. * Gets a light node using its scene-generated unique ID
  112820. * @param uniqueId defines the light's unique id
  112821. * @return the light or null if none found.
  112822. */
  112823. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  112824. /**
  112825. * Gets a particle system by id
  112826. * @param id defines the particle system id
  112827. * @return the corresponding system or null if none found
  112828. */
  112829. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  112830. /**
  112831. * Gets a geometry using its ID
  112832. * @param id defines the geometry's id
  112833. * @return the geometry or null if none found.
  112834. */
  112835. getGeometryByID(id: string): Nullable<Geometry>;
  112836. private _getGeometryByUniqueID;
  112837. /**
  112838. * Add a new geometry to this scene
  112839. * @param geometry defines the geometry to be added to the scene.
  112840. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  112841. * @return a boolean defining if the geometry was added or not
  112842. */
  112843. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  112844. /**
  112845. * Removes an existing geometry
  112846. * @param geometry defines the geometry to be removed from the scene
  112847. * @return a boolean defining if the geometry was removed or not
  112848. */
  112849. removeGeometry(geometry: Geometry): boolean;
  112850. /**
  112851. * Gets the list of geometries attached to the scene
  112852. * @returns an array of Geometry
  112853. */
  112854. getGeometries(): Geometry[];
  112855. /**
  112856. * Gets the first added mesh found of a given ID
  112857. * @param id defines the id to search for
  112858. * @return the mesh found or null if not found at all
  112859. */
  112860. getMeshByID(id: string): Nullable<AbstractMesh>;
  112861. /**
  112862. * Gets a list of meshes using their id
  112863. * @param id defines the id to search for
  112864. * @returns a list of meshes
  112865. */
  112866. getMeshesByID(id: string): Array<AbstractMesh>;
  112867. /**
  112868. * Gets the first added transform node found of a given ID
  112869. * @param id defines the id to search for
  112870. * @return the found transform node or null if not found at all.
  112871. */
  112872. getTransformNodeByID(id: string): Nullable<TransformNode>;
  112873. /**
  112874. * Gets a transform node with its auto-generated unique id
  112875. * @param uniqueId efines the unique id to search for
  112876. * @return the found transform node or null if not found at all.
  112877. */
  112878. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  112879. /**
  112880. * Gets a list of transform nodes using their id
  112881. * @param id defines the id to search for
  112882. * @returns a list of transform nodes
  112883. */
  112884. getTransformNodesByID(id: string): Array<TransformNode>;
  112885. /**
  112886. * Gets a mesh with its auto-generated unique id
  112887. * @param uniqueId defines the unique id to search for
  112888. * @return the found mesh or null if not found at all.
  112889. */
  112890. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  112891. /**
  112892. * Gets a the last added mesh using a given id
  112893. * @param id defines the id to search for
  112894. * @return the found mesh or null if not found at all.
  112895. */
  112896. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  112897. /**
  112898. * Gets a the last added node (Mesh, Camera, Light) using a given id
  112899. * @param id defines the id to search for
  112900. * @return the found node or null if not found at all
  112901. */
  112902. getLastEntryByID(id: string): Nullable<Node>;
  112903. /**
  112904. * Gets a node (Mesh, Camera, Light) using a given id
  112905. * @param id defines the id to search for
  112906. * @return the found node or null if not found at all
  112907. */
  112908. getNodeByID(id: string): Nullable<Node>;
  112909. /**
  112910. * Gets a node (Mesh, Camera, Light) using a given name
  112911. * @param name defines the name to search for
  112912. * @return the found node or null if not found at all.
  112913. */
  112914. getNodeByName(name: string): Nullable<Node>;
  112915. /**
  112916. * Gets a mesh using a given name
  112917. * @param name defines the name to search for
  112918. * @return the found mesh or null if not found at all.
  112919. */
  112920. getMeshByName(name: string): Nullable<AbstractMesh>;
  112921. /**
  112922. * Gets a transform node using a given name
  112923. * @param name defines the name to search for
  112924. * @return the found transform node or null if not found at all.
  112925. */
  112926. getTransformNodeByName(name: string): Nullable<TransformNode>;
  112927. /**
  112928. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  112929. * @param id defines the id to search for
  112930. * @return the found skeleton or null if not found at all.
  112931. */
  112932. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  112933. /**
  112934. * Gets a skeleton using a given auto generated unique id
  112935. * @param uniqueId defines the unique id to search for
  112936. * @return the found skeleton or null if not found at all.
  112937. */
  112938. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  112939. /**
  112940. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  112941. * @param id defines the id to search for
  112942. * @return the found skeleton or null if not found at all.
  112943. */
  112944. getSkeletonById(id: string): Nullable<Skeleton>;
  112945. /**
  112946. * Gets a skeleton using a given name
  112947. * @param name defines the name to search for
  112948. * @return the found skeleton or null if not found at all.
  112949. */
  112950. getSkeletonByName(name: string): Nullable<Skeleton>;
  112951. /**
  112952. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  112953. * @param id defines the id to search for
  112954. * @return the found morph target manager or null if not found at all.
  112955. */
  112956. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  112957. /**
  112958. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  112959. * @param id defines the id to search for
  112960. * @return the found morph target or null if not found at all.
  112961. */
  112962. getMorphTargetById(id: string): Nullable<MorphTarget>;
  112963. /**
  112964. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  112965. * @param name defines the name to search for
  112966. * @return the found morph target or null if not found at all.
  112967. */
  112968. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  112969. /**
  112970. * Gets a boolean indicating if the given mesh is active
  112971. * @param mesh defines the mesh to look for
  112972. * @returns true if the mesh is in the active list
  112973. */
  112974. isActiveMesh(mesh: AbstractMesh): boolean;
  112975. /**
  112976. * Return a unique id as a string which can serve as an identifier for the scene
  112977. */
  112978. get uid(): string;
  112979. /**
  112980. * Add an externaly attached data from its key.
  112981. * This method call will fail and return false, if such key already exists.
  112982. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  112983. * @param key the unique key that identifies the data
  112984. * @param data the data object to associate to the key for this Engine instance
  112985. * @return true if no such key were already present and the data was added successfully, false otherwise
  112986. */
  112987. addExternalData<T>(key: string, data: T): boolean;
  112988. /**
  112989. * Get an externaly attached data from its key
  112990. * @param key the unique key that identifies the data
  112991. * @return the associated data, if present (can be null), or undefined if not present
  112992. */
  112993. getExternalData<T>(key: string): Nullable<T>;
  112994. /**
  112995. * Get an externaly attached data from its key, create it using a factory if it's not already present
  112996. * @param key the unique key that identifies the data
  112997. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  112998. * @return the associated data, can be null if the factory returned null.
  112999. */
  113000. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  113001. /**
  113002. * Remove an externaly attached data from the Engine instance
  113003. * @param key the unique key that identifies the data
  113004. * @return true if the data was successfully removed, false if it doesn't exist
  113005. */
  113006. removeExternalData(key: string): boolean;
  113007. private _evaluateSubMesh;
  113008. /**
  113009. * Clear the processed materials smart array preventing retention point in material dispose.
  113010. */
  113011. freeProcessedMaterials(): void;
  113012. private _preventFreeActiveMeshesAndRenderingGroups;
  113013. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113014. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113015. * when disposing several meshes in a row or a hierarchy of meshes.
  113016. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113017. */
  113018. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113019. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113020. /**
  113021. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113022. */
  113023. freeActiveMeshes(): void;
  113024. /**
  113025. * Clear the info related to rendering groups preventing retention points during dispose.
  113026. */
  113027. freeRenderingGroups(): void;
  113028. /** @hidden */
  113029. _isInIntermediateRendering(): boolean;
  113030. /**
  113031. * Lambda returning the list of potentially active meshes.
  113032. */
  113033. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113034. /**
  113035. * Lambda returning the list of potentially active sub meshes.
  113036. */
  113037. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113038. /**
  113039. * Lambda returning the list of potentially intersecting sub meshes.
  113040. */
  113041. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113042. /**
  113043. * Lambda returning the list of potentially colliding sub meshes.
  113044. */
  113045. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113046. private _activeMeshesFrozen;
  113047. private _skipEvaluateActiveMeshesCompletely;
  113048. /**
  113049. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113050. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113051. * @returns the current scene
  113052. */
  113053. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113054. /**
  113055. * Use this function to restart evaluating active meshes on every frame
  113056. * @returns the current scene
  113057. */
  113058. unfreezeActiveMeshes(): Scene;
  113059. private _evaluateActiveMeshes;
  113060. private _activeMesh;
  113061. /**
  113062. * Update the transform matrix to update from the current active camera
  113063. * @param force defines a boolean used to force the update even if cache is up to date
  113064. */
  113065. updateTransformMatrix(force?: boolean): void;
  113066. private _bindFrameBuffer;
  113067. /** @hidden */
  113068. _allowPostProcessClearColor: boolean;
  113069. /** @hidden */
  113070. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113071. private _processSubCameras;
  113072. private _checkIntersections;
  113073. /** @hidden */
  113074. _advancePhysicsEngineStep(step: number): void;
  113075. /**
  113076. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113077. */
  113078. getDeterministicFrameTime: () => number;
  113079. /** @hidden */
  113080. _animate(): void;
  113081. /** Execute all animations (for a frame) */
  113082. animate(): void;
  113083. /**
  113084. * Render the scene
  113085. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113086. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113087. */
  113088. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113089. /**
  113090. * Freeze all materials
  113091. * A frozen material will not be updatable but should be faster to render
  113092. */
  113093. freezeMaterials(): void;
  113094. /**
  113095. * Unfreeze all materials
  113096. * A frozen material will not be updatable but should be faster to render
  113097. */
  113098. unfreezeMaterials(): void;
  113099. /**
  113100. * Releases all held ressources
  113101. */
  113102. dispose(): void;
  113103. /**
  113104. * Gets if the scene is already disposed
  113105. */
  113106. get isDisposed(): boolean;
  113107. /**
  113108. * Call this function to reduce memory footprint of the scene.
  113109. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113110. */
  113111. clearCachedVertexData(): void;
  113112. /**
  113113. * This function will remove the local cached buffer data from texture.
  113114. * It will save memory but will prevent the texture from being rebuilt
  113115. */
  113116. cleanCachedTextureBuffer(): void;
  113117. /**
  113118. * Get the world extend vectors with an optional filter
  113119. *
  113120. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113121. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113122. */
  113123. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113124. min: Vector3;
  113125. max: Vector3;
  113126. };
  113127. /**
  113128. * Creates a ray that can be used to pick in the scene
  113129. * @param x defines the x coordinate of the origin (on-screen)
  113130. * @param y defines the y coordinate of the origin (on-screen)
  113131. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113132. * @param camera defines the camera to use for the picking
  113133. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113134. * @returns a Ray
  113135. */
  113136. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113137. /**
  113138. * Creates a ray that can be used to pick in the scene
  113139. * @param x defines the x coordinate of the origin (on-screen)
  113140. * @param y defines the y coordinate of the origin (on-screen)
  113141. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113142. * @param result defines the ray where to store the picking ray
  113143. * @param camera defines the camera to use for the picking
  113144. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113145. * @returns the current scene
  113146. */
  113147. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113148. /**
  113149. * Creates a ray that can be used to pick in the scene
  113150. * @param x defines the x coordinate of the origin (on-screen)
  113151. * @param y defines the y coordinate of the origin (on-screen)
  113152. * @param camera defines the camera to use for the picking
  113153. * @returns a Ray
  113154. */
  113155. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113156. /**
  113157. * Creates a ray that can be used to pick in the scene
  113158. * @param x defines the x coordinate of the origin (on-screen)
  113159. * @param y defines the y coordinate of the origin (on-screen)
  113160. * @param result defines the ray where to store the picking ray
  113161. * @param camera defines the camera to use for the picking
  113162. * @returns the current scene
  113163. */
  113164. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113165. /** Launch a ray to try to pick a mesh in the scene
  113166. * @param x position on screen
  113167. * @param y position on screen
  113168. * @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
  113169. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113170. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113172. * @returns a PickingInfo
  113173. */
  113174. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113175. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113176. * @param x position on screen
  113177. * @param y position on screen
  113178. * @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
  113179. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113180. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113181. * @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)
  113182. */
  113183. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113184. /** Use the given ray to pick a mesh in the scene
  113185. * @param ray The ray to use to pick meshes
  113186. * @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
  113187. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113189. * @returns a PickingInfo
  113190. */
  113191. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113192. /**
  113193. * Launch a ray to try to pick a mesh in the scene
  113194. * @param x X position on screen
  113195. * @param y Y position on screen
  113196. * @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
  113197. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113198. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113199. * @returns an array of PickingInfo
  113200. */
  113201. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113202. /**
  113203. * Launch a ray to try to pick a mesh in the scene
  113204. * @param ray Ray to use
  113205. * @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
  113206. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113207. * @returns an array of PickingInfo
  113208. */
  113209. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113210. /**
  113211. * Force the value of meshUnderPointer
  113212. * @param mesh defines the mesh to use
  113213. */
  113214. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113215. /**
  113216. * Gets the mesh under the pointer
  113217. * @returns a Mesh or null if no mesh is under the pointer
  113218. */
  113219. getPointerOverMesh(): Nullable<AbstractMesh>;
  113220. /** @hidden */
  113221. _rebuildGeometries(): void;
  113222. /** @hidden */
  113223. _rebuildTextures(): void;
  113224. private _getByTags;
  113225. /**
  113226. * Get a list of meshes by tags
  113227. * @param tagsQuery defines the tags query to use
  113228. * @param forEach defines a predicate used to filter results
  113229. * @returns an array of Mesh
  113230. */
  113231. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113232. /**
  113233. * Get a list of cameras by tags
  113234. * @param tagsQuery defines the tags query to use
  113235. * @param forEach defines a predicate used to filter results
  113236. * @returns an array of Camera
  113237. */
  113238. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113239. /**
  113240. * Get a list of lights by tags
  113241. * @param tagsQuery defines the tags query to use
  113242. * @param forEach defines a predicate used to filter results
  113243. * @returns an array of Light
  113244. */
  113245. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113246. /**
  113247. * Get a list of materials by tags
  113248. * @param tagsQuery defines the tags query to use
  113249. * @param forEach defines a predicate used to filter results
  113250. * @returns an array of Material
  113251. */
  113252. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113253. /**
  113254. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113255. * This allowed control for front to back rendering or reversly depending of the special needs.
  113256. *
  113257. * @param renderingGroupId The rendering group id corresponding to its index
  113258. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113259. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113260. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113261. */
  113262. 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;
  113263. /**
  113264. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113265. *
  113266. * @param renderingGroupId The rendering group id corresponding to its index
  113267. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113268. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113269. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113270. */
  113271. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113272. /**
  113273. * Gets the current auto clear configuration for one rendering group of the rendering
  113274. * manager.
  113275. * @param index the rendering group index to get the information for
  113276. * @returns The auto clear setup for the requested rendering group
  113277. */
  113278. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113279. private _blockMaterialDirtyMechanism;
  113280. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113281. get blockMaterialDirtyMechanism(): boolean;
  113282. set blockMaterialDirtyMechanism(value: boolean);
  113283. /**
  113284. * Will flag all materials as dirty to trigger new shader compilation
  113285. * @param flag defines the flag used to specify which material part must be marked as dirty
  113286. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113287. */
  113288. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113289. /** @hidden */
  113290. _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;
  113291. /** @hidden */
  113292. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113293. /** @hidden */
  113294. _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;
  113295. /** @hidden */
  113296. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113297. /** @hidden */
  113298. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113299. /** @hidden */
  113300. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113301. }
  113302. }
  113303. declare module BABYLON {
  113304. /**
  113305. * Set of assets to keep when moving a scene into an asset container.
  113306. */
  113307. export class KeepAssets extends AbstractScene {
  113308. }
  113309. /**
  113310. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113311. */
  113312. export class InstantiatedEntries {
  113313. /**
  113314. * List of new root nodes (eg. nodes with no parent)
  113315. */
  113316. rootNodes: TransformNode[];
  113317. /**
  113318. * List of new skeletons
  113319. */
  113320. skeletons: Skeleton[];
  113321. /**
  113322. * List of new animation groups
  113323. */
  113324. animationGroups: AnimationGroup[];
  113325. }
  113326. /**
  113327. * Container with a set of assets that can be added or removed from a scene.
  113328. */
  113329. export class AssetContainer extends AbstractScene {
  113330. private _wasAddedToScene;
  113331. /**
  113332. * The scene the AssetContainer belongs to.
  113333. */
  113334. scene: Scene;
  113335. /**
  113336. * Instantiates an AssetContainer.
  113337. * @param scene The scene the AssetContainer belongs to.
  113338. */
  113339. constructor(scene: Scene);
  113340. /**
  113341. * Instantiate or clone all meshes and add the new ones to the scene.
  113342. * Skeletons and animation groups will all be cloned
  113343. * @param nameFunction defines an optional function used to get new names for clones
  113344. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113345. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113346. */
  113347. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113348. /**
  113349. * Adds all the assets from the container to the scene.
  113350. */
  113351. addAllToScene(): void;
  113352. /**
  113353. * Removes all the assets in the container from the scene
  113354. */
  113355. removeAllFromScene(): void;
  113356. /**
  113357. * Disposes all the assets in the container
  113358. */
  113359. dispose(): void;
  113360. private _moveAssets;
  113361. /**
  113362. * Removes all the assets contained in the scene and adds them to the container.
  113363. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113364. */
  113365. moveAllFromScene(keepAssets?: KeepAssets): void;
  113366. /**
  113367. * 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.
  113368. * @returns the root mesh
  113369. */
  113370. createRootMesh(): Mesh;
  113371. /**
  113372. * Merge animations (direct and animation groups) from this asset container into a scene
  113373. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113374. * @param animatables set of animatables to retarget to a node from the scene
  113375. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113376. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113377. */
  113378. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113379. }
  113380. }
  113381. declare module BABYLON {
  113382. /**
  113383. * Defines how the parser contract is defined.
  113384. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113385. */
  113386. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113387. /**
  113388. * Defines how the individual parser contract is defined.
  113389. * These parser can parse an individual asset
  113390. */
  113391. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113392. /**
  113393. * Base class of the scene acting as a container for the different elements composing a scene.
  113394. * This class is dynamically extended by the different components of the scene increasing
  113395. * flexibility and reducing coupling
  113396. */
  113397. export abstract class AbstractScene {
  113398. /**
  113399. * Stores the list of available parsers in the application.
  113400. */
  113401. private static _BabylonFileParsers;
  113402. /**
  113403. * Stores the list of available individual parsers in the application.
  113404. */
  113405. private static _IndividualBabylonFileParsers;
  113406. /**
  113407. * Adds a parser in the list of available ones
  113408. * @param name Defines the name of the parser
  113409. * @param parser Defines the parser to add
  113410. */
  113411. static AddParser(name: string, parser: BabylonFileParser): void;
  113412. /**
  113413. * Gets a general parser from the list of avaialble ones
  113414. * @param name Defines the name of the parser
  113415. * @returns the requested parser or null
  113416. */
  113417. static GetParser(name: string): Nullable<BabylonFileParser>;
  113418. /**
  113419. * Adds n individual parser in the list of available ones
  113420. * @param name Defines the name of the parser
  113421. * @param parser Defines the parser to add
  113422. */
  113423. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113424. /**
  113425. * Gets an individual parser from the list of avaialble ones
  113426. * @param name Defines the name of the parser
  113427. * @returns the requested parser or null
  113428. */
  113429. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113430. /**
  113431. * Parser json data and populate both a scene and its associated container object
  113432. * @param jsonData Defines the data to parse
  113433. * @param scene Defines the scene to parse the data for
  113434. * @param container Defines the container attached to the parsing sequence
  113435. * @param rootUrl Defines the root url of the data
  113436. */
  113437. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113438. /**
  113439. * Gets the list of root nodes (ie. nodes with no parent)
  113440. */
  113441. rootNodes: Node[];
  113442. /** All of the cameras added to this scene
  113443. * @see http://doc.babylonjs.com/babylon101/cameras
  113444. */
  113445. cameras: Camera[];
  113446. /**
  113447. * All of the lights added to this scene
  113448. * @see http://doc.babylonjs.com/babylon101/lights
  113449. */
  113450. lights: Light[];
  113451. /**
  113452. * All of the (abstract) meshes added to this scene
  113453. */
  113454. meshes: AbstractMesh[];
  113455. /**
  113456. * The list of skeletons added to the scene
  113457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113458. */
  113459. skeletons: Skeleton[];
  113460. /**
  113461. * All of the particle systems added to this scene
  113462. * @see http://doc.babylonjs.com/babylon101/particles
  113463. */
  113464. particleSystems: IParticleSystem[];
  113465. /**
  113466. * Gets a list of Animations associated with the scene
  113467. */
  113468. animations: Animation[];
  113469. /**
  113470. * All of the animation groups added to this scene
  113471. * @see http://doc.babylonjs.com/how_to/group
  113472. */
  113473. animationGroups: AnimationGroup[];
  113474. /**
  113475. * All of the multi-materials added to this scene
  113476. * @see http://doc.babylonjs.com/how_to/multi_materials
  113477. */
  113478. multiMaterials: MultiMaterial[];
  113479. /**
  113480. * All of the materials added to this scene
  113481. * In the context of a Scene, it is not supposed to be modified manually.
  113482. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113483. * Note also that the order of the Material within the array is not significant and might change.
  113484. * @see http://doc.babylonjs.com/babylon101/materials
  113485. */
  113486. materials: Material[];
  113487. /**
  113488. * The list of morph target managers added to the scene
  113489. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113490. */
  113491. morphTargetManagers: MorphTargetManager[];
  113492. /**
  113493. * The list of geometries used in the scene.
  113494. */
  113495. geometries: Geometry[];
  113496. /**
  113497. * All of the tranform nodes added to this scene
  113498. * In the context of a Scene, it is not supposed to be modified manually.
  113499. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113500. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113501. * @see http://doc.babylonjs.com/how_to/transformnode
  113502. */
  113503. transformNodes: TransformNode[];
  113504. /**
  113505. * ActionManagers available on the scene.
  113506. */
  113507. actionManagers: AbstractActionManager[];
  113508. /**
  113509. * Textures to keep.
  113510. */
  113511. textures: BaseTexture[];
  113512. /**
  113513. * Environment texture for the scene
  113514. */
  113515. environmentTexture: Nullable<BaseTexture>;
  113516. /**
  113517. * @returns all meshes, lights, cameras, transformNodes and bones
  113518. */
  113519. getNodes(): Array<Node>;
  113520. }
  113521. }
  113522. declare module BABYLON {
  113523. /**
  113524. * Interface used to define options for Sound class
  113525. */
  113526. export interface ISoundOptions {
  113527. /**
  113528. * Does the sound autoplay once loaded.
  113529. */
  113530. autoplay?: boolean;
  113531. /**
  113532. * Does the sound loop after it finishes playing once.
  113533. */
  113534. loop?: boolean;
  113535. /**
  113536. * Sound's volume
  113537. */
  113538. volume?: number;
  113539. /**
  113540. * Is it a spatial sound?
  113541. */
  113542. spatialSound?: boolean;
  113543. /**
  113544. * Maximum distance to hear that sound
  113545. */
  113546. maxDistance?: number;
  113547. /**
  113548. * Uses user defined attenuation function
  113549. */
  113550. useCustomAttenuation?: boolean;
  113551. /**
  113552. * Define the roll off factor of spatial sounds.
  113553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113554. */
  113555. rolloffFactor?: number;
  113556. /**
  113557. * Define the reference distance the sound should be heard perfectly.
  113558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113559. */
  113560. refDistance?: number;
  113561. /**
  113562. * Define the distance attenuation model the sound will follow.
  113563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113564. */
  113565. distanceModel?: string;
  113566. /**
  113567. * Defines the playback speed (1 by default)
  113568. */
  113569. playbackRate?: number;
  113570. /**
  113571. * Defines if the sound is from a streaming source
  113572. */
  113573. streaming?: boolean;
  113574. /**
  113575. * Defines an optional length (in seconds) inside the sound file
  113576. */
  113577. length?: number;
  113578. /**
  113579. * Defines an optional offset (in seconds) inside the sound file
  113580. */
  113581. offset?: number;
  113582. /**
  113583. * If true, URLs will not be required to state the audio file codec to use.
  113584. */
  113585. skipCodecCheck?: boolean;
  113586. }
  113587. /**
  113588. * Defines a sound that can be played in the application.
  113589. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113591. */
  113592. export class Sound {
  113593. /**
  113594. * The name of the sound in the scene.
  113595. */
  113596. name: string;
  113597. /**
  113598. * Does the sound autoplay once loaded.
  113599. */
  113600. autoplay: boolean;
  113601. /**
  113602. * Does the sound loop after it finishes playing once.
  113603. */
  113604. loop: boolean;
  113605. /**
  113606. * Does the sound use a custom attenuation curve to simulate the falloff
  113607. * happening when the source gets further away from the camera.
  113608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113609. */
  113610. useCustomAttenuation: boolean;
  113611. /**
  113612. * The sound track id this sound belongs to.
  113613. */
  113614. soundTrackId: number;
  113615. /**
  113616. * Is this sound currently played.
  113617. */
  113618. isPlaying: boolean;
  113619. /**
  113620. * Is this sound currently paused.
  113621. */
  113622. isPaused: boolean;
  113623. /**
  113624. * Does this sound enables spatial sound.
  113625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113626. */
  113627. spatialSound: boolean;
  113628. /**
  113629. * Define the reference distance the sound should be heard perfectly.
  113630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113631. */
  113632. refDistance: number;
  113633. /**
  113634. * Define the roll off factor of spatial sounds.
  113635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113636. */
  113637. rolloffFactor: number;
  113638. /**
  113639. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113641. */
  113642. maxDistance: number;
  113643. /**
  113644. * Define the distance attenuation model the sound will follow.
  113645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113646. */
  113647. distanceModel: string;
  113648. /**
  113649. * @hidden
  113650. * Back Compat
  113651. **/
  113652. onended: () => any;
  113653. /**
  113654. * Observable event when the current playing sound finishes.
  113655. */
  113656. onEndedObservable: Observable<Sound>;
  113657. private _panningModel;
  113658. private _playbackRate;
  113659. private _streaming;
  113660. private _startTime;
  113661. private _startOffset;
  113662. private _position;
  113663. /** @hidden */
  113664. _positionInEmitterSpace: boolean;
  113665. private _localDirection;
  113666. private _volume;
  113667. private _isReadyToPlay;
  113668. private _isDirectional;
  113669. private _readyToPlayCallback;
  113670. private _audioBuffer;
  113671. private _soundSource;
  113672. private _streamingSource;
  113673. private _soundPanner;
  113674. private _soundGain;
  113675. private _inputAudioNode;
  113676. private _outputAudioNode;
  113677. private _coneInnerAngle;
  113678. private _coneOuterAngle;
  113679. private _coneOuterGain;
  113680. private _scene;
  113681. private _connectedTransformNode;
  113682. private _customAttenuationFunction;
  113683. private _registerFunc;
  113684. private _isOutputConnected;
  113685. private _htmlAudioElement;
  113686. private _urlType;
  113687. private _length?;
  113688. private _offset?;
  113689. /** @hidden */
  113690. static _SceneComponentInitialization: (scene: Scene) => void;
  113691. /**
  113692. * Create a sound and attach it to a scene
  113693. * @param name Name of your sound
  113694. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113695. * @param scene defines the scene the sound belongs to
  113696. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113697. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113698. */
  113699. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113700. /**
  113701. * Release the sound and its associated resources
  113702. */
  113703. dispose(): void;
  113704. /**
  113705. * Gets if the sounds is ready to be played or not.
  113706. * @returns true if ready, otherwise false
  113707. */
  113708. isReady(): boolean;
  113709. private _soundLoaded;
  113710. /**
  113711. * Sets the data of the sound from an audiobuffer
  113712. * @param audioBuffer The audioBuffer containing the data
  113713. */
  113714. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113715. /**
  113716. * Updates the current sounds options such as maxdistance, loop...
  113717. * @param options A JSON object containing values named as the object properties
  113718. */
  113719. updateOptions(options: ISoundOptions): void;
  113720. private _createSpatialParameters;
  113721. private _updateSpatialParameters;
  113722. /**
  113723. * Switch the panning model to HRTF:
  113724. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113726. */
  113727. switchPanningModelToHRTF(): void;
  113728. /**
  113729. * Switch the panning model to Equal Power:
  113730. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113732. */
  113733. switchPanningModelToEqualPower(): void;
  113734. private _switchPanningModel;
  113735. /**
  113736. * Connect this sound to a sound track audio node like gain...
  113737. * @param soundTrackAudioNode the sound track audio node to connect to
  113738. */
  113739. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  113740. /**
  113741. * Transform this sound into a directional source
  113742. * @param coneInnerAngle Size of the inner cone in degree
  113743. * @param coneOuterAngle Size of the outer cone in degree
  113744. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  113745. */
  113746. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  113747. /**
  113748. * Gets or sets the inner angle for the directional cone.
  113749. */
  113750. get directionalConeInnerAngle(): number;
  113751. /**
  113752. * Gets or sets the inner angle for the directional cone.
  113753. */
  113754. set directionalConeInnerAngle(value: number);
  113755. /**
  113756. * Gets or sets the outer angle for the directional cone.
  113757. */
  113758. get directionalConeOuterAngle(): number;
  113759. /**
  113760. * Gets or sets the outer angle for the directional cone.
  113761. */
  113762. set directionalConeOuterAngle(value: number);
  113763. /**
  113764. * Sets the position of the emitter if spatial sound is enabled
  113765. * @param newPosition Defines the new posisiton
  113766. */
  113767. setPosition(newPosition: Vector3): void;
  113768. /**
  113769. * Sets the local direction of the emitter if spatial sound is enabled
  113770. * @param newLocalDirection Defines the new local direction
  113771. */
  113772. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  113773. private _updateDirection;
  113774. /** @hidden */
  113775. updateDistanceFromListener(): void;
  113776. /**
  113777. * Sets a new custom attenuation function for the sound.
  113778. * @param callback Defines the function used for the attenuation
  113779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113780. */
  113781. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  113782. /**
  113783. * Play the sound
  113784. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  113785. * @param offset (optional) Start the sound at a specific time in seconds
  113786. * @param length (optional) Sound duration (in seconds)
  113787. */
  113788. play(time?: number, offset?: number, length?: number): void;
  113789. private _onended;
  113790. /**
  113791. * Stop the sound
  113792. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  113793. */
  113794. stop(time?: number): void;
  113795. /**
  113796. * Put the sound in pause
  113797. */
  113798. pause(): void;
  113799. /**
  113800. * Sets a dedicated volume for this sounds
  113801. * @param newVolume Define the new volume of the sound
  113802. * @param time Define time for gradual change to new volume
  113803. */
  113804. setVolume(newVolume: number, time?: number): void;
  113805. /**
  113806. * Set the sound play back rate
  113807. * @param newPlaybackRate Define the playback rate the sound should be played at
  113808. */
  113809. setPlaybackRate(newPlaybackRate: number): void;
  113810. /**
  113811. * Gets the volume of the sound.
  113812. * @returns the volume of the sound
  113813. */
  113814. getVolume(): number;
  113815. /**
  113816. * Attach the sound to a dedicated mesh
  113817. * @param transformNode The transform node to connect the sound with
  113818. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113819. */
  113820. attachToMesh(transformNode: TransformNode): void;
  113821. /**
  113822. * Detach the sound from the previously attached mesh
  113823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113824. */
  113825. detachFromMesh(): void;
  113826. private _onRegisterAfterWorldMatrixUpdate;
  113827. /**
  113828. * Clone the current sound in the scene.
  113829. * @returns the new sound clone
  113830. */
  113831. clone(): Nullable<Sound>;
  113832. /**
  113833. * Gets the current underlying audio buffer containing the data
  113834. * @returns the audio buffer
  113835. */
  113836. getAudioBuffer(): Nullable<AudioBuffer>;
  113837. /**
  113838. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  113839. * @returns the source node
  113840. */
  113841. getSoundSource(): Nullable<AudioBufferSourceNode>;
  113842. /**
  113843. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  113844. * @returns the gain node
  113845. */
  113846. getSoundGain(): Nullable<GainNode>;
  113847. /**
  113848. * Serializes the Sound in a JSON representation
  113849. * @returns the JSON representation of the sound
  113850. */
  113851. serialize(): any;
  113852. /**
  113853. * Parse a JSON representation of a sound to innstantiate in a given scene
  113854. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  113855. * @param scene Define the scene the new parsed sound should be created in
  113856. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  113857. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  113858. * @returns the newly parsed sound
  113859. */
  113860. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  113861. }
  113862. }
  113863. declare module BABYLON {
  113864. /**
  113865. * This defines an action helpful to play a defined sound on a triggered action.
  113866. */
  113867. export class PlaySoundAction extends Action {
  113868. private _sound;
  113869. /**
  113870. * Instantiate the action
  113871. * @param triggerOptions defines the trigger options
  113872. * @param sound defines the sound to play
  113873. * @param condition defines the trigger related conditions
  113874. */
  113875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113876. /** @hidden */
  113877. _prepare(): void;
  113878. /**
  113879. * Execute the action and play the sound.
  113880. */
  113881. execute(): void;
  113882. /**
  113883. * Serializes the actions and its related information.
  113884. * @param parent defines the object to serialize in
  113885. * @returns the serialized object
  113886. */
  113887. serialize(parent: any): any;
  113888. }
  113889. /**
  113890. * This defines an action helpful to stop a defined sound on a triggered action.
  113891. */
  113892. export class StopSoundAction extends Action {
  113893. private _sound;
  113894. /**
  113895. * Instantiate the action
  113896. * @param triggerOptions defines the trigger options
  113897. * @param sound defines the sound to stop
  113898. * @param condition defines the trigger related conditions
  113899. */
  113900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113901. /** @hidden */
  113902. _prepare(): void;
  113903. /**
  113904. * Execute the action and stop the sound.
  113905. */
  113906. execute(): void;
  113907. /**
  113908. * Serializes the actions and its related information.
  113909. * @param parent defines the object to serialize in
  113910. * @returns the serialized object
  113911. */
  113912. serialize(parent: any): any;
  113913. }
  113914. }
  113915. declare module BABYLON {
  113916. /**
  113917. * This defines an action responsible to change the value of a property
  113918. * by interpolating between its current value and the newly set one once triggered.
  113919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  113920. */
  113921. export class InterpolateValueAction extends Action {
  113922. /**
  113923. * Defines the path of the property where the value should be interpolated
  113924. */
  113925. propertyPath: string;
  113926. /**
  113927. * Defines the target value at the end of the interpolation.
  113928. */
  113929. value: any;
  113930. /**
  113931. * Defines the time it will take for the property to interpolate to the value.
  113932. */
  113933. duration: number;
  113934. /**
  113935. * Defines if the other scene animations should be stopped when the action has been triggered
  113936. */
  113937. stopOtherAnimations?: boolean;
  113938. /**
  113939. * Defines a callback raised once the interpolation animation has been done.
  113940. */
  113941. onInterpolationDone?: () => void;
  113942. /**
  113943. * Observable triggered once the interpolation animation has been done.
  113944. */
  113945. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  113946. private _target;
  113947. private _effectiveTarget;
  113948. private _property;
  113949. /**
  113950. * Instantiate the action
  113951. * @param triggerOptions defines the trigger options
  113952. * @param target defines the object containing the value to interpolate
  113953. * @param propertyPath defines the path to the property in the target object
  113954. * @param value defines the target value at the end of the interpolation
  113955. * @param duration deines the time it will take for the property to interpolate to the value.
  113956. * @param condition defines the trigger related conditions
  113957. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  113958. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  113959. */
  113960. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  113961. /** @hidden */
  113962. _prepare(): void;
  113963. /**
  113964. * Execute the action starts the value interpolation.
  113965. */
  113966. execute(): void;
  113967. /**
  113968. * Serializes the actions and its related information.
  113969. * @param parent defines the object to serialize in
  113970. * @returns the serialized object
  113971. */
  113972. serialize(parent: any): any;
  113973. }
  113974. }
  113975. declare module BABYLON {
  113976. /**
  113977. * Options allowed during the creation of a sound track.
  113978. */
  113979. export interface ISoundTrackOptions {
  113980. /**
  113981. * The volume the sound track should take during creation
  113982. */
  113983. volume?: number;
  113984. /**
  113985. * Define if the sound track is the main sound track of the scene
  113986. */
  113987. mainTrack?: boolean;
  113988. }
  113989. /**
  113990. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  113991. * It will be also used in a future release to apply effects on a specific track.
  113992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  113993. */
  113994. export class SoundTrack {
  113995. /**
  113996. * The unique identifier of the sound track in the scene.
  113997. */
  113998. id: number;
  113999. /**
  114000. * The list of sounds included in the sound track.
  114001. */
  114002. soundCollection: Array<Sound>;
  114003. private _outputAudioNode;
  114004. private _scene;
  114005. private _connectedAnalyser;
  114006. private _options;
  114007. private _isInitialized;
  114008. /**
  114009. * Creates a new sound track.
  114010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114011. * @param scene Define the scene the sound track belongs to
  114012. * @param options
  114013. */
  114014. constructor(scene: Scene, options?: ISoundTrackOptions);
  114015. private _initializeSoundTrackAudioGraph;
  114016. /**
  114017. * Release the sound track and its associated resources
  114018. */
  114019. dispose(): void;
  114020. /**
  114021. * Adds a sound to this sound track
  114022. * @param sound define the cound to add
  114023. * @ignoreNaming
  114024. */
  114025. AddSound(sound: Sound): void;
  114026. /**
  114027. * Removes a sound to this sound track
  114028. * @param sound define the cound to remove
  114029. * @ignoreNaming
  114030. */
  114031. RemoveSound(sound: Sound): void;
  114032. /**
  114033. * Set a global volume for the full sound track.
  114034. * @param newVolume Define the new volume of the sound track
  114035. */
  114036. setVolume(newVolume: number): void;
  114037. /**
  114038. * Switch the panning model to HRTF:
  114039. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114041. */
  114042. switchPanningModelToHRTF(): void;
  114043. /**
  114044. * Switch the panning model to Equal Power:
  114045. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114047. */
  114048. switchPanningModelToEqualPower(): void;
  114049. /**
  114050. * Connect the sound track to an audio analyser allowing some amazing
  114051. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114053. * @param analyser The analyser to connect to the engine
  114054. */
  114055. connectToAnalyser(analyser: Analyser): void;
  114056. }
  114057. }
  114058. declare module BABYLON {
  114059. interface AbstractScene {
  114060. /**
  114061. * The list of sounds used in the scene.
  114062. */
  114063. sounds: Nullable<Array<Sound>>;
  114064. }
  114065. interface Scene {
  114066. /**
  114067. * @hidden
  114068. * Backing field
  114069. */
  114070. _mainSoundTrack: SoundTrack;
  114071. /**
  114072. * The main sound track played by the scene.
  114073. * It cotains your primary collection of sounds.
  114074. */
  114075. mainSoundTrack: SoundTrack;
  114076. /**
  114077. * The list of sound tracks added to the scene
  114078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114079. */
  114080. soundTracks: Nullable<Array<SoundTrack>>;
  114081. /**
  114082. * Gets a sound using a given name
  114083. * @param name defines the name to search for
  114084. * @return the found sound or null if not found at all.
  114085. */
  114086. getSoundByName(name: string): Nullable<Sound>;
  114087. /**
  114088. * Gets or sets if audio support is enabled
  114089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114090. */
  114091. audioEnabled: boolean;
  114092. /**
  114093. * Gets or sets if audio will be output to headphones
  114094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114095. */
  114096. headphone: boolean;
  114097. /**
  114098. * Gets or sets custom audio listener position provider
  114099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114100. */
  114101. audioListenerPositionProvider: Nullable<() => Vector3>;
  114102. /**
  114103. * Gets or sets a refresh rate when using 3D audio positioning
  114104. */
  114105. audioPositioningRefreshRate: number;
  114106. }
  114107. /**
  114108. * Defines the sound scene component responsible to manage any sounds
  114109. * in a given scene.
  114110. */
  114111. export class AudioSceneComponent implements ISceneSerializableComponent {
  114112. /**
  114113. * The component name helpfull to identify the component in the list of scene components.
  114114. */
  114115. readonly name: string;
  114116. /**
  114117. * The scene the component belongs to.
  114118. */
  114119. scene: Scene;
  114120. private _audioEnabled;
  114121. /**
  114122. * Gets whether audio is enabled or not.
  114123. * Please use related enable/disable method to switch state.
  114124. */
  114125. get audioEnabled(): boolean;
  114126. private _headphone;
  114127. /**
  114128. * Gets whether audio is outputing to headphone or not.
  114129. * Please use the according Switch methods to change output.
  114130. */
  114131. get headphone(): boolean;
  114132. /**
  114133. * Gets or sets a refresh rate when using 3D audio positioning
  114134. */
  114135. audioPositioningRefreshRate: number;
  114136. private _audioListenerPositionProvider;
  114137. /**
  114138. * Gets the current audio listener position provider
  114139. */
  114140. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114141. /**
  114142. * Sets a custom listener position for all sounds in the scene
  114143. * By default, this is the position of the first active camera
  114144. */
  114145. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114146. /**
  114147. * Creates a new instance of the component for the given scene
  114148. * @param scene Defines the scene to register the component in
  114149. */
  114150. constructor(scene: Scene);
  114151. /**
  114152. * Registers the component in a given scene
  114153. */
  114154. register(): void;
  114155. /**
  114156. * Rebuilds the elements related to this component in case of
  114157. * context lost for instance.
  114158. */
  114159. rebuild(): void;
  114160. /**
  114161. * Serializes the component data to the specified json object
  114162. * @param serializationObject The object to serialize to
  114163. */
  114164. serialize(serializationObject: any): void;
  114165. /**
  114166. * Adds all the elements from the container to the scene
  114167. * @param container the container holding the elements
  114168. */
  114169. addFromContainer(container: AbstractScene): void;
  114170. /**
  114171. * Removes all the elements in the container from the scene
  114172. * @param container contains the elements to remove
  114173. * @param dispose if the removed element should be disposed (default: false)
  114174. */
  114175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114176. /**
  114177. * Disposes the component and the associated ressources.
  114178. */
  114179. dispose(): void;
  114180. /**
  114181. * Disables audio in the associated scene.
  114182. */
  114183. disableAudio(): void;
  114184. /**
  114185. * Enables audio in the associated scene.
  114186. */
  114187. enableAudio(): void;
  114188. /**
  114189. * Switch audio to headphone output.
  114190. */
  114191. switchAudioModeForHeadphones(): void;
  114192. /**
  114193. * Switch audio to normal speakers.
  114194. */
  114195. switchAudioModeForNormalSpeakers(): void;
  114196. private _cachedCameraDirection;
  114197. private _cachedCameraPosition;
  114198. private _lastCheck;
  114199. private _afterRender;
  114200. }
  114201. }
  114202. declare module BABYLON {
  114203. /**
  114204. * Wraps one or more Sound objects and selects one with random weight for playback.
  114205. */
  114206. export class WeightedSound {
  114207. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114208. loop: boolean;
  114209. private _coneInnerAngle;
  114210. private _coneOuterAngle;
  114211. private _volume;
  114212. /** A Sound is currently playing. */
  114213. isPlaying: boolean;
  114214. /** A Sound is currently paused. */
  114215. isPaused: boolean;
  114216. private _sounds;
  114217. private _weights;
  114218. private _currentIndex?;
  114219. /**
  114220. * Creates a new WeightedSound from the list of sounds given.
  114221. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114222. * @param sounds Array of Sounds that will be selected from.
  114223. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114224. */
  114225. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114226. /**
  114227. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114228. */
  114229. get directionalConeInnerAngle(): number;
  114230. /**
  114231. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114232. */
  114233. set directionalConeInnerAngle(value: number);
  114234. /**
  114235. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114236. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114237. */
  114238. get directionalConeOuterAngle(): number;
  114239. /**
  114240. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114241. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114242. */
  114243. set directionalConeOuterAngle(value: number);
  114244. /**
  114245. * Playback volume.
  114246. */
  114247. get volume(): number;
  114248. /**
  114249. * Playback volume.
  114250. */
  114251. set volume(value: number);
  114252. private _onended;
  114253. /**
  114254. * Suspend playback
  114255. */
  114256. pause(): void;
  114257. /**
  114258. * Stop playback
  114259. */
  114260. stop(): void;
  114261. /**
  114262. * Start playback.
  114263. * @param startOffset Position the clip head at a specific time in seconds.
  114264. */
  114265. play(startOffset?: number): void;
  114266. }
  114267. }
  114268. declare module BABYLON {
  114269. /**
  114270. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114272. */
  114273. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114274. /**
  114275. * Gets the name of the behavior.
  114276. */
  114277. get name(): string;
  114278. /**
  114279. * The easing function used by animations
  114280. */
  114281. static EasingFunction: BackEase;
  114282. /**
  114283. * The easing mode used by animations
  114284. */
  114285. static EasingMode: number;
  114286. /**
  114287. * The duration of the animation, in milliseconds
  114288. */
  114289. transitionDuration: number;
  114290. /**
  114291. * Length of the distance animated by the transition when lower radius is reached
  114292. */
  114293. lowerRadiusTransitionRange: number;
  114294. /**
  114295. * Length of the distance animated by the transition when upper radius is reached
  114296. */
  114297. upperRadiusTransitionRange: number;
  114298. private _autoTransitionRange;
  114299. /**
  114300. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114301. */
  114302. get autoTransitionRange(): boolean;
  114303. /**
  114304. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114305. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114306. */
  114307. set autoTransitionRange(value: boolean);
  114308. private _attachedCamera;
  114309. private _onAfterCheckInputsObserver;
  114310. private _onMeshTargetChangedObserver;
  114311. /**
  114312. * Initializes the behavior.
  114313. */
  114314. init(): void;
  114315. /**
  114316. * Attaches the behavior to its arc rotate camera.
  114317. * @param camera Defines the camera to attach the behavior to
  114318. */
  114319. attach(camera: ArcRotateCamera): void;
  114320. /**
  114321. * Detaches the behavior from its current arc rotate camera.
  114322. */
  114323. detach(): void;
  114324. private _radiusIsAnimating;
  114325. private _radiusBounceTransition;
  114326. private _animatables;
  114327. private _cachedWheelPrecision;
  114328. /**
  114329. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114330. * @param radiusLimit The limit to check against.
  114331. * @return Bool to indicate if at limit.
  114332. */
  114333. private _isRadiusAtLimit;
  114334. /**
  114335. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114336. * @param radiusDelta The delta by which to animate to. Can be negative.
  114337. */
  114338. private _applyBoundRadiusAnimation;
  114339. /**
  114340. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114341. */
  114342. protected _clearAnimationLocks(): void;
  114343. /**
  114344. * Stops and removes all animations that have been applied to the camera
  114345. */
  114346. stopAllAnimations(): void;
  114347. }
  114348. }
  114349. declare module BABYLON {
  114350. /**
  114351. * 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.
  114352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114353. */
  114354. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114355. /**
  114356. * Gets the name of the behavior.
  114357. */
  114358. get name(): string;
  114359. private _mode;
  114360. private _radiusScale;
  114361. private _positionScale;
  114362. private _defaultElevation;
  114363. private _elevationReturnTime;
  114364. private _elevationReturnWaitTime;
  114365. private _zoomStopsAnimation;
  114366. private _framingTime;
  114367. /**
  114368. * The easing function used by animations
  114369. */
  114370. static EasingFunction: ExponentialEase;
  114371. /**
  114372. * The easing mode used by animations
  114373. */
  114374. static EasingMode: number;
  114375. /**
  114376. * Sets the current mode used by the behavior
  114377. */
  114378. set mode(mode: number);
  114379. /**
  114380. * Gets current mode used by the behavior.
  114381. */
  114382. get mode(): number;
  114383. /**
  114384. * Sets the scale applied to the radius (1 by default)
  114385. */
  114386. set radiusScale(radius: number);
  114387. /**
  114388. * Gets the scale applied to the radius
  114389. */
  114390. get radiusScale(): number;
  114391. /**
  114392. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114393. */
  114394. set positionScale(scale: number);
  114395. /**
  114396. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114397. */
  114398. get positionScale(): number;
  114399. /**
  114400. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114401. * behaviour is triggered, in radians.
  114402. */
  114403. set defaultElevation(elevation: number);
  114404. /**
  114405. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114406. * behaviour is triggered, in radians.
  114407. */
  114408. get defaultElevation(): number;
  114409. /**
  114410. * Sets the time (in milliseconds) taken to return to the default beta position.
  114411. * Negative value indicates camera should not return to default.
  114412. */
  114413. set elevationReturnTime(speed: number);
  114414. /**
  114415. * Gets the time (in milliseconds) taken to return to the default beta position.
  114416. * Negative value indicates camera should not return to default.
  114417. */
  114418. get elevationReturnTime(): number;
  114419. /**
  114420. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114421. */
  114422. set elevationReturnWaitTime(time: number);
  114423. /**
  114424. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114425. */
  114426. get elevationReturnWaitTime(): number;
  114427. /**
  114428. * Sets the flag that indicates if user zooming should stop animation.
  114429. */
  114430. set zoomStopsAnimation(flag: boolean);
  114431. /**
  114432. * Gets the flag that indicates if user zooming should stop animation.
  114433. */
  114434. get zoomStopsAnimation(): boolean;
  114435. /**
  114436. * Sets the transition time when framing the mesh, in milliseconds
  114437. */
  114438. set framingTime(time: number);
  114439. /**
  114440. * Gets the transition time when framing the mesh, in milliseconds
  114441. */
  114442. get framingTime(): number;
  114443. /**
  114444. * Define if the behavior should automatically change the configured
  114445. * camera limits and sensibilities.
  114446. */
  114447. autoCorrectCameraLimitsAndSensibility: boolean;
  114448. private _onPrePointerObservableObserver;
  114449. private _onAfterCheckInputsObserver;
  114450. private _onMeshTargetChangedObserver;
  114451. private _attachedCamera;
  114452. private _isPointerDown;
  114453. private _lastInteractionTime;
  114454. /**
  114455. * Initializes the behavior.
  114456. */
  114457. init(): void;
  114458. /**
  114459. * Attaches the behavior to its arc rotate camera.
  114460. * @param camera Defines the camera to attach the behavior to
  114461. */
  114462. attach(camera: ArcRotateCamera): void;
  114463. /**
  114464. * Detaches the behavior from its current arc rotate camera.
  114465. */
  114466. detach(): void;
  114467. private _animatables;
  114468. private _betaIsAnimating;
  114469. private _betaTransition;
  114470. private _radiusTransition;
  114471. private _vectorTransition;
  114472. /**
  114473. * Targets the given mesh and updates zoom level accordingly.
  114474. * @param mesh The mesh to target.
  114475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114477. */
  114478. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114479. /**
  114480. * Targets the given mesh with its children and updates zoom level accordingly.
  114481. * @param mesh The mesh to target.
  114482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114484. */
  114485. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114486. /**
  114487. * Targets the given meshes with their children and updates zoom level accordingly.
  114488. * @param meshes The mesh to target.
  114489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114491. */
  114492. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114493. /**
  114494. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114495. * @param minimumWorld Determines the smaller position of the bounding box extend
  114496. * @param maximumWorld Determines the bigger position of the bounding box extend
  114497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114499. */
  114500. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114501. /**
  114502. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114503. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114504. * frustum width.
  114505. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114506. * to fully enclose the mesh in the viewing frustum.
  114507. */
  114508. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114509. /**
  114510. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114511. * is automatically returned to its default position (expected to be above ground plane).
  114512. */
  114513. private _maintainCameraAboveGround;
  114514. /**
  114515. * Returns the frustum slope based on the canvas ratio and camera FOV
  114516. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114517. */
  114518. private _getFrustumSlope;
  114519. /**
  114520. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114521. */
  114522. private _clearAnimationLocks;
  114523. /**
  114524. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114525. */
  114526. private _applyUserInteraction;
  114527. /**
  114528. * Stops and removes all animations that have been applied to the camera
  114529. */
  114530. stopAllAnimations(): void;
  114531. /**
  114532. * Gets a value indicating if the user is moving the camera
  114533. */
  114534. get isUserIsMoving(): boolean;
  114535. /**
  114536. * The camera can move all the way towards the mesh.
  114537. */
  114538. static IgnoreBoundsSizeMode: number;
  114539. /**
  114540. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114541. */
  114542. static FitFrustumSidesMode: number;
  114543. }
  114544. }
  114545. declare module BABYLON {
  114546. /**
  114547. * Base class for Camera Pointer Inputs.
  114548. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114549. * for example usage.
  114550. */
  114551. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114552. /**
  114553. * Defines the camera the input is attached to.
  114554. */
  114555. abstract camera: Camera;
  114556. /**
  114557. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114558. */
  114559. protected _altKey: boolean;
  114560. protected _ctrlKey: boolean;
  114561. protected _metaKey: boolean;
  114562. protected _shiftKey: boolean;
  114563. /**
  114564. * Which mouse buttons were pressed at time of last mouse event.
  114565. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114566. */
  114567. protected _buttonsPressed: number;
  114568. /**
  114569. * Defines the buttons associated with the input to handle camera move.
  114570. */
  114571. buttons: number[];
  114572. /**
  114573. * Attach the input controls to a specific dom element to get the input from.
  114574. * @param element Defines the element the controls should be listened from
  114575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114576. */
  114577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114578. /**
  114579. * Detach the current controls from the specified dom element.
  114580. * @param element Defines the element to stop listening the inputs from
  114581. */
  114582. detachControl(element: Nullable<HTMLElement>): void;
  114583. /**
  114584. * Gets the class name of the current input.
  114585. * @returns the class name
  114586. */
  114587. getClassName(): string;
  114588. /**
  114589. * Get the friendly name associated with the input class.
  114590. * @returns the input friendly name
  114591. */
  114592. getSimpleName(): string;
  114593. /**
  114594. * Called on pointer POINTERDOUBLETAP event.
  114595. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114596. */
  114597. protected onDoubleTap(type: string): void;
  114598. /**
  114599. * Called on pointer POINTERMOVE event if only a single touch is active.
  114600. * Override this method to provide functionality.
  114601. */
  114602. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114603. /**
  114604. * Called on pointer POINTERMOVE event if multiple touches are active.
  114605. * Override this method to provide functionality.
  114606. */
  114607. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114608. /**
  114609. * Called on JS contextmenu event.
  114610. * Override this method to provide functionality.
  114611. */
  114612. protected onContextMenu(evt: PointerEvent): void;
  114613. /**
  114614. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114615. * press.
  114616. * Override this method to provide functionality.
  114617. */
  114618. protected onButtonDown(evt: PointerEvent): void;
  114619. /**
  114620. * Called each time a new POINTERUP event occurs. Ie, for each button
  114621. * release.
  114622. * Override this method to provide functionality.
  114623. */
  114624. protected onButtonUp(evt: PointerEvent): void;
  114625. /**
  114626. * Called when window becomes inactive.
  114627. * Override this method to provide functionality.
  114628. */
  114629. protected onLostFocus(): void;
  114630. private _pointerInput;
  114631. private _observer;
  114632. private _onLostFocus;
  114633. private pointA;
  114634. private pointB;
  114635. }
  114636. }
  114637. declare module BABYLON {
  114638. /**
  114639. * Manage the pointers inputs to control an arc rotate camera.
  114640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114641. */
  114642. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114643. /**
  114644. * Defines the camera the input is attached to.
  114645. */
  114646. camera: ArcRotateCamera;
  114647. /**
  114648. * Gets the class name of the current input.
  114649. * @returns the class name
  114650. */
  114651. getClassName(): string;
  114652. /**
  114653. * Defines the buttons associated with the input to handle camera move.
  114654. */
  114655. buttons: number[];
  114656. /**
  114657. * Defines the pointer angular sensibility along the X axis or how fast is
  114658. * the camera rotating.
  114659. */
  114660. angularSensibilityX: number;
  114661. /**
  114662. * Defines the pointer angular sensibility along the Y axis or how fast is
  114663. * the camera rotating.
  114664. */
  114665. angularSensibilityY: number;
  114666. /**
  114667. * Defines the pointer pinch precision or how fast is the camera zooming.
  114668. */
  114669. pinchPrecision: number;
  114670. /**
  114671. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114672. * from 0.
  114673. * It defines the percentage of current camera.radius to use as delta when
  114674. * pinch zoom is used.
  114675. */
  114676. pinchDeltaPercentage: number;
  114677. /**
  114678. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114679. * that any object in the plane at the camera's target point will scale
  114680. * perfectly with finger motion.
  114681. * Overrides pinchDeltaPercentage and pinchPrecision.
  114682. */
  114683. useNaturalPinchZoom: boolean;
  114684. /**
  114685. * Defines the pointer panning sensibility or how fast is the camera moving.
  114686. */
  114687. panningSensibility: number;
  114688. /**
  114689. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114690. */
  114691. multiTouchPanning: boolean;
  114692. /**
  114693. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114694. * zoom (pinch) through multitouch.
  114695. */
  114696. multiTouchPanAndZoom: boolean;
  114697. /**
  114698. * Revers pinch action direction.
  114699. */
  114700. pinchInwards: boolean;
  114701. private _isPanClick;
  114702. private _twoFingerActivityCount;
  114703. private _isPinching;
  114704. /**
  114705. * Called on pointer POINTERMOVE event if only a single touch is active.
  114706. */
  114707. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114708. /**
  114709. * Called on pointer POINTERDOUBLETAP event.
  114710. */
  114711. protected onDoubleTap(type: string): void;
  114712. /**
  114713. * Called on pointer POINTERMOVE event if multiple touches are active.
  114714. */
  114715. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114716. /**
  114717. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114718. * press.
  114719. */
  114720. protected onButtonDown(evt: PointerEvent): void;
  114721. /**
  114722. * Called each time a new POINTERUP event occurs. Ie, for each button
  114723. * release.
  114724. */
  114725. protected onButtonUp(evt: PointerEvent): void;
  114726. /**
  114727. * Called when window becomes inactive.
  114728. */
  114729. protected onLostFocus(): void;
  114730. }
  114731. }
  114732. declare module BABYLON {
  114733. /**
  114734. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  114735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114736. */
  114737. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  114738. /**
  114739. * Defines the camera the input is attached to.
  114740. */
  114741. camera: ArcRotateCamera;
  114742. /**
  114743. * Defines the list of key codes associated with the up action (increase alpha)
  114744. */
  114745. keysUp: number[];
  114746. /**
  114747. * Defines the list of key codes associated with the down action (decrease alpha)
  114748. */
  114749. keysDown: number[];
  114750. /**
  114751. * Defines the list of key codes associated with the left action (increase beta)
  114752. */
  114753. keysLeft: number[];
  114754. /**
  114755. * Defines the list of key codes associated with the right action (decrease beta)
  114756. */
  114757. keysRight: number[];
  114758. /**
  114759. * Defines the list of key codes associated with the reset action.
  114760. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  114761. */
  114762. keysReset: number[];
  114763. /**
  114764. * Defines the panning sensibility of the inputs.
  114765. * (How fast is the camera panning)
  114766. */
  114767. panningSensibility: number;
  114768. /**
  114769. * Defines the zooming sensibility of the inputs.
  114770. * (How fast is the camera zooming)
  114771. */
  114772. zoomingSensibility: number;
  114773. /**
  114774. * Defines whether maintaining the alt key down switch the movement mode from
  114775. * orientation to zoom.
  114776. */
  114777. useAltToZoom: boolean;
  114778. /**
  114779. * Rotation speed of the camera
  114780. */
  114781. angularSpeed: number;
  114782. private _keys;
  114783. private _ctrlPressed;
  114784. private _altPressed;
  114785. private _onCanvasBlurObserver;
  114786. private _onKeyboardObserver;
  114787. private _engine;
  114788. private _scene;
  114789. /**
  114790. * Attach the input controls to a specific dom element to get the input from.
  114791. * @param element Defines the element the controls should be listened from
  114792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114793. */
  114794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114795. /**
  114796. * Detach the current controls from the specified dom element.
  114797. * @param element Defines the element to stop listening the inputs from
  114798. */
  114799. detachControl(element: Nullable<HTMLElement>): void;
  114800. /**
  114801. * Update the current camera state depending on the inputs that have been used this frame.
  114802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114803. */
  114804. checkInputs(): void;
  114805. /**
  114806. * Gets the class name of the current intput.
  114807. * @returns the class name
  114808. */
  114809. getClassName(): string;
  114810. /**
  114811. * Get the friendly name associated with the input class.
  114812. * @returns the input friendly name
  114813. */
  114814. getSimpleName(): string;
  114815. }
  114816. }
  114817. declare module BABYLON {
  114818. /**
  114819. * Manage the mouse wheel inputs to control an arc rotate camera.
  114820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114821. */
  114822. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  114823. /**
  114824. * Defines the camera the input is attached to.
  114825. */
  114826. camera: ArcRotateCamera;
  114827. /**
  114828. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  114829. */
  114830. wheelPrecision: number;
  114831. /**
  114832. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114833. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114834. */
  114835. wheelDeltaPercentage: number;
  114836. private _wheel;
  114837. private _observer;
  114838. private computeDeltaFromMouseWheelLegacyEvent;
  114839. /**
  114840. * Attach the input controls to a specific dom element to get the input from.
  114841. * @param element Defines the element the controls should be listened from
  114842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114843. */
  114844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114845. /**
  114846. * Detach the current controls from the specified dom element.
  114847. * @param element Defines the element to stop listening the inputs from
  114848. */
  114849. detachControl(element: Nullable<HTMLElement>): void;
  114850. /**
  114851. * Gets the class name of the current intput.
  114852. * @returns the class name
  114853. */
  114854. getClassName(): string;
  114855. /**
  114856. * Get the friendly name associated with the input class.
  114857. * @returns the input friendly name
  114858. */
  114859. getSimpleName(): string;
  114860. }
  114861. }
  114862. declare module BABYLON {
  114863. /**
  114864. * Default Inputs manager for the ArcRotateCamera.
  114865. * It groups all the default supported inputs for ease of use.
  114866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114867. */
  114868. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  114869. /**
  114870. * Instantiates a new ArcRotateCameraInputsManager.
  114871. * @param camera Defines the camera the inputs belong to
  114872. */
  114873. constructor(camera: ArcRotateCamera);
  114874. /**
  114875. * Add mouse wheel input support to the input manager.
  114876. * @returns the current input manager
  114877. */
  114878. addMouseWheel(): ArcRotateCameraInputsManager;
  114879. /**
  114880. * Add pointers input support to the input manager.
  114881. * @returns the current input manager
  114882. */
  114883. addPointers(): ArcRotateCameraInputsManager;
  114884. /**
  114885. * Add keyboard input support to the input manager.
  114886. * @returns the current input manager
  114887. */
  114888. addKeyboard(): ArcRotateCameraInputsManager;
  114889. }
  114890. }
  114891. declare module BABYLON {
  114892. /**
  114893. * This represents an orbital type of camera.
  114894. *
  114895. * 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.
  114896. * 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.
  114897. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  114898. */
  114899. export class ArcRotateCamera extends TargetCamera {
  114900. /**
  114901. * Defines the rotation angle of the camera along the longitudinal axis.
  114902. */
  114903. alpha: number;
  114904. /**
  114905. * Defines the rotation angle of the camera along the latitudinal axis.
  114906. */
  114907. beta: number;
  114908. /**
  114909. * Defines the radius of the camera from it s target point.
  114910. */
  114911. radius: number;
  114912. protected _target: Vector3;
  114913. protected _targetHost: Nullable<AbstractMesh>;
  114914. /**
  114915. * Defines the target point of the camera.
  114916. * The camera looks towards it form the radius distance.
  114917. */
  114918. get target(): Vector3;
  114919. set target(value: Vector3);
  114920. /**
  114921. * Define the current local position of the camera in the scene
  114922. */
  114923. get position(): Vector3;
  114924. set position(newPosition: Vector3);
  114925. protected _upVector: Vector3;
  114926. protected _upToYMatrix: Matrix;
  114927. protected _YToUpMatrix: Matrix;
  114928. /**
  114929. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  114930. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  114931. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  114932. */
  114933. set upVector(vec: Vector3);
  114934. get upVector(): Vector3;
  114935. /**
  114936. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  114937. */
  114938. setMatUp(): void;
  114939. /**
  114940. * Current inertia value on the longitudinal axis.
  114941. * The bigger this number the longer it will take for the camera to stop.
  114942. */
  114943. inertialAlphaOffset: number;
  114944. /**
  114945. * Current inertia value on the latitudinal axis.
  114946. * The bigger this number the longer it will take for the camera to stop.
  114947. */
  114948. inertialBetaOffset: number;
  114949. /**
  114950. * Current inertia value on the radius axis.
  114951. * The bigger this number the longer it will take for the camera to stop.
  114952. */
  114953. inertialRadiusOffset: number;
  114954. /**
  114955. * Minimum allowed angle on the longitudinal axis.
  114956. * This can help limiting how the Camera is able to move in the scene.
  114957. */
  114958. lowerAlphaLimit: Nullable<number>;
  114959. /**
  114960. * Maximum allowed angle on the longitudinal axis.
  114961. * This can help limiting how the Camera is able to move in the scene.
  114962. */
  114963. upperAlphaLimit: Nullable<number>;
  114964. /**
  114965. * Minimum allowed angle on the latitudinal axis.
  114966. * This can help limiting how the Camera is able to move in the scene.
  114967. */
  114968. lowerBetaLimit: number;
  114969. /**
  114970. * Maximum allowed angle on the latitudinal axis.
  114971. * This can help limiting how the Camera is able to move in the scene.
  114972. */
  114973. upperBetaLimit: number;
  114974. /**
  114975. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  114976. * This can help limiting how the Camera is able to move in the scene.
  114977. */
  114978. lowerRadiusLimit: Nullable<number>;
  114979. /**
  114980. * Maximum allowed distance of the camera to the target (The camera can not get further).
  114981. * This can help limiting how the Camera is able to move in the scene.
  114982. */
  114983. upperRadiusLimit: Nullable<number>;
  114984. /**
  114985. * Defines the current inertia value used during panning of the camera along the X axis.
  114986. */
  114987. inertialPanningX: number;
  114988. /**
  114989. * Defines the current inertia value used during panning of the camera along the Y axis.
  114990. */
  114991. inertialPanningY: number;
  114992. /**
  114993. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  114994. * Basically if your fingers moves away from more than this distance you will be considered
  114995. * in pinch mode.
  114996. */
  114997. pinchToPanMaxDistance: number;
  114998. /**
  114999. * Defines the maximum distance the camera can pan.
  115000. * This could help keeping the cammera always in your scene.
  115001. */
  115002. panningDistanceLimit: Nullable<number>;
  115003. /**
  115004. * Defines the target of the camera before paning.
  115005. */
  115006. panningOriginTarget: Vector3;
  115007. /**
  115008. * Defines the value of the inertia used during panning.
  115009. * 0 would mean stop inertia and one would mean no decelleration at all.
  115010. */
  115011. panningInertia: number;
  115012. /**
  115013. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115014. */
  115015. get angularSensibilityX(): number;
  115016. set angularSensibilityX(value: number);
  115017. /**
  115018. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115019. */
  115020. get angularSensibilityY(): number;
  115021. set angularSensibilityY(value: number);
  115022. /**
  115023. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115024. */
  115025. get pinchPrecision(): number;
  115026. set pinchPrecision(value: number);
  115027. /**
  115028. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115029. * It will be used instead of pinchDeltaPrecision if different from 0.
  115030. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115031. */
  115032. get pinchDeltaPercentage(): number;
  115033. set pinchDeltaPercentage(value: number);
  115034. /**
  115035. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115036. * and pinch delta percentage.
  115037. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115038. * that any object in the plane at the camera's target point will scale
  115039. * perfectly with finger motion.
  115040. */
  115041. get useNaturalPinchZoom(): boolean;
  115042. set useNaturalPinchZoom(value: boolean);
  115043. /**
  115044. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115045. */
  115046. get panningSensibility(): number;
  115047. set panningSensibility(value: number);
  115048. /**
  115049. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115050. */
  115051. get keysUp(): number[];
  115052. set keysUp(value: number[]);
  115053. /**
  115054. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115055. */
  115056. get keysDown(): number[];
  115057. set keysDown(value: number[]);
  115058. /**
  115059. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115060. */
  115061. get keysLeft(): number[];
  115062. set keysLeft(value: number[]);
  115063. /**
  115064. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115065. */
  115066. get keysRight(): number[];
  115067. set keysRight(value: number[]);
  115068. /**
  115069. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115070. */
  115071. get wheelPrecision(): number;
  115072. set wheelPrecision(value: number);
  115073. /**
  115074. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115075. * It will be used instead of pinchDeltaPrecision if different from 0.
  115076. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115077. */
  115078. get wheelDeltaPercentage(): number;
  115079. set wheelDeltaPercentage(value: number);
  115080. /**
  115081. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115082. */
  115083. zoomOnFactor: number;
  115084. /**
  115085. * Defines a screen offset for the camera position.
  115086. */
  115087. targetScreenOffset: Vector2;
  115088. /**
  115089. * Allows the camera to be completely reversed.
  115090. * If false the camera can not arrive upside down.
  115091. */
  115092. allowUpsideDown: boolean;
  115093. /**
  115094. * Define if double tap/click is used to restore the previously saved state of the camera.
  115095. */
  115096. useInputToRestoreState: boolean;
  115097. /** @hidden */
  115098. _viewMatrix: Matrix;
  115099. /** @hidden */
  115100. _useCtrlForPanning: boolean;
  115101. /** @hidden */
  115102. _panningMouseButton: number;
  115103. /**
  115104. * Defines the input associated to the camera.
  115105. */
  115106. inputs: ArcRotateCameraInputsManager;
  115107. /** @hidden */
  115108. _reset: () => void;
  115109. /**
  115110. * Defines the allowed panning axis.
  115111. */
  115112. panningAxis: Vector3;
  115113. protected _localDirection: Vector3;
  115114. protected _transformedDirection: Vector3;
  115115. private _bouncingBehavior;
  115116. /**
  115117. * Gets the bouncing behavior of the camera if it has been enabled.
  115118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115119. */
  115120. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115121. /**
  115122. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115124. */
  115125. get useBouncingBehavior(): boolean;
  115126. set useBouncingBehavior(value: boolean);
  115127. private _framingBehavior;
  115128. /**
  115129. * Gets the framing behavior of the camera if it has been enabled.
  115130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115131. */
  115132. get framingBehavior(): Nullable<FramingBehavior>;
  115133. /**
  115134. * Defines if the framing behavior of the camera is enabled on the camera.
  115135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115136. */
  115137. get useFramingBehavior(): boolean;
  115138. set useFramingBehavior(value: boolean);
  115139. private _autoRotationBehavior;
  115140. /**
  115141. * Gets the auto rotation behavior of the camera if it has been enabled.
  115142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115143. */
  115144. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115145. /**
  115146. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115148. */
  115149. get useAutoRotationBehavior(): boolean;
  115150. set useAutoRotationBehavior(value: boolean);
  115151. /**
  115152. * Observable triggered when the mesh target has been changed on the camera.
  115153. */
  115154. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115155. /**
  115156. * Event raised when the camera is colliding with a mesh.
  115157. */
  115158. onCollide: (collidedMesh: AbstractMesh) => void;
  115159. /**
  115160. * Defines whether the camera should check collision with the objects oh the scene.
  115161. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115162. */
  115163. checkCollisions: boolean;
  115164. /**
  115165. * Defines the collision radius of the camera.
  115166. * This simulates a sphere around the camera.
  115167. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115168. */
  115169. collisionRadius: Vector3;
  115170. protected _collider: Collider;
  115171. protected _previousPosition: Vector3;
  115172. protected _collisionVelocity: Vector3;
  115173. protected _newPosition: Vector3;
  115174. protected _previousAlpha: number;
  115175. protected _previousBeta: number;
  115176. protected _previousRadius: number;
  115177. protected _collisionTriggered: boolean;
  115178. protected _targetBoundingCenter: Nullable<Vector3>;
  115179. private _computationVector;
  115180. /**
  115181. * Instantiates a new ArcRotateCamera in a given scene
  115182. * @param name Defines the name of the camera
  115183. * @param alpha Defines the camera rotation along the logitudinal axis
  115184. * @param beta Defines the camera rotation along the latitudinal axis
  115185. * @param radius Defines the camera distance from its target
  115186. * @param target Defines the camera target
  115187. * @param scene Defines the scene the camera belongs to
  115188. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115189. */
  115190. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115191. /** @hidden */
  115192. _initCache(): void;
  115193. /** @hidden */
  115194. _updateCache(ignoreParentClass?: boolean): void;
  115195. protected _getTargetPosition(): Vector3;
  115196. private _storedAlpha;
  115197. private _storedBeta;
  115198. private _storedRadius;
  115199. private _storedTarget;
  115200. private _storedTargetScreenOffset;
  115201. /**
  115202. * Stores the current state of the camera (alpha, beta, radius and target)
  115203. * @returns the camera itself
  115204. */
  115205. storeState(): Camera;
  115206. /**
  115207. * @hidden
  115208. * Restored camera state. You must call storeState() first
  115209. */
  115210. _restoreStateValues(): boolean;
  115211. /** @hidden */
  115212. _isSynchronizedViewMatrix(): boolean;
  115213. /**
  115214. * Attached controls to the current camera.
  115215. * @param element Defines the element the controls should be listened from
  115216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115217. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115218. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115219. */
  115220. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115221. /**
  115222. * Detach the current controls from the camera.
  115223. * The camera will stop reacting to inputs.
  115224. * @param element Defines the element to stop listening the inputs from
  115225. */
  115226. detachControl(element: HTMLElement): void;
  115227. /** @hidden */
  115228. _checkInputs(): void;
  115229. protected _checkLimits(): void;
  115230. /**
  115231. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115232. */
  115233. rebuildAnglesAndRadius(): void;
  115234. /**
  115235. * Use a position to define the current camera related information like alpha, beta and radius
  115236. * @param position Defines the position to set the camera at
  115237. */
  115238. setPosition(position: Vector3): void;
  115239. /**
  115240. * Defines the target the camera should look at.
  115241. * This will automatically adapt alpha beta and radius to fit within the new target.
  115242. * @param target Defines the new target as a Vector or a mesh
  115243. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115244. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115245. */
  115246. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115247. /** @hidden */
  115248. _getViewMatrix(): Matrix;
  115249. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115250. /**
  115251. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115252. * @param meshes Defines the mesh to zoom on
  115253. * @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)
  115254. */
  115255. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115256. /**
  115257. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115258. * The target will be changed but the radius
  115259. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115260. * @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)
  115261. */
  115262. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115263. min: Vector3;
  115264. max: Vector3;
  115265. distance: number;
  115266. }, doNotUpdateMaxZ?: boolean): void;
  115267. /**
  115268. * @override
  115269. * Override Camera.createRigCamera
  115270. */
  115271. createRigCamera(name: string, cameraIndex: number): Camera;
  115272. /**
  115273. * @hidden
  115274. * @override
  115275. * Override Camera._updateRigCameras
  115276. */
  115277. _updateRigCameras(): void;
  115278. /**
  115279. * Destroy the camera and release the current resources hold by it.
  115280. */
  115281. dispose(): void;
  115282. /**
  115283. * Gets the current object class name.
  115284. * @return the class name
  115285. */
  115286. getClassName(): string;
  115287. }
  115288. }
  115289. declare module BABYLON {
  115290. /**
  115291. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115293. */
  115294. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115295. /**
  115296. * Gets the name of the behavior.
  115297. */
  115298. get name(): string;
  115299. private _zoomStopsAnimation;
  115300. private _idleRotationSpeed;
  115301. private _idleRotationWaitTime;
  115302. private _idleRotationSpinupTime;
  115303. /**
  115304. * Sets the flag that indicates if user zooming should stop animation.
  115305. */
  115306. set zoomStopsAnimation(flag: boolean);
  115307. /**
  115308. * Gets the flag that indicates if user zooming should stop animation.
  115309. */
  115310. get zoomStopsAnimation(): boolean;
  115311. /**
  115312. * Sets the default speed at which the camera rotates around the model.
  115313. */
  115314. set idleRotationSpeed(speed: number);
  115315. /**
  115316. * Gets the default speed at which the camera rotates around the model.
  115317. */
  115318. get idleRotationSpeed(): number;
  115319. /**
  115320. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115321. */
  115322. set idleRotationWaitTime(time: number);
  115323. /**
  115324. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115325. */
  115326. get idleRotationWaitTime(): number;
  115327. /**
  115328. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115329. */
  115330. set idleRotationSpinupTime(time: number);
  115331. /**
  115332. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115333. */
  115334. get idleRotationSpinupTime(): number;
  115335. /**
  115336. * Gets a value indicating if the camera is currently rotating because of this behavior
  115337. */
  115338. get rotationInProgress(): boolean;
  115339. private _onPrePointerObservableObserver;
  115340. private _onAfterCheckInputsObserver;
  115341. private _attachedCamera;
  115342. private _isPointerDown;
  115343. private _lastFrameTime;
  115344. private _lastInteractionTime;
  115345. private _cameraRotationSpeed;
  115346. /**
  115347. * Initializes the behavior.
  115348. */
  115349. init(): void;
  115350. /**
  115351. * Attaches the behavior to its arc rotate camera.
  115352. * @param camera Defines the camera to attach the behavior to
  115353. */
  115354. attach(camera: ArcRotateCamera): void;
  115355. /**
  115356. * Detaches the behavior from its current arc rotate camera.
  115357. */
  115358. detach(): void;
  115359. /**
  115360. * Returns true if user is scrolling.
  115361. * @return true if user is scrolling.
  115362. */
  115363. private _userIsZooming;
  115364. private _lastFrameRadius;
  115365. private _shouldAnimationStopForInteraction;
  115366. /**
  115367. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115368. */
  115369. private _applyUserInteraction;
  115370. private _userIsMoving;
  115371. }
  115372. }
  115373. declare module BABYLON {
  115374. /**
  115375. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115376. */
  115377. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115378. private ui;
  115379. /**
  115380. * The name of the behavior
  115381. */
  115382. name: string;
  115383. /**
  115384. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115385. */
  115386. distanceAwayFromFace: number;
  115387. /**
  115388. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115389. */
  115390. distanceAwayFromBottomOfFace: number;
  115391. private _faceVectors;
  115392. private _target;
  115393. private _scene;
  115394. private _onRenderObserver;
  115395. private _tmpMatrix;
  115396. private _tmpVector;
  115397. /**
  115398. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115399. * @param ui The transform node that should be attched to the mesh
  115400. */
  115401. constructor(ui: TransformNode);
  115402. /**
  115403. * Initializes the behavior
  115404. */
  115405. init(): void;
  115406. private _closestFace;
  115407. private _zeroVector;
  115408. private _lookAtTmpMatrix;
  115409. private _lookAtToRef;
  115410. /**
  115411. * Attaches the AttachToBoxBehavior to the passed in mesh
  115412. * @param target The mesh that the specified node will be attached to
  115413. */
  115414. attach(target: Mesh): void;
  115415. /**
  115416. * Detaches the behavior from the mesh
  115417. */
  115418. detach(): void;
  115419. }
  115420. }
  115421. declare module BABYLON {
  115422. /**
  115423. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115424. */
  115425. export class FadeInOutBehavior implements Behavior<Mesh> {
  115426. /**
  115427. * Time in milliseconds to delay before fading in (Default: 0)
  115428. */
  115429. delay: number;
  115430. /**
  115431. * Time in milliseconds for the mesh to fade in (Default: 300)
  115432. */
  115433. fadeInTime: number;
  115434. private _millisecondsPerFrame;
  115435. private _hovered;
  115436. private _hoverValue;
  115437. private _ownerNode;
  115438. /**
  115439. * Instatiates the FadeInOutBehavior
  115440. */
  115441. constructor();
  115442. /**
  115443. * The name of the behavior
  115444. */
  115445. get name(): string;
  115446. /**
  115447. * Initializes the behavior
  115448. */
  115449. init(): void;
  115450. /**
  115451. * Attaches the fade behavior on the passed in mesh
  115452. * @param ownerNode The mesh that will be faded in/out once attached
  115453. */
  115454. attach(ownerNode: Mesh): void;
  115455. /**
  115456. * Detaches the behavior from the mesh
  115457. */
  115458. detach(): void;
  115459. /**
  115460. * Triggers the mesh to begin fading in or out
  115461. * @param value if the object should fade in or out (true to fade in)
  115462. */
  115463. fadeIn(value: boolean): void;
  115464. private _update;
  115465. private _setAllVisibility;
  115466. }
  115467. }
  115468. declare module BABYLON {
  115469. /**
  115470. * Class containing a set of static utilities functions for managing Pivots
  115471. * @hidden
  115472. */
  115473. export class PivotTools {
  115474. private static _PivotCached;
  115475. private static _OldPivotPoint;
  115476. private static _PivotTranslation;
  115477. private static _PivotTmpVector;
  115478. /** @hidden */
  115479. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115480. /** @hidden */
  115481. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115482. }
  115483. }
  115484. declare module BABYLON {
  115485. /**
  115486. * Class containing static functions to help procedurally build meshes
  115487. */
  115488. export class PlaneBuilder {
  115489. /**
  115490. * Creates a plane mesh
  115491. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115492. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115493. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115497. * @param name defines the name of the mesh
  115498. * @param options defines the options used to create the mesh
  115499. * @param scene defines the hosting scene
  115500. * @returns the plane mesh
  115501. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115502. */
  115503. static CreatePlane(name: string, options: {
  115504. size?: number;
  115505. width?: number;
  115506. height?: number;
  115507. sideOrientation?: number;
  115508. frontUVs?: Vector4;
  115509. backUVs?: Vector4;
  115510. updatable?: boolean;
  115511. sourcePlane?: Plane;
  115512. }, scene?: Nullable<Scene>): Mesh;
  115513. }
  115514. }
  115515. declare module BABYLON {
  115516. /**
  115517. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115518. */
  115519. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115520. private static _AnyMouseID;
  115521. /**
  115522. * Abstract mesh the behavior is set on
  115523. */
  115524. attachedNode: AbstractMesh;
  115525. private _dragPlane;
  115526. private _scene;
  115527. private _pointerObserver;
  115528. private _beforeRenderObserver;
  115529. private static _planeScene;
  115530. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115531. /**
  115532. * 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)
  115533. */
  115534. maxDragAngle: number;
  115535. /**
  115536. * @hidden
  115537. */
  115538. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115539. /**
  115540. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115541. */
  115542. currentDraggingPointerID: number;
  115543. /**
  115544. * The last position where the pointer hit the drag plane in world space
  115545. */
  115546. lastDragPosition: Vector3;
  115547. /**
  115548. * If the behavior is currently in a dragging state
  115549. */
  115550. dragging: boolean;
  115551. /**
  115552. * 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)
  115553. */
  115554. dragDeltaRatio: number;
  115555. /**
  115556. * If the drag plane orientation should be updated during the dragging (Default: true)
  115557. */
  115558. updateDragPlane: boolean;
  115559. private _debugMode;
  115560. private _moving;
  115561. /**
  115562. * Fires each time the attached mesh is dragged with the pointer
  115563. * * delta between last drag position and current drag position in world space
  115564. * * dragDistance along the drag axis
  115565. * * dragPlaneNormal normal of the current drag plane used during the drag
  115566. * * dragPlanePoint in world space where the drag intersects the drag plane
  115567. */
  115568. onDragObservable: Observable<{
  115569. delta: Vector3;
  115570. dragPlanePoint: Vector3;
  115571. dragPlaneNormal: Vector3;
  115572. dragDistance: number;
  115573. pointerId: number;
  115574. }>;
  115575. /**
  115576. * Fires each time a drag begins (eg. mouse down on mesh)
  115577. */
  115578. onDragStartObservable: Observable<{
  115579. dragPlanePoint: Vector3;
  115580. pointerId: number;
  115581. }>;
  115582. /**
  115583. * Fires each time a drag ends (eg. mouse release after drag)
  115584. */
  115585. onDragEndObservable: Observable<{
  115586. dragPlanePoint: Vector3;
  115587. pointerId: number;
  115588. }>;
  115589. /**
  115590. * If the attached mesh should be moved when dragged
  115591. */
  115592. moveAttached: boolean;
  115593. /**
  115594. * If the drag behavior will react to drag events (Default: true)
  115595. */
  115596. enabled: boolean;
  115597. /**
  115598. * If pointer events should start and release the drag (Default: true)
  115599. */
  115600. startAndReleaseDragOnPointerEvents: boolean;
  115601. /**
  115602. * If camera controls should be detached during the drag
  115603. */
  115604. detachCameraControls: boolean;
  115605. /**
  115606. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115607. */
  115608. useObjectOrientationForDragging: boolean;
  115609. private _options;
  115610. /**
  115611. * Gets the options used by the behavior
  115612. */
  115613. get options(): {
  115614. dragAxis?: Vector3;
  115615. dragPlaneNormal?: Vector3;
  115616. };
  115617. /**
  115618. * Sets the options used by the behavior
  115619. */
  115620. set options(options: {
  115621. dragAxis?: Vector3;
  115622. dragPlaneNormal?: Vector3;
  115623. });
  115624. /**
  115625. * Creates a pointer drag behavior that can be attached to a mesh
  115626. * @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)
  115627. */
  115628. constructor(options?: {
  115629. dragAxis?: Vector3;
  115630. dragPlaneNormal?: Vector3;
  115631. });
  115632. /**
  115633. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115634. */
  115635. validateDrag: (targetPosition: Vector3) => boolean;
  115636. /**
  115637. * The name of the behavior
  115638. */
  115639. get name(): string;
  115640. /**
  115641. * Initializes the behavior
  115642. */
  115643. init(): void;
  115644. private _tmpVector;
  115645. private _alternatePickedPoint;
  115646. private _worldDragAxis;
  115647. private _targetPosition;
  115648. private _attachedElement;
  115649. /**
  115650. * Attaches the drag behavior the passed in mesh
  115651. * @param ownerNode The mesh that will be dragged around once attached
  115652. * @param predicate Predicate to use for pick filtering
  115653. */
  115654. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115655. /**
  115656. * Force relase the drag action by code.
  115657. */
  115658. releaseDrag(): void;
  115659. private _startDragRay;
  115660. private _lastPointerRay;
  115661. /**
  115662. * Simulates the start of a pointer drag event on the behavior
  115663. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115664. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115665. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115666. */
  115667. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115668. private _startDrag;
  115669. private _dragDelta;
  115670. private _moveDrag;
  115671. private _pickWithRayOnDragPlane;
  115672. private _pointA;
  115673. private _pointB;
  115674. private _pointC;
  115675. private _lineA;
  115676. private _lineB;
  115677. private _localAxis;
  115678. private _lookAt;
  115679. private _updateDragPlanePosition;
  115680. /**
  115681. * Detaches the behavior from the mesh
  115682. */
  115683. detach(): void;
  115684. }
  115685. }
  115686. declare module BABYLON {
  115687. /**
  115688. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115689. */
  115690. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115691. private _dragBehaviorA;
  115692. private _dragBehaviorB;
  115693. private _startDistance;
  115694. private _initialScale;
  115695. private _targetScale;
  115696. private _ownerNode;
  115697. private _sceneRenderObserver;
  115698. /**
  115699. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115700. */
  115701. constructor();
  115702. /**
  115703. * The name of the behavior
  115704. */
  115705. get name(): string;
  115706. /**
  115707. * Initializes the behavior
  115708. */
  115709. init(): void;
  115710. private _getCurrentDistance;
  115711. /**
  115712. * Attaches the scale behavior the passed in mesh
  115713. * @param ownerNode The mesh that will be scaled around once attached
  115714. */
  115715. attach(ownerNode: Mesh): void;
  115716. /**
  115717. * Detaches the behavior from the mesh
  115718. */
  115719. detach(): void;
  115720. }
  115721. }
  115722. declare module BABYLON {
  115723. /**
  115724. * 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
  115725. */
  115726. export class SixDofDragBehavior implements Behavior<Mesh> {
  115727. private static _virtualScene;
  115728. private _ownerNode;
  115729. private _sceneRenderObserver;
  115730. private _scene;
  115731. private _targetPosition;
  115732. private _virtualOriginMesh;
  115733. private _virtualDragMesh;
  115734. private _pointerObserver;
  115735. private _moving;
  115736. private _startingOrientation;
  115737. private _attachedElement;
  115738. /**
  115739. * 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)
  115740. */
  115741. private zDragFactor;
  115742. /**
  115743. * If the object should rotate to face the drag origin
  115744. */
  115745. rotateDraggedObject: boolean;
  115746. /**
  115747. * If the behavior is currently in a dragging state
  115748. */
  115749. dragging: boolean;
  115750. /**
  115751. * 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)
  115752. */
  115753. dragDeltaRatio: number;
  115754. /**
  115755. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115756. */
  115757. currentDraggingPointerID: number;
  115758. /**
  115759. * If camera controls should be detached during the drag
  115760. */
  115761. detachCameraControls: boolean;
  115762. /**
  115763. * Fires each time a drag starts
  115764. */
  115765. onDragStartObservable: Observable<{}>;
  115766. /**
  115767. * Fires each time a drag ends (eg. mouse release after drag)
  115768. */
  115769. onDragEndObservable: Observable<{}>;
  115770. /**
  115771. * 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
  115772. */
  115773. constructor();
  115774. /**
  115775. * The name of the behavior
  115776. */
  115777. get name(): string;
  115778. /**
  115779. * Initializes the behavior
  115780. */
  115781. init(): void;
  115782. /**
  115783. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  115784. */
  115785. private get _pointerCamera();
  115786. /**
  115787. * Attaches the scale behavior the passed in mesh
  115788. * @param ownerNode The mesh that will be scaled around once attached
  115789. */
  115790. attach(ownerNode: Mesh): void;
  115791. /**
  115792. * Detaches the behavior from the mesh
  115793. */
  115794. detach(): void;
  115795. }
  115796. }
  115797. declare module BABYLON {
  115798. /**
  115799. * Class used to apply inverse kinematics to bones
  115800. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  115801. */
  115802. export class BoneIKController {
  115803. private static _tmpVecs;
  115804. private static _tmpQuat;
  115805. private static _tmpMats;
  115806. /**
  115807. * Gets or sets the target mesh
  115808. */
  115809. targetMesh: AbstractMesh;
  115810. /** Gets or sets the mesh used as pole */
  115811. poleTargetMesh: AbstractMesh;
  115812. /**
  115813. * Gets or sets the bone used as pole
  115814. */
  115815. poleTargetBone: Nullable<Bone>;
  115816. /**
  115817. * Gets or sets the target position
  115818. */
  115819. targetPosition: Vector3;
  115820. /**
  115821. * Gets or sets the pole target position
  115822. */
  115823. poleTargetPosition: Vector3;
  115824. /**
  115825. * Gets or sets the pole target local offset
  115826. */
  115827. poleTargetLocalOffset: Vector3;
  115828. /**
  115829. * Gets or sets the pole angle
  115830. */
  115831. poleAngle: number;
  115832. /**
  115833. * Gets or sets the mesh associated with the controller
  115834. */
  115835. mesh: AbstractMesh;
  115836. /**
  115837. * 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)
  115838. */
  115839. slerpAmount: number;
  115840. private _bone1Quat;
  115841. private _bone1Mat;
  115842. private _bone2Ang;
  115843. private _bone1;
  115844. private _bone2;
  115845. private _bone1Length;
  115846. private _bone2Length;
  115847. private _maxAngle;
  115848. private _maxReach;
  115849. private _rightHandedSystem;
  115850. private _bendAxis;
  115851. private _slerping;
  115852. private _adjustRoll;
  115853. /**
  115854. * Gets or sets maximum allowed angle
  115855. */
  115856. get maxAngle(): number;
  115857. set maxAngle(value: number);
  115858. /**
  115859. * Creates a new BoneIKController
  115860. * @param mesh defines the mesh to control
  115861. * @param bone defines the bone to control
  115862. * @param options defines options to set up the controller
  115863. */
  115864. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  115865. targetMesh?: AbstractMesh;
  115866. poleTargetMesh?: AbstractMesh;
  115867. poleTargetBone?: Bone;
  115868. poleTargetLocalOffset?: Vector3;
  115869. poleAngle?: number;
  115870. bendAxis?: Vector3;
  115871. maxAngle?: number;
  115872. slerpAmount?: number;
  115873. });
  115874. private _setMaxAngle;
  115875. /**
  115876. * Force the controller to update the bones
  115877. */
  115878. update(): void;
  115879. }
  115880. }
  115881. declare module BABYLON {
  115882. /**
  115883. * Class used to make a bone look toward a point in space
  115884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  115885. */
  115886. export class BoneLookController {
  115887. private static _tmpVecs;
  115888. private static _tmpQuat;
  115889. private static _tmpMats;
  115890. /**
  115891. * The target Vector3 that the bone will look at
  115892. */
  115893. target: Vector3;
  115894. /**
  115895. * The mesh that the bone is attached to
  115896. */
  115897. mesh: AbstractMesh;
  115898. /**
  115899. * The bone that will be looking to the target
  115900. */
  115901. bone: Bone;
  115902. /**
  115903. * The up axis of the coordinate system that is used when the bone is rotated
  115904. */
  115905. upAxis: Vector3;
  115906. /**
  115907. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  115908. */
  115909. upAxisSpace: Space;
  115910. /**
  115911. * Used to make an adjustment to the yaw of the bone
  115912. */
  115913. adjustYaw: number;
  115914. /**
  115915. * Used to make an adjustment to the pitch of the bone
  115916. */
  115917. adjustPitch: number;
  115918. /**
  115919. * Used to make an adjustment to the roll of the bone
  115920. */
  115921. adjustRoll: number;
  115922. /**
  115923. * 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)
  115924. */
  115925. slerpAmount: number;
  115926. private _minYaw;
  115927. private _maxYaw;
  115928. private _minPitch;
  115929. private _maxPitch;
  115930. private _minYawSin;
  115931. private _minYawCos;
  115932. private _maxYawSin;
  115933. private _maxYawCos;
  115934. private _midYawConstraint;
  115935. private _minPitchTan;
  115936. private _maxPitchTan;
  115937. private _boneQuat;
  115938. private _slerping;
  115939. private _transformYawPitch;
  115940. private _transformYawPitchInv;
  115941. private _firstFrameSkipped;
  115942. private _yawRange;
  115943. private _fowardAxis;
  115944. /**
  115945. * Gets or sets the minimum yaw angle that the bone can look to
  115946. */
  115947. get minYaw(): number;
  115948. set minYaw(value: number);
  115949. /**
  115950. * Gets or sets the maximum yaw angle that the bone can look to
  115951. */
  115952. get maxYaw(): number;
  115953. set maxYaw(value: number);
  115954. /**
  115955. * Gets or sets the minimum pitch angle that the bone can look to
  115956. */
  115957. get minPitch(): number;
  115958. set minPitch(value: number);
  115959. /**
  115960. * Gets or sets the maximum pitch angle that the bone can look to
  115961. */
  115962. get maxPitch(): number;
  115963. set maxPitch(value: number);
  115964. /**
  115965. * Create a BoneLookController
  115966. * @param mesh the mesh that the bone belongs to
  115967. * @param bone the bone that will be looking to the target
  115968. * @param target the target Vector3 to look at
  115969. * @param options optional settings:
  115970. * * maxYaw: the maximum angle the bone will yaw to
  115971. * * minYaw: the minimum angle the bone will yaw to
  115972. * * maxPitch: the maximum angle the bone will pitch to
  115973. * * minPitch: the minimum angle the bone will yaw to
  115974. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  115975. * * upAxis: the up axis of the coordinate system
  115976. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  115977. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  115978. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  115979. * * adjustYaw: used to make an adjustment to the yaw of the bone
  115980. * * adjustPitch: used to make an adjustment to the pitch of the bone
  115981. * * adjustRoll: used to make an adjustment to the roll of the bone
  115982. **/
  115983. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  115984. maxYaw?: number;
  115985. minYaw?: number;
  115986. maxPitch?: number;
  115987. minPitch?: number;
  115988. slerpAmount?: number;
  115989. upAxis?: Vector3;
  115990. upAxisSpace?: Space;
  115991. yawAxis?: Vector3;
  115992. pitchAxis?: Vector3;
  115993. adjustYaw?: number;
  115994. adjustPitch?: number;
  115995. adjustRoll?: number;
  115996. });
  115997. /**
  115998. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  115999. */
  116000. update(): void;
  116001. private _getAngleDiff;
  116002. private _getAngleBetween;
  116003. private _isAngleBetween;
  116004. }
  116005. }
  116006. declare module BABYLON {
  116007. /**
  116008. * Manage the gamepad inputs to control an arc rotate camera.
  116009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116010. */
  116011. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116012. /**
  116013. * Defines the camera the input is attached to.
  116014. */
  116015. camera: ArcRotateCamera;
  116016. /**
  116017. * Defines the gamepad the input is gathering event from.
  116018. */
  116019. gamepad: Nullable<Gamepad>;
  116020. /**
  116021. * Defines the gamepad rotation sensiblity.
  116022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116023. */
  116024. gamepadRotationSensibility: number;
  116025. /**
  116026. * Defines the gamepad move sensiblity.
  116027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116028. */
  116029. gamepadMoveSensibility: number;
  116030. private _yAxisScale;
  116031. /**
  116032. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116033. */
  116034. get invertYAxis(): boolean;
  116035. set invertYAxis(value: boolean);
  116036. private _onGamepadConnectedObserver;
  116037. private _onGamepadDisconnectedObserver;
  116038. /**
  116039. * Attach the input controls to a specific dom element to get the input from.
  116040. * @param element Defines the element the controls should be listened from
  116041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116042. */
  116043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116044. /**
  116045. * Detach the current controls from the specified dom element.
  116046. * @param element Defines the element to stop listening the inputs from
  116047. */
  116048. detachControl(element: Nullable<HTMLElement>): void;
  116049. /**
  116050. * Update the current camera state depending on the inputs that have been used this frame.
  116051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116052. */
  116053. checkInputs(): void;
  116054. /**
  116055. * Gets the class name of the current intput.
  116056. * @returns the class name
  116057. */
  116058. getClassName(): string;
  116059. /**
  116060. * Get the friendly name associated with the input class.
  116061. * @returns the input friendly name
  116062. */
  116063. getSimpleName(): string;
  116064. }
  116065. }
  116066. declare module BABYLON {
  116067. interface ArcRotateCameraInputsManager {
  116068. /**
  116069. * Add orientation input support to the input manager.
  116070. * @returns the current input manager
  116071. */
  116072. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116073. }
  116074. /**
  116075. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116077. */
  116078. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116079. /**
  116080. * Defines the camera the input is attached to.
  116081. */
  116082. camera: ArcRotateCamera;
  116083. /**
  116084. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116085. */
  116086. alphaCorrection: number;
  116087. /**
  116088. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116089. */
  116090. gammaCorrection: number;
  116091. private _alpha;
  116092. private _gamma;
  116093. private _dirty;
  116094. private _deviceOrientationHandler;
  116095. /**
  116096. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116097. */
  116098. constructor();
  116099. /**
  116100. * Attach the input controls to a specific dom element to get the input from.
  116101. * @param element Defines the element the controls should be listened from
  116102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116103. */
  116104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116105. /** @hidden */
  116106. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116107. /**
  116108. * Update the current camera state depending on the inputs that have been used this frame.
  116109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116110. */
  116111. checkInputs(): void;
  116112. /**
  116113. * Detach the current controls from the specified dom element.
  116114. * @param element Defines the element to stop listening the inputs from
  116115. */
  116116. detachControl(element: Nullable<HTMLElement>): void;
  116117. /**
  116118. * Gets the class name of the current intput.
  116119. * @returns the class name
  116120. */
  116121. getClassName(): string;
  116122. /**
  116123. * Get the friendly name associated with the input class.
  116124. * @returns the input friendly name
  116125. */
  116126. getSimpleName(): string;
  116127. }
  116128. }
  116129. declare module BABYLON {
  116130. /**
  116131. * Listen to mouse events to control the camera.
  116132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116133. */
  116134. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116135. /**
  116136. * Defines the camera the input is attached to.
  116137. */
  116138. camera: FlyCamera;
  116139. /**
  116140. * Defines if touch is enabled. (Default is true.)
  116141. */
  116142. touchEnabled: boolean;
  116143. /**
  116144. * Defines the buttons associated with the input to handle camera rotation.
  116145. */
  116146. buttons: number[];
  116147. /**
  116148. * Assign buttons for Yaw control.
  116149. */
  116150. buttonsYaw: number[];
  116151. /**
  116152. * Assign buttons for Pitch control.
  116153. */
  116154. buttonsPitch: number[];
  116155. /**
  116156. * Assign buttons for Roll control.
  116157. */
  116158. buttonsRoll: number[];
  116159. /**
  116160. * Detect if any button is being pressed while mouse is moved.
  116161. * -1 = Mouse locked.
  116162. * 0 = Left button.
  116163. * 1 = Middle Button.
  116164. * 2 = Right Button.
  116165. */
  116166. activeButton: number;
  116167. /**
  116168. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116169. * Higher values reduce its sensitivity.
  116170. */
  116171. angularSensibility: number;
  116172. private _mousemoveCallback;
  116173. private _observer;
  116174. private _rollObserver;
  116175. private previousPosition;
  116176. private noPreventDefault;
  116177. private element;
  116178. /**
  116179. * Listen to mouse events to control the camera.
  116180. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116182. */
  116183. constructor(touchEnabled?: boolean);
  116184. /**
  116185. * Attach the mouse control to the HTML DOM element.
  116186. * @param element Defines the element that listens to the input events.
  116187. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116188. */
  116189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116190. /**
  116191. * Detach the current controls from the specified dom element.
  116192. * @param element Defines the element to stop listening the inputs from
  116193. */
  116194. detachControl(element: Nullable<HTMLElement>): void;
  116195. /**
  116196. * Gets the class name of the current input.
  116197. * @returns the class name.
  116198. */
  116199. getClassName(): string;
  116200. /**
  116201. * Get the friendly name associated with the input class.
  116202. * @returns the input's friendly name.
  116203. */
  116204. getSimpleName(): string;
  116205. private _pointerInput;
  116206. private _onMouseMove;
  116207. /**
  116208. * Rotate camera by mouse offset.
  116209. */
  116210. private rotateCamera;
  116211. }
  116212. }
  116213. declare module BABYLON {
  116214. /**
  116215. * Default Inputs manager for the FlyCamera.
  116216. * It groups all the default supported inputs for ease of use.
  116217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116218. */
  116219. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116220. /**
  116221. * Instantiates a new FlyCameraInputsManager.
  116222. * @param camera Defines the camera the inputs belong to.
  116223. */
  116224. constructor(camera: FlyCamera);
  116225. /**
  116226. * Add keyboard input support to the input manager.
  116227. * @returns the new FlyCameraKeyboardMoveInput().
  116228. */
  116229. addKeyboard(): FlyCameraInputsManager;
  116230. /**
  116231. * Add mouse input support to the input manager.
  116232. * @param touchEnabled Enable touch screen support.
  116233. * @returns the new FlyCameraMouseInput().
  116234. */
  116235. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116236. }
  116237. }
  116238. declare module BABYLON {
  116239. /**
  116240. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116241. * such as in a 3D Space Shooter or a Flight Simulator.
  116242. */
  116243. export class FlyCamera extends TargetCamera {
  116244. /**
  116245. * Define the collision ellipsoid of the camera.
  116246. * This is helpful for simulating a camera body, like a player's body.
  116247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116248. */
  116249. ellipsoid: Vector3;
  116250. /**
  116251. * Define an offset for the position of the ellipsoid around the camera.
  116252. * This can be helpful if the camera is attached away from the player's body center,
  116253. * such as at its head.
  116254. */
  116255. ellipsoidOffset: Vector3;
  116256. /**
  116257. * Enable or disable collisions of the camera with the rest of the scene objects.
  116258. */
  116259. checkCollisions: boolean;
  116260. /**
  116261. * Enable or disable gravity on the camera.
  116262. */
  116263. applyGravity: boolean;
  116264. /**
  116265. * Define the current direction the camera is moving to.
  116266. */
  116267. cameraDirection: Vector3;
  116268. /**
  116269. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116270. * This overrides and empties cameraRotation.
  116271. */
  116272. rotationQuaternion: Quaternion;
  116273. /**
  116274. * Track Roll to maintain the wanted Rolling when looking around.
  116275. */
  116276. _trackRoll: number;
  116277. /**
  116278. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116279. */
  116280. rollCorrect: number;
  116281. /**
  116282. * Mimic a banked turn, Rolling the camera when Yawing.
  116283. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116284. */
  116285. bankedTurn: boolean;
  116286. /**
  116287. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116288. */
  116289. bankedTurnLimit: number;
  116290. /**
  116291. * Value of 0 disables the banked Roll.
  116292. * Value of 1 is equal to the Yaw angle in radians.
  116293. */
  116294. bankedTurnMultiplier: number;
  116295. /**
  116296. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116297. */
  116298. inputs: FlyCameraInputsManager;
  116299. /**
  116300. * Gets the input sensibility for mouse input.
  116301. * Higher values reduce sensitivity.
  116302. */
  116303. get angularSensibility(): number;
  116304. /**
  116305. * Sets the input sensibility for a mouse input.
  116306. * Higher values reduce sensitivity.
  116307. */
  116308. set angularSensibility(value: number);
  116309. /**
  116310. * Get the keys for camera movement forward.
  116311. */
  116312. get keysForward(): number[];
  116313. /**
  116314. * Set the keys for camera movement forward.
  116315. */
  116316. set keysForward(value: number[]);
  116317. /**
  116318. * Get the keys for camera movement backward.
  116319. */
  116320. get keysBackward(): number[];
  116321. set keysBackward(value: number[]);
  116322. /**
  116323. * Get the keys for camera movement up.
  116324. */
  116325. get keysUp(): number[];
  116326. /**
  116327. * Set the keys for camera movement up.
  116328. */
  116329. set keysUp(value: number[]);
  116330. /**
  116331. * Get the keys for camera movement down.
  116332. */
  116333. get keysDown(): number[];
  116334. /**
  116335. * Set the keys for camera movement down.
  116336. */
  116337. set keysDown(value: number[]);
  116338. /**
  116339. * Get the keys for camera movement left.
  116340. */
  116341. get keysLeft(): number[];
  116342. /**
  116343. * Set the keys for camera movement left.
  116344. */
  116345. set keysLeft(value: number[]);
  116346. /**
  116347. * Set the keys for camera movement right.
  116348. */
  116349. get keysRight(): number[];
  116350. /**
  116351. * Set the keys for camera movement right.
  116352. */
  116353. set keysRight(value: number[]);
  116354. /**
  116355. * Event raised when the camera collides with a mesh in the scene.
  116356. */
  116357. onCollide: (collidedMesh: AbstractMesh) => void;
  116358. private _collider;
  116359. private _needMoveForGravity;
  116360. private _oldPosition;
  116361. private _diffPosition;
  116362. private _newPosition;
  116363. /** @hidden */
  116364. _localDirection: Vector3;
  116365. /** @hidden */
  116366. _transformedDirection: Vector3;
  116367. /**
  116368. * Instantiates a FlyCamera.
  116369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116370. * such as in a 3D Space Shooter or a Flight Simulator.
  116371. * @param name Define the name of the camera in the scene.
  116372. * @param position Define the starting position of the camera in the scene.
  116373. * @param scene Define the scene the camera belongs to.
  116374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116375. */
  116376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116377. /**
  116378. * Attach a control to the HTML DOM element.
  116379. * @param element Defines the element that listens to the input events.
  116380. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116381. */
  116382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116383. /**
  116384. * Detach a control from the HTML DOM element.
  116385. * The camera will stop reacting to that input.
  116386. * @param element Defines the element that listens to the input events.
  116387. */
  116388. detachControl(element: HTMLElement): void;
  116389. private _collisionMask;
  116390. /**
  116391. * Get the mask that the camera ignores in collision events.
  116392. */
  116393. get collisionMask(): number;
  116394. /**
  116395. * Set the mask that the camera ignores in collision events.
  116396. */
  116397. set collisionMask(mask: number);
  116398. /** @hidden */
  116399. _collideWithWorld(displacement: Vector3): void;
  116400. /** @hidden */
  116401. private _onCollisionPositionChange;
  116402. /** @hidden */
  116403. _checkInputs(): void;
  116404. /** @hidden */
  116405. _decideIfNeedsToMove(): boolean;
  116406. /** @hidden */
  116407. _updatePosition(): void;
  116408. /**
  116409. * Restore the Roll to its target value at the rate specified.
  116410. * @param rate - Higher means slower restoring.
  116411. * @hidden
  116412. */
  116413. restoreRoll(rate: number): void;
  116414. /**
  116415. * Destroy the camera and release the current resources held by it.
  116416. */
  116417. dispose(): void;
  116418. /**
  116419. * Get the current object class name.
  116420. * @returns the class name.
  116421. */
  116422. getClassName(): string;
  116423. }
  116424. }
  116425. declare module BABYLON {
  116426. /**
  116427. * Listen to keyboard events to control the camera.
  116428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116429. */
  116430. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116431. /**
  116432. * Defines the camera the input is attached to.
  116433. */
  116434. camera: FlyCamera;
  116435. /**
  116436. * The list of keyboard keys used to control the forward move of the camera.
  116437. */
  116438. keysForward: number[];
  116439. /**
  116440. * The list of keyboard keys used to control the backward move of the camera.
  116441. */
  116442. keysBackward: number[];
  116443. /**
  116444. * The list of keyboard keys used to control the forward move of the camera.
  116445. */
  116446. keysUp: number[];
  116447. /**
  116448. * The list of keyboard keys used to control the backward move of the camera.
  116449. */
  116450. keysDown: number[];
  116451. /**
  116452. * The list of keyboard keys used to control the right strafe move of the camera.
  116453. */
  116454. keysRight: number[];
  116455. /**
  116456. * The list of keyboard keys used to control the left strafe move of the camera.
  116457. */
  116458. keysLeft: number[];
  116459. private _keys;
  116460. private _onCanvasBlurObserver;
  116461. private _onKeyboardObserver;
  116462. private _engine;
  116463. private _scene;
  116464. /**
  116465. * Attach the input controls to a specific dom element to get the input from.
  116466. * @param element Defines the element the controls should be listened from
  116467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116468. */
  116469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116470. /**
  116471. * Detach the current controls from the specified dom element.
  116472. * @param element Defines the element to stop listening the inputs from
  116473. */
  116474. detachControl(element: Nullable<HTMLElement>): void;
  116475. /**
  116476. * Gets the class name of the current intput.
  116477. * @returns the class name
  116478. */
  116479. getClassName(): string;
  116480. /** @hidden */
  116481. _onLostFocus(e: FocusEvent): void;
  116482. /**
  116483. * Get the friendly name associated with the input class.
  116484. * @returns the input friendly name
  116485. */
  116486. getSimpleName(): string;
  116487. /**
  116488. * Update the current camera state depending on the inputs that have been used this frame.
  116489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116490. */
  116491. checkInputs(): void;
  116492. }
  116493. }
  116494. declare module BABYLON {
  116495. /**
  116496. * Manage the mouse wheel inputs to control a follow camera.
  116497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116498. */
  116499. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116500. /**
  116501. * Defines the camera the input is attached to.
  116502. */
  116503. camera: FollowCamera;
  116504. /**
  116505. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116506. */
  116507. axisControlRadius: boolean;
  116508. /**
  116509. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116510. */
  116511. axisControlHeight: boolean;
  116512. /**
  116513. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116514. */
  116515. axisControlRotation: boolean;
  116516. /**
  116517. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116518. * relation to mouseWheel events.
  116519. */
  116520. wheelPrecision: number;
  116521. /**
  116522. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116523. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116524. */
  116525. wheelDeltaPercentage: number;
  116526. private _wheel;
  116527. private _observer;
  116528. /**
  116529. * Attach the input controls to a specific dom element to get the input from.
  116530. * @param element Defines the element the controls should be listened from
  116531. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116532. */
  116533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116534. /**
  116535. * Detach the current controls from the specified dom element.
  116536. * @param element Defines the element to stop listening the inputs from
  116537. */
  116538. detachControl(element: Nullable<HTMLElement>): void;
  116539. /**
  116540. * Gets the class name of the current intput.
  116541. * @returns the class name
  116542. */
  116543. getClassName(): string;
  116544. /**
  116545. * Get the friendly name associated with the input class.
  116546. * @returns the input friendly name
  116547. */
  116548. getSimpleName(): string;
  116549. }
  116550. }
  116551. declare module BABYLON {
  116552. /**
  116553. * Manage the pointers inputs to control an follow camera.
  116554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116555. */
  116556. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116557. /**
  116558. * Defines the camera the input is attached to.
  116559. */
  116560. camera: FollowCamera;
  116561. /**
  116562. * Gets the class name of the current input.
  116563. * @returns the class name
  116564. */
  116565. getClassName(): string;
  116566. /**
  116567. * Defines the pointer angular sensibility along the X axis or how fast is
  116568. * the camera rotating.
  116569. * A negative number will reverse the axis direction.
  116570. */
  116571. angularSensibilityX: number;
  116572. /**
  116573. * Defines the pointer angular sensibility along the Y axis or how fast is
  116574. * the camera rotating.
  116575. * A negative number will reverse the axis direction.
  116576. */
  116577. angularSensibilityY: number;
  116578. /**
  116579. * Defines the pointer pinch precision or how fast is the camera zooming.
  116580. * A negative number will reverse the axis direction.
  116581. */
  116582. pinchPrecision: number;
  116583. /**
  116584. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116585. * from 0.
  116586. * It defines the percentage of current camera.radius to use as delta when
  116587. * pinch zoom is used.
  116588. */
  116589. pinchDeltaPercentage: number;
  116590. /**
  116591. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116592. */
  116593. axisXControlRadius: boolean;
  116594. /**
  116595. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116596. */
  116597. axisXControlHeight: boolean;
  116598. /**
  116599. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116600. */
  116601. axisXControlRotation: boolean;
  116602. /**
  116603. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116604. */
  116605. axisYControlRadius: boolean;
  116606. /**
  116607. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116608. */
  116609. axisYControlHeight: boolean;
  116610. /**
  116611. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116612. */
  116613. axisYControlRotation: boolean;
  116614. /**
  116615. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116616. */
  116617. axisPinchControlRadius: boolean;
  116618. /**
  116619. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116620. */
  116621. axisPinchControlHeight: boolean;
  116622. /**
  116623. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116624. */
  116625. axisPinchControlRotation: boolean;
  116626. /**
  116627. * Log error messages if basic misconfiguration has occurred.
  116628. */
  116629. warningEnable: boolean;
  116630. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116631. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116632. private _warningCounter;
  116633. private _warning;
  116634. }
  116635. }
  116636. declare module BABYLON {
  116637. /**
  116638. * Default Inputs manager for the FollowCamera.
  116639. * It groups all the default supported inputs for ease of use.
  116640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116641. */
  116642. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116643. /**
  116644. * Instantiates a new FollowCameraInputsManager.
  116645. * @param camera Defines the camera the inputs belong to
  116646. */
  116647. constructor(camera: FollowCamera);
  116648. /**
  116649. * Add keyboard input support to the input manager.
  116650. * @returns the current input manager
  116651. */
  116652. addKeyboard(): FollowCameraInputsManager;
  116653. /**
  116654. * Add mouse wheel input support to the input manager.
  116655. * @returns the current input manager
  116656. */
  116657. addMouseWheel(): FollowCameraInputsManager;
  116658. /**
  116659. * Add pointers input support to the input manager.
  116660. * @returns the current input manager
  116661. */
  116662. addPointers(): FollowCameraInputsManager;
  116663. /**
  116664. * Add orientation input support to the input manager.
  116665. * @returns the current input manager
  116666. */
  116667. addVRDeviceOrientation(): FollowCameraInputsManager;
  116668. }
  116669. }
  116670. declare module BABYLON {
  116671. /**
  116672. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116673. * an arc rotate version arcFollowCamera are available.
  116674. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116675. */
  116676. export class FollowCamera extends TargetCamera {
  116677. /**
  116678. * Distance the follow camera should follow an object at
  116679. */
  116680. radius: number;
  116681. /**
  116682. * Minimum allowed distance of the camera to the axis of rotation
  116683. * (The camera can not get closer).
  116684. * This can help limiting how the Camera is able to move in the scene.
  116685. */
  116686. lowerRadiusLimit: Nullable<number>;
  116687. /**
  116688. * Maximum allowed distance of the camera to the axis of rotation
  116689. * (The camera can not get further).
  116690. * This can help limiting how the Camera is able to move in the scene.
  116691. */
  116692. upperRadiusLimit: Nullable<number>;
  116693. /**
  116694. * Define a rotation offset between the camera and the object it follows
  116695. */
  116696. rotationOffset: number;
  116697. /**
  116698. * Minimum allowed angle to camera position relative to target object.
  116699. * This can help limiting how the Camera is able to move in the scene.
  116700. */
  116701. lowerRotationOffsetLimit: Nullable<number>;
  116702. /**
  116703. * Maximum allowed angle to camera position relative to target object.
  116704. * This can help limiting how the Camera is able to move in the scene.
  116705. */
  116706. upperRotationOffsetLimit: Nullable<number>;
  116707. /**
  116708. * Define a height offset between the camera and the object it follows.
  116709. * It can help following an object from the top (like a car chaing a plane)
  116710. */
  116711. heightOffset: number;
  116712. /**
  116713. * Minimum allowed height of camera position relative to target object.
  116714. * This can help limiting how the Camera is able to move in the scene.
  116715. */
  116716. lowerHeightOffsetLimit: Nullable<number>;
  116717. /**
  116718. * Maximum allowed height of camera position relative to target object.
  116719. * This can help limiting how the Camera is able to move in the scene.
  116720. */
  116721. upperHeightOffsetLimit: Nullable<number>;
  116722. /**
  116723. * Define how fast the camera can accelerate to follow it s target.
  116724. */
  116725. cameraAcceleration: number;
  116726. /**
  116727. * Define the speed limit of the camera following an object.
  116728. */
  116729. maxCameraSpeed: number;
  116730. /**
  116731. * Define the target of the camera.
  116732. */
  116733. lockedTarget: Nullable<AbstractMesh>;
  116734. /**
  116735. * Defines the input associated with the camera.
  116736. */
  116737. inputs: FollowCameraInputsManager;
  116738. /**
  116739. * Instantiates the follow camera.
  116740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116741. * @param name Define the name of the camera in the scene
  116742. * @param position Define the position of the camera
  116743. * @param scene Define the scene the camera belong to
  116744. * @param lockedTarget Define the target of the camera
  116745. */
  116746. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  116747. private _follow;
  116748. /**
  116749. * Attached controls to the current camera.
  116750. * @param element Defines the element the controls should be listened from
  116751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116752. */
  116753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116754. /**
  116755. * Detach the current controls from the camera.
  116756. * The camera will stop reacting to inputs.
  116757. * @param element Defines the element to stop listening the inputs from
  116758. */
  116759. detachControl(element: HTMLElement): void;
  116760. /** @hidden */
  116761. _checkInputs(): void;
  116762. private _checkLimits;
  116763. /**
  116764. * Gets the camera class name.
  116765. * @returns the class name
  116766. */
  116767. getClassName(): string;
  116768. }
  116769. /**
  116770. * Arc Rotate version of the follow camera.
  116771. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  116772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116773. */
  116774. export class ArcFollowCamera extends TargetCamera {
  116775. /** The longitudinal angle of the camera */
  116776. alpha: number;
  116777. /** The latitudinal angle of the camera */
  116778. beta: number;
  116779. /** The radius of the camera from its target */
  116780. radius: number;
  116781. /** Define the camera target (the messh it should follow) */
  116782. target: Nullable<AbstractMesh>;
  116783. private _cartesianCoordinates;
  116784. /**
  116785. * Instantiates a new ArcFollowCamera
  116786. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116787. * @param name Define the name of the camera
  116788. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  116789. * @param beta Define the rotation angle of the camera around the elevation axis
  116790. * @param radius Define the radius of the camera from its target point
  116791. * @param target Define the target of the camera
  116792. * @param scene Define the scene the camera belongs to
  116793. */
  116794. constructor(name: string,
  116795. /** The longitudinal angle of the camera */
  116796. alpha: number,
  116797. /** The latitudinal angle of the camera */
  116798. beta: number,
  116799. /** The radius of the camera from its target */
  116800. radius: number,
  116801. /** Define the camera target (the messh it should follow) */
  116802. target: Nullable<AbstractMesh>, scene: Scene);
  116803. private _follow;
  116804. /** @hidden */
  116805. _checkInputs(): void;
  116806. /**
  116807. * Returns the class name of the object.
  116808. * It is mostly used internally for serialization purposes.
  116809. */
  116810. getClassName(): string;
  116811. }
  116812. }
  116813. declare module BABYLON {
  116814. /**
  116815. * Manage the keyboard inputs to control the movement of a follow camera.
  116816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116817. */
  116818. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  116819. /**
  116820. * Defines the camera the input is attached to.
  116821. */
  116822. camera: FollowCamera;
  116823. /**
  116824. * Defines the list of key codes associated with the up action (increase heightOffset)
  116825. */
  116826. keysHeightOffsetIncr: number[];
  116827. /**
  116828. * Defines the list of key codes associated with the down action (decrease heightOffset)
  116829. */
  116830. keysHeightOffsetDecr: number[];
  116831. /**
  116832. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  116833. */
  116834. keysHeightOffsetModifierAlt: boolean;
  116835. /**
  116836. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  116837. */
  116838. keysHeightOffsetModifierCtrl: boolean;
  116839. /**
  116840. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  116841. */
  116842. keysHeightOffsetModifierShift: boolean;
  116843. /**
  116844. * Defines the list of key codes associated with the left action (increase rotationOffset)
  116845. */
  116846. keysRotationOffsetIncr: number[];
  116847. /**
  116848. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  116849. */
  116850. keysRotationOffsetDecr: number[];
  116851. /**
  116852. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  116853. */
  116854. keysRotationOffsetModifierAlt: boolean;
  116855. /**
  116856. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  116857. */
  116858. keysRotationOffsetModifierCtrl: boolean;
  116859. /**
  116860. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  116861. */
  116862. keysRotationOffsetModifierShift: boolean;
  116863. /**
  116864. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  116865. */
  116866. keysRadiusIncr: number[];
  116867. /**
  116868. * Defines the list of key codes associated with the zoom-out action (increase radius)
  116869. */
  116870. keysRadiusDecr: number[];
  116871. /**
  116872. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  116873. */
  116874. keysRadiusModifierAlt: boolean;
  116875. /**
  116876. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  116877. */
  116878. keysRadiusModifierCtrl: boolean;
  116879. /**
  116880. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  116881. */
  116882. keysRadiusModifierShift: boolean;
  116883. /**
  116884. * Defines the rate of change of heightOffset.
  116885. */
  116886. heightSensibility: number;
  116887. /**
  116888. * Defines the rate of change of rotationOffset.
  116889. */
  116890. rotationSensibility: number;
  116891. /**
  116892. * Defines the rate of change of radius.
  116893. */
  116894. radiusSensibility: number;
  116895. private _keys;
  116896. private _ctrlPressed;
  116897. private _altPressed;
  116898. private _shiftPressed;
  116899. private _onCanvasBlurObserver;
  116900. private _onKeyboardObserver;
  116901. private _engine;
  116902. private _scene;
  116903. /**
  116904. * Attach the input controls to a specific dom element to get the input from.
  116905. * @param element Defines the element the controls should be listened from
  116906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116907. */
  116908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116909. /**
  116910. * Detach the current controls from the specified dom element.
  116911. * @param element Defines the element to stop listening the inputs from
  116912. */
  116913. detachControl(element: Nullable<HTMLElement>): void;
  116914. /**
  116915. * Update the current camera state depending on the inputs that have been used this frame.
  116916. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116917. */
  116918. checkInputs(): void;
  116919. /**
  116920. * Gets the class name of the current input.
  116921. * @returns the class name
  116922. */
  116923. getClassName(): string;
  116924. /**
  116925. * Get the friendly name associated with the input class.
  116926. * @returns the input friendly name
  116927. */
  116928. getSimpleName(): string;
  116929. /**
  116930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116931. * allow modification of the heightOffset value.
  116932. */
  116933. private _modifierHeightOffset;
  116934. /**
  116935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116936. * allow modification of the rotationOffset value.
  116937. */
  116938. private _modifierRotationOffset;
  116939. /**
  116940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116941. * allow modification of the radius value.
  116942. */
  116943. private _modifierRadius;
  116944. }
  116945. }
  116946. declare module BABYLON {
  116947. interface FreeCameraInputsManager {
  116948. /**
  116949. * @hidden
  116950. */
  116951. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  116952. /**
  116953. * Add orientation input support to the input manager.
  116954. * @returns the current input manager
  116955. */
  116956. addDeviceOrientation(): FreeCameraInputsManager;
  116957. }
  116958. /**
  116959. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  116960. * Screen rotation is taken into account.
  116961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116962. */
  116963. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  116964. private _camera;
  116965. private _screenOrientationAngle;
  116966. private _constantTranform;
  116967. private _screenQuaternion;
  116968. private _alpha;
  116969. private _beta;
  116970. private _gamma;
  116971. /**
  116972. * Can be used to detect if a device orientation sensor is available on a device
  116973. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  116974. * @returns a promise that will resolve on orientation change
  116975. */
  116976. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  116977. /**
  116978. * @hidden
  116979. */
  116980. _onDeviceOrientationChangedObservable: Observable<void>;
  116981. /**
  116982. * Instantiates a new input
  116983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116984. */
  116985. constructor();
  116986. /**
  116987. * Define the camera controlled by the input.
  116988. */
  116989. get camera(): FreeCamera;
  116990. set camera(camera: FreeCamera);
  116991. /**
  116992. * Attach the input controls to a specific dom element to get the input from.
  116993. * @param element Defines the element the controls should be listened from
  116994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116995. */
  116996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116997. private _orientationChanged;
  116998. private _deviceOrientation;
  116999. /**
  117000. * Detach the current controls from the specified dom element.
  117001. * @param element Defines the element to stop listening the inputs from
  117002. */
  117003. detachControl(element: Nullable<HTMLElement>): void;
  117004. /**
  117005. * Update the current camera state depending on the inputs that have been used this frame.
  117006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117007. */
  117008. checkInputs(): void;
  117009. /**
  117010. * Gets the class name of the current intput.
  117011. * @returns the class name
  117012. */
  117013. getClassName(): string;
  117014. /**
  117015. * Get the friendly name associated with the input class.
  117016. * @returns the input friendly name
  117017. */
  117018. getSimpleName(): string;
  117019. }
  117020. }
  117021. declare module BABYLON {
  117022. /**
  117023. * Manage the gamepad inputs to control a free camera.
  117024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117025. */
  117026. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117027. /**
  117028. * Define the camera the input is attached to.
  117029. */
  117030. camera: FreeCamera;
  117031. /**
  117032. * Define the Gamepad controlling the input
  117033. */
  117034. gamepad: Nullable<Gamepad>;
  117035. /**
  117036. * Defines the gamepad rotation sensiblity.
  117037. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117038. */
  117039. gamepadAngularSensibility: number;
  117040. /**
  117041. * Defines the gamepad move sensiblity.
  117042. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117043. */
  117044. gamepadMoveSensibility: number;
  117045. private _yAxisScale;
  117046. /**
  117047. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117048. */
  117049. get invertYAxis(): boolean;
  117050. set invertYAxis(value: boolean);
  117051. private _onGamepadConnectedObserver;
  117052. private _onGamepadDisconnectedObserver;
  117053. private _cameraTransform;
  117054. private _deltaTransform;
  117055. private _vector3;
  117056. private _vector2;
  117057. /**
  117058. * Attach the input controls to a specific dom element to get the input from.
  117059. * @param element Defines the element the controls should be listened from
  117060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117061. */
  117062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117063. /**
  117064. * Detach the current controls from the specified dom element.
  117065. * @param element Defines the element to stop listening the inputs from
  117066. */
  117067. detachControl(element: Nullable<HTMLElement>): void;
  117068. /**
  117069. * Update the current camera state depending on the inputs that have been used this frame.
  117070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117071. */
  117072. checkInputs(): void;
  117073. /**
  117074. * Gets the class name of the current intput.
  117075. * @returns the class name
  117076. */
  117077. getClassName(): string;
  117078. /**
  117079. * Get the friendly name associated with the input class.
  117080. * @returns the input friendly name
  117081. */
  117082. getSimpleName(): string;
  117083. }
  117084. }
  117085. declare module BABYLON {
  117086. /**
  117087. * Defines the potential axis of a Joystick
  117088. */
  117089. export enum JoystickAxis {
  117090. /** X axis */
  117091. X = 0,
  117092. /** Y axis */
  117093. Y = 1,
  117094. /** Z axis */
  117095. Z = 2
  117096. }
  117097. /**
  117098. * Class used to define virtual joystick (used in touch mode)
  117099. */
  117100. export class VirtualJoystick {
  117101. /**
  117102. * Gets or sets a boolean indicating that left and right values must be inverted
  117103. */
  117104. reverseLeftRight: boolean;
  117105. /**
  117106. * Gets or sets a boolean indicating that up and down values must be inverted
  117107. */
  117108. reverseUpDown: boolean;
  117109. /**
  117110. * Gets the offset value for the position (ie. the change of the position value)
  117111. */
  117112. deltaPosition: Vector3;
  117113. /**
  117114. * Gets a boolean indicating if the virtual joystick was pressed
  117115. */
  117116. pressed: boolean;
  117117. /**
  117118. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117119. */
  117120. static Canvas: Nullable<HTMLCanvasElement>;
  117121. private static _globalJoystickIndex;
  117122. private static vjCanvasContext;
  117123. private static vjCanvasWidth;
  117124. private static vjCanvasHeight;
  117125. private static halfWidth;
  117126. private _action;
  117127. private _axisTargetedByLeftAndRight;
  117128. private _axisTargetedByUpAndDown;
  117129. private _joystickSensibility;
  117130. private _inversedSensibility;
  117131. private _joystickPointerID;
  117132. private _joystickColor;
  117133. private _joystickPointerPos;
  117134. private _joystickPreviousPointerPos;
  117135. private _joystickPointerStartPos;
  117136. private _deltaJoystickVector;
  117137. private _leftJoystick;
  117138. private _touches;
  117139. private _onPointerDownHandlerRef;
  117140. private _onPointerMoveHandlerRef;
  117141. private _onPointerUpHandlerRef;
  117142. private _onResize;
  117143. /**
  117144. * Creates a new virtual joystick
  117145. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117146. */
  117147. constructor(leftJoystick?: boolean);
  117148. /**
  117149. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117150. * @param newJoystickSensibility defines the new sensibility
  117151. */
  117152. setJoystickSensibility(newJoystickSensibility: number): void;
  117153. private _onPointerDown;
  117154. private _onPointerMove;
  117155. private _onPointerUp;
  117156. /**
  117157. * Change the color of the virtual joystick
  117158. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117159. */
  117160. setJoystickColor(newColor: string): void;
  117161. /**
  117162. * Defines a callback to call when the joystick is touched
  117163. * @param action defines the callback
  117164. */
  117165. setActionOnTouch(action: () => any): void;
  117166. /**
  117167. * Defines which axis you'd like to control for left & right
  117168. * @param axis defines the axis to use
  117169. */
  117170. setAxisForLeftRight(axis: JoystickAxis): void;
  117171. /**
  117172. * Defines which axis you'd like to control for up & down
  117173. * @param axis defines the axis to use
  117174. */
  117175. setAxisForUpDown(axis: JoystickAxis): void;
  117176. private _drawVirtualJoystick;
  117177. /**
  117178. * Release internal HTML canvas
  117179. */
  117180. releaseCanvas(): void;
  117181. }
  117182. }
  117183. declare module BABYLON {
  117184. interface FreeCameraInputsManager {
  117185. /**
  117186. * Add virtual joystick input support to the input manager.
  117187. * @returns the current input manager
  117188. */
  117189. addVirtualJoystick(): FreeCameraInputsManager;
  117190. }
  117191. /**
  117192. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117194. */
  117195. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117196. /**
  117197. * Defines the camera the input is attached to.
  117198. */
  117199. camera: FreeCamera;
  117200. private _leftjoystick;
  117201. private _rightjoystick;
  117202. /**
  117203. * Gets the left stick of the virtual joystick.
  117204. * @returns The virtual Joystick
  117205. */
  117206. getLeftJoystick(): VirtualJoystick;
  117207. /**
  117208. * Gets the right stick of the virtual joystick.
  117209. * @returns The virtual Joystick
  117210. */
  117211. getRightJoystick(): VirtualJoystick;
  117212. /**
  117213. * Update the current camera state depending on the inputs that have been used this frame.
  117214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117215. */
  117216. checkInputs(): void;
  117217. /**
  117218. * Attach the input controls to a specific dom element to get the input from.
  117219. * @param element Defines the element the controls should be listened from
  117220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117221. */
  117222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117223. /**
  117224. * Detach the current controls from the specified dom element.
  117225. * @param element Defines the element to stop listening the inputs from
  117226. */
  117227. detachControl(element: Nullable<HTMLElement>): void;
  117228. /**
  117229. * Gets the class name of the current intput.
  117230. * @returns the class name
  117231. */
  117232. getClassName(): string;
  117233. /**
  117234. * Get the friendly name associated with the input class.
  117235. * @returns the input friendly name
  117236. */
  117237. getSimpleName(): string;
  117238. }
  117239. }
  117240. declare module BABYLON {
  117241. /**
  117242. * This represents a FPS type of camera controlled by touch.
  117243. * This is like a universal camera minus the Gamepad controls.
  117244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117245. */
  117246. export class TouchCamera extends FreeCamera {
  117247. /**
  117248. * Defines the touch sensibility for rotation.
  117249. * The higher the faster.
  117250. */
  117251. get touchAngularSensibility(): number;
  117252. set touchAngularSensibility(value: number);
  117253. /**
  117254. * Defines the touch sensibility for move.
  117255. * The higher the faster.
  117256. */
  117257. get touchMoveSensibility(): number;
  117258. set touchMoveSensibility(value: number);
  117259. /**
  117260. * Instantiates a new touch camera.
  117261. * This represents a FPS type of camera controlled by touch.
  117262. * This is like a universal camera minus the Gamepad controls.
  117263. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117264. * @param name Define the name of the camera in the scene
  117265. * @param position Define the start position of the camera in the scene
  117266. * @param scene Define the scene the camera belongs to
  117267. */
  117268. constructor(name: string, position: Vector3, scene: Scene);
  117269. /**
  117270. * Gets the current object class name.
  117271. * @return the class name
  117272. */
  117273. getClassName(): string;
  117274. /** @hidden */
  117275. _setupInputs(): void;
  117276. }
  117277. }
  117278. declare module BABYLON {
  117279. /**
  117280. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117281. * being tilted forward or back and left or right.
  117282. */
  117283. export class DeviceOrientationCamera extends FreeCamera {
  117284. private _initialQuaternion;
  117285. private _quaternionCache;
  117286. private _tmpDragQuaternion;
  117287. private _disablePointerInputWhenUsingDeviceOrientation;
  117288. /**
  117289. * Creates a new device orientation camera
  117290. * @param name The name of the camera
  117291. * @param position The start position camera
  117292. * @param scene The scene the camera belongs to
  117293. */
  117294. constructor(name: string, position: Vector3, scene: Scene);
  117295. /**
  117296. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117297. */
  117298. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117299. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117300. private _dragFactor;
  117301. /**
  117302. * Enabled turning on the y axis when the orientation sensor is active
  117303. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117304. */
  117305. enableHorizontalDragging(dragFactor?: number): void;
  117306. /**
  117307. * Gets the current instance class name ("DeviceOrientationCamera").
  117308. * This helps avoiding instanceof at run time.
  117309. * @returns the class name
  117310. */
  117311. getClassName(): string;
  117312. /**
  117313. * @hidden
  117314. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117315. */
  117316. _checkInputs(): void;
  117317. /**
  117318. * Reset the camera to its default orientation on the specified axis only.
  117319. * @param axis The axis to reset
  117320. */
  117321. resetToCurrentRotation(axis?: Axis): void;
  117322. }
  117323. }
  117324. declare module BABYLON {
  117325. /**
  117326. * Defines supported buttons for XBox360 compatible gamepads
  117327. */
  117328. export enum Xbox360Button {
  117329. /** A */
  117330. A = 0,
  117331. /** B */
  117332. B = 1,
  117333. /** X */
  117334. X = 2,
  117335. /** Y */
  117336. Y = 3,
  117337. /** Left button */
  117338. LB = 4,
  117339. /** Right button */
  117340. RB = 5,
  117341. /** Back */
  117342. Back = 8,
  117343. /** Start */
  117344. Start = 9,
  117345. /** Left stick */
  117346. LeftStick = 10,
  117347. /** Right stick */
  117348. RightStick = 11
  117349. }
  117350. /** Defines values for XBox360 DPad */
  117351. export enum Xbox360Dpad {
  117352. /** Up */
  117353. Up = 12,
  117354. /** Down */
  117355. Down = 13,
  117356. /** Left */
  117357. Left = 14,
  117358. /** Right */
  117359. Right = 15
  117360. }
  117361. /**
  117362. * Defines a XBox360 gamepad
  117363. */
  117364. export class Xbox360Pad extends Gamepad {
  117365. private _leftTrigger;
  117366. private _rightTrigger;
  117367. private _onlefttriggerchanged;
  117368. private _onrighttriggerchanged;
  117369. private _onbuttondown;
  117370. private _onbuttonup;
  117371. private _ondpaddown;
  117372. private _ondpadup;
  117373. /** Observable raised when a button is pressed */
  117374. onButtonDownObservable: Observable<Xbox360Button>;
  117375. /** Observable raised when a button is released */
  117376. onButtonUpObservable: Observable<Xbox360Button>;
  117377. /** Observable raised when a pad is pressed */
  117378. onPadDownObservable: Observable<Xbox360Dpad>;
  117379. /** Observable raised when a pad is released */
  117380. onPadUpObservable: Observable<Xbox360Dpad>;
  117381. private _buttonA;
  117382. private _buttonB;
  117383. private _buttonX;
  117384. private _buttonY;
  117385. private _buttonBack;
  117386. private _buttonStart;
  117387. private _buttonLB;
  117388. private _buttonRB;
  117389. private _buttonLeftStick;
  117390. private _buttonRightStick;
  117391. private _dPadUp;
  117392. private _dPadDown;
  117393. private _dPadLeft;
  117394. private _dPadRight;
  117395. private _isXboxOnePad;
  117396. /**
  117397. * Creates a new XBox360 gamepad object
  117398. * @param id defines the id of this gamepad
  117399. * @param index defines its index
  117400. * @param gamepad defines the internal HTML gamepad object
  117401. * @param xboxOne defines if it is a XBox One gamepad
  117402. */
  117403. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117404. /**
  117405. * Defines the callback to call when left trigger is pressed
  117406. * @param callback defines the callback to use
  117407. */
  117408. onlefttriggerchanged(callback: (value: number) => void): void;
  117409. /**
  117410. * Defines the callback to call when right trigger is pressed
  117411. * @param callback defines the callback to use
  117412. */
  117413. onrighttriggerchanged(callback: (value: number) => void): void;
  117414. /**
  117415. * Gets the left trigger value
  117416. */
  117417. get leftTrigger(): number;
  117418. /**
  117419. * Sets the left trigger value
  117420. */
  117421. set leftTrigger(newValue: number);
  117422. /**
  117423. * Gets the right trigger value
  117424. */
  117425. get rightTrigger(): number;
  117426. /**
  117427. * Sets the right trigger value
  117428. */
  117429. set rightTrigger(newValue: number);
  117430. /**
  117431. * Defines the callback to call when a button is pressed
  117432. * @param callback defines the callback to use
  117433. */
  117434. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117435. /**
  117436. * Defines the callback to call when a button is released
  117437. * @param callback defines the callback to use
  117438. */
  117439. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117440. /**
  117441. * Defines the callback to call when a pad is pressed
  117442. * @param callback defines the callback to use
  117443. */
  117444. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117445. /**
  117446. * Defines the callback to call when a pad is released
  117447. * @param callback defines the callback to use
  117448. */
  117449. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117450. private _setButtonValue;
  117451. private _setDPadValue;
  117452. /**
  117453. * Gets the value of the `A` button
  117454. */
  117455. get buttonA(): number;
  117456. /**
  117457. * Sets the value of the `A` button
  117458. */
  117459. set buttonA(value: number);
  117460. /**
  117461. * Gets the value of the `B` button
  117462. */
  117463. get buttonB(): number;
  117464. /**
  117465. * Sets the value of the `B` button
  117466. */
  117467. set buttonB(value: number);
  117468. /**
  117469. * Gets the value of the `X` button
  117470. */
  117471. get buttonX(): number;
  117472. /**
  117473. * Sets the value of the `X` button
  117474. */
  117475. set buttonX(value: number);
  117476. /**
  117477. * Gets the value of the `Y` button
  117478. */
  117479. get buttonY(): number;
  117480. /**
  117481. * Sets the value of the `Y` button
  117482. */
  117483. set buttonY(value: number);
  117484. /**
  117485. * Gets the value of the `Start` button
  117486. */
  117487. get buttonStart(): number;
  117488. /**
  117489. * Sets the value of the `Start` button
  117490. */
  117491. set buttonStart(value: number);
  117492. /**
  117493. * Gets the value of the `Back` button
  117494. */
  117495. get buttonBack(): number;
  117496. /**
  117497. * Sets the value of the `Back` button
  117498. */
  117499. set buttonBack(value: number);
  117500. /**
  117501. * Gets the value of the `Left` button
  117502. */
  117503. get buttonLB(): number;
  117504. /**
  117505. * Sets the value of the `Left` button
  117506. */
  117507. set buttonLB(value: number);
  117508. /**
  117509. * Gets the value of the `Right` button
  117510. */
  117511. get buttonRB(): number;
  117512. /**
  117513. * Sets the value of the `Right` button
  117514. */
  117515. set buttonRB(value: number);
  117516. /**
  117517. * Gets the value of the Left joystick
  117518. */
  117519. get buttonLeftStick(): number;
  117520. /**
  117521. * Sets the value of the Left joystick
  117522. */
  117523. set buttonLeftStick(value: number);
  117524. /**
  117525. * Gets the value of the Right joystick
  117526. */
  117527. get buttonRightStick(): number;
  117528. /**
  117529. * Sets the value of the Right joystick
  117530. */
  117531. set buttonRightStick(value: number);
  117532. /**
  117533. * Gets the value of D-pad up
  117534. */
  117535. get dPadUp(): number;
  117536. /**
  117537. * Sets the value of D-pad up
  117538. */
  117539. set dPadUp(value: number);
  117540. /**
  117541. * Gets the value of D-pad down
  117542. */
  117543. get dPadDown(): number;
  117544. /**
  117545. * Sets the value of D-pad down
  117546. */
  117547. set dPadDown(value: number);
  117548. /**
  117549. * Gets the value of D-pad left
  117550. */
  117551. get dPadLeft(): number;
  117552. /**
  117553. * Sets the value of D-pad left
  117554. */
  117555. set dPadLeft(value: number);
  117556. /**
  117557. * Gets the value of D-pad right
  117558. */
  117559. get dPadRight(): number;
  117560. /**
  117561. * Sets the value of D-pad right
  117562. */
  117563. set dPadRight(value: number);
  117564. /**
  117565. * Force the gamepad to synchronize with device values
  117566. */
  117567. update(): void;
  117568. /**
  117569. * Disposes the gamepad
  117570. */
  117571. dispose(): void;
  117572. }
  117573. }
  117574. declare module BABYLON {
  117575. /**
  117576. * Defines supported buttons for DualShock compatible gamepads
  117577. */
  117578. export enum DualShockButton {
  117579. /** Cross */
  117580. Cross = 0,
  117581. /** Circle */
  117582. Circle = 1,
  117583. /** Square */
  117584. Square = 2,
  117585. /** Triangle */
  117586. Triangle = 3,
  117587. /** L1 */
  117588. L1 = 4,
  117589. /** R1 */
  117590. R1 = 5,
  117591. /** Share */
  117592. Share = 8,
  117593. /** Options */
  117594. Options = 9,
  117595. /** Left stick */
  117596. LeftStick = 10,
  117597. /** Right stick */
  117598. RightStick = 11
  117599. }
  117600. /** Defines values for DualShock DPad */
  117601. export enum DualShockDpad {
  117602. /** Up */
  117603. Up = 12,
  117604. /** Down */
  117605. Down = 13,
  117606. /** Left */
  117607. Left = 14,
  117608. /** Right */
  117609. Right = 15
  117610. }
  117611. /**
  117612. * Defines a DualShock gamepad
  117613. */
  117614. export class DualShockPad extends Gamepad {
  117615. private _leftTrigger;
  117616. private _rightTrigger;
  117617. private _onlefttriggerchanged;
  117618. private _onrighttriggerchanged;
  117619. private _onbuttondown;
  117620. private _onbuttonup;
  117621. private _ondpaddown;
  117622. private _ondpadup;
  117623. /** Observable raised when a button is pressed */
  117624. onButtonDownObservable: Observable<DualShockButton>;
  117625. /** Observable raised when a button is released */
  117626. onButtonUpObservable: Observable<DualShockButton>;
  117627. /** Observable raised when a pad is pressed */
  117628. onPadDownObservable: Observable<DualShockDpad>;
  117629. /** Observable raised when a pad is released */
  117630. onPadUpObservable: Observable<DualShockDpad>;
  117631. private _buttonCross;
  117632. private _buttonCircle;
  117633. private _buttonSquare;
  117634. private _buttonTriangle;
  117635. private _buttonShare;
  117636. private _buttonOptions;
  117637. private _buttonL1;
  117638. private _buttonR1;
  117639. private _buttonLeftStick;
  117640. private _buttonRightStick;
  117641. private _dPadUp;
  117642. private _dPadDown;
  117643. private _dPadLeft;
  117644. private _dPadRight;
  117645. /**
  117646. * Creates a new DualShock gamepad object
  117647. * @param id defines the id of this gamepad
  117648. * @param index defines its index
  117649. * @param gamepad defines the internal HTML gamepad object
  117650. */
  117651. constructor(id: string, index: number, gamepad: any);
  117652. /**
  117653. * Defines the callback to call when left trigger is pressed
  117654. * @param callback defines the callback to use
  117655. */
  117656. onlefttriggerchanged(callback: (value: number) => void): void;
  117657. /**
  117658. * Defines the callback to call when right trigger is pressed
  117659. * @param callback defines the callback to use
  117660. */
  117661. onrighttriggerchanged(callback: (value: number) => void): void;
  117662. /**
  117663. * Gets the left trigger value
  117664. */
  117665. get leftTrigger(): number;
  117666. /**
  117667. * Sets the left trigger value
  117668. */
  117669. set leftTrigger(newValue: number);
  117670. /**
  117671. * Gets the right trigger value
  117672. */
  117673. get rightTrigger(): number;
  117674. /**
  117675. * Sets the right trigger value
  117676. */
  117677. set rightTrigger(newValue: number);
  117678. /**
  117679. * Defines the callback to call when a button is pressed
  117680. * @param callback defines the callback to use
  117681. */
  117682. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117683. /**
  117684. * Defines the callback to call when a button is released
  117685. * @param callback defines the callback to use
  117686. */
  117687. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117688. /**
  117689. * Defines the callback to call when a pad is pressed
  117690. * @param callback defines the callback to use
  117691. */
  117692. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117693. /**
  117694. * Defines the callback to call when a pad is released
  117695. * @param callback defines the callback to use
  117696. */
  117697. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117698. private _setButtonValue;
  117699. private _setDPadValue;
  117700. /**
  117701. * Gets the value of the `Cross` button
  117702. */
  117703. get buttonCross(): number;
  117704. /**
  117705. * Sets the value of the `Cross` button
  117706. */
  117707. set buttonCross(value: number);
  117708. /**
  117709. * Gets the value of the `Circle` button
  117710. */
  117711. get buttonCircle(): number;
  117712. /**
  117713. * Sets the value of the `Circle` button
  117714. */
  117715. set buttonCircle(value: number);
  117716. /**
  117717. * Gets the value of the `Square` button
  117718. */
  117719. get buttonSquare(): number;
  117720. /**
  117721. * Sets the value of the `Square` button
  117722. */
  117723. set buttonSquare(value: number);
  117724. /**
  117725. * Gets the value of the `Triangle` button
  117726. */
  117727. get buttonTriangle(): number;
  117728. /**
  117729. * Sets the value of the `Triangle` button
  117730. */
  117731. set buttonTriangle(value: number);
  117732. /**
  117733. * Gets the value of the `Options` button
  117734. */
  117735. get buttonOptions(): number;
  117736. /**
  117737. * Sets the value of the `Options` button
  117738. */
  117739. set buttonOptions(value: number);
  117740. /**
  117741. * Gets the value of the `Share` button
  117742. */
  117743. get buttonShare(): number;
  117744. /**
  117745. * Sets the value of the `Share` button
  117746. */
  117747. set buttonShare(value: number);
  117748. /**
  117749. * Gets the value of the `L1` button
  117750. */
  117751. get buttonL1(): number;
  117752. /**
  117753. * Sets the value of the `L1` button
  117754. */
  117755. set buttonL1(value: number);
  117756. /**
  117757. * Gets the value of the `R1` button
  117758. */
  117759. get buttonR1(): number;
  117760. /**
  117761. * Sets the value of the `R1` button
  117762. */
  117763. set buttonR1(value: number);
  117764. /**
  117765. * Gets the value of the Left joystick
  117766. */
  117767. get buttonLeftStick(): number;
  117768. /**
  117769. * Sets the value of the Left joystick
  117770. */
  117771. set buttonLeftStick(value: number);
  117772. /**
  117773. * Gets the value of the Right joystick
  117774. */
  117775. get buttonRightStick(): number;
  117776. /**
  117777. * Sets the value of the Right joystick
  117778. */
  117779. set buttonRightStick(value: number);
  117780. /**
  117781. * Gets the value of D-pad up
  117782. */
  117783. get dPadUp(): number;
  117784. /**
  117785. * Sets the value of D-pad up
  117786. */
  117787. set dPadUp(value: number);
  117788. /**
  117789. * Gets the value of D-pad down
  117790. */
  117791. get dPadDown(): number;
  117792. /**
  117793. * Sets the value of D-pad down
  117794. */
  117795. set dPadDown(value: number);
  117796. /**
  117797. * Gets the value of D-pad left
  117798. */
  117799. get dPadLeft(): number;
  117800. /**
  117801. * Sets the value of D-pad left
  117802. */
  117803. set dPadLeft(value: number);
  117804. /**
  117805. * Gets the value of D-pad right
  117806. */
  117807. get dPadRight(): number;
  117808. /**
  117809. * Sets the value of D-pad right
  117810. */
  117811. set dPadRight(value: number);
  117812. /**
  117813. * Force the gamepad to synchronize with device values
  117814. */
  117815. update(): void;
  117816. /**
  117817. * Disposes the gamepad
  117818. */
  117819. dispose(): void;
  117820. }
  117821. }
  117822. declare module BABYLON {
  117823. /**
  117824. * Manager for handling gamepads
  117825. */
  117826. export class GamepadManager {
  117827. private _scene?;
  117828. private _babylonGamepads;
  117829. private _oneGamepadConnected;
  117830. /** @hidden */
  117831. _isMonitoring: boolean;
  117832. private _gamepadEventSupported;
  117833. private _gamepadSupport?;
  117834. /**
  117835. * observable to be triggered when the gamepad controller has been connected
  117836. */
  117837. onGamepadConnectedObservable: Observable<Gamepad>;
  117838. /**
  117839. * observable to be triggered when the gamepad controller has been disconnected
  117840. */
  117841. onGamepadDisconnectedObservable: Observable<Gamepad>;
  117842. private _onGamepadConnectedEvent;
  117843. private _onGamepadDisconnectedEvent;
  117844. /**
  117845. * Initializes the gamepad manager
  117846. * @param _scene BabylonJS scene
  117847. */
  117848. constructor(_scene?: Scene | undefined);
  117849. /**
  117850. * The gamepads in the game pad manager
  117851. */
  117852. get gamepads(): Gamepad[];
  117853. /**
  117854. * Get the gamepad controllers based on type
  117855. * @param type The type of gamepad controller
  117856. * @returns Nullable gamepad
  117857. */
  117858. getGamepadByType(type?: number): Nullable<Gamepad>;
  117859. /**
  117860. * Disposes the gamepad manager
  117861. */
  117862. dispose(): void;
  117863. private _addNewGamepad;
  117864. private _startMonitoringGamepads;
  117865. private _stopMonitoringGamepads;
  117866. /** @hidden */
  117867. _checkGamepadsStatus(): void;
  117868. private _updateGamepadObjects;
  117869. }
  117870. }
  117871. declare module BABYLON {
  117872. interface Scene {
  117873. /** @hidden */
  117874. _gamepadManager: Nullable<GamepadManager>;
  117875. /**
  117876. * Gets the gamepad manager associated with the scene
  117877. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  117878. */
  117879. gamepadManager: GamepadManager;
  117880. }
  117881. /**
  117882. * Interface representing a free camera inputs manager
  117883. */
  117884. interface FreeCameraInputsManager {
  117885. /**
  117886. * Adds gamepad input support to the FreeCameraInputsManager.
  117887. * @returns the FreeCameraInputsManager
  117888. */
  117889. addGamepad(): FreeCameraInputsManager;
  117890. }
  117891. /**
  117892. * Interface representing an arc rotate camera inputs manager
  117893. */
  117894. interface ArcRotateCameraInputsManager {
  117895. /**
  117896. * Adds gamepad input support to the ArcRotateCamera InputManager.
  117897. * @returns the camera inputs manager
  117898. */
  117899. addGamepad(): ArcRotateCameraInputsManager;
  117900. }
  117901. /**
  117902. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  117903. */
  117904. export class GamepadSystemSceneComponent implements ISceneComponent {
  117905. /**
  117906. * The component name helpfull to identify the component in the list of scene components.
  117907. */
  117908. readonly name: string;
  117909. /**
  117910. * The scene the component belongs to.
  117911. */
  117912. scene: Scene;
  117913. /**
  117914. * Creates a new instance of the component for the given scene
  117915. * @param scene Defines the scene to register the component in
  117916. */
  117917. constructor(scene: Scene);
  117918. /**
  117919. * Registers the component in a given scene
  117920. */
  117921. register(): void;
  117922. /**
  117923. * Rebuilds the elements related to this component in case of
  117924. * context lost for instance.
  117925. */
  117926. rebuild(): void;
  117927. /**
  117928. * Disposes the component and the associated ressources
  117929. */
  117930. dispose(): void;
  117931. private _beforeCameraUpdate;
  117932. }
  117933. }
  117934. declare module BABYLON {
  117935. /**
  117936. * 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,
  117937. * which still works and will still be found in many Playgrounds.
  117938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117939. */
  117940. export class UniversalCamera extends TouchCamera {
  117941. /**
  117942. * Defines the gamepad rotation sensiblity.
  117943. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117944. */
  117945. get gamepadAngularSensibility(): number;
  117946. set gamepadAngularSensibility(value: number);
  117947. /**
  117948. * Defines the gamepad move sensiblity.
  117949. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117950. */
  117951. get gamepadMoveSensibility(): number;
  117952. set gamepadMoveSensibility(value: number);
  117953. /**
  117954. * 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,
  117955. * which still works and will still be found in many Playgrounds.
  117956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117957. * @param name Define the name of the camera in the scene
  117958. * @param position Define the start position of the camera in the scene
  117959. * @param scene Define the scene the camera belongs to
  117960. */
  117961. constructor(name: string, position: Vector3, scene: Scene);
  117962. /**
  117963. * Gets the current object class name.
  117964. * @return the class name
  117965. */
  117966. getClassName(): string;
  117967. }
  117968. }
  117969. declare module BABYLON {
  117970. /**
  117971. * This represents a FPS type of camera. This is only here for back compat purpose.
  117972. * Please use the UniversalCamera instead as both are identical.
  117973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117974. */
  117975. export class GamepadCamera extends UniversalCamera {
  117976. /**
  117977. * Instantiates a new Gamepad Camera
  117978. * This represents a FPS type of camera. This is only here for back compat purpose.
  117979. * Please use the UniversalCamera instead as both are identical.
  117980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117981. * @param name Define the name of the camera in the scene
  117982. * @param position Define the start position of the camera in the scene
  117983. * @param scene Define the scene the camera belongs to
  117984. */
  117985. constructor(name: string, position: Vector3, scene: Scene);
  117986. /**
  117987. * Gets the current object class name.
  117988. * @return the class name
  117989. */
  117990. getClassName(): string;
  117991. }
  117992. }
  117993. declare module BABYLON {
  117994. /** @hidden */
  117995. export var passPixelShader: {
  117996. name: string;
  117997. shader: string;
  117998. };
  117999. }
  118000. declare module BABYLON {
  118001. /** @hidden */
  118002. export var passCubePixelShader: {
  118003. name: string;
  118004. shader: string;
  118005. };
  118006. }
  118007. declare module BABYLON {
  118008. /**
  118009. * PassPostProcess which produces an output the same as it's input
  118010. */
  118011. export class PassPostProcess extends PostProcess {
  118012. /**
  118013. * Creates the PassPostProcess
  118014. * @param name The name of the effect.
  118015. * @param options The required width/height ratio to downsize to before computing the render pass.
  118016. * @param camera The camera to apply the render pass to.
  118017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118018. * @param engine The engine which the post process will be applied. (default: current engine)
  118019. * @param reusable If the post process can be reused on the same frame. (default: false)
  118020. * @param textureType The type of texture to be used when performing the post processing.
  118021. * @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)
  118022. */
  118023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118024. }
  118025. /**
  118026. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118027. */
  118028. export class PassCubePostProcess extends PostProcess {
  118029. private _face;
  118030. /**
  118031. * Gets or sets the cube face to display.
  118032. * * 0 is +X
  118033. * * 1 is -X
  118034. * * 2 is +Y
  118035. * * 3 is -Y
  118036. * * 4 is +Z
  118037. * * 5 is -Z
  118038. */
  118039. get face(): number;
  118040. set face(value: number);
  118041. /**
  118042. * Creates the PassCubePostProcess
  118043. * @param name The name of the effect.
  118044. * @param options The required width/height ratio to downsize to before computing the render pass.
  118045. * @param camera The camera to apply the render pass to.
  118046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118047. * @param engine The engine which the post process will be applied. (default: current engine)
  118048. * @param reusable If the post process can be reused on the same frame. (default: false)
  118049. * @param textureType The type of texture to be used when performing the post processing.
  118050. * @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)
  118051. */
  118052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118053. }
  118054. }
  118055. declare module BABYLON {
  118056. /** @hidden */
  118057. export var anaglyphPixelShader: {
  118058. name: string;
  118059. shader: string;
  118060. };
  118061. }
  118062. declare module BABYLON {
  118063. /**
  118064. * Postprocess used to generate anaglyphic rendering
  118065. */
  118066. export class AnaglyphPostProcess extends PostProcess {
  118067. private _passedProcess;
  118068. /**
  118069. * Creates a new AnaglyphPostProcess
  118070. * @param name defines postprocess name
  118071. * @param options defines creation options or target ratio scale
  118072. * @param rigCameras defines cameras using this postprocess
  118073. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118074. * @param engine defines hosting engine
  118075. * @param reusable defines if the postprocess will be reused multiple times per frame
  118076. */
  118077. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118078. }
  118079. }
  118080. declare module BABYLON {
  118081. /**
  118082. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118083. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118084. */
  118085. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118086. /**
  118087. * Creates a new AnaglyphArcRotateCamera
  118088. * @param name defines camera name
  118089. * @param alpha defines alpha angle (in radians)
  118090. * @param beta defines beta angle (in radians)
  118091. * @param radius defines radius
  118092. * @param target defines camera target
  118093. * @param interaxialDistance defines distance between each color axis
  118094. * @param scene defines the hosting scene
  118095. */
  118096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118097. /**
  118098. * Gets camera class name
  118099. * @returns AnaglyphArcRotateCamera
  118100. */
  118101. getClassName(): string;
  118102. }
  118103. }
  118104. declare module BABYLON {
  118105. /**
  118106. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118107. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118108. */
  118109. export class AnaglyphFreeCamera extends FreeCamera {
  118110. /**
  118111. * Creates a new AnaglyphFreeCamera
  118112. * @param name defines camera name
  118113. * @param position defines initial position
  118114. * @param interaxialDistance defines distance between each color axis
  118115. * @param scene defines the hosting scene
  118116. */
  118117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118118. /**
  118119. * Gets camera class name
  118120. * @returns AnaglyphFreeCamera
  118121. */
  118122. getClassName(): string;
  118123. }
  118124. }
  118125. declare module BABYLON {
  118126. /**
  118127. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118128. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118129. */
  118130. export class AnaglyphGamepadCamera extends GamepadCamera {
  118131. /**
  118132. * Creates a new AnaglyphGamepadCamera
  118133. * @param name defines camera name
  118134. * @param position defines initial position
  118135. * @param interaxialDistance defines distance between each color axis
  118136. * @param scene defines the hosting scene
  118137. */
  118138. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118139. /**
  118140. * Gets camera class name
  118141. * @returns AnaglyphGamepadCamera
  118142. */
  118143. getClassName(): string;
  118144. }
  118145. }
  118146. declare module BABYLON {
  118147. /**
  118148. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118149. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118150. */
  118151. export class AnaglyphUniversalCamera extends UniversalCamera {
  118152. /**
  118153. * Creates a new AnaglyphUniversalCamera
  118154. * @param name defines camera name
  118155. * @param position defines initial position
  118156. * @param interaxialDistance defines distance between each color axis
  118157. * @param scene defines the hosting scene
  118158. */
  118159. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118160. /**
  118161. * Gets camera class name
  118162. * @returns AnaglyphUniversalCamera
  118163. */
  118164. getClassName(): string;
  118165. }
  118166. }
  118167. declare module BABYLON {
  118168. /**
  118169. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118170. * @see http://doc.babylonjs.com/features/cameras
  118171. */
  118172. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118173. /**
  118174. * Creates a new StereoscopicArcRotateCamera
  118175. * @param name defines camera name
  118176. * @param alpha defines alpha angle (in radians)
  118177. * @param beta defines beta angle (in radians)
  118178. * @param radius defines radius
  118179. * @param target defines camera target
  118180. * @param interaxialDistance defines distance between each color axis
  118181. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118182. * @param scene defines the hosting scene
  118183. */
  118184. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118185. /**
  118186. * Gets camera class name
  118187. * @returns StereoscopicArcRotateCamera
  118188. */
  118189. getClassName(): string;
  118190. }
  118191. }
  118192. declare module BABYLON {
  118193. /**
  118194. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118195. * @see http://doc.babylonjs.com/features/cameras
  118196. */
  118197. export class StereoscopicFreeCamera extends FreeCamera {
  118198. /**
  118199. * Creates a new StereoscopicFreeCamera
  118200. * @param name defines camera name
  118201. * @param position defines initial position
  118202. * @param interaxialDistance defines distance between each color axis
  118203. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118204. * @param scene defines the hosting scene
  118205. */
  118206. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118207. /**
  118208. * Gets camera class name
  118209. * @returns StereoscopicFreeCamera
  118210. */
  118211. getClassName(): string;
  118212. }
  118213. }
  118214. declare module BABYLON {
  118215. /**
  118216. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118217. * @see http://doc.babylonjs.com/features/cameras
  118218. */
  118219. export class StereoscopicGamepadCamera extends GamepadCamera {
  118220. /**
  118221. * Creates a new StereoscopicGamepadCamera
  118222. * @param name defines camera name
  118223. * @param position defines initial position
  118224. * @param interaxialDistance defines distance between each color axis
  118225. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118226. * @param scene defines the hosting scene
  118227. */
  118228. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118229. /**
  118230. * Gets camera class name
  118231. * @returns StereoscopicGamepadCamera
  118232. */
  118233. getClassName(): string;
  118234. }
  118235. }
  118236. declare module BABYLON {
  118237. /**
  118238. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118239. * @see http://doc.babylonjs.com/features/cameras
  118240. */
  118241. export class StereoscopicUniversalCamera extends UniversalCamera {
  118242. /**
  118243. * Creates a new StereoscopicUniversalCamera
  118244. * @param name defines camera name
  118245. * @param position defines initial position
  118246. * @param interaxialDistance defines distance between each color axis
  118247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118248. * @param scene defines the hosting scene
  118249. */
  118250. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118251. /**
  118252. * Gets camera class name
  118253. * @returns StereoscopicUniversalCamera
  118254. */
  118255. getClassName(): string;
  118256. }
  118257. }
  118258. declare module BABYLON {
  118259. /**
  118260. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118261. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118262. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118263. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118264. */
  118265. export class VirtualJoysticksCamera extends FreeCamera {
  118266. /**
  118267. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118268. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118269. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118270. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118271. * @param name Define the name of the camera in the scene
  118272. * @param position Define the start position of the camera in the scene
  118273. * @param scene Define the scene the camera belongs to
  118274. */
  118275. constructor(name: string, position: Vector3, scene: Scene);
  118276. /**
  118277. * Gets the current object class name.
  118278. * @return the class name
  118279. */
  118280. getClassName(): string;
  118281. }
  118282. }
  118283. declare module BABYLON {
  118284. /**
  118285. * This represents all the required metrics to create a VR camera.
  118286. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118287. */
  118288. export class VRCameraMetrics {
  118289. /**
  118290. * Define the horizontal resolution off the screen.
  118291. */
  118292. hResolution: number;
  118293. /**
  118294. * Define the vertical resolution off the screen.
  118295. */
  118296. vResolution: number;
  118297. /**
  118298. * Define the horizontal screen size.
  118299. */
  118300. hScreenSize: number;
  118301. /**
  118302. * Define the vertical screen size.
  118303. */
  118304. vScreenSize: number;
  118305. /**
  118306. * Define the vertical screen center position.
  118307. */
  118308. vScreenCenter: number;
  118309. /**
  118310. * Define the distance of the eyes to the screen.
  118311. */
  118312. eyeToScreenDistance: number;
  118313. /**
  118314. * Define the distance between both lenses
  118315. */
  118316. lensSeparationDistance: number;
  118317. /**
  118318. * Define the distance between both viewer's eyes.
  118319. */
  118320. interpupillaryDistance: number;
  118321. /**
  118322. * Define the distortion factor of the VR postprocess.
  118323. * Please, touch with care.
  118324. */
  118325. distortionK: number[];
  118326. /**
  118327. * Define the chromatic aberration correction factors for the VR post process.
  118328. */
  118329. chromaAbCorrection: number[];
  118330. /**
  118331. * Define the scale factor of the post process.
  118332. * The smaller the better but the slower.
  118333. */
  118334. postProcessScaleFactor: number;
  118335. /**
  118336. * Define an offset for the lens center.
  118337. */
  118338. lensCenterOffset: number;
  118339. /**
  118340. * Define if the current vr camera should compensate the distortion of the lense or not.
  118341. */
  118342. compensateDistortion: boolean;
  118343. /**
  118344. * Defines if multiview should be enabled when rendering (Default: false)
  118345. */
  118346. multiviewEnabled: boolean;
  118347. /**
  118348. * Gets the rendering aspect ratio based on the provided resolutions.
  118349. */
  118350. get aspectRatio(): number;
  118351. /**
  118352. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118353. */
  118354. get aspectRatioFov(): number;
  118355. /**
  118356. * @hidden
  118357. */
  118358. get leftHMatrix(): Matrix;
  118359. /**
  118360. * @hidden
  118361. */
  118362. get rightHMatrix(): Matrix;
  118363. /**
  118364. * @hidden
  118365. */
  118366. get leftPreViewMatrix(): Matrix;
  118367. /**
  118368. * @hidden
  118369. */
  118370. get rightPreViewMatrix(): Matrix;
  118371. /**
  118372. * Get the default VRMetrics based on the most generic setup.
  118373. * @returns the default vr metrics
  118374. */
  118375. static GetDefault(): VRCameraMetrics;
  118376. }
  118377. }
  118378. declare module BABYLON {
  118379. /** @hidden */
  118380. export var vrDistortionCorrectionPixelShader: {
  118381. name: string;
  118382. shader: string;
  118383. };
  118384. }
  118385. declare module BABYLON {
  118386. /**
  118387. * VRDistortionCorrectionPostProcess used for mobile VR
  118388. */
  118389. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118390. private _isRightEye;
  118391. private _distortionFactors;
  118392. private _postProcessScaleFactor;
  118393. private _lensCenterOffset;
  118394. private _scaleIn;
  118395. private _scaleFactor;
  118396. private _lensCenter;
  118397. /**
  118398. * Initializes the VRDistortionCorrectionPostProcess
  118399. * @param name The name of the effect.
  118400. * @param camera The camera to apply the render pass to.
  118401. * @param isRightEye If this is for the right eye distortion
  118402. * @param vrMetrics All the required metrics for the VR camera
  118403. */
  118404. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118405. }
  118406. }
  118407. declare module BABYLON {
  118408. /**
  118409. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118410. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118411. */
  118412. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118413. /**
  118414. * Creates a new VRDeviceOrientationArcRotateCamera
  118415. * @param name defines camera name
  118416. * @param alpha defines the camera rotation along the logitudinal axis
  118417. * @param beta defines the camera rotation along the latitudinal axis
  118418. * @param radius defines the camera distance from its target
  118419. * @param target defines the camera target
  118420. * @param scene defines the scene the camera belongs to
  118421. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118422. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118423. */
  118424. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118425. /**
  118426. * Gets camera class name
  118427. * @returns VRDeviceOrientationArcRotateCamera
  118428. */
  118429. getClassName(): string;
  118430. }
  118431. }
  118432. declare module BABYLON {
  118433. /**
  118434. * Camera used to simulate VR rendering (based on FreeCamera)
  118435. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118436. */
  118437. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118438. /**
  118439. * Creates a new VRDeviceOrientationFreeCamera
  118440. * @param name defines camera name
  118441. * @param position defines the start position of the camera
  118442. * @param scene defines the scene the camera belongs to
  118443. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118444. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118445. */
  118446. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118447. /**
  118448. * Gets camera class name
  118449. * @returns VRDeviceOrientationFreeCamera
  118450. */
  118451. getClassName(): string;
  118452. }
  118453. }
  118454. declare module BABYLON {
  118455. /**
  118456. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118457. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118458. */
  118459. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118460. /**
  118461. * Creates a new VRDeviceOrientationGamepadCamera
  118462. * @param name defines camera name
  118463. * @param position defines the start position of the camera
  118464. * @param scene defines the scene the camera belongs to
  118465. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118466. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118467. */
  118468. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118469. /**
  118470. * Gets camera class name
  118471. * @returns VRDeviceOrientationGamepadCamera
  118472. */
  118473. getClassName(): string;
  118474. }
  118475. }
  118476. declare module BABYLON {
  118477. /** @hidden */
  118478. export var imageProcessingPixelShader: {
  118479. name: string;
  118480. shader: string;
  118481. };
  118482. }
  118483. declare module BABYLON {
  118484. /**
  118485. * ImageProcessingPostProcess
  118486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118487. */
  118488. export class ImageProcessingPostProcess extends PostProcess {
  118489. /**
  118490. * Default configuration related to image processing available in the PBR Material.
  118491. */
  118492. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118493. /**
  118494. * Gets the image processing configuration used either in this material.
  118495. */
  118496. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118497. /**
  118498. * Sets the Default image processing configuration used either in the this material.
  118499. *
  118500. * If sets to null, the scene one is in use.
  118501. */
  118502. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118503. /**
  118504. * Keep track of the image processing observer to allow dispose and replace.
  118505. */
  118506. private _imageProcessingObserver;
  118507. /**
  118508. * Attaches a new image processing configuration to the PBR Material.
  118509. * @param configuration
  118510. */
  118511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118512. /**
  118513. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118514. */
  118515. get colorCurves(): Nullable<ColorCurves>;
  118516. /**
  118517. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118518. */
  118519. set colorCurves(value: Nullable<ColorCurves>);
  118520. /**
  118521. * Gets wether the color curves effect is enabled.
  118522. */
  118523. get colorCurvesEnabled(): boolean;
  118524. /**
  118525. * Sets wether the color curves effect is enabled.
  118526. */
  118527. set colorCurvesEnabled(value: boolean);
  118528. /**
  118529. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118530. */
  118531. get colorGradingTexture(): Nullable<BaseTexture>;
  118532. /**
  118533. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118534. */
  118535. set colorGradingTexture(value: Nullable<BaseTexture>);
  118536. /**
  118537. * Gets wether the color grading effect is enabled.
  118538. */
  118539. get colorGradingEnabled(): boolean;
  118540. /**
  118541. * Gets wether the color grading effect is enabled.
  118542. */
  118543. set colorGradingEnabled(value: boolean);
  118544. /**
  118545. * Gets exposure used in the effect.
  118546. */
  118547. get exposure(): number;
  118548. /**
  118549. * Sets exposure used in the effect.
  118550. */
  118551. set exposure(value: number);
  118552. /**
  118553. * Gets wether tonemapping is enabled or not.
  118554. */
  118555. get toneMappingEnabled(): boolean;
  118556. /**
  118557. * Sets wether tonemapping is enabled or not
  118558. */
  118559. set toneMappingEnabled(value: boolean);
  118560. /**
  118561. * Gets the type of tone mapping effect.
  118562. */
  118563. get toneMappingType(): number;
  118564. /**
  118565. * Sets the type of tone mapping effect.
  118566. */
  118567. set toneMappingType(value: number);
  118568. /**
  118569. * Gets contrast used in the effect.
  118570. */
  118571. get contrast(): number;
  118572. /**
  118573. * Sets contrast used in the effect.
  118574. */
  118575. set contrast(value: number);
  118576. /**
  118577. * Gets Vignette stretch size.
  118578. */
  118579. get vignetteStretch(): number;
  118580. /**
  118581. * Sets Vignette stretch size.
  118582. */
  118583. set vignetteStretch(value: number);
  118584. /**
  118585. * Gets Vignette centre X Offset.
  118586. */
  118587. get vignetteCentreX(): number;
  118588. /**
  118589. * Sets Vignette centre X Offset.
  118590. */
  118591. set vignetteCentreX(value: number);
  118592. /**
  118593. * Gets Vignette centre Y Offset.
  118594. */
  118595. get vignetteCentreY(): number;
  118596. /**
  118597. * Sets Vignette centre Y Offset.
  118598. */
  118599. set vignetteCentreY(value: number);
  118600. /**
  118601. * Gets Vignette weight or intensity of the vignette effect.
  118602. */
  118603. get vignetteWeight(): number;
  118604. /**
  118605. * Sets Vignette weight or intensity of the vignette effect.
  118606. */
  118607. set vignetteWeight(value: number);
  118608. /**
  118609. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118610. * if vignetteEnabled is set to true.
  118611. */
  118612. get vignetteColor(): Color4;
  118613. /**
  118614. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118615. * if vignetteEnabled is set to true.
  118616. */
  118617. set vignetteColor(value: Color4);
  118618. /**
  118619. * Gets Camera field of view used by the Vignette effect.
  118620. */
  118621. get vignetteCameraFov(): number;
  118622. /**
  118623. * Sets Camera field of view used by the Vignette effect.
  118624. */
  118625. set vignetteCameraFov(value: number);
  118626. /**
  118627. * Gets the vignette blend mode allowing different kind of effect.
  118628. */
  118629. get vignetteBlendMode(): number;
  118630. /**
  118631. * Sets the vignette blend mode allowing different kind of effect.
  118632. */
  118633. set vignetteBlendMode(value: number);
  118634. /**
  118635. * Gets wether the vignette effect is enabled.
  118636. */
  118637. get vignetteEnabled(): boolean;
  118638. /**
  118639. * Sets wether the vignette effect is enabled.
  118640. */
  118641. set vignetteEnabled(value: boolean);
  118642. private _fromLinearSpace;
  118643. /**
  118644. * Gets wether the input of the processing is in Gamma or Linear Space.
  118645. */
  118646. get fromLinearSpace(): boolean;
  118647. /**
  118648. * Sets wether the input of the processing is in Gamma or Linear Space.
  118649. */
  118650. set fromLinearSpace(value: boolean);
  118651. /**
  118652. * Defines cache preventing GC.
  118653. */
  118654. private _defines;
  118655. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118656. /**
  118657. * "ImageProcessingPostProcess"
  118658. * @returns "ImageProcessingPostProcess"
  118659. */
  118660. getClassName(): string;
  118661. protected _updateParameters(): void;
  118662. dispose(camera?: Camera): void;
  118663. }
  118664. }
  118665. declare module BABYLON {
  118666. /**
  118667. * Class containing static functions to help procedurally build meshes
  118668. */
  118669. export class GroundBuilder {
  118670. /**
  118671. * Creates a ground mesh
  118672. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118673. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118675. * @param name defines the name of the mesh
  118676. * @param options defines the options used to create the mesh
  118677. * @param scene defines the hosting scene
  118678. * @returns the ground mesh
  118679. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118680. */
  118681. static CreateGround(name: string, options: {
  118682. width?: number;
  118683. height?: number;
  118684. subdivisions?: number;
  118685. subdivisionsX?: number;
  118686. subdivisionsY?: number;
  118687. updatable?: boolean;
  118688. }, scene: any): Mesh;
  118689. /**
  118690. * Creates a tiled ground mesh
  118691. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118692. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118693. * * 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
  118694. * * 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
  118695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118696. * @param name defines the name of the mesh
  118697. * @param options defines the options used to create the mesh
  118698. * @param scene defines the hosting scene
  118699. * @returns the tiled ground mesh
  118700. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118701. */
  118702. static CreateTiledGround(name: string, options: {
  118703. xmin: number;
  118704. zmin: number;
  118705. xmax: number;
  118706. zmax: number;
  118707. subdivisions?: {
  118708. w: number;
  118709. h: number;
  118710. };
  118711. precision?: {
  118712. w: number;
  118713. h: number;
  118714. };
  118715. updatable?: boolean;
  118716. }, scene?: Nullable<Scene>): Mesh;
  118717. /**
  118718. * Creates a ground mesh from a height map
  118719. * * The parameter `url` sets the URL of the height map image resource.
  118720. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118721. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118722. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118723. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118724. * * 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.
  118725. * * 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).
  118726. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118728. * @param name defines the name of the mesh
  118729. * @param url defines the url to the height map
  118730. * @param options defines the options used to create the mesh
  118731. * @param scene defines the hosting scene
  118732. * @returns the ground mesh
  118733. * @see https://doc.babylonjs.com/babylon101/height_map
  118734. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118735. */
  118736. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118737. width?: number;
  118738. height?: number;
  118739. subdivisions?: number;
  118740. minHeight?: number;
  118741. maxHeight?: number;
  118742. colorFilter?: Color3;
  118743. alphaFilter?: number;
  118744. updatable?: boolean;
  118745. onReady?: (mesh: GroundMesh) => void;
  118746. }, scene?: Nullable<Scene>): GroundMesh;
  118747. }
  118748. }
  118749. declare module BABYLON {
  118750. /**
  118751. * Class containing static functions to help procedurally build meshes
  118752. */
  118753. export class TorusBuilder {
  118754. /**
  118755. * Creates a torus mesh
  118756. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118757. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118758. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118762. * @param name defines the name of the mesh
  118763. * @param options defines the options used to create the mesh
  118764. * @param scene defines the hosting scene
  118765. * @returns the torus mesh
  118766. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118767. */
  118768. static CreateTorus(name: string, options: {
  118769. diameter?: number;
  118770. thickness?: number;
  118771. tessellation?: number;
  118772. updatable?: boolean;
  118773. sideOrientation?: number;
  118774. frontUVs?: Vector4;
  118775. backUVs?: Vector4;
  118776. }, scene: any): Mesh;
  118777. }
  118778. }
  118779. declare module BABYLON {
  118780. /**
  118781. * Class containing static functions to help procedurally build meshes
  118782. */
  118783. export class CylinderBuilder {
  118784. /**
  118785. * Creates a cylinder or a cone mesh
  118786. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118787. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118788. * * 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.
  118789. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118790. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118791. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118792. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118793. * * 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).
  118794. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118795. * * 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).
  118796. * * 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
  118797. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118798. * * 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
  118799. * * 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.
  118800. * * If `enclose` is false, a ring surface is one element.
  118801. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118802. * * 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
  118803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118806. * @param name defines the name of the mesh
  118807. * @param options defines the options used to create the mesh
  118808. * @param scene defines the hosting scene
  118809. * @returns the cylinder mesh
  118810. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118811. */
  118812. static CreateCylinder(name: string, options: {
  118813. height?: number;
  118814. diameterTop?: number;
  118815. diameterBottom?: number;
  118816. diameter?: number;
  118817. tessellation?: number;
  118818. subdivisions?: number;
  118819. arc?: number;
  118820. faceColors?: Color4[];
  118821. faceUV?: Vector4[];
  118822. updatable?: boolean;
  118823. hasRings?: boolean;
  118824. enclose?: boolean;
  118825. cap?: number;
  118826. sideOrientation?: number;
  118827. frontUVs?: Vector4;
  118828. backUVs?: Vector4;
  118829. }, scene: any): Mesh;
  118830. }
  118831. }
  118832. declare module BABYLON {
  118833. /**
  118834. * States of the webXR experience
  118835. */
  118836. export enum WebXRState {
  118837. /**
  118838. * Transitioning to being in XR mode
  118839. */
  118840. ENTERING_XR = 0,
  118841. /**
  118842. * Transitioning to non XR mode
  118843. */
  118844. EXITING_XR = 1,
  118845. /**
  118846. * In XR mode and presenting
  118847. */
  118848. IN_XR = 2,
  118849. /**
  118850. * Not entered XR mode
  118851. */
  118852. NOT_IN_XR = 3
  118853. }
  118854. /**
  118855. * Abstraction of the XR render target
  118856. */
  118857. export interface WebXRRenderTarget extends IDisposable {
  118858. /**
  118859. * xrpresent context of the canvas which can be used to display/mirror xr content
  118860. */
  118861. canvasContext: WebGLRenderingContext;
  118862. /**
  118863. * xr layer for the canvas
  118864. */
  118865. xrLayer: Nullable<XRWebGLLayer>;
  118866. /**
  118867. * Initializes the xr layer for the session
  118868. * @param xrSession xr session
  118869. * @returns a promise that will resolve once the XR Layer has been created
  118870. */
  118871. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118872. }
  118873. }
  118874. declare module BABYLON {
  118875. /**
  118876. * COnfiguration object for WebXR output canvas
  118877. */
  118878. export class WebXRManagedOutputCanvasOptions {
  118879. /**
  118880. * An optional canvas in case you wish to create it yourself and provide it here.
  118881. * If not provided, a new canvas will be created
  118882. */
  118883. canvasElement?: HTMLCanvasElement;
  118884. /**
  118885. * Options for this XR Layer output
  118886. */
  118887. canvasOptions?: XRWebGLLayerOptions;
  118888. /**
  118889. * CSS styling for a newly created canvas (if not provided)
  118890. */
  118891. newCanvasCssStyle?: string;
  118892. /**
  118893. * Get the default values of the configuration object
  118894. * @returns default values of this configuration object
  118895. */
  118896. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  118897. }
  118898. /**
  118899. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  118900. */
  118901. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  118902. private _options;
  118903. private _canvas;
  118904. private _engine;
  118905. /**
  118906. * Rendering context of the canvas which can be used to display/mirror xr content
  118907. */
  118908. canvasContext: WebGLRenderingContext;
  118909. /**
  118910. * xr layer for the canvas
  118911. */
  118912. xrLayer: Nullable<XRWebGLLayer>;
  118913. /**
  118914. * Initializes the canvas to be added/removed upon entering/exiting xr
  118915. * @param _xrSessionManager The XR Session manager
  118916. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  118917. */
  118918. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  118919. /**
  118920. * Disposes of the object
  118921. */
  118922. dispose(): void;
  118923. /**
  118924. * Initializes the xr layer for the session
  118925. * @param xrSession xr session
  118926. * @returns a promise that will resolve once the XR Layer has been created
  118927. */
  118928. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118929. private _addCanvas;
  118930. private _removeCanvas;
  118931. private _setManagedOutputCanvas;
  118932. }
  118933. }
  118934. declare module BABYLON {
  118935. /**
  118936. * Manages an XRSession to work with Babylon's engine
  118937. * @see https://doc.babylonjs.com/how_to/webxr
  118938. */
  118939. export class WebXRSessionManager implements IDisposable {
  118940. /** The scene which the session should be created for */
  118941. scene: Scene;
  118942. private _referenceSpace;
  118943. private _rttProvider;
  118944. private _sessionEnded;
  118945. private _xrNavigator;
  118946. private baseLayer;
  118947. /**
  118948. * The base reference space from which the session started. good if you want to reset your
  118949. * reference space
  118950. */
  118951. baseReferenceSpace: XRReferenceSpace;
  118952. /**
  118953. * Current XR frame
  118954. */
  118955. currentFrame: Nullable<XRFrame>;
  118956. /** WebXR timestamp updated every frame */
  118957. currentTimestamp: number;
  118958. /**
  118959. * Used just in case of a failure to initialize an immersive session.
  118960. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  118961. */
  118962. defaultHeightCompensation: number;
  118963. /**
  118964. * Fires every time a new xrFrame arrives which can be used to update the camera
  118965. */
  118966. onXRFrameObservable: Observable<XRFrame>;
  118967. /**
  118968. * Fires when the reference space changed
  118969. */
  118970. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  118971. /**
  118972. * Fires when the xr session is ended either by the device or manually done
  118973. */
  118974. onXRSessionEnded: Observable<any>;
  118975. /**
  118976. * Fires when the xr session is ended either by the device or manually done
  118977. */
  118978. onXRSessionInit: Observable<XRSession>;
  118979. /**
  118980. * Underlying xr session
  118981. */
  118982. session: XRSession;
  118983. /**
  118984. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  118985. * or get the offset the player is currently at.
  118986. */
  118987. viewerReferenceSpace: XRReferenceSpace;
  118988. /**
  118989. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  118990. * @param scene The scene which the session should be created for
  118991. */
  118992. constructor(
  118993. /** The scene which the session should be created for */
  118994. scene: Scene);
  118995. /**
  118996. * The current reference space used in this session. This reference space can constantly change!
  118997. * It is mainly used to offset the camera's position.
  118998. */
  118999. get referenceSpace(): XRReferenceSpace;
  119000. /**
  119001. * Set a new reference space and triggers the observable
  119002. */
  119003. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  119004. /**
  119005. * Disposes of the session manager
  119006. */
  119007. dispose(): void;
  119008. /**
  119009. * Stops the xrSession and restores the render loop
  119010. * @returns Promise which resolves after it exits XR
  119011. */
  119012. exitXRAsync(): Promise<void>;
  119013. /**
  119014. * Gets the correct render target texture to be rendered this frame for this eye
  119015. * @param eye the eye for which to get the render target
  119016. * @returns the render target for the specified eye
  119017. */
  119018. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119019. /**
  119020. * Creates a WebXRRenderTarget object for the XR session
  119021. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119022. * @param options optional options to provide when creating a new render target
  119023. * @returns a WebXR render target to which the session can render
  119024. */
  119025. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119026. /**
  119027. * Initializes the manager
  119028. * After initialization enterXR can be called to start an XR session
  119029. * @returns Promise which resolves after it is initialized
  119030. */
  119031. initializeAsync(): Promise<void>;
  119032. /**
  119033. * Initializes an xr session
  119034. * @param xrSessionMode mode to initialize
  119035. * @param xrSessionInit defines optional and required values to pass to the session builder
  119036. * @returns a promise which will resolve once the session has been initialized
  119037. */
  119038. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119039. /**
  119040. * Checks if a session would be supported for the creation options specified
  119041. * @param sessionMode session mode to check if supported eg. immersive-vr
  119042. * @returns A Promise that resolves to true if supported and false if not
  119043. */
  119044. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119045. /**
  119046. * Resets the reference space to the one started the session
  119047. */
  119048. resetReferenceSpace(): void;
  119049. /**
  119050. * Starts rendering to the xr layer
  119051. */
  119052. runXRRenderLoop(): void;
  119053. /**
  119054. * Sets the reference space on the xr session
  119055. * @param referenceSpaceType space to set
  119056. * @returns a promise that will resolve once the reference space has been set
  119057. */
  119058. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119059. /**
  119060. * Updates the render state of the session
  119061. * @param state state to set
  119062. * @returns a promise that resolves once the render state has been updated
  119063. */
  119064. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119065. /**
  119066. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119067. * @param sessionMode defines the session to test
  119068. * @returns a promise with boolean as final value
  119069. */
  119070. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119071. private _createRenderTargetTexture;
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. /**
  119076. * WebXR Camera which holds the views for the xrSession
  119077. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119078. */
  119079. export class WebXRCamera extends FreeCamera {
  119080. private _xrSessionManager;
  119081. private _firstFrame;
  119082. private _referenceQuaternion;
  119083. private _referencedPosition;
  119084. private _xrInvPositionCache;
  119085. private _xrInvQuaternionCache;
  119086. /**
  119087. * Should position compensation execute on first frame.
  119088. * This is used when copying the position from a native (non XR) camera
  119089. */
  119090. compensateOnFirstFrame: boolean;
  119091. /**
  119092. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119093. * @param name the name of the camera
  119094. * @param scene the scene to add the camera to
  119095. * @param _xrSessionManager a constructed xr session manager
  119096. */
  119097. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119098. /**
  119099. * Return the user's height, unrelated to the current ground.
  119100. * This will be the y position of this camera, when ground level is 0.
  119101. */
  119102. get realWorldHeight(): number;
  119103. /** @hidden */
  119104. _updateForDualEyeDebugging(): void;
  119105. /**
  119106. * Sets this camera's transformation based on a non-vr camera
  119107. * @param otherCamera the non-vr camera to copy the transformation from
  119108. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119109. */
  119110. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119111. /**
  119112. * Gets the current instance class name ("WebXRCamera").
  119113. * @returns the class name
  119114. */
  119115. getClassName(): string;
  119116. private _updateFromXRSession;
  119117. private _updateNumberOfRigCameras;
  119118. private _updateReferenceSpace;
  119119. private _updateReferenceSpaceOffset;
  119120. }
  119121. }
  119122. declare module BABYLON {
  119123. /**
  119124. * Defining the interface required for a (webxr) feature
  119125. */
  119126. export interface IWebXRFeature extends IDisposable {
  119127. /**
  119128. * Is this feature attached
  119129. */
  119130. attached: boolean;
  119131. /**
  119132. * Should auto-attach be disabled?
  119133. */
  119134. disableAutoAttach: boolean;
  119135. /**
  119136. * Attach the feature to the session
  119137. * Will usually be called by the features manager
  119138. *
  119139. * @param force should attachment be forced (even when already attached)
  119140. * @returns true if successful.
  119141. */
  119142. attach(force?: boolean): boolean;
  119143. /**
  119144. * Detach the feature from the session
  119145. * Will usually be called by the features manager
  119146. *
  119147. * @returns true if successful.
  119148. */
  119149. detach(): boolean;
  119150. }
  119151. /**
  119152. * A list of the currently available features without referencing them
  119153. */
  119154. export class WebXRFeatureName {
  119155. /**
  119156. * The name of the anchor system feature
  119157. */
  119158. static ANCHOR_SYSTEM: string;
  119159. /**
  119160. * The name of the background remover feature
  119161. */
  119162. static BACKGROUND_REMOVER: string;
  119163. /**
  119164. * The name of the hit test feature
  119165. */
  119166. static HIT_TEST: string;
  119167. /**
  119168. * physics impostors for xr controllers feature
  119169. */
  119170. static PHYSICS_CONTROLLERS: string;
  119171. /**
  119172. * The name of the plane detection feature
  119173. */
  119174. static PLANE_DETECTION: string;
  119175. /**
  119176. * The name of the pointer selection feature
  119177. */
  119178. static POINTER_SELECTION: string;
  119179. /**
  119180. * The name of the teleportation feature
  119181. */
  119182. static TELEPORTATION: string;
  119183. }
  119184. /**
  119185. * Defining the constructor of a feature. Used to register the modules.
  119186. */
  119187. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119188. /**
  119189. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119190. * It is mainly used in AR sessions.
  119191. *
  119192. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119193. */
  119194. export class WebXRFeaturesManager implements IDisposable {
  119195. private _xrSessionManager;
  119196. private static readonly _AvailableFeatures;
  119197. private _features;
  119198. /**
  119199. * constructs a new features manages.
  119200. *
  119201. * @param _xrSessionManager an instance of WebXRSessionManager
  119202. */
  119203. constructor(_xrSessionManager: WebXRSessionManager);
  119204. /**
  119205. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119206. * Mainly used internally.
  119207. *
  119208. * @param featureName the name of the feature to register
  119209. * @param constructorFunction the function used to construct the module
  119210. * @param version the (babylon) version of the module
  119211. * @param stable is that a stable version of this module
  119212. */
  119213. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119214. /**
  119215. * Returns a constructor of a specific feature.
  119216. *
  119217. * @param featureName the name of the feature to construct
  119218. * @param version the version of the feature to load
  119219. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119220. * @param options optional options provided to the module.
  119221. * @returns a function that, when called, will return a new instance of this feature
  119222. */
  119223. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119224. /**
  119225. * Can be used to return the list of features currently registered
  119226. *
  119227. * @returns an Array of available features
  119228. */
  119229. static GetAvailableFeatures(): string[];
  119230. /**
  119231. * Gets the versions available for a specific feature
  119232. * @param featureName the name of the feature
  119233. * @returns an array with the available versions
  119234. */
  119235. static GetAvailableVersions(featureName: string): string[];
  119236. /**
  119237. * Return the latest unstable version of this feature
  119238. * @param featureName the name of the feature to search
  119239. * @returns the version number. if not found will return -1
  119240. */
  119241. static GetLatestVersionOfFeature(featureName: string): number;
  119242. /**
  119243. * Return the latest stable version of this feature
  119244. * @param featureName the name of the feature to search
  119245. * @returns the version number. if not found will return -1
  119246. */
  119247. static GetStableVersionOfFeature(featureName: string): number;
  119248. /**
  119249. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119250. * Can be used during a session to start a feature
  119251. * @param featureName the name of feature to attach
  119252. */
  119253. attachFeature(featureName: string): void;
  119254. /**
  119255. * Can be used inside a session or when the session ends to detach a specific feature
  119256. * @param featureName the name of the feature to detach
  119257. */
  119258. detachFeature(featureName: string): void;
  119259. /**
  119260. * Used to disable an already-enabled feature
  119261. * The feature will be disposed and will be recreated once enabled.
  119262. * @param featureName the feature to disable
  119263. * @returns true if disable was successful
  119264. */
  119265. disableFeature(featureName: string | {
  119266. Name: string;
  119267. }): boolean;
  119268. /**
  119269. * dispose this features manager
  119270. */
  119271. dispose(): void;
  119272. /**
  119273. * 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.
  119274. * 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.
  119275. *
  119276. * @param featureName the name of the feature to load or the class of the feature
  119277. * @param version optional version to load. if not provided the latest version will be enabled
  119278. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119279. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119280. * @returns a new constructed feature or throws an error if feature not found.
  119281. */
  119282. enableFeature(featureName: string | {
  119283. Name: string;
  119284. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119285. /**
  119286. * get the implementation of an enabled feature.
  119287. * @param featureName the name of the feature to load
  119288. * @returns the feature class, if found
  119289. */
  119290. getEnabledFeature(featureName: string): IWebXRFeature;
  119291. /**
  119292. * Get the list of enabled features
  119293. * @returns an array of enabled features
  119294. */
  119295. getEnabledFeatures(): string[];
  119296. }
  119297. }
  119298. declare module BABYLON {
  119299. /**
  119300. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119301. * @see https://doc.babylonjs.com/how_to/webxr
  119302. */
  119303. export class WebXRExperienceHelper implements IDisposable {
  119304. private scene;
  119305. private _nonVRCamera;
  119306. private _originalSceneAutoClear;
  119307. private _supported;
  119308. /**
  119309. * Camera used to render xr content
  119310. */
  119311. camera: WebXRCamera;
  119312. /** A features manager for this xr session */
  119313. featuresManager: WebXRFeaturesManager;
  119314. /**
  119315. * Observers registered here will be triggered after the camera's initial transformation is set
  119316. * This can be used to set a different ground level or an extra rotation.
  119317. *
  119318. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119319. * to the position set after this observable is done executing.
  119320. */
  119321. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119322. /**
  119323. * Fires when the state of the experience helper has changed
  119324. */
  119325. onStateChangedObservable: Observable<WebXRState>;
  119326. /** Session manager used to keep track of xr session */
  119327. sessionManager: WebXRSessionManager;
  119328. /**
  119329. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119330. */
  119331. state: WebXRState;
  119332. /**
  119333. * Creates a WebXRExperienceHelper
  119334. * @param scene The scene the helper should be created in
  119335. */
  119336. private constructor();
  119337. /**
  119338. * Creates the experience helper
  119339. * @param scene the scene to attach the experience helper to
  119340. * @returns a promise for the experience helper
  119341. */
  119342. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119343. /**
  119344. * Disposes of the experience helper
  119345. */
  119346. dispose(): void;
  119347. /**
  119348. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119349. * @param sessionMode options for the XR session
  119350. * @param referenceSpaceType frame of reference of the XR session
  119351. * @param renderTarget the output canvas that will be used to enter XR mode
  119352. * @returns promise that resolves after xr mode has entered
  119353. */
  119354. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  119355. /**
  119356. * Exits XR mode and returns the scene to its original state
  119357. * @returns promise that resolves after xr mode has exited
  119358. */
  119359. exitXRAsync(): Promise<void>;
  119360. private _nonXRToXRCamera;
  119361. private _setState;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /**
  119366. * X-Y values for axes in WebXR
  119367. */
  119368. export interface IWebXRMotionControllerAxesValue {
  119369. /**
  119370. * The value of the x axis
  119371. */
  119372. x: number;
  119373. /**
  119374. * The value of the y-axis
  119375. */
  119376. y: number;
  119377. }
  119378. /**
  119379. * changed / previous values for the values of this component
  119380. */
  119381. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119382. /**
  119383. * current (this frame) value
  119384. */
  119385. current: T;
  119386. /**
  119387. * previous (last change) value
  119388. */
  119389. previous: T;
  119390. }
  119391. /**
  119392. * Represents changes in the component between current frame and last values recorded
  119393. */
  119394. export interface IWebXRMotionControllerComponentChanges {
  119395. /**
  119396. * will be populated with previous and current values if axes changed
  119397. */
  119398. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119399. /**
  119400. * will be populated with previous and current values if pressed changed
  119401. */
  119402. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119403. /**
  119404. * will be populated with previous and current values if touched changed
  119405. */
  119406. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119407. /**
  119408. * will be populated with previous and current values if value changed
  119409. */
  119410. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119411. }
  119412. /**
  119413. * This class represents a single component (for example button or thumbstick) of a motion controller
  119414. */
  119415. export class WebXRControllerComponent implements IDisposable {
  119416. /**
  119417. * the id of this component
  119418. */
  119419. id: string;
  119420. /**
  119421. * the type of the component
  119422. */
  119423. type: MotionControllerComponentType;
  119424. private _buttonIndex;
  119425. private _axesIndices;
  119426. private _axes;
  119427. private _changes;
  119428. private _currentValue;
  119429. private _hasChanges;
  119430. private _pressed;
  119431. private _touched;
  119432. /**
  119433. * button component type
  119434. */
  119435. static BUTTON_TYPE: MotionControllerComponentType;
  119436. /**
  119437. * squeeze component type
  119438. */
  119439. static SQUEEZE_TYPE: MotionControllerComponentType;
  119440. /**
  119441. * Thumbstick component type
  119442. */
  119443. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119444. /**
  119445. * Touchpad component type
  119446. */
  119447. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119448. /**
  119449. * trigger component type
  119450. */
  119451. static TRIGGER_TYPE: MotionControllerComponentType;
  119452. /**
  119453. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119454. * the axes data changes
  119455. */
  119456. onAxisValueChangedObservable: Observable<{
  119457. x: number;
  119458. y: number;
  119459. }>;
  119460. /**
  119461. * Observers registered here will be triggered when the state of a button changes
  119462. * State change is either pressed / touched / value
  119463. */
  119464. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119465. /**
  119466. * Creates a new component for a motion controller.
  119467. * It is created by the motion controller itself
  119468. *
  119469. * @param id the id of this component
  119470. * @param type the type of the component
  119471. * @param _buttonIndex index in the buttons array of the gamepad
  119472. * @param _axesIndices indices of the values in the axes array of the gamepad
  119473. */
  119474. constructor(
  119475. /**
  119476. * the id of this component
  119477. */
  119478. id: string,
  119479. /**
  119480. * the type of the component
  119481. */
  119482. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119483. /**
  119484. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119485. */
  119486. get axes(): IWebXRMotionControllerAxesValue;
  119487. /**
  119488. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119489. */
  119490. get changes(): IWebXRMotionControllerComponentChanges;
  119491. /**
  119492. * Return whether or not the component changed the last frame
  119493. */
  119494. get hasChanges(): boolean;
  119495. /**
  119496. * is the button currently pressed
  119497. */
  119498. get pressed(): boolean;
  119499. /**
  119500. * is the button currently touched
  119501. */
  119502. get touched(): boolean;
  119503. /**
  119504. * Get the current value of this component
  119505. */
  119506. get value(): number;
  119507. /**
  119508. * Dispose this component
  119509. */
  119510. dispose(): void;
  119511. /**
  119512. * Are there axes correlating to this component
  119513. * @return true is axes data is available
  119514. */
  119515. isAxes(): boolean;
  119516. /**
  119517. * Is this component a button (hence - pressable)
  119518. * @returns true if can be pressed
  119519. */
  119520. isButton(): boolean;
  119521. /**
  119522. * update this component using the gamepad object it is in. Called on every frame
  119523. * @param nativeController the native gamepad controller object
  119524. */
  119525. update(nativeController: IMinimalMotionControllerObject): void;
  119526. }
  119527. }
  119528. declare module BABYLON {
  119529. /**
  119530. * Class used to represent data loading progression
  119531. */
  119532. export class SceneLoaderProgressEvent {
  119533. /** defines if data length to load can be evaluated */
  119534. readonly lengthComputable: boolean;
  119535. /** defines the loaded data length */
  119536. readonly loaded: number;
  119537. /** defines the data length to load */
  119538. readonly total: number;
  119539. /**
  119540. * Create a new progress event
  119541. * @param lengthComputable defines if data length to load can be evaluated
  119542. * @param loaded defines the loaded data length
  119543. * @param total defines the data length to load
  119544. */
  119545. constructor(
  119546. /** defines if data length to load can be evaluated */
  119547. lengthComputable: boolean,
  119548. /** defines the loaded data length */
  119549. loaded: number,
  119550. /** defines the data length to load */
  119551. total: number);
  119552. /**
  119553. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119554. * @param event defines the source event
  119555. * @returns a new SceneLoaderProgressEvent
  119556. */
  119557. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119558. }
  119559. /**
  119560. * Interface used by SceneLoader plugins to define supported file extensions
  119561. */
  119562. export interface ISceneLoaderPluginExtensions {
  119563. /**
  119564. * Defines the list of supported extensions
  119565. */
  119566. [extension: string]: {
  119567. isBinary: boolean;
  119568. };
  119569. }
  119570. /**
  119571. * Interface used by SceneLoader plugin factory
  119572. */
  119573. export interface ISceneLoaderPluginFactory {
  119574. /**
  119575. * Defines the name of the factory
  119576. */
  119577. name: string;
  119578. /**
  119579. * Function called to create a new plugin
  119580. * @return the new plugin
  119581. */
  119582. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119583. /**
  119584. * The callback that returns true if the data can be directly loaded.
  119585. * @param data string containing the file data
  119586. * @returns if the data can be loaded directly
  119587. */
  119588. canDirectLoad?(data: string): boolean;
  119589. }
  119590. /**
  119591. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119592. */
  119593. export interface ISceneLoaderPluginBase {
  119594. /**
  119595. * The friendly name of this plugin.
  119596. */
  119597. name: string;
  119598. /**
  119599. * The file extensions supported by this plugin.
  119600. */
  119601. extensions: string | ISceneLoaderPluginExtensions;
  119602. /**
  119603. * The callback called when loading from a url.
  119604. * @param scene scene loading this url
  119605. * @param url url to load
  119606. * @param onSuccess callback called when the file successfully loads
  119607. * @param onProgress callback called while file is loading (if the server supports this mode)
  119608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119609. * @param onError callback called when the file fails to load
  119610. * @returns a file request object
  119611. */
  119612. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119613. /**
  119614. * The callback called when loading from a file object.
  119615. * @param scene scene loading this file
  119616. * @param file defines the file to load
  119617. * @param onSuccess defines the callback to call when data is loaded
  119618. * @param onProgress defines the callback to call during loading process
  119619. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119620. * @param onError defines the callback to call when an error occurs
  119621. * @returns a file request object
  119622. */
  119623. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119624. /**
  119625. * The callback that returns true if the data can be directly loaded.
  119626. * @param data string containing the file data
  119627. * @returns if the data can be loaded directly
  119628. */
  119629. canDirectLoad?(data: string): boolean;
  119630. /**
  119631. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119632. * @param scene scene loading this data
  119633. * @param data string containing the data
  119634. * @returns data to pass to the plugin
  119635. */
  119636. directLoad?(scene: Scene, data: string): any;
  119637. /**
  119638. * The callback that allows custom handling of the root url based on the response url.
  119639. * @param rootUrl the original root url
  119640. * @param responseURL the response url if available
  119641. * @returns the new root url
  119642. */
  119643. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119644. }
  119645. /**
  119646. * Interface used to define a SceneLoader plugin
  119647. */
  119648. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119649. /**
  119650. * Import meshes into a scene.
  119651. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119652. * @param scene The scene to import into
  119653. * @param data The data to import
  119654. * @param rootUrl The root url for scene and resources
  119655. * @param meshes The meshes array to import into
  119656. * @param particleSystems The particle systems array to import into
  119657. * @param skeletons The skeletons array to import into
  119658. * @param onError The callback when import fails
  119659. * @returns True if successful or false otherwise
  119660. */
  119661. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119662. /**
  119663. * Load into a scene.
  119664. * @param scene The scene to load into
  119665. * @param data The data to import
  119666. * @param rootUrl The root url for scene and resources
  119667. * @param onError The callback when import fails
  119668. * @returns True if successful or false otherwise
  119669. */
  119670. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119671. /**
  119672. * Load into an asset container.
  119673. * @param scene The scene to load into
  119674. * @param data The data to import
  119675. * @param rootUrl The root url for scene and resources
  119676. * @param onError The callback when import fails
  119677. * @returns The loaded asset container
  119678. */
  119679. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119680. }
  119681. /**
  119682. * Interface used to define an async SceneLoader plugin
  119683. */
  119684. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119685. /**
  119686. * Import meshes into a scene.
  119687. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119688. * @param scene The scene to import into
  119689. * @param data The data to import
  119690. * @param rootUrl The root url for scene and resources
  119691. * @param onProgress The callback when the load progresses
  119692. * @param fileName Defines the name of the file to load
  119693. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119694. */
  119695. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119696. meshes: AbstractMesh[];
  119697. particleSystems: IParticleSystem[];
  119698. skeletons: Skeleton[];
  119699. animationGroups: AnimationGroup[];
  119700. }>;
  119701. /**
  119702. * Load into a scene.
  119703. * @param scene The scene to load into
  119704. * @param data The data to import
  119705. * @param rootUrl The root url for scene and resources
  119706. * @param onProgress The callback when the load progresses
  119707. * @param fileName Defines the name of the file to load
  119708. * @returns Nothing
  119709. */
  119710. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119711. /**
  119712. * Load into an asset container.
  119713. * @param scene The scene to load into
  119714. * @param data The data to import
  119715. * @param rootUrl The root url for scene and resources
  119716. * @param onProgress The callback when the load progresses
  119717. * @param fileName Defines the name of the file to load
  119718. * @returns The loaded asset container
  119719. */
  119720. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119721. }
  119722. /**
  119723. * Mode that determines how to handle old animation groups before loading new ones.
  119724. */
  119725. export enum SceneLoaderAnimationGroupLoadingMode {
  119726. /**
  119727. * Reset all old animations to initial state then dispose them.
  119728. */
  119729. Clean = 0,
  119730. /**
  119731. * Stop all old animations.
  119732. */
  119733. Stop = 1,
  119734. /**
  119735. * Restart old animations from first frame.
  119736. */
  119737. Sync = 2,
  119738. /**
  119739. * Old animations remains untouched.
  119740. */
  119741. NoSync = 3
  119742. }
  119743. /**
  119744. * Class used to load scene from various file formats using registered plugins
  119745. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  119746. */
  119747. export class SceneLoader {
  119748. /**
  119749. * No logging while loading
  119750. */
  119751. static readonly NO_LOGGING: number;
  119752. /**
  119753. * Minimal logging while loading
  119754. */
  119755. static readonly MINIMAL_LOGGING: number;
  119756. /**
  119757. * Summary logging while loading
  119758. */
  119759. static readonly SUMMARY_LOGGING: number;
  119760. /**
  119761. * Detailled logging while loading
  119762. */
  119763. static readonly DETAILED_LOGGING: number;
  119764. /**
  119765. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  119766. */
  119767. static get ForceFullSceneLoadingForIncremental(): boolean;
  119768. static set ForceFullSceneLoadingForIncremental(value: boolean);
  119769. /**
  119770. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  119771. */
  119772. static get ShowLoadingScreen(): boolean;
  119773. static set ShowLoadingScreen(value: boolean);
  119774. /**
  119775. * Defines the current logging level (while loading the scene)
  119776. * @ignorenaming
  119777. */
  119778. static get loggingLevel(): number;
  119779. static set loggingLevel(value: number);
  119780. /**
  119781. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  119782. */
  119783. static get CleanBoneMatrixWeights(): boolean;
  119784. static set CleanBoneMatrixWeights(value: boolean);
  119785. /**
  119786. * Event raised when a plugin is used to load a scene
  119787. */
  119788. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  119789. private static _registeredPlugins;
  119790. private static _getDefaultPlugin;
  119791. private static _getPluginForExtension;
  119792. private static _getPluginForDirectLoad;
  119793. private static _getPluginForFilename;
  119794. private static _getDirectLoad;
  119795. private static _loadData;
  119796. private static _getFileInfo;
  119797. /**
  119798. * Gets a plugin that can load the given extension
  119799. * @param extension defines the extension to load
  119800. * @returns a plugin or null if none works
  119801. */
  119802. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  119803. /**
  119804. * Gets a boolean indicating that the given extension can be loaded
  119805. * @param extension defines the extension to load
  119806. * @returns true if the extension is supported
  119807. */
  119808. static IsPluginForExtensionAvailable(extension: string): boolean;
  119809. /**
  119810. * Adds a new plugin to the list of registered plugins
  119811. * @param plugin defines the plugin to add
  119812. */
  119813. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  119814. /**
  119815. * Import meshes into a scene
  119816. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119817. * @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)
  119818. * @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)
  119819. * @param scene the instance of BABYLON.Scene to append to
  119820. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  119821. * @param onProgress a callback with a progress event for each file being loaded
  119822. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119823. * @param pluginExtension the extension used to determine the plugin
  119824. * @returns The loaded plugin
  119825. */
  119826. 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>;
  119827. /**
  119828. * Import meshes into a scene
  119829. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119830. * @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)
  119831. * @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)
  119832. * @param scene the instance of BABYLON.Scene to append to
  119833. * @param onProgress a callback with a progress event for each file being loaded
  119834. * @param pluginExtension the extension used to determine the plugin
  119835. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  119836. */
  119837. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  119838. meshes: AbstractMesh[];
  119839. particleSystems: IParticleSystem[];
  119840. skeletons: Skeleton[];
  119841. animationGroups: AnimationGroup[];
  119842. }>;
  119843. /**
  119844. * Load a scene
  119845. * @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)
  119846. * @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)
  119847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119848. * @param onSuccess a callback with the scene when import succeeds
  119849. * @param onProgress a callback with a progress event for each file being loaded
  119850. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119851. * @param pluginExtension the extension used to determine the plugin
  119852. * @returns The loaded plugin
  119853. */
  119854. 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>;
  119855. /**
  119856. * Load a scene
  119857. * @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)
  119858. * @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)
  119859. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119860. * @param onProgress a callback with a progress event for each file being loaded
  119861. * @param pluginExtension the extension used to determine the plugin
  119862. * @returns The loaded scene
  119863. */
  119864. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119865. /**
  119866. * Append a scene
  119867. * @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)
  119868. * @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)
  119869. * @param scene is the instance of BABYLON.Scene to append to
  119870. * @param onSuccess a callback with the scene when import succeeds
  119871. * @param onProgress a callback with a progress event for each file being loaded
  119872. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119873. * @param pluginExtension the extension used to determine the plugin
  119874. * @returns The loaded plugin
  119875. */
  119876. 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>;
  119877. /**
  119878. * Append a scene
  119879. * @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)
  119880. * @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)
  119881. * @param scene is the instance of BABYLON.Scene to append to
  119882. * @param onProgress a callback with a progress event for each file being loaded
  119883. * @param pluginExtension the extension used to determine the plugin
  119884. * @returns The given scene
  119885. */
  119886. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119887. /**
  119888. * Load a scene into an asset container
  119889. * @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)
  119890. * @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)
  119891. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119892. * @param onSuccess a callback with the scene when import succeeds
  119893. * @param onProgress a callback with a progress event for each file being loaded
  119894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119895. * @param pluginExtension the extension used to determine the plugin
  119896. * @returns The loaded plugin
  119897. */
  119898. 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>;
  119899. /**
  119900. * Load a scene into an asset container
  119901. * @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)
  119902. * @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)
  119903. * @param scene is the instance of Scene to append to
  119904. * @param onProgress a callback with a progress event for each file being loaded
  119905. * @param pluginExtension the extension used to determine the plugin
  119906. * @returns The loaded asset container
  119907. */
  119908. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  119909. /**
  119910. * Import animations from a file into a scene
  119911. * @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)
  119912. * @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)
  119913. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119914. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119915. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119916. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119917. * @param onSuccess a callback with the scene when import succeeds
  119918. * @param onProgress a callback with a progress event for each file being loaded
  119919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119920. */
  119921. 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;
  119922. /**
  119923. * Import animations from a file into a scene
  119924. * @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)
  119925. * @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)
  119926. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119927. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119928. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119929. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119930. * @param onSuccess a callback with the scene when import succeeds
  119931. * @param onProgress a callback with a progress event for each file being loaded
  119932. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119933. * @returns the updated scene with imported animations
  119934. */
  119935. 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>;
  119936. }
  119937. }
  119938. declare module BABYLON {
  119939. /**
  119940. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  119941. */
  119942. export type MotionControllerHandedness = "none" | "left" | "right";
  119943. /**
  119944. * The type of components available in motion controllers.
  119945. * This is not the name of the component.
  119946. */
  119947. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  119948. /**
  119949. * The state of a controller component
  119950. */
  119951. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  119952. /**
  119953. * The schema of motion controller layout.
  119954. * No object will be initialized using this interface
  119955. * This is used just to define the profile.
  119956. */
  119957. export interface IMotionControllerLayout {
  119958. /**
  119959. * Path to load the assets. Usually relative to the base path
  119960. */
  119961. assetPath: string;
  119962. /**
  119963. * Available components (unsorted)
  119964. */
  119965. components: {
  119966. /**
  119967. * A map of component Ids
  119968. */
  119969. [componentId: string]: {
  119970. /**
  119971. * The type of input the component outputs
  119972. */
  119973. type: MotionControllerComponentType;
  119974. /**
  119975. * The indices of this component in the gamepad object
  119976. */
  119977. gamepadIndices: {
  119978. /**
  119979. * Index of button
  119980. */
  119981. button?: number;
  119982. /**
  119983. * If available, index of x-axis
  119984. */
  119985. xAxis?: number;
  119986. /**
  119987. * If available, index of y-axis
  119988. */
  119989. yAxis?: number;
  119990. };
  119991. /**
  119992. * The mesh's root node name
  119993. */
  119994. rootNodeName: string;
  119995. /**
  119996. * Animation definitions for this model
  119997. */
  119998. visualResponses: {
  119999. [stateKey: string]: {
  120000. /**
  120001. * What property will be animated
  120002. */
  120003. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  120004. /**
  120005. * What states influence this visual response
  120006. */
  120007. states: MotionControllerComponentStateType[];
  120008. /**
  120009. * Type of animation - movement or visibility
  120010. */
  120011. valueNodeProperty: "transform" | "visibility";
  120012. /**
  120013. * Base node name to move. Its position will be calculated according to the min and max nodes
  120014. */
  120015. valueNodeName?: string;
  120016. /**
  120017. * Minimum movement node
  120018. */
  120019. minNodeName?: string;
  120020. /**
  120021. * Max movement node
  120022. */
  120023. maxNodeName?: string;
  120024. };
  120025. };
  120026. /**
  120027. * If touch enabled, what is the name of node to display user feedback
  120028. */
  120029. touchPointNodeName?: string;
  120030. };
  120031. };
  120032. /**
  120033. * Is it xr standard mapping or not
  120034. */
  120035. gamepadMapping: "" | "xr-standard";
  120036. /**
  120037. * Base root node of this entire model
  120038. */
  120039. rootNodeName: string;
  120040. /**
  120041. * Defines the main button component id
  120042. */
  120043. selectComponentId: string;
  120044. }
  120045. /**
  120046. * A definition for the layout map in the input profile
  120047. */
  120048. export interface IMotionControllerLayoutMap {
  120049. /**
  120050. * Layouts with handedness type as a key
  120051. */
  120052. [handedness: string]: IMotionControllerLayout;
  120053. }
  120054. /**
  120055. * The XR Input profile schema
  120056. * Profiles can be found here:
  120057. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120058. */
  120059. export interface IMotionControllerProfile {
  120060. /**
  120061. * fallback profiles for this profileId
  120062. */
  120063. fallbackProfileIds: string[];
  120064. /**
  120065. * The layout map, with handedness as key
  120066. */
  120067. layouts: IMotionControllerLayoutMap;
  120068. /**
  120069. * The id of this profile
  120070. * correlates to the profile(s) in the xrInput.profiles array
  120071. */
  120072. profileId: string;
  120073. }
  120074. /**
  120075. * A helper-interface for the 3 meshes needed for controller button animation
  120076. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120077. */
  120078. export interface IMotionControllerButtonMeshMap {
  120079. /**
  120080. * the mesh that defines the pressed value mesh position.
  120081. * This is used to find the max-position of this button
  120082. */
  120083. pressedMesh: AbstractMesh;
  120084. /**
  120085. * the mesh that defines the unpressed value mesh position.
  120086. * This is used to find the min (or initial) position of this button
  120087. */
  120088. unpressedMesh: AbstractMesh;
  120089. /**
  120090. * The mesh that will be changed when value changes
  120091. */
  120092. valueMesh: AbstractMesh;
  120093. }
  120094. /**
  120095. * A helper-interface for the 3 meshes needed for controller axis animation.
  120096. * This will be expanded when touchpad animations are fully supported
  120097. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120098. */
  120099. export interface IMotionControllerMeshMap {
  120100. /**
  120101. * the mesh that defines the maximum value mesh position.
  120102. */
  120103. maxMesh?: AbstractMesh;
  120104. /**
  120105. * the mesh that defines the minimum value mesh position.
  120106. */
  120107. minMesh?: AbstractMesh;
  120108. /**
  120109. * The mesh that will be changed when axis value changes
  120110. */
  120111. valueMesh: AbstractMesh;
  120112. }
  120113. /**
  120114. * The elements needed for change-detection of the gamepad objects in motion controllers
  120115. */
  120116. export interface IMinimalMotionControllerObject {
  120117. /**
  120118. * Available axes of this controller
  120119. */
  120120. axes: number[];
  120121. /**
  120122. * An array of available buttons
  120123. */
  120124. buttons: Array<{
  120125. /**
  120126. * Value of the button/trigger
  120127. */
  120128. value: number;
  120129. /**
  120130. * If the button/trigger is currently touched
  120131. */
  120132. touched: boolean;
  120133. /**
  120134. * If the button/trigger is currently pressed
  120135. */
  120136. pressed: boolean;
  120137. }>;
  120138. /**
  120139. * EXPERIMENTAL haptic support.
  120140. */
  120141. hapticActuators?: Array<{
  120142. pulse: (value: number, duration: number) => Promise<boolean>;
  120143. }>;
  120144. }
  120145. /**
  120146. * An Abstract Motion controller
  120147. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120148. * Each component has an observable to check for changes in value and state
  120149. */
  120150. export abstract class WebXRAbstractMotionController implements IDisposable {
  120151. protected scene: Scene;
  120152. protected layout: IMotionControllerLayout;
  120153. /**
  120154. * The gamepad object correlating to this controller
  120155. */
  120156. gamepadObject: IMinimalMotionControllerObject;
  120157. /**
  120158. * handedness (left/right/none) of this controller
  120159. */
  120160. handedness: MotionControllerHandedness;
  120161. private _initComponent;
  120162. private _modelReady;
  120163. /**
  120164. * A map of components (WebXRControllerComponent) in this motion controller
  120165. * Components have a ComponentType and can also have both button and axis definitions
  120166. */
  120167. readonly components: {
  120168. [id: string]: WebXRControllerComponent;
  120169. };
  120170. /**
  120171. * Disable the model's animation. Can be set at any time.
  120172. */
  120173. disableAnimation: boolean;
  120174. /**
  120175. * Observers registered here will be triggered when the model of this controller is done loading
  120176. */
  120177. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120178. /**
  120179. * The profile id of this motion controller
  120180. */
  120181. abstract profileId: string;
  120182. /**
  120183. * The root mesh of the model. It is null if the model was not yet initialized
  120184. */
  120185. rootMesh: Nullable<AbstractMesh>;
  120186. /**
  120187. * constructs a new abstract motion controller
  120188. * @param scene the scene to which the model of the controller will be added
  120189. * @param layout The profile layout to load
  120190. * @param gamepadObject The gamepad object correlating to this controller
  120191. * @param handedness handedness (left/right/none) of this controller
  120192. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120193. */
  120194. constructor(scene: Scene, layout: IMotionControllerLayout,
  120195. /**
  120196. * The gamepad object correlating to this controller
  120197. */
  120198. gamepadObject: IMinimalMotionControllerObject,
  120199. /**
  120200. * handedness (left/right/none) of this controller
  120201. */
  120202. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120203. /**
  120204. * Dispose this controller, the model mesh and all its components
  120205. */
  120206. dispose(): void;
  120207. /**
  120208. * Returns all components of specific type
  120209. * @param type the type to search for
  120210. * @return an array of components with this type
  120211. */
  120212. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120213. /**
  120214. * get a component based an its component id as defined in layout.components
  120215. * @param id the id of the component
  120216. * @returns the component correlates to the id or undefined if not found
  120217. */
  120218. getComponent(id: string): WebXRControllerComponent;
  120219. /**
  120220. * Get the list of components available in this motion controller
  120221. * @returns an array of strings correlating to available components
  120222. */
  120223. getComponentIds(): string[];
  120224. /**
  120225. * Get the first component of specific type
  120226. * @param type type of component to find
  120227. * @return a controller component or null if not found
  120228. */
  120229. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120230. /**
  120231. * Get the main (Select) component of this controller as defined in the layout
  120232. * @returns the main component of this controller
  120233. */
  120234. getMainComponent(): WebXRControllerComponent;
  120235. /**
  120236. * Loads the model correlating to this controller
  120237. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120238. * @returns A promise fulfilled with the result of the model loading
  120239. */
  120240. loadModel(): Promise<boolean>;
  120241. /**
  120242. * Update this model using the current XRFrame
  120243. * @param xrFrame the current xr frame to use and update the model
  120244. */
  120245. updateFromXRFrame(xrFrame: XRFrame): void;
  120246. /**
  120247. * Backwards compatibility due to a deeply-integrated typo
  120248. */
  120249. get handness(): XREye;
  120250. /**
  120251. * Pulse (vibrate) this controller
  120252. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120253. * Consecutive calls to this function will cancel the last pulse call
  120254. *
  120255. * @param value the strength of the pulse in 0.0...1.0 range
  120256. * @param duration Duration of the pulse in milliseconds
  120257. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120258. * @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
  120259. */
  120260. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120261. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120262. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120263. /**
  120264. * Moves the axis on the controller mesh based on its current state
  120265. * @param axis the index of the axis
  120266. * @param axisValue the value of the axis which determines the meshes new position
  120267. * @hidden
  120268. */
  120269. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120270. /**
  120271. * Update the model itself with the current frame data
  120272. * @param xrFrame the frame to use for updating the model mesh
  120273. */
  120274. protected updateModel(xrFrame: XRFrame): void;
  120275. /**
  120276. * Get the filename and path for this controller's model
  120277. * @returns a map of filename and path
  120278. */
  120279. protected abstract _getFilenameAndPath(): {
  120280. filename: string;
  120281. path: string;
  120282. };
  120283. /**
  120284. * This function is called before the mesh is loaded. It checks for loading constraints.
  120285. * For example, this function can check if the GLB loader is available
  120286. * If this function returns false, the generic controller will be loaded instead
  120287. * @returns Is the client ready to load the mesh
  120288. */
  120289. protected abstract _getModelLoadingConstraints(): boolean;
  120290. /**
  120291. * This function will be called after the model was successfully loaded and can be used
  120292. * for mesh transformations before it is available for the user
  120293. * @param meshes the loaded meshes
  120294. */
  120295. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120296. /**
  120297. * Set the root mesh for this controller. Important for the WebXR controller class
  120298. * @param meshes the loaded meshes
  120299. */
  120300. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120301. /**
  120302. * A function executed each frame that updates the mesh (if needed)
  120303. * @param xrFrame the current xrFrame
  120304. */
  120305. protected abstract _updateModel(xrFrame: XRFrame): void;
  120306. private _getGenericFilenameAndPath;
  120307. private _getGenericParentMesh;
  120308. }
  120309. }
  120310. declare module BABYLON {
  120311. /**
  120312. * A generic trigger-only motion controller for WebXR
  120313. */
  120314. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120315. /**
  120316. * Static version of the profile id of this controller
  120317. */
  120318. static ProfileId: string;
  120319. profileId: string;
  120320. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120321. protected _getFilenameAndPath(): {
  120322. filename: string;
  120323. path: string;
  120324. };
  120325. protected _getModelLoadingConstraints(): boolean;
  120326. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120327. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120328. protected _updateModel(): void;
  120329. }
  120330. }
  120331. declare module BABYLON {
  120332. /**
  120333. * Class containing static functions to help procedurally build meshes
  120334. */
  120335. export class SphereBuilder {
  120336. /**
  120337. * Creates a sphere mesh
  120338. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120339. * * 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`)
  120340. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120341. * * 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
  120342. * * 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)
  120343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120346. * @param name defines the name of the mesh
  120347. * @param options defines the options used to create the mesh
  120348. * @param scene defines the hosting scene
  120349. * @returns the sphere mesh
  120350. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120351. */
  120352. static CreateSphere(name: string, options: {
  120353. segments?: number;
  120354. diameter?: number;
  120355. diameterX?: number;
  120356. diameterY?: number;
  120357. diameterZ?: number;
  120358. arc?: number;
  120359. slice?: number;
  120360. sideOrientation?: number;
  120361. frontUVs?: Vector4;
  120362. backUVs?: Vector4;
  120363. updatable?: boolean;
  120364. }, scene?: Nullable<Scene>): Mesh;
  120365. }
  120366. }
  120367. declare module BABYLON {
  120368. /**
  120369. * A profiled motion controller has its profile loaded from an online repository.
  120370. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120371. */
  120372. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120373. private _repositoryUrl;
  120374. private _buttonMeshMapping;
  120375. private _touchDots;
  120376. /**
  120377. * The profile ID of this controller. Will be populated when the controller initializes.
  120378. */
  120379. profileId: string;
  120380. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120381. dispose(): void;
  120382. protected _getFilenameAndPath(): {
  120383. filename: string;
  120384. path: string;
  120385. };
  120386. protected _getModelLoadingConstraints(): boolean;
  120387. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120388. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120389. protected _updateModel(_xrFrame: XRFrame): void;
  120390. }
  120391. }
  120392. declare module BABYLON {
  120393. /**
  120394. * A construction function type to create a new controller based on an xrInput object
  120395. */
  120396. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120397. /**
  120398. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120399. *
  120400. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120401. * it should be replaced with auto-loaded controllers.
  120402. *
  120403. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120404. */
  120405. export class WebXRMotionControllerManager {
  120406. private static _AvailableControllers;
  120407. private static _Fallbacks;
  120408. private static _ProfileLoadingPromises;
  120409. private static _ProfilesList;
  120410. /**
  120411. * The base URL of the online controller repository. Can be changed at any time.
  120412. */
  120413. static BaseRepositoryUrl: string;
  120414. /**
  120415. * Which repository gets priority - local or online
  120416. */
  120417. static PrioritizeOnlineRepository: boolean;
  120418. /**
  120419. * Use the online repository, or use only locally-defined controllers
  120420. */
  120421. static UseOnlineRepository: boolean;
  120422. /**
  120423. * Clear the cache used for profile loading and reload when requested again
  120424. */
  120425. static ClearProfilesCache(): void;
  120426. /**
  120427. * Register the default fallbacks.
  120428. * This function is called automatically when this file is imported.
  120429. */
  120430. static DefaultFallbacks(): void;
  120431. /**
  120432. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120433. * @param profileId the profile to which a fallback needs to be found
  120434. * @return an array with corresponding fallback profiles
  120435. */
  120436. static FindFallbackWithProfileId(profileId: string): string[];
  120437. /**
  120438. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120439. * The order of search:
  120440. *
  120441. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120442. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120443. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120444. * 4) return the generic trigger controller if none were found
  120445. *
  120446. * @param xrInput the xrInput to which a new controller is initialized
  120447. * @param scene the scene to which the model will be added
  120448. * @param forceProfile force a certain profile for this controller
  120449. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120450. */
  120451. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120452. /**
  120453. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120454. *
  120455. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120456. *
  120457. * @param type the profile type to register
  120458. * @param constructFunction the function to be called when loading this profile
  120459. */
  120460. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120461. /**
  120462. * Register a fallback to a specific profile.
  120463. * @param profileId the profileId that will receive the fallbacks
  120464. * @param fallbacks A list of fallback profiles
  120465. */
  120466. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120467. /**
  120468. * Will update the list of profiles available in the repository
  120469. * @return a promise that resolves to a map of profiles available online
  120470. */
  120471. static UpdateProfilesList(): Promise<{
  120472. [profile: string]: string;
  120473. }>;
  120474. private static _LoadProfileFromRepository;
  120475. private static _LoadProfilesFromAvailableControllers;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. /**
  120480. * Configuration options for the WebXR controller creation
  120481. */
  120482. export interface IWebXRControllerOptions {
  120483. /**
  120484. * Should the controller mesh be animated when a user interacts with it
  120485. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120486. */
  120487. disableMotionControllerAnimation?: boolean;
  120488. /**
  120489. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120490. */
  120491. doNotLoadControllerMesh?: boolean;
  120492. /**
  120493. * Force a specific controller type for this controller.
  120494. * This can be used when creating your own profile or when testing different controllers
  120495. */
  120496. forceControllerProfile?: string;
  120497. /**
  120498. * Defines a rendering group ID for meshes that will be loaded.
  120499. * This is for the default controllers only.
  120500. */
  120501. renderingGroupId?: number;
  120502. }
  120503. /**
  120504. * Represents an XR controller
  120505. */
  120506. export class WebXRInputSource {
  120507. private _scene;
  120508. /** The underlying input source for the controller */
  120509. inputSource: XRInputSource;
  120510. private _options;
  120511. private _tmpQuaternion;
  120512. private _tmpVector;
  120513. private _uniqueId;
  120514. /**
  120515. * 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
  120516. */
  120517. grip?: AbstractMesh;
  120518. /**
  120519. * If available, this is the gamepad object related to this controller.
  120520. * Using this object it is possible to get click events and trackpad changes of the
  120521. * webxr controller that is currently being used.
  120522. */
  120523. motionController?: WebXRAbstractMotionController;
  120524. /**
  120525. * Event that fires when the controller is removed/disposed.
  120526. * The object provided as event data is this controller, after associated assets were disposed.
  120527. * uniqueId is still available.
  120528. */
  120529. onDisposeObservable: Observable<WebXRInputSource>;
  120530. /**
  120531. * Will be triggered when the mesh associated with the motion controller is done loading.
  120532. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120533. * A shortened version of controller -> motion controller -> on mesh loaded.
  120534. */
  120535. onMeshLoadedObservable: Observable<AbstractMesh>;
  120536. /**
  120537. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120538. */
  120539. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120540. /**
  120541. * Pointer which can be used to select objects or attach a visible laser to
  120542. */
  120543. pointer: AbstractMesh;
  120544. /**
  120545. * Creates the controller
  120546. * @see https://doc.babylonjs.com/how_to/webxr
  120547. * @param _scene the scene which the controller should be associated to
  120548. * @param inputSource the underlying input source for the controller
  120549. * @param _options options for this controller creation
  120550. */
  120551. constructor(_scene: Scene,
  120552. /** The underlying input source for the controller */
  120553. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120554. /**
  120555. * Get this controllers unique id
  120556. */
  120557. get uniqueId(): string;
  120558. /**
  120559. * Disposes of the object
  120560. */
  120561. dispose(): void;
  120562. /**
  120563. * Gets a world space ray coming from the pointer or grip
  120564. * @param result the resulting ray
  120565. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120566. */
  120567. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120568. /**
  120569. * Updates the controller pose based on the given XRFrame
  120570. * @param xrFrame xr frame to update the pose with
  120571. * @param referenceSpace reference space to use
  120572. */
  120573. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /**
  120578. * The schema for initialization options of the XR Input class
  120579. */
  120580. export interface IWebXRInputOptions {
  120581. /**
  120582. * If set to true no model will be automatically loaded
  120583. */
  120584. doNotLoadControllerMeshes?: boolean;
  120585. /**
  120586. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120587. * If not found, the xr input profile data will be used.
  120588. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120589. */
  120590. forceInputProfile?: string;
  120591. /**
  120592. * Do not send a request to the controller repository to load the profile.
  120593. *
  120594. * Instead, use the controllers available in babylon itself.
  120595. */
  120596. disableOnlineControllerRepository?: boolean;
  120597. /**
  120598. * A custom URL for the controllers repository
  120599. */
  120600. customControllersRepositoryURL?: string;
  120601. /**
  120602. * Should the controller model's components not move according to the user input
  120603. */
  120604. disableControllerAnimation?: boolean;
  120605. /**
  120606. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120607. */
  120608. controllerOptions?: IWebXRControllerOptions;
  120609. }
  120610. /**
  120611. * XR input used to track XR inputs such as controllers/rays
  120612. */
  120613. export class WebXRInput implements IDisposable {
  120614. /**
  120615. * the xr session manager for this session
  120616. */
  120617. xrSessionManager: WebXRSessionManager;
  120618. /**
  120619. * the WebXR camera for this session. Mainly used for teleportation
  120620. */
  120621. xrCamera: WebXRCamera;
  120622. private readonly options;
  120623. /**
  120624. * XR controllers being tracked
  120625. */
  120626. controllers: Array<WebXRInputSource>;
  120627. private _frameObserver;
  120628. private _sessionEndedObserver;
  120629. private _sessionInitObserver;
  120630. /**
  120631. * Event when a controller has been connected/added
  120632. */
  120633. onControllerAddedObservable: Observable<WebXRInputSource>;
  120634. /**
  120635. * Event when a controller has been removed/disconnected
  120636. */
  120637. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120638. /**
  120639. * Initializes the WebXRInput
  120640. * @param xrSessionManager the xr session manager for this session
  120641. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120642. * @param options = initialization options for this xr input
  120643. */
  120644. constructor(
  120645. /**
  120646. * the xr session manager for this session
  120647. */
  120648. xrSessionManager: WebXRSessionManager,
  120649. /**
  120650. * the WebXR camera for this session. Mainly used for teleportation
  120651. */
  120652. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120653. private _onInputSourcesChange;
  120654. private _addAndRemoveControllers;
  120655. /**
  120656. * Disposes of the object
  120657. */
  120658. dispose(): void;
  120659. }
  120660. }
  120661. declare module BABYLON {
  120662. /**
  120663. * This is the base class for all WebXR features.
  120664. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120665. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120666. */
  120667. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120668. protected _xrSessionManager: WebXRSessionManager;
  120669. private _attached;
  120670. private _removeOnDetach;
  120671. /**
  120672. * Should auto-attach be disabled?
  120673. */
  120674. disableAutoAttach: boolean;
  120675. /**
  120676. * Construct a new (abstract) WebXR feature
  120677. * @param _xrSessionManager the xr session manager for this feature
  120678. */
  120679. constructor(_xrSessionManager: WebXRSessionManager);
  120680. /**
  120681. * Is this feature attached
  120682. */
  120683. get attached(): boolean;
  120684. /**
  120685. * attach this feature
  120686. *
  120687. * @param force should attachment be forced (even when already attached)
  120688. * @returns true if successful, false is failed or already attached
  120689. */
  120690. attach(force?: boolean): boolean;
  120691. /**
  120692. * detach this feature.
  120693. *
  120694. * @returns true if successful, false if failed or already detached
  120695. */
  120696. detach(): boolean;
  120697. /**
  120698. * Dispose this feature and all of the resources attached
  120699. */
  120700. dispose(): void;
  120701. /**
  120702. * This is used to register callbacks that will automatically be removed when detach is called.
  120703. * @param observable the observable to which the observer will be attached
  120704. * @param callback the callback to register
  120705. */
  120706. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120707. /**
  120708. * Code in this function will be executed on each xrFrame received from the browser.
  120709. * This function will not execute after the feature is detached.
  120710. * @param _xrFrame the current frame
  120711. */
  120712. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120713. }
  120714. }
  120715. declare module BABYLON {
  120716. /**
  120717. * Renders a layer on top of an existing scene
  120718. */
  120719. export class UtilityLayerRenderer implements IDisposable {
  120720. /** the original scene that will be rendered on top of */
  120721. originalScene: Scene;
  120722. private _pointerCaptures;
  120723. private _lastPointerEvents;
  120724. private static _DefaultUtilityLayer;
  120725. private static _DefaultKeepDepthUtilityLayer;
  120726. private _sharedGizmoLight;
  120727. private _renderCamera;
  120728. /**
  120729. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  120730. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  120731. * @returns the camera that is used when rendering the utility layer
  120732. */
  120733. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  120734. /**
  120735. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  120736. * @param cam the camera that should be used when rendering the utility layer
  120737. */
  120738. setRenderCamera(cam: Nullable<Camera>): void;
  120739. /**
  120740. * @hidden
  120741. * Light which used by gizmos to get light shading
  120742. */
  120743. _getSharedGizmoLight(): HemisphericLight;
  120744. /**
  120745. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  120746. */
  120747. pickUtilitySceneFirst: boolean;
  120748. /**
  120749. * 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)
  120750. */
  120751. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  120752. /**
  120753. * 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)
  120754. */
  120755. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  120756. /**
  120757. * The scene that is rendered on top of the original scene
  120758. */
  120759. utilityLayerScene: Scene;
  120760. /**
  120761. * If the utility layer should automatically be rendered on top of existing scene
  120762. */
  120763. shouldRender: boolean;
  120764. /**
  120765. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  120766. */
  120767. onlyCheckPointerDownEvents: boolean;
  120768. /**
  120769. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  120770. */
  120771. processAllEvents: boolean;
  120772. /**
  120773. * Observable raised when the pointer move from the utility layer scene to the main scene
  120774. */
  120775. onPointerOutObservable: Observable<number>;
  120776. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  120777. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  120778. private _afterRenderObserver;
  120779. private _sceneDisposeObserver;
  120780. private _originalPointerObserver;
  120781. /**
  120782. * Instantiates a UtilityLayerRenderer
  120783. * @param originalScene the original scene that will be rendered on top of
  120784. * @param handleEvents boolean indicating if the utility layer should handle events
  120785. */
  120786. constructor(
  120787. /** the original scene that will be rendered on top of */
  120788. originalScene: Scene, handleEvents?: boolean);
  120789. private _notifyObservers;
  120790. /**
  120791. * Renders the utility layers scene on top of the original scene
  120792. */
  120793. render(): void;
  120794. /**
  120795. * Disposes of the renderer
  120796. */
  120797. dispose(): void;
  120798. private _updateCamera;
  120799. }
  120800. }
  120801. declare module BABYLON {
  120802. /**
  120803. * Options interface for the pointer selection module
  120804. */
  120805. export interface IWebXRControllerPointerSelectionOptions {
  120806. /**
  120807. * if provided, this scene will be used to render meshes.
  120808. */
  120809. customUtilityLayerScene?: Scene;
  120810. /**
  120811. * 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)
  120812. * If not disabled, the last picked point will be used to execute a pointer up event
  120813. * If disabled, pointer up event will be triggered right after the pointer down event.
  120814. * Used in screen and gaze target ray mode only
  120815. */
  120816. disablePointerUpOnTouchOut: boolean;
  120817. /**
  120818. * For gaze mode (time to select instead of press)
  120819. */
  120820. forceGazeMode: boolean;
  120821. /**
  120822. * 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
  120823. * to start a new countdown to the pointer down event.
  120824. * Defaults to 1.
  120825. */
  120826. gazeModePointerMovedFactor?: number;
  120827. /**
  120828. * Different button type to use instead of the main component
  120829. */
  120830. overrideButtonId?: string;
  120831. /**
  120832. * use this rendering group id for the meshes (optional)
  120833. */
  120834. renderingGroupId?: number;
  120835. /**
  120836. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  120837. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  120838. * 3000 means 3 seconds between pointing at something and selecting it
  120839. */
  120840. timeToSelect?: number;
  120841. /**
  120842. * Should meshes created here be added to a utility layer or the main scene
  120843. */
  120844. useUtilityLayer?: boolean;
  120845. /**
  120846. * the xr input to use with this pointer selection
  120847. */
  120848. xrInput: WebXRInput;
  120849. }
  120850. /**
  120851. * A module that will enable pointer selection for motion controllers of XR Input Sources
  120852. */
  120853. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  120854. private readonly _options;
  120855. private static _idCounter;
  120856. private _attachController;
  120857. private _controllers;
  120858. private _scene;
  120859. private _tmpVectorForPickCompare;
  120860. /**
  120861. * The module's name
  120862. */
  120863. static readonly Name: string;
  120864. /**
  120865. * The (Babylon) version of this module.
  120866. * This is an integer representing the implementation version.
  120867. * This number does not correspond to the WebXR specs version
  120868. */
  120869. static readonly Version: number;
  120870. /**
  120871. * Disable lighting on the laser pointer (so it will always be visible)
  120872. */
  120873. disablePointerLighting: boolean;
  120874. /**
  120875. * Disable lighting on the selection mesh (so it will always be visible)
  120876. */
  120877. disableSelectionMeshLighting: boolean;
  120878. /**
  120879. * Should the laser pointer be displayed
  120880. */
  120881. displayLaserPointer: boolean;
  120882. /**
  120883. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  120884. */
  120885. displaySelectionMesh: boolean;
  120886. /**
  120887. * This color will be set to the laser pointer when selection is triggered
  120888. */
  120889. laserPointerPickedColor: Color3;
  120890. /**
  120891. * Default color of the laser pointer
  120892. */
  120893. lasterPointerDefaultColor: Color3;
  120894. /**
  120895. * default color of the selection ring
  120896. */
  120897. selectionMeshDefaultColor: Color3;
  120898. /**
  120899. * This color will be applied to the selection ring when selection is triggered
  120900. */
  120901. selectionMeshPickedColor: Color3;
  120902. /**
  120903. * Optional filter to be used for ray selection. This predicate shares behavior with
  120904. * scene.pointerMovePredicate which takes priority if it is also assigned.
  120905. */
  120906. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  120907. /**
  120908. * constructs a new background remover module
  120909. * @param _xrSessionManager the session manager for this module
  120910. * @param _options read-only options to be used in this module
  120911. */
  120912. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  120913. /**
  120914. * attach this feature
  120915. * Will usually be called by the features manager
  120916. *
  120917. * @returns true if successful.
  120918. */
  120919. attach(): boolean;
  120920. /**
  120921. * detach this feature.
  120922. * Will usually be called by the features manager
  120923. *
  120924. * @returns true if successful.
  120925. */
  120926. detach(): boolean;
  120927. /**
  120928. * Will get the mesh under a specific pointer.
  120929. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  120930. * @param controllerId the controllerId to check
  120931. * @returns The mesh under pointer or null if no mesh is under the pointer
  120932. */
  120933. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  120934. /**
  120935. * Get the xr controller that correlates to the pointer id in the pointer event
  120936. *
  120937. * @param id the pointer id to search for
  120938. * @returns the controller that correlates to this id or null if not found
  120939. */
  120940. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  120941. protected _onXRFrame(_xrFrame: XRFrame): void;
  120942. private _attachGazeMode;
  120943. private _attachScreenRayMode;
  120944. private _attachTrackedPointerRayMode;
  120945. private _convertNormalToDirectionOfRay;
  120946. private _detachController;
  120947. private _generateNewMeshPair;
  120948. private _pickingMoved;
  120949. private _updatePointerDistance;
  120950. }
  120951. }
  120952. declare module BABYLON {
  120953. /**
  120954. * Button which can be used to enter a different mode of XR
  120955. */
  120956. export class WebXREnterExitUIButton {
  120957. /** button element */
  120958. element: HTMLElement;
  120959. /** XR initialization options for the button */
  120960. sessionMode: XRSessionMode;
  120961. /** Reference space type */
  120962. referenceSpaceType: XRReferenceSpaceType;
  120963. /**
  120964. * Creates a WebXREnterExitUIButton
  120965. * @param element button element
  120966. * @param sessionMode XR initialization session mode
  120967. * @param referenceSpaceType the type of reference space to be used
  120968. */
  120969. constructor(
  120970. /** button element */
  120971. element: HTMLElement,
  120972. /** XR initialization options for the button */
  120973. sessionMode: XRSessionMode,
  120974. /** Reference space type */
  120975. referenceSpaceType: XRReferenceSpaceType);
  120976. /**
  120977. * Extendable function which can be used to update the button's visuals when the state changes
  120978. * @param activeButton the current active button in the UI
  120979. */
  120980. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  120981. }
  120982. /**
  120983. * Options to create the webXR UI
  120984. */
  120985. export class WebXREnterExitUIOptions {
  120986. /**
  120987. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  120988. */
  120989. customButtons?: Array<WebXREnterExitUIButton>;
  120990. /**
  120991. * A reference space type to use when creating the default button.
  120992. * Default is local-floor
  120993. */
  120994. referenceSpaceType?: XRReferenceSpaceType;
  120995. /**
  120996. * Context to enter xr with
  120997. */
  120998. renderTarget?: Nullable<WebXRRenderTarget>;
  120999. /**
  121000. * A session mode to use when creating the default button.
  121001. * Default is immersive-vr
  121002. */
  121003. sessionMode?: XRSessionMode;
  121004. }
  121005. /**
  121006. * UI to allow the user to enter/exit XR mode
  121007. */
  121008. export class WebXREnterExitUI implements IDisposable {
  121009. private scene;
  121010. /** version of the options passed to this UI */
  121011. options: WebXREnterExitUIOptions;
  121012. private _activeButton;
  121013. private _buttons;
  121014. private _overlay;
  121015. /**
  121016. * Fired every time the active button is changed.
  121017. *
  121018. * When xr is entered via a button that launches xr that button will be the callback parameter
  121019. *
  121020. * When exiting xr the callback parameter will be null)
  121021. */
  121022. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121023. /**
  121024. *
  121025. * @param scene babylon scene object to use
  121026. * @param options (read-only) version of the options passed to this UI
  121027. */
  121028. private constructor();
  121029. /**
  121030. * Creates UI to allow the user to enter/exit XR mode
  121031. * @param scene the scene to add the ui to
  121032. * @param helper the xr experience helper to enter/exit xr with
  121033. * @param options options to configure the UI
  121034. * @returns the created ui
  121035. */
  121036. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121037. /**
  121038. * Disposes of the XR UI component
  121039. */
  121040. dispose(): void;
  121041. private _updateButtons;
  121042. }
  121043. }
  121044. declare module BABYLON {
  121045. /**
  121046. * Class containing static functions to help procedurally build meshes
  121047. */
  121048. export class LinesBuilder {
  121049. /**
  121050. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121051. * * 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
  121052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121053. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121054. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121055. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121056. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121057. * * 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
  121058. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121061. * @param name defines the name of the new line system
  121062. * @param options defines the options used to create the line system
  121063. * @param scene defines the hosting scene
  121064. * @returns a new line system mesh
  121065. */
  121066. static CreateLineSystem(name: string, options: {
  121067. lines: Vector3[][];
  121068. updatable?: boolean;
  121069. instance?: Nullable<LinesMesh>;
  121070. colors?: Nullable<Color4[][]>;
  121071. useVertexAlpha?: boolean;
  121072. }, scene: Nullable<Scene>): LinesMesh;
  121073. /**
  121074. * Creates a line mesh
  121075. * 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
  121076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121077. * * The parameter `points` is an array successive Vector3
  121078. * * 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
  121079. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121081. * * When updating an instance, remember that only point positions can change, not the number of points
  121082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121084. * @param name defines the name of the new line system
  121085. * @param options defines the options used to create the line system
  121086. * @param scene defines the hosting scene
  121087. * @returns a new line mesh
  121088. */
  121089. static CreateLines(name: string, options: {
  121090. points: Vector3[];
  121091. updatable?: boolean;
  121092. instance?: Nullable<LinesMesh>;
  121093. colors?: Color4[];
  121094. useVertexAlpha?: boolean;
  121095. }, scene?: Nullable<Scene>): LinesMesh;
  121096. /**
  121097. * Creates a dashed line mesh
  121098. * * 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
  121099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121100. * * The parameter `points` is an array successive Vector3
  121101. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121102. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121103. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121104. * * 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
  121105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121106. * * When updating an instance, remember that only point positions can change, not the number of points
  121107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121108. * @param name defines the name of the mesh
  121109. * @param options defines the options used to create the mesh
  121110. * @param scene defines the hosting scene
  121111. * @returns the dashed line mesh
  121112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121113. */
  121114. static CreateDashedLines(name: string, options: {
  121115. points: Vector3[];
  121116. dashSize?: number;
  121117. gapSize?: number;
  121118. dashNb?: number;
  121119. updatable?: boolean;
  121120. instance?: LinesMesh;
  121121. useVertexAlpha?: boolean;
  121122. }, scene?: Nullable<Scene>): LinesMesh;
  121123. }
  121124. }
  121125. declare module BABYLON {
  121126. /**
  121127. * The options container for the teleportation module
  121128. */
  121129. export interface IWebXRTeleportationOptions {
  121130. /**
  121131. * if provided, this scene will be used to render meshes.
  121132. */
  121133. customUtilityLayerScene?: Scene;
  121134. /**
  121135. * Values to configure the default target mesh
  121136. */
  121137. defaultTargetMeshOptions?: {
  121138. /**
  121139. * Fill color of the teleportation area
  121140. */
  121141. teleportationFillColor?: string;
  121142. /**
  121143. * Border color for the teleportation area
  121144. */
  121145. teleportationBorderColor?: string;
  121146. /**
  121147. * Disable the mesh's animation sequence
  121148. */
  121149. disableAnimation?: boolean;
  121150. /**
  121151. * Disable lighting on the material or the ring and arrow
  121152. */
  121153. disableLighting?: boolean;
  121154. /**
  121155. * Override the default material of the torus and arrow
  121156. */
  121157. torusArrowMaterial?: Material;
  121158. };
  121159. /**
  121160. * A list of meshes to use as floor meshes.
  121161. * Meshes can be added and removed after initializing the feature using the
  121162. * addFloorMesh and removeFloorMesh functions
  121163. * If empty, rotation will still work
  121164. */
  121165. floorMeshes?: AbstractMesh[];
  121166. /**
  121167. * use this rendering group id for the meshes (optional)
  121168. */
  121169. renderingGroupId?: number;
  121170. /**
  121171. * Should teleportation move only to snap points
  121172. */
  121173. snapPointsOnly?: boolean;
  121174. /**
  121175. * An array of points to which the teleportation will snap to.
  121176. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121177. */
  121178. snapPositions?: Vector3[];
  121179. /**
  121180. * How close should the teleportation ray be in order to snap to position.
  121181. * Default to 0.8 units (meters)
  121182. */
  121183. snapToPositionRadius?: number;
  121184. /**
  121185. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121186. * If you want to support rotation, make sure your mesh has a direction indicator.
  121187. *
  121188. * When left untouched, the default mesh will be initialized.
  121189. */
  121190. teleportationTargetMesh?: AbstractMesh;
  121191. /**
  121192. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121193. */
  121194. timeToTeleport?: number;
  121195. /**
  121196. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121197. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121198. */
  121199. useMainComponentOnly?: boolean;
  121200. /**
  121201. * Should meshes created here be added to a utility layer or the main scene
  121202. */
  121203. useUtilityLayer?: boolean;
  121204. /**
  121205. * Babylon XR Input class for controller
  121206. */
  121207. xrInput: WebXRInput;
  121208. }
  121209. /**
  121210. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121211. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121212. * the input of the attached controllers.
  121213. */
  121214. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121215. private _options;
  121216. private _controllers;
  121217. private _currentTeleportationControllerId;
  121218. private _floorMeshes;
  121219. private _quadraticBezierCurve;
  121220. private _selectionFeature;
  121221. private _snapToPositions;
  121222. private _snappedToPoint;
  121223. private _teleportationRingMaterial?;
  121224. private _tmpRay;
  121225. private _tmpVector;
  121226. /**
  121227. * The module's name
  121228. */
  121229. static readonly Name: string;
  121230. /**
  121231. * The (Babylon) version of this module.
  121232. * This is an integer representing the implementation version.
  121233. * This number does not correspond to the webxr specs version
  121234. */
  121235. static readonly Version: number;
  121236. /**
  121237. * Is movement backwards enabled
  121238. */
  121239. backwardsMovementEnabled: boolean;
  121240. /**
  121241. * Distance to travel when moving backwards
  121242. */
  121243. backwardsTeleportationDistance: number;
  121244. /**
  121245. * The distance from the user to the inspection point in the direction of the controller
  121246. * A higher number will allow the user to move further
  121247. * defaults to 5 (meters, in xr units)
  121248. */
  121249. parabolicCheckRadius: number;
  121250. /**
  121251. * Should the module support parabolic ray on top of direct ray
  121252. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121253. * Very helpful when moving between floors / different heights
  121254. */
  121255. parabolicRayEnabled: boolean;
  121256. /**
  121257. * How much rotation should be applied when rotating right and left
  121258. */
  121259. rotationAngle: number;
  121260. /**
  121261. * Is rotation enabled when moving forward?
  121262. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121263. */
  121264. rotationEnabled: boolean;
  121265. /**
  121266. * constructs a new anchor system
  121267. * @param _xrSessionManager an instance of WebXRSessionManager
  121268. * @param _options configuration object for this feature
  121269. */
  121270. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121271. /**
  121272. * Get the snapPointsOnly flag
  121273. */
  121274. get snapPointsOnly(): boolean;
  121275. /**
  121276. * Sets the snapPointsOnly flag
  121277. * @param snapToPoints should teleportation be exclusively to snap points
  121278. */
  121279. set snapPointsOnly(snapToPoints: boolean);
  121280. /**
  121281. * Add a new mesh to the floor meshes array
  121282. * @param mesh the mesh to use as floor mesh
  121283. */
  121284. addFloorMesh(mesh: AbstractMesh): void;
  121285. /**
  121286. * Add a new snap-to point to fix teleportation to this position
  121287. * @param newSnapPoint The new Snap-To point
  121288. */
  121289. addSnapPoint(newSnapPoint: Vector3): void;
  121290. attach(): boolean;
  121291. detach(): boolean;
  121292. dispose(): void;
  121293. /**
  121294. * Remove a mesh from the floor meshes array
  121295. * @param mesh the mesh to remove
  121296. */
  121297. removeFloorMesh(mesh: AbstractMesh): void;
  121298. /**
  121299. * Remove a mesh from the floor meshes array using its name
  121300. * @param name the mesh name to remove
  121301. */
  121302. removeFloorMeshByName(name: string): void;
  121303. /**
  121304. * 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
  121305. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121306. * @returns was the point found and removed or not
  121307. */
  121308. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121309. /**
  121310. * This function sets a selection feature that will be disabled when
  121311. * the forward ray is shown and will be reattached when hidden.
  121312. * This is used to remove the selection rays when moving.
  121313. * @param selectionFeature the feature to disable when forward movement is enabled
  121314. */
  121315. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121316. protected _onXRFrame(_xrFrame: XRFrame): void;
  121317. private _attachController;
  121318. private _createDefaultTargetMesh;
  121319. private _detachController;
  121320. private _findClosestSnapPointWithRadius;
  121321. private _setTargetMeshPosition;
  121322. private _setTargetMeshVisibility;
  121323. private _showParabolicPath;
  121324. private _teleportForward;
  121325. }
  121326. }
  121327. declare module BABYLON {
  121328. /**
  121329. * Options for the default xr helper
  121330. */
  121331. export class WebXRDefaultExperienceOptions {
  121332. /**
  121333. * Enable or disable default UI to enter XR
  121334. */
  121335. disableDefaultUI?: boolean;
  121336. /**
  121337. * Should teleportation not initialize. defaults to false.
  121338. */
  121339. disableTeleportation?: boolean;
  121340. /**
  121341. * Floor meshes that will be used for teleport
  121342. */
  121343. floorMeshes?: Array<AbstractMesh>;
  121344. /**
  121345. * If set to true, the first frame will not be used to reset position
  121346. * The first frame is mainly used when copying transformation from the old camera
  121347. * Mainly used in AR
  121348. */
  121349. ignoreNativeCameraTransformation?: boolean;
  121350. /**
  121351. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121352. */
  121353. inputOptions?: IWebXRInputOptions;
  121354. /**
  121355. * optional configuration for the output canvas
  121356. */
  121357. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121358. /**
  121359. * optional UI options. This can be used among other to change session mode and reference space type
  121360. */
  121361. uiOptions?: WebXREnterExitUIOptions;
  121362. /**
  121363. * When loading teleportation and pointer select, use stable versions instead of latest.
  121364. */
  121365. useStablePlugins?: boolean;
  121366. /**
  121367. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121368. */
  121369. renderingGroupId?: number;
  121370. }
  121371. /**
  121372. * Default experience which provides a similar setup to the previous webVRExperience
  121373. */
  121374. export class WebXRDefaultExperience {
  121375. /**
  121376. * Base experience
  121377. */
  121378. baseExperience: WebXRExperienceHelper;
  121379. /**
  121380. * Enables ui for entering/exiting xr
  121381. */
  121382. enterExitUI: WebXREnterExitUI;
  121383. /**
  121384. * Input experience extension
  121385. */
  121386. input: WebXRInput;
  121387. /**
  121388. * Enables laser pointer and selection
  121389. */
  121390. pointerSelection: WebXRControllerPointerSelection;
  121391. /**
  121392. * Default target xr should render to
  121393. */
  121394. renderTarget: WebXRRenderTarget;
  121395. /**
  121396. * Enables teleportation
  121397. */
  121398. teleportation: WebXRMotionControllerTeleportation;
  121399. private constructor();
  121400. /**
  121401. * Creates the default xr experience
  121402. * @param scene scene
  121403. * @param options options for basic configuration
  121404. * @returns resulting WebXRDefaultExperience
  121405. */
  121406. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121407. /**
  121408. * DIsposes of the experience helper
  121409. */
  121410. dispose(): void;
  121411. }
  121412. }
  121413. declare module BABYLON {
  121414. /**
  121415. * Options to modify the vr teleportation behavior.
  121416. */
  121417. export interface VRTeleportationOptions {
  121418. /**
  121419. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121420. */
  121421. floorMeshName?: string;
  121422. /**
  121423. * A list of meshes to be used as the teleportation floor. (default: empty)
  121424. */
  121425. floorMeshes?: Mesh[];
  121426. /**
  121427. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121428. */
  121429. teleportationMode?: number;
  121430. /**
  121431. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121432. */
  121433. teleportationTime?: number;
  121434. /**
  121435. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121436. */
  121437. teleportationSpeed?: number;
  121438. /**
  121439. * The easing function used in the animation or null for Linear. (default CircleEase)
  121440. */
  121441. easingFunction?: EasingFunction;
  121442. }
  121443. /**
  121444. * Options to modify the vr experience helper's behavior.
  121445. */
  121446. export interface VRExperienceHelperOptions extends WebVROptions {
  121447. /**
  121448. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121449. */
  121450. createDeviceOrientationCamera?: boolean;
  121451. /**
  121452. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121453. */
  121454. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121455. /**
  121456. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121457. */
  121458. laserToggle?: boolean;
  121459. /**
  121460. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121461. */
  121462. floorMeshes?: Mesh[];
  121463. /**
  121464. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121465. */
  121466. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121467. /**
  121468. * Defines if WebXR should be used instead of WebVR (if available)
  121469. */
  121470. useXR?: boolean;
  121471. }
  121472. /**
  121473. * Event containing information after VR has been entered
  121474. */
  121475. export class OnAfterEnteringVRObservableEvent {
  121476. /**
  121477. * If entering vr was successful
  121478. */
  121479. success: boolean;
  121480. }
  121481. /**
  121482. * Helps to quickly add VR support to an existing scene.
  121483. * See http://doc.babylonjs.com/how_to/webvr_helper
  121484. */
  121485. export class VRExperienceHelper {
  121486. /** Options to modify the vr experience helper's behavior. */
  121487. webVROptions: VRExperienceHelperOptions;
  121488. private _scene;
  121489. private _position;
  121490. private _btnVR;
  121491. private _btnVRDisplayed;
  121492. private _webVRsupported;
  121493. private _webVRready;
  121494. private _webVRrequesting;
  121495. private _webVRpresenting;
  121496. private _hasEnteredVR;
  121497. private _fullscreenVRpresenting;
  121498. private _inputElement;
  121499. private _webVRCamera;
  121500. private _vrDeviceOrientationCamera;
  121501. private _deviceOrientationCamera;
  121502. private _existingCamera;
  121503. private _onKeyDown;
  121504. private _onVrDisplayPresentChange;
  121505. private _onVRDisplayChanged;
  121506. private _onVRRequestPresentStart;
  121507. private _onVRRequestPresentComplete;
  121508. /**
  121509. * 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)
  121510. */
  121511. enableGazeEvenWhenNoPointerLock: boolean;
  121512. /**
  121513. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121514. */
  121515. exitVROnDoubleTap: boolean;
  121516. /**
  121517. * Observable raised right before entering VR.
  121518. */
  121519. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121520. /**
  121521. * Observable raised when entering VR has completed.
  121522. */
  121523. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121524. /**
  121525. * Observable raised when exiting VR.
  121526. */
  121527. onExitingVRObservable: Observable<VRExperienceHelper>;
  121528. /**
  121529. * Observable raised when controller mesh is loaded.
  121530. */
  121531. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121532. /** Return this.onEnteringVRObservable
  121533. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121534. */
  121535. get onEnteringVR(): Observable<VRExperienceHelper>;
  121536. /** Return this.onExitingVRObservable
  121537. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121538. */
  121539. get onExitingVR(): Observable<VRExperienceHelper>;
  121540. /** Return this.onControllerMeshLoadedObservable
  121541. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121542. */
  121543. get onControllerMeshLoaded(): Observable<WebVRController>;
  121544. private _rayLength;
  121545. private _useCustomVRButton;
  121546. private _teleportationRequested;
  121547. private _teleportActive;
  121548. private _floorMeshName;
  121549. private _floorMeshesCollection;
  121550. private _teleportationMode;
  121551. private _teleportationTime;
  121552. private _teleportationSpeed;
  121553. private _teleportationEasing;
  121554. private _rotationAllowed;
  121555. private _teleportBackwardsVector;
  121556. private _teleportationTarget;
  121557. private _isDefaultTeleportationTarget;
  121558. private _postProcessMove;
  121559. private _teleportationFillColor;
  121560. private _teleportationBorderColor;
  121561. private _rotationAngle;
  121562. private _haloCenter;
  121563. private _cameraGazer;
  121564. private _padSensibilityUp;
  121565. private _padSensibilityDown;
  121566. private _leftController;
  121567. private _rightController;
  121568. private _gazeColor;
  121569. private _laserColor;
  121570. private _pickedLaserColor;
  121571. private _pickedGazeColor;
  121572. /**
  121573. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121574. */
  121575. onNewMeshSelected: Observable<AbstractMesh>;
  121576. /**
  121577. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121578. * This observable will provide the mesh and the controller used to select the mesh
  121579. */
  121580. onMeshSelectedWithController: Observable<{
  121581. mesh: AbstractMesh;
  121582. controller: WebVRController;
  121583. }>;
  121584. /**
  121585. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121586. */
  121587. onNewMeshPicked: Observable<PickingInfo>;
  121588. private _circleEase;
  121589. /**
  121590. * Observable raised before camera teleportation
  121591. */
  121592. onBeforeCameraTeleport: Observable<Vector3>;
  121593. /**
  121594. * Observable raised after camera teleportation
  121595. */
  121596. onAfterCameraTeleport: Observable<Vector3>;
  121597. /**
  121598. * Observable raised when current selected mesh gets unselected
  121599. */
  121600. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121601. private _raySelectionPredicate;
  121602. /**
  121603. * To be optionaly changed by user to define custom ray selection
  121604. */
  121605. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121606. /**
  121607. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121608. */
  121609. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121610. /**
  121611. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121612. */
  121613. teleportationEnabled: boolean;
  121614. private _defaultHeight;
  121615. private _teleportationInitialized;
  121616. private _interactionsEnabled;
  121617. private _interactionsRequested;
  121618. private _displayGaze;
  121619. private _displayLaserPointer;
  121620. /**
  121621. * The mesh used to display where the user is going to teleport.
  121622. */
  121623. get teleportationTarget(): Mesh;
  121624. /**
  121625. * Sets the mesh to be used to display where the user is going to teleport.
  121626. */
  121627. set teleportationTarget(value: Mesh);
  121628. /**
  121629. * 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
  121630. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121631. * See http://doc.babylonjs.com/resources/baking_transformations
  121632. */
  121633. get gazeTrackerMesh(): Mesh;
  121634. set gazeTrackerMesh(value: Mesh);
  121635. /**
  121636. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121637. */
  121638. updateGazeTrackerScale: boolean;
  121639. /**
  121640. * If the gaze trackers color should be updated when selecting meshes
  121641. */
  121642. updateGazeTrackerColor: boolean;
  121643. /**
  121644. * If the controller laser color should be updated when selecting meshes
  121645. */
  121646. updateControllerLaserColor: boolean;
  121647. /**
  121648. * The gaze tracking mesh corresponding to the left controller
  121649. */
  121650. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121651. /**
  121652. * The gaze tracking mesh corresponding to the right controller
  121653. */
  121654. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121655. /**
  121656. * If the ray of the gaze should be displayed.
  121657. */
  121658. get displayGaze(): boolean;
  121659. /**
  121660. * Sets if the ray of the gaze should be displayed.
  121661. */
  121662. set displayGaze(value: boolean);
  121663. /**
  121664. * If the ray of the LaserPointer should be displayed.
  121665. */
  121666. get displayLaserPointer(): boolean;
  121667. /**
  121668. * Sets if the ray of the LaserPointer should be displayed.
  121669. */
  121670. set displayLaserPointer(value: boolean);
  121671. /**
  121672. * The deviceOrientationCamera used as the camera when not in VR.
  121673. */
  121674. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121675. /**
  121676. * Based on the current WebVR support, returns the current VR camera used.
  121677. */
  121678. get currentVRCamera(): Nullable<Camera>;
  121679. /**
  121680. * The webVRCamera which is used when in VR.
  121681. */
  121682. get webVRCamera(): WebVRFreeCamera;
  121683. /**
  121684. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121685. */
  121686. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121687. /**
  121688. * The html button that is used to trigger entering into VR.
  121689. */
  121690. get vrButton(): Nullable<HTMLButtonElement>;
  121691. private get _teleportationRequestInitiated();
  121692. /**
  121693. * Defines whether or not Pointer lock should be requested when switching to
  121694. * full screen.
  121695. */
  121696. requestPointerLockOnFullScreen: boolean;
  121697. /**
  121698. * If asking to force XR, this will be populated with the default xr experience
  121699. */
  121700. xr: WebXRDefaultExperience;
  121701. /**
  121702. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121703. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121704. */
  121705. xrTestDone: boolean;
  121706. /**
  121707. * Instantiates a VRExperienceHelper.
  121708. * Helps to quickly add VR support to an existing scene.
  121709. * @param scene The scene the VRExperienceHelper belongs to.
  121710. * @param webVROptions Options to modify the vr experience helper's behavior.
  121711. */
  121712. constructor(scene: Scene,
  121713. /** Options to modify the vr experience helper's behavior. */
  121714. webVROptions?: VRExperienceHelperOptions);
  121715. private completeVRInit;
  121716. private _onDefaultMeshLoaded;
  121717. private _onResize;
  121718. private _onFullscreenChange;
  121719. /**
  121720. * Gets a value indicating if we are currently in VR mode.
  121721. */
  121722. get isInVRMode(): boolean;
  121723. private onVrDisplayPresentChange;
  121724. private onVRDisplayChanged;
  121725. private moveButtonToBottomRight;
  121726. private displayVRButton;
  121727. private updateButtonVisibility;
  121728. private _cachedAngularSensibility;
  121729. /**
  121730. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  121731. * Otherwise, will use the fullscreen API.
  121732. */
  121733. enterVR(): void;
  121734. /**
  121735. * Attempt to exit VR, or fullscreen.
  121736. */
  121737. exitVR(): void;
  121738. /**
  121739. * The position of the vr experience helper.
  121740. */
  121741. get position(): Vector3;
  121742. /**
  121743. * Sets the position of the vr experience helper.
  121744. */
  121745. set position(value: Vector3);
  121746. /**
  121747. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  121748. */
  121749. enableInteractions(): void;
  121750. private get _noControllerIsActive();
  121751. private beforeRender;
  121752. private _isTeleportationFloor;
  121753. /**
  121754. * Adds a floor mesh to be used for teleportation.
  121755. * @param floorMesh the mesh to be used for teleportation.
  121756. */
  121757. addFloorMesh(floorMesh: Mesh): void;
  121758. /**
  121759. * Removes a floor mesh from being used for teleportation.
  121760. * @param floorMesh the mesh to be removed.
  121761. */
  121762. removeFloorMesh(floorMesh: Mesh): void;
  121763. /**
  121764. * Enables interactions and teleportation using the VR controllers and gaze.
  121765. * @param vrTeleportationOptions options to modify teleportation behavior.
  121766. */
  121767. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  121768. private _onNewGamepadConnected;
  121769. private _tryEnableInteractionOnController;
  121770. private _onNewGamepadDisconnected;
  121771. private _enableInteractionOnController;
  121772. private _checkTeleportWithRay;
  121773. private _checkRotate;
  121774. private _checkTeleportBackwards;
  121775. private _enableTeleportationOnController;
  121776. private _createTeleportationCircles;
  121777. private _displayTeleportationTarget;
  121778. private _hideTeleportationTarget;
  121779. private _rotateCamera;
  121780. private _moveTeleportationSelectorTo;
  121781. private _workingVector;
  121782. private _workingQuaternion;
  121783. private _workingMatrix;
  121784. /**
  121785. * Time Constant Teleportation Mode
  121786. */
  121787. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  121788. /**
  121789. * Speed Constant Teleportation Mode
  121790. */
  121791. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  121792. /**
  121793. * Teleports the users feet to the desired location
  121794. * @param location The location where the user's feet should be placed
  121795. */
  121796. teleportCamera(location: Vector3): void;
  121797. private _convertNormalToDirectionOfRay;
  121798. private _castRayAndSelectObject;
  121799. private _notifySelectedMeshUnselected;
  121800. /**
  121801. * Permanently set new colors for the laser pointer
  121802. * @param color the new laser color
  121803. * @param pickedColor the new laser color when picked mesh detected
  121804. */
  121805. setLaserColor(color: Color3, pickedColor?: Color3): void;
  121806. /**
  121807. * Set lighting enabled / disabled on the laser pointer of both controllers
  121808. * @param enabled should the lighting be enabled on the laser pointer
  121809. */
  121810. setLaserLightingState(enabled?: boolean): void;
  121811. /**
  121812. * Permanently set new colors for the gaze pointer
  121813. * @param color the new gaze color
  121814. * @param pickedColor the new gaze color when picked mesh detected
  121815. */
  121816. setGazeColor(color: Color3, pickedColor?: Color3): void;
  121817. /**
  121818. * Sets the color of the laser ray from the vr controllers.
  121819. * @param color new color for the ray.
  121820. */
  121821. changeLaserColor(color: Color3): void;
  121822. /**
  121823. * Sets the color of the ray from the vr headsets gaze.
  121824. * @param color new color for the ray.
  121825. */
  121826. changeGazeColor(color: Color3): void;
  121827. /**
  121828. * Exits VR and disposes of the vr experience helper
  121829. */
  121830. dispose(): void;
  121831. /**
  121832. * Gets the name of the VRExperienceHelper class
  121833. * @returns "VRExperienceHelper"
  121834. */
  121835. getClassName(): string;
  121836. }
  121837. }
  121838. declare module BABYLON {
  121839. /**
  121840. * Contains an array of blocks representing the octree
  121841. */
  121842. export interface IOctreeContainer<T> {
  121843. /**
  121844. * Blocks within the octree
  121845. */
  121846. blocks: Array<OctreeBlock<T>>;
  121847. }
  121848. /**
  121849. * Class used to store a cell in an octree
  121850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121851. */
  121852. export class OctreeBlock<T> {
  121853. /**
  121854. * Gets the content of the current block
  121855. */
  121856. entries: T[];
  121857. /**
  121858. * Gets the list of block children
  121859. */
  121860. blocks: Array<OctreeBlock<T>>;
  121861. private _depth;
  121862. private _maxDepth;
  121863. private _capacity;
  121864. private _minPoint;
  121865. private _maxPoint;
  121866. private _boundingVectors;
  121867. private _creationFunc;
  121868. /**
  121869. * Creates a new block
  121870. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  121871. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  121872. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121873. * @param depth defines the current depth of this block in the octree
  121874. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  121875. * @param creationFunc defines a callback to call when an element is added to the block
  121876. */
  121877. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  121878. /**
  121879. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121880. */
  121881. get capacity(): number;
  121882. /**
  121883. * Gets the minimum vector (in world space) of the block's bounding box
  121884. */
  121885. get minPoint(): Vector3;
  121886. /**
  121887. * Gets the maximum vector (in world space) of the block's bounding box
  121888. */
  121889. get maxPoint(): Vector3;
  121890. /**
  121891. * Add a new element to this block
  121892. * @param entry defines the element to add
  121893. */
  121894. addEntry(entry: T): void;
  121895. /**
  121896. * Remove an element from this block
  121897. * @param entry defines the element to remove
  121898. */
  121899. removeEntry(entry: T): void;
  121900. /**
  121901. * Add an array of elements to this block
  121902. * @param entries defines the array of elements to add
  121903. */
  121904. addEntries(entries: T[]): void;
  121905. /**
  121906. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  121907. * @param frustumPlanes defines the frustum planes to test
  121908. * @param selection defines the array to store current content if selection is positive
  121909. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121910. */
  121911. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121912. /**
  121913. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  121914. * @param sphereCenter defines the bounding sphere center
  121915. * @param sphereRadius defines the bounding sphere radius
  121916. * @param selection defines the array to store current content if selection is positive
  121917. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121918. */
  121919. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121920. /**
  121921. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  121922. * @param ray defines the ray to test with
  121923. * @param selection defines the array to store current content if selection is positive
  121924. */
  121925. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  121926. /**
  121927. * Subdivide the content into child blocks (this block will then be empty)
  121928. */
  121929. createInnerBlocks(): void;
  121930. /**
  121931. * @hidden
  121932. */
  121933. 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;
  121934. }
  121935. }
  121936. declare module BABYLON {
  121937. /**
  121938. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  121939. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121940. */
  121941. export class Octree<T> {
  121942. /** 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.) */
  121943. maxDepth: number;
  121944. /**
  121945. * Blocks within the octree containing objects
  121946. */
  121947. blocks: Array<OctreeBlock<T>>;
  121948. /**
  121949. * Content stored in the octree
  121950. */
  121951. dynamicContent: T[];
  121952. private _maxBlockCapacity;
  121953. private _selectionContent;
  121954. private _creationFunc;
  121955. /**
  121956. * Creates a octree
  121957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121958. * @param creationFunc function to be used to instatiate the octree
  121959. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  121960. * @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.)
  121961. */
  121962. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  121963. /** 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.) */
  121964. maxDepth?: number);
  121965. /**
  121966. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  121967. * @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);
  121968. * @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);
  121969. * @param entries meshes to be added to the octree blocks
  121970. */
  121971. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  121972. /**
  121973. * Adds a mesh to the octree
  121974. * @param entry Mesh to add to the octree
  121975. */
  121976. addMesh(entry: T): void;
  121977. /**
  121978. * Remove an element from the octree
  121979. * @param entry defines the element to remove
  121980. */
  121981. removeMesh(entry: T): void;
  121982. /**
  121983. * Selects an array of meshes within the frustum
  121984. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  121985. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  121986. * @returns array of meshes within the frustum
  121987. */
  121988. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  121989. /**
  121990. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  121991. * @param sphereCenter defines the bounding sphere center
  121992. * @param sphereRadius defines the bounding sphere radius
  121993. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121994. * @returns an array of objects that intersect the sphere
  121995. */
  121996. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  121997. /**
  121998. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  121999. * @param ray defines the ray to test with
  122000. * @returns array of intersected objects
  122001. */
  122002. intersectsRay(ray: Ray): SmartArray<T>;
  122003. /**
  122004. * Adds a mesh into the octree block if it intersects the block
  122005. */
  122006. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  122007. /**
  122008. * Adds a submesh into the octree block if it intersects the block
  122009. */
  122010. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. interface Scene {
  122015. /**
  122016. * @hidden
  122017. * Backing Filed
  122018. */
  122019. _selectionOctree: Octree<AbstractMesh>;
  122020. /**
  122021. * Gets the octree used to boost mesh selection (picking)
  122022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122023. */
  122024. selectionOctree: Octree<AbstractMesh>;
  122025. /**
  122026. * Creates or updates the octree used to boost selection (picking)
  122027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122028. * @param maxCapacity defines the maximum capacity per leaf
  122029. * @param maxDepth defines the maximum depth of the octree
  122030. * @returns an octree of AbstractMesh
  122031. */
  122032. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122033. }
  122034. interface AbstractMesh {
  122035. /**
  122036. * @hidden
  122037. * Backing Field
  122038. */
  122039. _submeshesOctree: Octree<SubMesh>;
  122040. /**
  122041. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122042. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122043. * @param maxCapacity defines the maximum size of each block (64 by default)
  122044. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122045. * @returns the new octree
  122046. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122048. */
  122049. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122050. }
  122051. /**
  122052. * Defines the octree scene component responsible to manage any octrees
  122053. * in a given scene.
  122054. */
  122055. export class OctreeSceneComponent {
  122056. /**
  122057. * The component name help to identify the component in the list of scene components.
  122058. */
  122059. readonly name: string;
  122060. /**
  122061. * The scene the component belongs to.
  122062. */
  122063. scene: Scene;
  122064. /**
  122065. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122066. */
  122067. readonly checksIsEnabled: boolean;
  122068. /**
  122069. * Creates a new instance of the component for the given scene
  122070. * @param scene Defines the scene to register the component in
  122071. */
  122072. constructor(scene: Scene);
  122073. /**
  122074. * Registers the component in a given scene
  122075. */
  122076. register(): void;
  122077. /**
  122078. * Return the list of active meshes
  122079. * @returns the list of active meshes
  122080. */
  122081. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122082. /**
  122083. * Return the list of active sub meshes
  122084. * @param mesh The mesh to get the candidates sub meshes from
  122085. * @returns the list of active sub meshes
  122086. */
  122087. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122088. private _tempRay;
  122089. /**
  122090. * Return the list of sub meshes intersecting with a given local ray
  122091. * @param mesh defines the mesh to find the submesh for
  122092. * @param localRay defines the ray in local space
  122093. * @returns the list of intersecting sub meshes
  122094. */
  122095. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122096. /**
  122097. * Return the list of sub meshes colliding with a collider
  122098. * @param mesh defines the mesh to find the submesh for
  122099. * @param collider defines the collider to evaluate the collision against
  122100. * @returns the list of colliding sub meshes
  122101. */
  122102. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122103. /**
  122104. * Rebuilds the elements related to this component in case of
  122105. * context lost for instance.
  122106. */
  122107. rebuild(): void;
  122108. /**
  122109. * Disposes the component and the associated ressources.
  122110. */
  122111. dispose(): void;
  122112. }
  122113. }
  122114. declare module BABYLON {
  122115. /**
  122116. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122117. */
  122118. export class Gizmo implements IDisposable {
  122119. /** The utility layer the gizmo will be added to */
  122120. gizmoLayer: UtilityLayerRenderer;
  122121. /**
  122122. * The root mesh of the gizmo
  122123. */
  122124. _rootMesh: Mesh;
  122125. private _attachedMesh;
  122126. /**
  122127. * Ratio for the scale of the gizmo (Default: 1)
  122128. */
  122129. scaleRatio: number;
  122130. /**
  122131. * If a custom mesh has been set (Default: false)
  122132. */
  122133. protected _customMeshSet: boolean;
  122134. /**
  122135. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122136. * * When set, interactions will be enabled
  122137. */
  122138. get attachedMesh(): Nullable<AbstractMesh>;
  122139. set attachedMesh(value: Nullable<AbstractMesh>);
  122140. /**
  122141. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122142. * @param mesh The mesh to replace the default mesh of the gizmo
  122143. */
  122144. setCustomMesh(mesh: Mesh): void;
  122145. /**
  122146. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122147. */
  122148. updateGizmoRotationToMatchAttachedMesh: boolean;
  122149. /**
  122150. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122151. */
  122152. updateGizmoPositionToMatchAttachedMesh: boolean;
  122153. /**
  122154. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122155. */
  122156. updateScale: boolean;
  122157. protected _interactionsEnabled: boolean;
  122158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122159. private _beforeRenderObserver;
  122160. private _tempVector;
  122161. /**
  122162. * Creates a gizmo
  122163. * @param gizmoLayer The utility layer the gizmo will be added to
  122164. */
  122165. constructor(
  122166. /** The utility layer the gizmo will be added to */
  122167. gizmoLayer?: UtilityLayerRenderer);
  122168. /**
  122169. * Updates the gizmo to match the attached mesh's position/rotation
  122170. */
  122171. protected _update(): void;
  122172. /**
  122173. * Disposes of the gizmo
  122174. */
  122175. dispose(): void;
  122176. }
  122177. }
  122178. declare module BABYLON {
  122179. /**
  122180. * Single plane drag gizmo
  122181. */
  122182. export class PlaneDragGizmo extends Gizmo {
  122183. /**
  122184. * Drag behavior responsible for the gizmos dragging interactions
  122185. */
  122186. dragBehavior: PointerDragBehavior;
  122187. private _pointerObserver;
  122188. /**
  122189. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122190. */
  122191. snapDistance: number;
  122192. /**
  122193. * Event that fires each time the gizmo snaps to a new location.
  122194. * * snapDistance is the the change in distance
  122195. */
  122196. onSnapObservable: Observable<{
  122197. snapDistance: number;
  122198. }>;
  122199. private _plane;
  122200. private _coloredMaterial;
  122201. private _hoverMaterial;
  122202. private _isEnabled;
  122203. private _parent;
  122204. /** @hidden */
  122205. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122206. /** @hidden */
  122207. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122208. /**
  122209. * Creates a PlaneDragGizmo
  122210. * @param gizmoLayer The utility layer the gizmo will be added to
  122211. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122212. * @param color The color of the gizmo
  122213. */
  122214. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122215. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122216. /**
  122217. * If the gizmo is enabled
  122218. */
  122219. set isEnabled(value: boolean);
  122220. get isEnabled(): boolean;
  122221. /**
  122222. * Disposes of the gizmo
  122223. */
  122224. dispose(): void;
  122225. }
  122226. }
  122227. declare module BABYLON {
  122228. /**
  122229. * Gizmo that enables dragging a mesh along 3 axis
  122230. */
  122231. export class PositionGizmo extends Gizmo {
  122232. /**
  122233. * Internal gizmo used for interactions on the x axis
  122234. */
  122235. xGizmo: AxisDragGizmo;
  122236. /**
  122237. * Internal gizmo used for interactions on the y axis
  122238. */
  122239. yGizmo: AxisDragGizmo;
  122240. /**
  122241. * Internal gizmo used for interactions on the z axis
  122242. */
  122243. zGizmo: AxisDragGizmo;
  122244. /**
  122245. * Internal gizmo used for interactions on the yz plane
  122246. */
  122247. xPlaneGizmo: PlaneDragGizmo;
  122248. /**
  122249. * Internal gizmo used for interactions on the xz plane
  122250. */
  122251. yPlaneGizmo: PlaneDragGizmo;
  122252. /**
  122253. * Internal gizmo used for interactions on the xy plane
  122254. */
  122255. zPlaneGizmo: PlaneDragGizmo;
  122256. /**
  122257. * private variables
  122258. */
  122259. private _meshAttached;
  122260. private _updateGizmoRotationToMatchAttachedMesh;
  122261. private _snapDistance;
  122262. private _scaleRatio;
  122263. /** Fires an event when any of it's sub gizmos are dragged */
  122264. onDragStartObservable: Observable<unknown>;
  122265. /** Fires an event when any of it's sub gizmos are released from dragging */
  122266. onDragEndObservable: Observable<unknown>;
  122267. /**
  122268. * If set to true, planar drag is enabled
  122269. */
  122270. private _planarGizmoEnabled;
  122271. get attachedMesh(): Nullable<AbstractMesh>;
  122272. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122273. /**
  122274. * Creates a PositionGizmo
  122275. * @param gizmoLayer The utility layer the gizmo will be added to
  122276. */
  122277. constructor(gizmoLayer?: UtilityLayerRenderer);
  122278. /**
  122279. * If the planar drag gizmo is enabled
  122280. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122281. */
  122282. set planarGizmoEnabled(value: boolean);
  122283. get planarGizmoEnabled(): boolean;
  122284. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122285. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122286. /**
  122287. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122288. */
  122289. set snapDistance(value: number);
  122290. get snapDistance(): number;
  122291. /**
  122292. * Ratio for the scale of the gizmo (Default: 1)
  122293. */
  122294. set scaleRatio(value: number);
  122295. get scaleRatio(): number;
  122296. /**
  122297. * Disposes of the gizmo
  122298. */
  122299. dispose(): void;
  122300. /**
  122301. * CustomMeshes are not supported by this gizmo
  122302. * @param mesh The mesh to replace the default mesh of the gizmo
  122303. */
  122304. setCustomMesh(mesh: Mesh): void;
  122305. }
  122306. }
  122307. declare module BABYLON {
  122308. /**
  122309. * Single axis drag gizmo
  122310. */
  122311. export class AxisDragGizmo extends Gizmo {
  122312. /**
  122313. * Drag behavior responsible for the gizmos dragging interactions
  122314. */
  122315. dragBehavior: PointerDragBehavior;
  122316. private _pointerObserver;
  122317. /**
  122318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122319. */
  122320. snapDistance: number;
  122321. /**
  122322. * Event that fires each time the gizmo snaps to a new location.
  122323. * * snapDistance is the the change in distance
  122324. */
  122325. onSnapObservable: Observable<{
  122326. snapDistance: number;
  122327. }>;
  122328. private _isEnabled;
  122329. private _parent;
  122330. private _arrow;
  122331. private _coloredMaterial;
  122332. private _hoverMaterial;
  122333. /** @hidden */
  122334. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122335. /** @hidden */
  122336. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122337. /**
  122338. * Creates an AxisDragGizmo
  122339. * @param gizmoLayer The utility layer the gizmo will be added to
  122340. * @param dragAxis The axis which the gizmo will be able to drag on
  122341. * @param color The color of the gizmo
  122342. */
  122343. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122344. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122345. /**
  122346. * If the gizmo is enabled
  122347. */
  122348. set isEnabled(value: boolean);
  122349. get isEnabled(): boolean;
  122350. /**
  122351. * Disposes of the gizmo
  122352. */
  122353. dispose(): void;
  122354. }
  122355. }
  122356. declare module BABYLON.Debug {
  122357. /**
  122358. * The Axes viewer will show 3 axes in a specific point in space
  122359. */
  122360. export class AxesViewer {
  122361. private _xAxis;
  122362. private _yAxis;
  122363. private _zAxis;
  122364. private _scaleLinesFactor;
  122365. private _instanced;
  122366. /**
  122367. * Gets the hosting scene
  122368. */
  122369. scene: Scene;
  122370. /**
  122371. * Gets or sets a number used to scale line length
  122372. */
  122373. scaleLines: number;
  122374. /** Gets the node hierarchy used to render x-axis */
  122375. get xAxis(): TransformNode;
  122376. /** Gets the node hierarchy used to render y-axis */
  122377. get yAxis(): TransformNode;
  122378. /** Gets the node hierarchy used to render z-axis */
  122379. get zAxis(): TransformNode;
  122380. /**
  122381. * Creates a new AxesViewer
  122382. * @param scene defines the hosting scene
  122383. * @param scaleLines defines a number used to scale line length (1 by default)
  122384. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122385. * @param xAxis defines the node hierarchy used to render the x-axis
  122386. * @param yAxis defines the node hierarchy used to render the y-axis
  122387. * @param zAxis defines the node hierarchy used to render the z-axis
  122388. */
  122389. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122390. /**
  122391. * Force the viewer to update
  122392. * @param position defines the position of the viewer
  122393. * @param xaxis defines the x axis of the viewer
  122394. * @param yaxis defines the y axis of the viewer
  122395. * @param zaxis defines the z axis of the viewer
  122396. */
  122397. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122398. /**
  122399. * Creates an instance of this axes viewer.
  122400. * @returns a new axes viewer with instanced meshes
  122401. */
  122402. createInstance(): AxesViewer;
  122403. /** Releases resources */
  122404. dispose(): void;
  122405. private static _SetRenderingGroupId;
  122406. }
  122407. }
  122408. declare module BABYLON.Debug {
  122409. /**
  122410. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122411. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122412. */
  122413. export class BoneAxesViewer extends AxesViewer {
  122414. /**
  122415. * Gets or sets the target mesh where to display the axes viewer
  122416. */
  122417. mesh: Nullable<Mesh>;
  122418. /**
  122419. * Gets or sets the target bone where to display the axes viewer
  122420. */
  122421. bone: Nullable<Bone>;
  122422. /** Gets current position */
  122423. pos: Vector3;
  122424. /** Gets direction of X axis */
  122425. xaxis: Vector3;
  122426. /** Gets direction of Y axis */
  122427. yaxis: Vector3;
  122428. /** Gets direction of Z axis */
  122429. zaxis: Vector3;
  122430. /**
  122431. * Creates a new BoneAxesViewer
  122432. * @param scene defines the hosting scene
  122433. * @param bone defines the target bone
  122434. * @param mesh defines the target mesh
  122435. * @param scaleLines defines a scaling factor for line length (1 by default)
  122436. */
  122437. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122438. /**
  122439. * Force the viewer to update
  122440. */
  122441. update(): void;
  122442. /** Releases resources */
  122443. dispose(): void;
  122444. }
  122445. }
  122446. declare module BABYLON {
  122447. /**
  122448. * Interface used to define scene explorer extensibility option
  122449. */
  122450. export interface IExplorerExtensibilityOption {
  122451. /**
  122452. * Define the option label
  122453. */
  122454. label: string;
  122455. /**
  122456. * Defines the action to execute on click
  122457. */
  122458. action: (entity: any) => void;
  122459. }
  122460. /**
  122461. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122462. */
  122463. export interface IExplorerExtensibilityGroup {
  122464. /**
  122465. * Defines a predicate to test if a given type mut be extended
  122466. */
  122467. predicate: (entity: any) => boolean;
  122468. /**
  122469. * Gets the list of options added to a type
  122470. */
  122471. entries: IExplorerExtensibilityOption[];
  122472. }
  122473. /**
  122474. * Interface used to define the options to use to create the Inspector
  122475. */
  122476. export interface IInspectorOptions {
  122477. /**
  122478. * Display in overlay mode (default: false)
  122479. */
  122480. overlay?: boolean;
  122481. /**
  122482. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122483. */
  122484. globalRoot?: HTMLElement;
  122485. /**
  122486. * Display the Scene explorer
  122487. */
  122488. showExplorer?: boolean;
  122489. /**
  122490. * Display the property inspector
  122491. */
  122492. showInspector?: boolean;
  122493. /**
  122494. * Display in embed mode (both panes on the right)
  122495. */
  122496. embedMode?: boolean;
  122497. /**
  122498. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122499. */
  122500. handleResize?: boolean;
  122501. /**
  122502. * Allow the panes to popup (default: true)
  122503. */
  122504. enablePopup?: boolean;
  122505. /**
  122506. * Allow the panes to be closed by users (default: true)
  122507. */
  122508. enableClose?: boolean;
  122509. /**
  122510. * Optional list of extensibility entries
  122511. */
  122512. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122513. /**
  122514. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122515. */
  122516. inspectorURL?: string;
  122517. /**
  122518. * Optional initial tab (default to DebugLayerTab.Properties)
  122519. */
  122520. initialTab?: DebugLayerTab;
  122521. }
  122522. interface Scene {
  122523. /**
  122524. * @hidden
  122525. * Backing field
  122526. */
  122527. _debugLayer: DebugLayer;
  122528. /**
  122529. * Gets the debug layer (aka Inspector) associated with the scene
  122530. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122531. */
  122532. debugLayer: DebugLayer;
  122533. }
  122534. /**
  122535. * Enum of inspector action tab
  122536. */
  122537. export enum DebugLayerTab {
  122538. /**
  122539. * Properties tag (default)
  122540. */
  122541. Properties = 0,
  122542. /**
  122543. * Debug tab
  122544. */
  122545. Debug = 1,
  122546. /**
  122547. * Statistics tab
  122548. */
  122549. Statistics = 2,
  122550. /**
  122551. * Tools tab
  122552. */
  122553. Tools = 3,
  122554. /**
  122555. * Settings tab
  122556. */
  122557. Settings = 4
  122558. }
  122559. /**
  122560. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122561. * what is happening in your scene
  122562. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122563. */
  122564. export class DebugLayer {
  122565. /**
  122566. * Define the url to get the inspector script from.
  122567. * By default it uses the babylonjs CDN.
  122568. * @ignoreNaming
  122569. */
  122570. static InspectorURL: string;
  122571. private _scene;
  122572. private BJSINSPECTOR;
  122573. private _onPropertyChangedObservable?;
  122574. /**
  122575. * Observable triggered when a property is changed through the inspector.
  122576. */
  122577. get onPropertyChangedObservable(): any;
  122578. /**
  122579. * Instantiates a new debug layer.
  122580. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122581. * what is happening in your scene
  122582. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122583. * @param scene Defines the scene to inspect
  122584. */
  122585. constructor(scene: Scene);
  122586. /** Creates the inspector window. */
  122587. private _createInspector;
  122588. /**
  122589. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122590. * @param entity defines the entity to select
  122591. * @param lineContainerTitle defines the specific block to highlight
  122592. */
  122593. select(entity: any, lineContainerTitle?: string): void;
  122594. /** Get the inspector from bundle or global */
  122595. private _getGlobalInspector;
  122596. /**
  122597. * Get if the inspector is visible or not.
  122598. * @returns true if visible otherwise, false
  122599. */
  122600. isVisible(): boolean;
  122601. /**
  122602. * Hide the inspector and close its window.
  122603. */
  122604. hide(): void;
  122605. /**
  122606. * Launch the debugLayer.
  122607. * @param config Define the configuration of the inspector
  122608. * @return a promise fulfilled when the debug layer is visible
  122609. */
  122610. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122611. }
  122612. }
  122613. declare module BABYLON {
  122614. /**
  122615. * Class containing static functions to help procedurally build meshes
  122616. */
  122617. export class BoxBuilder {
  122618. /**
  122619. * Creates a box mesh
  122620. * * The parameter `size` sets the size (float) of each box side (default 1)
  122621. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122622. * * 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)
  122623. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122627. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122628. * @param name defines the name of the mesh
  122629. * @param options defines the options used to create the mesh
  122630. * @param scene defines the hosting scene
  122631. * @returns the box mesh
  122632. */
  122633. static CreateBox(name: string, options: {
  122634. size?: number;
  122635. width?: number;
  122636. height?: number;
  122637. depth?: number;
  122638. faceUV?: Vector4[];
  122639. faceColors?: Color4[];
  122640. sideOrientation?: number;
  122641. frontUVs?: Vector4;
  122642. backUVs?: Vector4;
  122643. wrap?: boolean;
  122644. topBaseAt?: number;
  122645. bottomBaseAt?: number;
  122646. updatable?: boolean;
  122647. }, scene?: Nullable<Scene>): Mesh;
  122648. }
  122649. }
  122650. declare module BABYLON.Debug {
  122651. /**
  122652. * Used to show the physics impostor around the specific mesh
  122653. */
  122654. export class PhysicsViewer {
  122655. /** @hidden */
  122656. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122657. /** @hidden */
  122658. protected _meshes: Array<Nullable<AbstractMesh>>;
  122659. /** @hidden */
  122660. protected _scene: Nullable<Scene>;
  122661. /** @hidden */
  122662. protected _numMeshes: number;
  122663. /** @hidden */
  122664. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122665. private _renderFunction;
  122666. private _utilityLayer;
  122667. private _debugBoxMesh;
  122668. private _debugSphereMesh;
  122669. private _debugCylinderMesh;
  122670. private _debugMaterial;
  122671. private _debugMeshMeshes;
  122672. /**
  122673. * Creates a new PhysicsViewer
  122674. * @param scene defines the hosting scene
  122675. */
  122676. constructor(scene: Scene);
  122677. /** @hidden */
  122678. protected _updateDebugMeshes(): void;
  122679. /**
  122680. * Renders a specified physic impostor
  122681. * @param impostor defines the impostor to render
  122682. * @param targetMesh defines the mesh represented by the impostor
  122683. * @returns the new debug mesh used to render the impostor
  122684. */
  122685. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122686. /**
  122687. * Hides a specified physic impostor
  122688. * @param impostor defines the impostor to hide
  122689. */
  122690. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122691. private _getDebugMaterial;
  122692. private _getDebugBoxMesh;
  122693. private _getDebugSphereMesh;
  122694. private _getDebugCylinderMesh;
  122695. private _getDebugMeshMesh;
  122696. private _getDebugMesh;
  122697. /** Releases all resources */
  122698. dispose(): void;
  122699. }
  122700. }
  122701. declare module BABYLON {
  122702. /**
  122703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122704. * in order to better appreciate the issue one might have.
  122705. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122706. */
  122707. export class RayHelper {
  122708. /**
  122709. * Defines the ray we are currently tryin to visualize.
  122710. */
  122711. ray: Nullable<Ray>;
  122712. private _renderPoints;
  122713. private _renderLine;
  122714. private _renderFunction;
  122715. private _scene;
  122716. private _updateToMeshFunction;
  122717. private _attachedToMesh;
  122718. private _meshSpaceDirection;
  122719. private _meshSpaceOrigin;
  122720. /**
  122721. * Helper function to create a colored helper in a scene in one line.
  122722. * @param ray Defines the ray we are currently tryin to visualize
  122723. * @param scene Defines the scene the ray is used in
  122724. * @param color Defines the color we want to see the ray in
  122725. * @returns The newly created ray helper.
  122726. */
  122727. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  122728. /**
  122729. * Instantiate a new ray helper.
  122730. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122731. * in order to better appreciate the issue one might have.
  122732. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122733. * @param ray Defines the ray we are currently tryin to visualize
  122734. */
  122735. constructor(ray: Ray);
  122736. /**
  122737. * Shows the ray we are willing to debug.
  122738. * @param scene Defines the scene the ray needs to be rendered in
  122739. * @param color Defines the color the ray needs to be rendered in
  122740. */
  122741. show(scene: Scene, color?: Color3): void;
  122742. /**
  122743. * Hides the ray we are debugging.
  122744. */
  122745. hide(): void;
  122746. private _render;
  122747. /**
  122748. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  122749. * @param mesh Defines the mesh we want the helper attached to
  122750. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  122751. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  122752. * @param length Defines the length of the ray
  122753. */
  122754. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  122755. /**
  122756. * Detach the ray helper from the mesh it has previously been attached to.
  122757. */
  122758. detachFromMesh(): void;
  122759. private _updateToMesh;
  122760. /**
  122761. * Dispose the helper and release its associated resources.
  122762. */
  122763. dispose(): void;
  122764. }
  122765. }
  122766. declare module BABYLON.Debug {
  122767. /**
  122768. * Class used to render a debug view of a given skeleton
  122769. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  122770. */
  122771. export class SkeletonViewer {
  122772. /** defines the skeleton to render */
  122773. skeleton: Skeleton;
  122774. /** defines the mesh attached to the skeleton */
  122775. mesh: AbstractMesh;
  122776. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122777. autoUpdateBonesMatrices: boolean;
  122778. /** defines the rendering group id to use with the viewer */
  122779. renderingGroupId: number;
  122780. /** Gets or sets the color used to render the skeleton */
  122781. color: Color3;
  122782. private _scene;
  122783. private _debugLines;
  122784. private _debugMesh;
  122785. private _isEnabled;
  122786. private _renderFunction;
  122787. private _utilityLayer;
  122788. /**
  122789. * Returns the mesh used to render the bones
  122790. */
  122791. get debugMesh(): Nullable<LinesMesh>;
  122792. /**
  122793. * Creates a new SkeletonViewer
  122794. * @param skeleton defines the skeleton to render
  122795. * @param mesh defines the mesh attached to the skeleton
  122796. * @param scene defines the hosting scene
  122797. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  122798. * @param renderingGroupId defines the rendering group id to use with the viewer
  122799. */
  122800. constructor(
  122801. /** defines the skeleton to render */
  122802. skeleton: Skeleton,
  122803. /** defines the mesh attached to the skeleton */
  122804. mesh: AbstractMesh, scene: Scene,
  122805. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122806. autoUpdateBonesMatrices?: boolean,
  122807. /** defines the rendering group id to use with the viewer */
  122808. renderingGroupId?: number);
  122809. /** Gets or sets a boolean indicating if the viewer is enabled */
  122810. set isEnabled(value: boolean);
  122811. get isEnabled(): boolean;
  122812. private _getBonePosition;
  122813. private _getLinesForBonesWithLength;
  122814. private _getLinesForBonesNoLength;
  122815. /** Update the viewer to sync with current skeleton state */
  122816. update(): void;
  122817. /** Release associated resources */
  122818. dispose(): void;
  122819. }
  122820. }
  122821. declare module BABYLON {
  122822. /**
  122823. * This class will take all inputs from Keyboard, Pointer, and
  122824. * any Gamepads and provide a polling system that all devices
  122825. * will use. This class assumes that there will only be one
  122826. * pointer device and one keyboard.
  122827. */
  122828. export class DeviceInputSystem implements IDisposable {
  122829. /** POINTER_DEVICE */
  122830. static readonly POINTER_DEVICE: string;
  122831. /** KEYBOARD_DEVICE */
  122832. static readonly KEYBOARD_DEVICE: string;
  122833. /**
  122834. * Observable to be triggered when a device is connected
  122835. */
  122836. onDeviceConnectedObservable: Observable<string>;
  122837. /**
  122838. * Observable to be triggered when a device is disconnected
  122839. */
  122840. onDeviceDisconnectedObservable: Observable<string>;
  122841. private _inputs;
  122842. private _gamepads;
  122843. private _keyboardActive;
  122844. private _pointerActive;
  122845. private _elementToAttachTo;
  122846. private _keyboardDownEvent;
  122847. private _keyboardUpEvent;
  122848. private _pointerMoveEvent;
  122849. private _pointerDownEvent;
  122850. private _pointerUpEvent;
  122851. private _gamepadConnectedEvent;
  122852. private _gamepadDisconnectedEvent;
  122853. private static _MAX_KEYCODES;
  122854. private static _MAX_POINTER_INPUTS;
  122855. /**
  122856. * Default Constructor
  122857. * @param engine - engine to pull input element from
  122858. */
  122859. constructor(engine: Engine);
  122860. /**
  122861. * Checks for current device input value, given an id and input index
  122862. * @param deviceName Id of connected device
  122863. * @param inputIndex Index of device input
  122864. * @returns Current value of input
  122865. */
  122866. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  122867. /**
  122868. * Dispose of all the eventlisteners and clears the observables
  122869. */
  122870. dispose(): void;
  122871. /**
  122872. * Add device and inputs to device map
  122873. * @param deviceName Assigned name of device (may be SN)
  122874. * @param numberOfInputs Number of input entries to create for given device
  122875. */
  122876. private _registerDevice;
  122877. /**
  122878. * Given a specific device name, remove that device from the device map
  122879. * @param deviceName Name of device to be removed
  122880. */
  122881. private _unregisterDevice;
  122882. /**
  122883. * Handle all actions that come from keyboard interaction
  122884. */
  122885. private _handleKeyActions;
  122886. /**
  122887. * Handle all actions that come from pointer interaction
  122888. */
  122889. private _handlePointerActions;
  122890. /**
  122891. * Handle all actions that come from gamepad interaction
  122892. */
  122893. private _handleGamepadActions;
  122894. /**
  122895. * Update all non-event based devices with each frame
  122896. */
  122897. private _updateDevice;
  122898. }
  122899. }
  122900. declare module BABYLON {
  122901. /**
  122902. * Options to create the null engine
  122903. */
  122904. export class NullEngineOptions {
  122905. /**
  122906. * Render width (Default: 512)
  122907. */
  122908. renderWidth: number;
  122909. /**
  122910. * Render height (Default: 256)
  122911. */
  122912. renderHeight: number;
  122913. /**
  122914. * Texture size (Default: 512)
  122915. */
  122916. textureSize: number;
  122917. /**
  122918. * If delta time between frames should be constant
  122919. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122920. */
  122921. deterministicLockstep: boolean;
  122922. /**
  122923. * Maximum about of steps between frames (Default: 4)
  122924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122925. */
  122926. lockstepMaxSteps: number;
  122927. }
  122928. /**
  122929. * The null engine class provides support for headless version of babylon.js.
  122930. * This can be used in server side scenario or for testing purposes
  122931. */
  122932. export class NullEngine extends Engine {
  122933. private _options;
  122934. /**
  122935. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122936. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122937. * @returns true if engine is in deterministic lock step mode
  122938. */
  122939. isDeterministicLockStep(): boolean;
  122940. /**
  122941. * Gets the max steps when engine is running in deterministic lock step
  122942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122943. * @returns the max steps
  122944. */
  122945. getLockstepMaxSteps(): number;
  122946. /**
  122947. * Gets the current hardware scaling level.
  122948. * By default the hardware scaling level is computed from the window device ratio.
  122949. * 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.
  122950. * @returns a number indicating the current hardware scaling level
  122951. */
  122952. getHardwareScalingLevel(): number;
  122953. constructor(options?: NullEngineOptions);
  122954. /**
  122955. * Creates a vertex buffer
  122956. * @param vertices the data for the vertex buffer
  122957. * @returns the new WebGL static buffer
  122958. */
  122959. createVertexBuffer(vertices: FloatArray): DataBuffer;
  122960. /**
  122961. * Creates a new index buffer
  122962. * @param indices defines the content of the index buffer
  122963. * @param updatable defines if the index buffer must be updatable
  122964. * @returns a new webGL buffer
  122965. */
  122966. createIndexBuffer(indices: IndicesArray): DataBuffer;
  122967. /**
  122968. * Clear the current render buffer or the current render target (if any is set up)
  122969. * @param color defines the color to use
  122970. * @param backBuffer defines if the back buffer must be cleared
  122971. * @param depth defines if the depth buffer must be cleared
  122972. * @param stencil defines if the stencil buffer must be cleared
  122973. */
  122974. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122975. /**
  122976. * Gets the current render width
  122977. * @param useScreen defines if screen size must be used (or the current render target if any)
  122978. * @returns a number defining the current render width
  122979. */
  122980. getRenderWidth(useScreen?: boolean): number;
  122981. /**
  122982. * Gets the current render height
  122983. * @param useScreen defines if screen size must be used (or the current render target if any)
  122984. * @returns a number defining the current render height
  122985. */
  122986. getRenderHeight(useScreen?: boolean): number;
  122987. /**
  122988. * Set the WebGL's viewport
  122989. * @param viewport defines the viewport element to be used
  122990. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  122991. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  122992. */
  122993. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  122994. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  122995. /**
  122996. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  122997. * @param pipelineContext defines the pipeline context to use
  122998. * @param uniformsNames defines the list of uniform names
  122999. * @returns an array of webGL uniform locations
  123000. */
  123001. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  123002. /**
  123003. * Gets the lsit of active attributes for a given webGL program
  123004. * @param pipelineContext defines the pipeline context to use
  123005. * @param attributesNames defines the list of attribute names to get
  123006. * @returns an array of indices indicating the offset of each attribute
  123007. */
  123008. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123009. /**
  123010. * Binds an effect to the webGL context
  123011. * @param effect defines the effect to bind
  123012. */
  123013. bindSamplers(effect: Effect): void;
  123014. /**
  123015. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123016. * @param effect defines the effect to activate
  123017. */
  123018. enableEffect(effect: Effect): void;
  123019. /**
  123020. * Set various states to the webGL context
  123021. * @param culling defines backface culling state
  123022. * @param zOffset defines the value to apply to zOffset (0 by default)
  123023. * @param force defines if states must be applied even if cache is up to date
  123024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123025. */
  123026. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123027. /**
  123028. * Set the value of an uniform to an array of int32
  123029. * @param uniform defines the webGL uniform location where to store the value
  123030. * @param array defines the array of int32 to store
  123031. */
  123032. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123033. /**
  123034. * Set the value of an uniform to an array of int32 (stored as vec2)
  123035. * @param uniform defines the webGL uniform location where to store the value
  123036. * @param array defines the array of int32 to store
  123037. */
  123038. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123039. /**
  123040. * Set the value of an uniform to an array of int32 (stored as vec3)
  123041. * @param uniform defines the webGL uniform location where to store the value
  123042. * @param array defines the array of int32 to store
  123043. */
  123044. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123045. /**
  123046. * Set the value of an uniform to an array of int32 (stored as vec4)
  123047. * @param uniform defines the webGL uniform location where to store the value
  123048. * @param array defines the array of int32 to store
  123049. */
  123050. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123051. /**
  123052. * Set the value of an uniform to an array of float32
  123053. * @param uniform defines the webGL uniform location where to store the value
  123054. * @param array defines the array of float32 to store
  123055. */
  123056. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123057. /**
  123058. * Set the value of an uniform to an array of float32 (stored as vec2)
  123059. * @param uniform defines the webGL uniform location where to store the value
  123060. * @param array defines the array of float32 to store
  123061. */
  123062. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123063. /**
  123064. * Set the value of an uniform to an array of float32 (stored as vec3)
  123065. * @param uniform defines the webGL uniform location where to store the value
  123066. * @param array defines the array of float32 to store
  123067. */
  123068. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123069. /**
  123070. * Set the value of an uniform to an array of float32 (stored as vec4)
  123071. * @param uniform defines the webGL uniform location where to store the value
  123072. * @param array defines the array of float32 to store
  123073. */
  123074. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123075. /**
  123076. * Set the value of an uniform to an array of number
  123077. * @param uniform defines the webGL uniform location where to store the value
  123078. * @param array defines the array of number to store
  123079. */
  123080. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123081. /**
  123082. * Set the value of an uniform to an array of number (stored as vec2)
  123083. * @param uniform defines the webGL uniform location where to store the value
  123084. * @param array defines the array of number to store
  123085. */
  123086. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123087. /**
  123088. * Set the value of an uniform to an array of number (stored as vec3)
  123089. * @param uniform defines the webGL uniform location where to store the value
  123090. * @param array defines the array of number to store
  123091. */
  123092. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123093. /**
  123094. * Set the value of an uniform to an array of number (stored as vec4)
  123095. * @param uniform defines the webGL uniform location where to store the value
  123096. * @param array defines the array of number to store
  123097. */
  123098. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123099. /**
  123100. * Set the value of an uniform to an array of float32 (stored as matrices)
  123101. * @param uniform defines the webGL uniform location where to store the value
  123102. * @param matrices defines the array of float32 to store
  123103. */
  123104. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123105. /**
  123106. * Set the value of an uniform to a matrix (3x3)
  123107. * @param uniform defines the webGL uniform location where to store the value
  123108. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123109. */
  123110. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123111. /**
  123112. * Set the value of an uniform to a matrix (2x2)
  123113. * @param uniform defines the webGL uniform location where to store the value
  123114. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123115. */
  123116. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123117. /**
  123118. * Set the value of an uniform to a number (float)
  123119. * @param uniform defines the webGL uniform location where to store the value
  123120. * @param value defines the float number to store
  123121. */
  123122. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123123. /**
  123124. * Set the value of an uniform to a vec2
  123125. * @param uniform defines the webGL uniform location where to store the value
  123126. * @param x defines the 1st component of the value
  123127. * @param y defines the 2nd component of the value
  123128. */
  123129. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123130. /**
  123131. * Set the value of an uniform to a vec3
  123132. * @param uniform defines the webGL uniform location where to store the value
  123133. * @param x defines the 1st component of the value
  123134. * @param y defines the 2nd component of the value
  123135. * @param z defines the 3rd component of the value
  123136. */
  123137. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123138. /**
  123139. * Set the value of an uniform to a boolean
  123140. * @param uniform defines the webGL uniform location where to store the value
  123141. * @param bool defines the boolean to store
  123142. */
  123143. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123144. /**
  123145. * Set the value of an uniform to a vec4
  123146. * @param uniform defines the webGL uniform location where to store the value
  123147. * @param x defines the 1st component of the value
  123148. * @param y defines the 2nd component of the value
  123149. * @param z defines the 3rd component of the value
  123150. * @param w defines the 4th component of the value
  123151. */
  123152. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123153. /**
  123154. * Sets the current alpha mode
  123155. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123156. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123157. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123158. */
  123159. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123160. /**
  123161. * Bind webGl buffers directly to the webGL context
  123162. * @param vertexBuffers defines the vertex buffer to bind
  123163. * @param indexBuffer defines the index buffer to bind
  123164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123166. * @param effect defines the effect associated with the vertex buffer
  123167. */
  123168. bindBuffers(vertexBuffers: {
  123169. [key: string]: VertexBuffer;
  123170. }, indexBuffer: DataBuffer, effect: Effect): void;
  123171. /**
  123172. * Force the entire cache to be cleared
  123173. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123174. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123175. */
  123176. wipeCaches(bruteForce?: boolean): void;
  123177. /**
  123178. * Send a draw order
  123179. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123180. * @param indexStart defines the starting index
  123181. * @param indexCount defines the number of index to draw
  123182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123183. */
  123184. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123185. /**
  123186. * Draw a list of indexed primitives
  123187. * @param fillMode defines the primitive to use
  123188. * @param indexStart defines the starting index
  123189. * @param indexCount defines the number of index to draw
  123190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123191. */
  123192. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123193. /**
  123194. * Draw a list of unindexed primitives
  123195. * @param fillMode defines the primitive to use
  123196. * @param verticesStart defines the index of first vertex to draw
  123197. * @param verticesCount defines the count of vertices to draw
  123198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123199. */
  123200. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123201. /** @hidden */
  123202. _createTexture(): WebGLTexture;
  123203. /** @hidden */
  123204. _releaseTexture(texture: InternalTexture): void;
  123205. /**
  123206. * Usually called from Texture.ts.
  123207. * Passed information to create a WebGLTexture
  123208. * @param urlArg defines a value which contains one of the following:
  123209. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123210. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123211. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123212. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123213. * @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)
  123214. * @param scene needed for loading to the correct scene
  123215. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123216. * @param onLoad optional callback to be called upon successful completion
  123217. * @param onError optional callback to be called upon failure
  123218. * @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
  123219. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123220. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123221. * @param forcedExtension defines the extension to use to pick the right loader
  123222. * @param mimeType defines an optional mime type
  123223. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123224. */
  123225. 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;
  123226. /**
  123227. * Creates a new render target texture
  123228. * @param size defines the size of the texture
  123229. * @param options defines the options used to create the texture
  123230. * @returns a new render target texture stored in an InternalTexture
  123231. */
  123232. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123233. /**
  123234. * Update the sampling mode of a given texture
  123235. * @param samplingMode defines the required sampling mode
  123236. * @param texture defines the texture to update
  123237. */
  123238. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123239. /**
  123240. * Binds the frame buffer to the specified texture.
  123241. * @param texture The texture to render to or null for the default canvas
  123242. * @param faceIndex The face of the texture to render to in case of cube texture
  123243. * @param requiredWidth The width of the target to render to
  123244. * @param requiredHeight The height of the target to render to
  123245. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123246. * @param lodLevel defines le lod level to bind to the frame buffer
  123247. */
  123248. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123249. /**
  123250. * Unbind the current render target texture from the webGL context
  123251. * @param texture defines the render target texture to unbind
  123252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123254. */
  123255. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123256. /**
  123257. * Creates a dynamic vertex buffer
  123258. * @param vertices the data for the dynamic vertex buffer
  123259. * @returns the new WebGL dynamic buffer
  123260. */
  123261. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123262. /**
  123263. * Update the content of a dynamic texture
  123264. * @param texture defines the texture to update
  123265. * @param canvas defines the canvas containing the source
  123266. * @param invertY defines if data must be stored with Y axis inverted
  123267. * @param premulAlpha defines if alpha is stored as premultiplied
  123268. * @param format defines the format of the data
  123269. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123270. */
  123271. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123272. /**
  123273. * Gets a boolean indicating if all created effects are ready
  123274. * @returns true if all effects are ready
  123275. */
  123276. areAllEffectsReady(): boolean;
  123277. /**
  123278. * @hidden
  123279. * Get the current error code of the webGL context
  123280. * @returns the error code
  123281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123282. */
  123283. getError(): number;
  123284. /** @hidden */
  123285. _getUnpackAlignement(): number;
  123286. /** @hidden */
  123287. _unpackFlipY(value: boolean): void;
  123288. /**
  123289. * Update a dynamic index buffer
  123290. * @param indexBuffer defines the target index buffer
  123291. * @param indices defines the data to update
  123292. * @param offset defines the offset in the target index buffer where update should start
  123293. */
  123294. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123295. /**
  123296. * Updates a dynamic vertex buffer.
  123297. * @param vertexBuffer the vertex buffer to update
  123298. * @param vertices the data used to update the vertex buffer
  123299. * @param byteOffset the byte offset of the data (optional)
  123300. * @param byteLength the byte length of the data (optional)
  123301. */
  123302. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123303. /** @hidden */
  123304. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123305. /** @hidden */
  123306. _bindTexture(channel: number, texture: InternalTexture): void;
  123307. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123308. /**
  123309. * 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
  123310. */
  123311. releaseEffects(): void;
  123312. displayLoadingUI(): void;
  123313. hideLoadingUI(): void;
  123314. /** @hidden */
  123315. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123316. /** @hidden */
  123317. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123318. /** @hidden */
  123319. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123320. /** @hidden */
  123321. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123322. }
  123323. }
  123324. declare module BABYLON {
  123325. /**
  123326. * @hidden
  123327. **/
  123328. export class _TimeToken {
  123329. _startTimeQuery: Nullable<WebGLQuery>;
  123330. _endTimeQuery: Nullable<WebGLQuery>;
  123331. _timeElapsedQuery: Nullable<WebGLQuery>;
  123332. _timeElapsedQueryEnded: boolean;
  123333. }
  123334. }
  123335. declare module BABYLON {
  123336. /** @hidden */
  123337. export class _OcclusionDataStorage {
  123338. /** @hidden */
  123339. occlusionInternalRetryCounter: number;
  123340. /** @hidden */
  123341. isOcclusionQueryInProgress: boolean;
  123342. /** @hidden */
  123343. isOccluded: boolean;
  123344. /** @hidden */
  123345. occlusionRetryCount: number;
  123346. /** @hidden */
  123347. occlusionType: number;
  123348. /** @hidden */
  123349. occlusionQueryAlgorithmType: number;
  123350. }
  123351. interface Engine {
  123352. /**
  123353. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123354. * @return the new query
  123355. */
  123356. createQuery(): WebGLQuery;
  123357. /**
  123358. * Delete and release a webGL query
  123359. * @param query defines the query to delete
  123360. * @return the current engine
  123361. */
  123362. deleteQuery(query: WebGLQuery): Engine;
  123363. /**
  123364. * Check if a given query has resolved and got its value
  123365. * @param query defines the query to check
  123366. * @returns true if the query got its value
  123367. */
  123368. isQueryResultAvailable(query: WebGLQuery): boolean;
  123369. /**
  123370. * Gets the value of a given query
  123371. * @param query defines the query to check
  123372. * @returns the value of the query
  123373. */
  123374. getQueryResult(query: WebGLQuery): number;
  123375. /**
  123376. * Initiates an occlusion query
  123377. * @param algorithmType defines the algorithm to use
  123378. * @param query defines the query to use
  123379. * @returns the current engine
  123380. * @see http://doc.babylonjs.com/features/occlusionquery
  123381. */
  123382. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123383. /**
  123384. * Ends an occlusion query
  123385. * @see http://doc.babylonjs.com/features/occlusionquery
  123386. * @param algorithmType defines the algorithm to use
  123387. * @returns the current engine
  123388. */
  123389. endOcclusionQuery(algorithmType: number): Engine;
  123390. /**
  123391. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123392. * Please note that only one query can be issued at a time
  123393. * @returns a time token used to track the time span
  123394. */
  123395. startTimeQuery(): Nullable<_TimeToken>;
  123396. /**
  123397. * Ends a time query
  123398. * @param token defines the token used to measure the time span
  123399. * @returns the time spent (in ns)
  123400. */
  123401. endTimeQuery(token: _TimeToken): int;
  123402. /** @hidden */
  123403. _currentNonTimestampToken: Nullable<_TimeToken>;
  123404. /** @hidden */
  123405. _createTimeQuery(): WebGLQuery;
  123406. /** @hidden */
  123407. _deleteTimeQuery(query: WebGLQuery): void;
  123408. /** @hidden */
  123409. _getGlAlgorithmType(algorithmType: number): number;
  123410. /** @hidden */
  123411. _getTimeQueryResult(query: WebGLQuery): any;
  123412. /** @hidden */
  123413. _getTimeQueryAvailability(query: WebGLQuery): any;
  123414. }
  123415. interface AbstractMesh {
  123416. /**
  123417. * Backing filed
  123418. * @hidden
  123419. */
  123420. __occlusionDataStorage: _OcclusionDataStorage;
  123421. /**
  123422. * Access property
  123423. * @hidden
  123424. */
  123425. _occlusionDataStorage: _OcclusionDataStorage;
  123426. /**
  123427. * 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.
  123428. * The default value is -1 which means don't break the query and wait till the result
  123429. * @see http://doc.babylonjs.com/features/occlusionquery
  123430. */
  123431. occlusionRetryCount: number;
  123432. /**
  123433. * 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:
  123434. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123435. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123436. * * 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.
  123437. * @see http://doc.babylonjs.com/features/occlusionquery
  123438. */
  123439. occlusionType: number;
  123440. /**
  123441. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123442. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123443. * * 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.
  123444. * @see http://doc.babylonjs.com/features/occlusionquery
  123445. */
  123446. occlusionQueryAlgorithmType: number;
  123447. /**
  123448. * 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
  123449. * @see http://doc.babylonjs.com/features/occlusionquery
  123450. */
  123451. isOccluded: boolean;
  123452. /**
  123453. * Flag to check the progress status of the query
  123454. * @see http://doc.babylonjs.com/features/occlusionquery
  123455. */
  123456. isOcclusionQueryInProgress: boolean;
  123457. }
  123458. }
  123459. declare module BABYLON {
  123460. /** @hidden */
  123461. export var _forceTransformFeedbackToBundle: boolean;
  123462. interface Engine {
  123463. /**
  123464. * Creates a webGL transform feedback object
  123465. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123466. * @returns the webGL transform feedback object
  123467. */
  123468. createTransformFeedback(): WebGLTransformFeedback;
  123469. /**
  123470. * Delete a webGL transform feedback object
  123471. * @param value defines the webGL transform feedback object to delete
  123472. */
  123473. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123474. /**
  123475. * Bind a webGL transform feedback object to the webgl context
  123476. * @param value defines the webGL transform feedback object to bind
  123477. */
  123478. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123479. /**
  123480. * Begins a transform feedback operation
  123481. * @param usePoints defines if points or triangles must be used
  123482. */
  123483. beginTransformFeedback(usePoints: boolean): void;
  123484. /**
  123485. * Ends a transform feedback operation
  123486. */
  123487. endTransformFeedback(): void;
  123488. /**
  123489. * Specify the varyings to use with transform feedback
  123490. * @param program defines the associated webGL program
  123491. * @param value defines the list of strings representing the varying names
  123492. */
  123493. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123494. /**
  123495. * Bind a webGL buffer for a transform feedback operation
  123496. * @param value defines the webGL buffer to bind
  123497. */
  123498. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123499. }
  123500. }
  123501. declare module BABYLON {
  123502. /**
  123503. * Creation options of the multi render target texture.
  123504. */
  123505. export interface IMultiRenderTargetOptions {
  123506. /**
  123507. * Define if the texture needs to create mip maps after render.
  123508. */
  123509. generateMipMaps?: boolean;
  123510. /**
  123511. * Define the types of all the draw buffers we want to create
  123512. */
  123513. types?: number[];
  123514. /**
  123515. * Define the sampling modes of all the draw buffers we want to create
  123516. */
  123517. samplingModes?: number[];
  123518. /**
  123519. * Define if a depth buffer is required
  123520. */
  123521. generateDepthBuffer?: boolean;
  123522. /**
  123523. * Define if a stencil buffer is required
  123524. */
  123525. generateStencilBuffer?: boolean;
  123526. /**
  123527. * Define if a depth texture is required instead of a depth buffer
  123528. */
  123529. generateDepthTexture?: boolean;
  123530. /**
  123531. * Define the number of desired draw buffers
  123532. */
  123533. textureCount?: number;
  123534. /**
  123535. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123536. */
  123537. doNotChangeAspectRatio?: boolean;
  123538. /**
  123539. * Define the default type of the buffers we are creating
  123540. */
  123541. defaultType?: number;
  123542. }
  123543. /**
  123544. * A multi render target, like a render target provides the ability to render to a texture.
  123545. * Unlike the render target, it can render to several draw buffers in one draw.
  123546. * This is specially interesting in deferred rendering or for any effects requiring more than
  123547. * just one color from a single pass.
  123548. */
  123549. export class MultiRenderTarget extends RenderTargetTexture {
  123550. private _internalTextures;
  123551. private _textures;
  123552. private _multiRenderTargetOptions;
  123553. /**
  123554. * Get if draw buffers are currently supported by the used hardware and browser.
  123555. */
  123556. get isSupported(): boolean;
  123557. /**
  123558. * Get the list of textures generated by the multi render target.
  123559. */
  123560. get textures(): Texture[];
  123561. /**
  123562. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123563. */
  123564. get depthTexture(): Texture;
  123565. /**
  123566. * Set the wrapping mode on U of all the textures we are rendering to.
  123567. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123568. */
  123569. set wrapU(wrap: number);
  123570. /**
  123571. * Set the wrapping mode on V of all the textures we are rendering to.
  123572. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123573. */
  123574. set wrapV(wrap: number);
  123575. /**
  123576. * Instantiate a new multi render target texture.
  123577. * A multi render target, like a render target provides the ability to render to a texture.
  123578. * Unlike the render target, it can render to several draw buffers in one draw.
  123579. * This is specially interesting in deferred rendering or for any effects requiring more than
  123580. * just one color from a single pass.
  123581. * @param name Define the name of the texture
  123582. * @param size Define the size of the buffers to render to
  123583. * @param count Define the number of target we are rendering into
  123584. * @param scene Define the scene the texture belongs to
  123585. * @param options Define the options used to create the multi render target
  123586. */
  123587. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123588. /** @hidden */
  123589. _rebuild(): void;
  123590. private _createInternalTextures;
  123591. private _createTextures;
  123592. /**
  123593. * Define the number of samples used if MSAA is enabled.
  123594. */
  123595. get samples(): number;
  123596. set samples(value: number);
  123597. /**
  123598. * Resize all the textures in the multi render target.
  123599. * Be carrefull as it will recreate all the data in the new texture.
  123600. * @param size Define the new size
  123601. */
  123602. resize(size: any): void;
  123603. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123604. /**
  123605. * Dispose the render targets and their associated resources
  123606. */
  123607. dispose(): void;
  123608. /**
  123609. * Release all the underlying texture used as draw buffers.
  123610. */
  123611. releaseInternalTextures(): void;
  123612. }
  123613. }
  123614. declare module BABYLON {
  123615. interface ThinEngine {
  123616. /**
  123617. * Unbind a list of render target textures from the webGL context
  123618. * This is used only when drawBuffer extension or webGL2 are active
  123619. * @param textures defines the render target textures to unbind
  123620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123622. */
  123623. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123624. /**
  123625. * Create a multi render target texture
  123626. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123627. * @param size defines the size of the texture
  123628. * @param options defines the creation options
  123629. * @returns the cube texture as an InternalTexture
  123630. */
  123631. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123632. /**
  123633. * Update the sample count for a given multiple render target texture
  123634. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123635. * @param textures defines the textures to update
  123636. * @param samples defines the sample count to set
  123637. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123638. */
  123639. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123640. }
  123641. }
  123642. declare module BABYLON {
  123643. /**
  123644. * Class used to define an additional view for the engine
  123645. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123646. */
  123647. export class EngineView {
  123648. /** Defines the canvas where to render the view */
  123649. target: HTMLCanvasElement;
  123650. /** Defines an optional camera used to render the view (will use active camera else) */
  123651. camera?: Camera;
  123652. }
  123653. interface Engine {
  123654. /**
  123655. * Gets or sets the HTML element to use for attaching events
  123656. */
  123657. inputElement: Nullable<HTMLElement>;
  123658. /**
  123659. * Gets the current engine view
  123660. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123661. */
  123662. activeView: Nullable<EngineView>;
  123663. /** Gets or sets the list of views */
  123664. views: EngineView[];
  123665. /**
  123666. * Register a new child canvas
  123667. * @param canvas defines the canvas to register
  123668. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123669. * @returns the associated view
  123670. */
  123671. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123672. /**
  123673. * Remove a registered child canvas
  123674. * @param canvas defines the canvas to remove
  123675. * @returns the current engine
  123676. */
  123677. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123678. }
  123679. }
  123680. declare module BABYLON {
  123681. interface Engine {
  123682. /** @hidden */
  123683. _excludedCompressedTextures: string[];
  123684. /** @hidden */
  123685. _textureFormatInUse: string;
  123686. /**
  123687. * Gets the list of texture formats supported
  123688. */
  123689. readonly texturesSupported: Array<string>;
  123690. /**
  123691. * Gets the texture format in use
  123692. */
  123693. readonly textureFormatInUse: Nullable<string>;
  123694. /**
  123695. * Set the compressed texture extensions or file names to skip.
  123696. *
  123697. * @param skippedFiles defines the list of those texture files you want to skip
  123698. * Example: [".dds", ".env", "myfile.png"]
  123699. */
  123700. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123701. /**
  123702. * Set the compressed texture format to use, based on the formats you have, and the formats
  123703. * supported by the hardware / browser.
  123704. *
  123705. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123706. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123707. * to API arguments needed to compressed textures. This puts the burden on the container
  123708. * generator to house the arcane code for determining these for current & future formats.
  123709. *
  123710. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123711. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123712. *
  123713. * Note: The result of this call is not taken into account when a texture is base64.
  123714. *
  123715. * @param formatsAvailable defines the list of those format families you have created
  123716. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  123717. *
  123718. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  123719. * @returns The extension selected.
  123720. */
  123721. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  123722. }
  123723. }
  123724. declare module BABYLON {
  123725. /**
  123726. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  123727. */
  123728. export interface CubeMapInfo {
  123729. /**
  123730. * The pixel array for the front face.
  123731. * This is stored in format, left to right, up to down format.
  123732. */
  123733. front: Nullable<ArrayBufferView>;
  123734. /**
  123735. * The pixel array for the back face.
  123736. * This is stored in format, left to right, up to down format.
  123737. */
  123738. back: Nullable<ArrayBufferView>;
  123739. /**
  123740. * The pixel array for the left face.
  123741. * This is stored in format, left to right, up to down format.
  123742. */
  123743. left: Nullable<ArrayBufferView>;
  123744. /**
  123745. * The pixel array for the right face.
  123746. * This is stored in format, left to right, up to down format.
  123747. */
  123748. right: Nullable<ArrayBufferView>;
  123749. /**
  123750. * The pixel array for the up face.
  123751. * This is stored in format, left to right, up to down format.
  123752. */
  123753. up: Nullable<ArrayBufferView>;
  123754. /**
  123755. * The pixel array for the down face.
  123756. * This is stored in format, left to right, up to down format.
  123757. */
  123758. down: Nullable<ArrayBufferView>;
  123759. /**
  123760. * The size of the cubemap stored.
  123761. *
  123762. * Each faces will be size * size pixels.
  123763. */
  123764. size: number;
  123765. /**
  123766. * The format of the texture.
  123767. *
  123768. * RGBA, RGB.
  123769. */
  123770. format: number;
  123771. /**
  123772. * The type of the texture data.
  123773. *
  123774. * UNSIGNED_INT, FLOAT.
  123775. */
  123776. type: number;
  123777. /**
  123778. * Specifies whether the texture is in gamma space.
  123779. */
  123780. gammaSpace: boolean;
  123781. }
  123782. /**
  123783. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  123784. */
  123785. export class PanoramaToCubeMapTools {
  123786. private static FACE_FRONT;
  123787. private static FACE_BACK;
  123788. private static FACE_RIGHT;
  123789. private static FACE_LEFT;
  123790. private static FACE_DOWN;
  123791. private static FACE_UP;
  123792. /**
  123793. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  123794. *
  123795. * @param float32Array The source data.
  123796. * @param inputWidth The width of the input panorama.
  123797. * @param inputHeight The height of the input panorama.
  123798. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  123799. * @return The cubemap data
  123800. */
  123801. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  123802. private static CreateCubemapTexture;
  123803. private static CalcProjectionSpherical;
  123804. }
  123805. }
  123806. declare module BABYLON {
  123807. /**
  123808. * Helper class dealing with the extraction of spherical polynomial dataArray
  123809. * from a cube map.
  123810. */
  123811. export class CubeMapToSphericalPolynomialTools {
  123812. private static FileFaces;
  123813. /**
  123814. * Converts a texture to the according Spherical Polynomial data.
  123815. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123816. *
  123817. * @param texture The texture to extract the information from.
  123818. * @return The Spherical Polynomial data.
  123819. */
  123820. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  123821. /**
  123822. * Converts a cubemap to the according Spherical Polynomial data.
  123823. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123824. *
  123825. * @param cubeInfo The Cube map to extract the information from.
  123826. * @return The Spherical Polynomial data.
  123827. */
  123828. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  123829. }
  123830. }
  123831. declare module BABYLON {
  123832. interface BaseTexture {
  123833. /**
  123834. * Get the polynomial representation of the texture data.
  123835. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  123836. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  123837. */
  123838. sphericalPolynomial: Nullable<SphericalPolynomial>;
  123839. }
  123840. }
  123841. declare module BABYLON {
  123842. /** @hidden */
  123843. export var rgbdEncodePixelShader: {
  123844. name: string;
  123845. shader: string;
  123846. };
  123847. }
  123848. declare module BABYLON {
  123849. /** @hidden */
  123850. export var rgbdDecodePixelShader: {
  123851. name: string;
  123852. shader: string;
  123853. };
  123854. }
  123855. declare module BABYLON {
  123856. /**
  123857. * Raw texture data and descriptor sufficient for WebGL texture upload
  123858. */
  123859. export interface EnvironmentTextureInfo {
  123860. /**
  123861. * Version of the environment map
  123862. */
  123863. version: number;
  123864. /**
  123865. * Width of image
  123866. */
  123867. width: number;
  123868. /**
  123869. * Irradiance information stored in the file.
  123870. */
  123871. irradiance: any;
  123872. /**
  123873. * Specular information stored in the file.
  123874. */
  123875. specular: any;
  123876. }
  123877. /**
  123878. * Defines One Image in the file. It requires only the position in the file
  123879. * as well as the length.
  123880. */
  123881. interface BufferImageData {
  123882. /**
  123883. * Length of the image data.
  123884. */
  123885. length: number;
  123886. /**
  123887. * Position of the data from the null terminator delimiting the end of the JSON.
  123888. */
  123889. position: number;
  123890. }
  123891. /**
  123892. * Defines the specular data enclosed in the file.
  123893. * This corresponds to the version 1 of the data.
  123894. */
  123895. export interface EnvironmentTextureSpecularInfoV1 {
  123896. /**
  123897. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  123898. */
  123899. specularDataPosition?: number;
  123900. /**
  123901. * This contains all the images data needed to reconstruct the cubemap.
  123902. */
  123903. mipmaps: Array<BufferImageData>;
  123904. /**
  123905. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  123906. */
  123907. lodGenerationScale: number;
  123908. }
  123909. /**
  123910. * Sets of helpers addressing the serialization and deserialization of environment texture
  123911. * stored in a BabylonJS env file.
  123912. * Those files are usually stored as .env files.
  123913. */
  123914. export class EnvironmentTextureTools {
  123915. /**
  123916. * Magic number identifying the env file.
  123917. */
  123918. private static _MagicBytes;
  123919. /**
  123920. * Gets the environment info from an env file.
  123921. * @param data The array buffer containing the .env bytes.
  123922. * @returns the environment file info (the json header) if successfully parsed.
  123923. */
  123924. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  123925. /**
  123926. * Creates an environment texture from a loaded cube texture.
  123927. * @param texture defines the cube texture to convert in env file
  123928. * @return a promise containing the environment data if succesfull.
  123929. */
  123930. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  123931. /**
  123932. * Creates a JSON representation of the spherical data.
  123933. * @param texture defines the texture containing the polynomials
  123934. * @return the JSON representation of the spherical info
  123935. */
  123936. private static _CreateEnvTextureIrradiance;
  123937. /**
  123938. * Creates the ArrayBufferViews used for initializing environment texture image data.
  123939. * @param data the image data
  123940. * @param info parameters that determine what views will be created for accessing the underlying buffer
  123941. * @return the views described by info providing access to the underlying buffer
  123942. */
  123943. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  123944. /**
  123945. * Uploads the texture info contained in the env file to the GPU.
  123946. * @param texture defines the internal texture to upload to
  123947. * @param data defines the data to load
  123948. * @param info defines the texture info retrieved through the GetEnvInfo method
  123949. * @returns a promise
  123950. */
  123951. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  123952. private static _OnImageReadyAsync;
  123953. /**
  123954. * Uploads the levels of image data to the GPU.
  123955. * @param texture defines the internal texture to upload to
  123956. * @param imageData defines the array buffer views of image data [mipmap][face]
  123957. * @returns a promise
  123958. */
  123959. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  123960. /**
  123961. * Uploads spherical polynomials information to the texture.
  123962. * @param texture defines the texture we are trying to upload the information to
  123963. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  123964. */
  123965. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  123966. /** @hidden */
  123967. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  123968. }
  123969. }
  123970. declare module BABYLON {
  123971. /**
  123972. * Contains position and normal vectors for a vertex
  123973. */
  123974. export class PositionNormalVertex {
  123975. /** the position of the vertex (defaut: 0,0,0) */
  123976. position: Vector3;
  123977. /** the normal of the vertex (defaut: 0,1,0) */
  123978. normal: Vector3;
  123979. /**
  123980. * Creates a PositionNormalVertex
  123981. * @param position the position of the vertex (defaut: 0,0,0)
  123982. * @param normal the normal of the vertex (defaut: 0,1,0)
  123983. */
  123984. constructor(
  123985. /** the position of the vertex (defaut: 0,0,0) */
  123986. position?: Vector3,
  123987. /** the normal of the vertex (defaut: 0,1,0) */
  123988. normal?: Vector3);
  123989. /**
  123990. * Clones the PositionNormalVertex
  123991. * @returns the cloned PositionNormalVertex
  123992. */
  123993. clone(): PositionNormalVertex;
  123994. }
  123995. /**
  123996. * Contains position, normal and uv vectors for a vertex
  123997. */
  123998. export class PositionNormalTextureVertex {
  123999. /** the position of the vertex (defaut: 0,0,0) */
  124000. position: Vector3;
  124001. /** the normal of the vertex (defaut: 0,1,0) */
  124002. normal: Vector3;
  124003. /** the uv of the vertex (default: 0,0) */
  124004. uv: Vector2;
  124005. /**
  124006. * Creates a PositionNormalTextureVertex
  124007. * @param position the position of the vertex (defaut: 0,0,0)
  124008. * @param normal the normal of the vertex (defaut: 0,1,0)
  124009. * @param uv the uv of the vertex (default: 0,0)
  124010. */
  124011. constructor(
  124012. /** the position of the vertex (defaut: 0,0,0) */
  124013. position?: Vector3,
  124014. /** the normal of the vertex (defaut: 0,1,0) */
  124015. normal?: Vector3,
  124016. /** the uv of the vertex (default: 0,0) */
  124017. uv?: Vector2);
  124018. /**
  124019. * Clones the PositionNormalTextureVertex
  124020. * @returns the cloned PositionNormalTextureVertex
  124021. */
  124022. clone(): PositionNormalTextureVertex;
  124023. }
  124024. }
  124025. declare module BABYLON {
  124026. /** @hidden */
  124027. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124028. private _genericAttributeLocation;
  124029. private _varyingLocationCount;
  124030. private _varyingLocationMap;
  124031. private _replacements;
  124032. private _textureCount;
  124033. private _uniforms;
  124034. lineProcessor(line: string): string;
  124035. attributeProcessor(attribute: string): string;
  124036. varyingProcessor(varying: string, isFragment: boolean): string;
  124037. uniformProcessor(uniform: string): string;
  124038. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124039. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124040. }
  124041. }
  124042. declare module BABYLON {
  124043. /**
  124044. * Container for accessors for natively-stored mesh data buffers.
  124045. */
  124046. class NativeDataBuffer extends DataBuffer {
  124047. /**
  124048. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124049. */
  124050. nativeIndexBuffer?: any;
  124051. /**
  124052. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124053. */
  124054. nativeVertexBuffer?: any;
  124055. }
  124056. /** @hidden */
  124057. class NativeTexture extends InternalTexture {
  124058. getInternalTexture(): InternalTexture;
  124059. getViewCount(): number;
  124060. }
  124061. /** @hidden */
  124062. export class NativeEngine extends Engine {
  124063. private readonly _native;
  124064. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124065. private readonly INVALID_HANDLE;
  124066. getHardwareScalingLevel(): number;
  124067. constructor();
  124068. dispose(): void;
  124069. /**
  124070. * Can be used to override the current requestAnimationFrame requester.
  124071. * @hidden
  124072. */
  124073. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124074. /**
  124075. * Override default engine behavior.
  124076. * @param color
  124077. * @param backBuffer
  124078. * @param depth
  124079. * @param stencil
  124080. */
  124081. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124082. /**
  124083. * Gets host document
  124084. * @returns the host document object
  124085. */
  124086. getHostDocument(): Nullable<Document>;
  124087. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124088. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124089. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124090. recordVertexArrayObject(vertexBuffers: {
  124091. [key: string]: VertexBuffer;
  124092. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124093. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124094. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124095. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124096. /**
  124097. * Draw a list of indexed primitives
  124098. * @param fillMode defines the primitive to use
  124099. * @param indexStart defines the starting index
  124100. * @param indexCount defines the number of index to draw
  124101. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124102. */
  124103. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124104. /**
  124105. * Draw a list of unindexed primitives
  124106. * @param fillMode defines the primitive to use
  124107. * @param verticesStart defines the index of first vertex to draw
  124108. * @param verticesCount defines the count of vertices to draw
  124109. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124110. */
  124111. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124112. createPipelineContext(): IPipelineContext;
  124113. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124114. /** @hidden */
  124115. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124116. /** @hidden */
  124117. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124118. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124119. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124120. protected _setProgram(program: WebGLProgram): void;
  124121. _releaseEffect(effect: Effect): void;
  124122. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124123. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124124. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124125. bindSamplers(effect: Effect): void;
  124126. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124127. getRenderWidth(useScreen?: boolean): number;
  124128. getRenderHeight(useScreen?: boolean): number;
  124129. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124130. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124131. /**
  124132. * Set the z offset to apply to current rendering
  124133. * @param value defines the offset to apply
  124134. */
  124135. setZOffset(value: number): void;
  124136. /**
  124137. * Gets the current value of the zOffset
  124138. * @returns the current zOffset state
  124139. */
  124140. getZOffset(): number;
  124141. /**
  124142. * Enable or disable depth buffering
  124143. * @param enable defines the state to set
  124144. */
  124145. setDepthBuffer(enable: boolean): void;
  124146. /**
  124147. * Gets a boolean indicating if depth writing is enabled
  124148. * @returns the current depth writing state
  124149. */
  124150. getDepthWrite(): boolean;
  124151. /**
  124152. * Enable or disable depth writing
  124153. * @param enable defines the state to set
  124154. */
  124155. setDepthWrite(enable: boolean): void;
  124156. /**
  124157. * Enable or disable color writing
  124158. * @param enable defines the state to set
  124159. */
  124160. setColorWrite(enable: boolean): void;
  124161. /**
  124162. * Gets a boolean indicating if color writing is enabled
  124163. * @returns the current color writing state
  124164. */
  124165. getColorWrite(): boolean;
  124166. /**
  124167. * Sets alpha constants used by some alpha blending modes
  124168. * @param r defines the red component
  124169. * @param g defines the green component
  124170. * @param b defines the blue component
  124171. * @param a defines the alpha component
  124172. */
  124173. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124174. /**
  124175. * Sets the current alpha mode
  124176. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124177. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124178. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124179. */
  124180. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124181. /**
  124182. * Gets the current alpha mode
  124183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124184. * @returns the current alpha mode
  124185. */
  124186. getAlphaMode(): number;
  124187. setInt(uniform: WebGLUniformLocation, int: number): void;
  124188. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124189. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124190. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124191. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124192. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124193. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124194. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124195. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124196. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124197. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124198. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124199. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124200. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124201. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124202. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124203. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124204. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124205. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124206. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124207. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124208. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124209. wipeCaches(bruteForce?: boolean): void;
  124210. _createTexture(): WebGLTexture;
  124211. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124212. /**
  124213. * Usually called from Texture.ts.
  124214. * Passed information to create a WebGLTexture
  124215. * @param url defines a value which contains one of the following:
  124216. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124217. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124218. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124220. * @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)
  124221. * @param scene needed for loading to the correct scene
  124222. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124223. * @param onLoad optional callback to be called upon successful completion
  124224. * @param onError optional callback to be called upon failure
  124225. * @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
  124226. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124227. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124228. * @param forcedExtension defines the extension to use to pick the right loader
  124229. * @param mimeType defines an optional mime type
  124230. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124231. */
  124232. 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;
  124233. /**
  124234. * Creates a cube texture
  124235. * @param rootUrl defines the url where the files to load is located
  124236. * @param scene defines the current scene
  124237. * @param files defines the list of files to load (1 per face)
  124238. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124239. * @param onLoad defines an optional callback raised when the texture is loaded
  124240. * @param onError defines an optional callback raised if there is an issue to load the texture
  124241. * @param format defines the format of the data
  124242. * @param forcedExtension defines the extension to use to pick the right loader
  124243. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124244. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124245. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124246. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124247. * @returns the cube texture as an InternalTexture
  124248. */
  124249. 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;
  124250. private _getSamplingFilter;
  124251. private static _GetNativeTextureFormat;
  124252. createRenderTargetTexture(size: number | {
  124253. width: number;
  124254. height: number;
  124255. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124256. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124257. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124258. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124259. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124260. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124261. /**
  124262. * Updates a dynamic vertex buffer.
  124263. * @param vertexBuffer the vertex buffer to update
  124264. * @param data the data used to update the vertex buffer
  124265. * @param byteOffset the byte offset of the data (optional)
  124266. * @param byteLength the byte length of the data (optional)
  124267. */
  124268. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124269. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124270. private _updateAnisotropicLevel;
  124271. private _getAddressMode;
  124272. /** @hidden */
  124273. _bindTexture(channel: number, texture: InternalTexture): void;
  124274. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124275. releaseEffects(): void;
  124276. /** @hidden */
  124277. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124278. /** @hidden */
  124279. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124280. /** @hidden */
  124281. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124282. /** @hidden */
  124283. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124284. }
  124285. }
  124286. declare module BABYLON {
  124287. /**
  124288. * Gather the list of clipboard event types as constants.
  124289. */
  124290. export class ClipboardEventTypes {
  124291. /**
  124292. * The clipboard event is fired when a copy command is active (pressed).
  124293. */
  124294. static readonly COPY: number;
  124295. /**
  124296. * The clipboard event is fired when a cut command is active (pressed).
  124297. */
  124298. static readonly CUT: number;
  124299. /**
  124300. * The clipboard event is fired when a paste command is active (pressed).
  124301. */
  124302. static readonly PASTE: number;
  124303. }
  124304. /**
  124305. * This class is used to store clipboard related info for the onClipboardObservable event.
  124306. */
  124307. export class ClipboardInfo {
  124308. /**
  124309. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124310. */
  124311. type: number;
  124312. /**
  124313. * Defines the related dom event
  124314. */
  124315. event: ClipboardEvent;
  124316. /**
  124317. *Creates an instance of ClipboardInfo.
  124318. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124319. * @param event Defines the related dom event
  124320. */
  124321. constructor(
  124322. /**
  124323. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124324. */
  124325. type: number,
  124326. /**
  124327. * Defines the related dom event
  124328. */
  124329. event: ClipboardEvent);
  124330. /**
  124331. * Get the clipboard event's type from the keycode.
  124332. * @param keyCode Defines the keyCode for the current keyboard event.
  124333. * @return {number}
  124334. */
  124335. static GetTypeFromCharacter(keyCode: number): number;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /**
  124340. * Google Daydream controller
  124341. */
  124342. export class DaydreamController extends WebVRController {
  124343. /**
  124344. * Base Url for the controller model.
  124345. */
  124346. static MODEL_BASE_URL: string;
  124347. /**
  124348. * File name for the controller model.
  124349. */
  124350. static MODEL_FILENAME: string;
  124351. /**
  124352. * Gamepad Id prefix used to identify Daydream Controller.
  124353. */
  124354. static readonly GAMEPAD_ID_PREFIX: string;
  124355. /**
  124356. * Creates a new DaydreamController from a gamepad
  124357. * @param vrGamepad the gamepad that the controller should be created from
  124358. */
  124359. constructor(vrGamepad: any);
  124360. /**
  124361. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124362. * @param scene scene in which to add meshes
  124363. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124364. */
  124365. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124366. /**
  124367. * Called once for each button that changed state since the last frame
  124368. * @param buttonIdx Which button index changed
  124369. * @param state New state of the button
  124370. * @param changes Which properties on the state changed since last frame
  124371. */
  124372. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Gear VR Controller
  124378. */
  124379. export class GearVRController extends WebVRController {
  124380. /**
  124381. * Base Url for the controller model.
  124382. */
  124383. static MODEL_BASE_URL: string;
  124384. /**
  124385. * File name for the controller model.
  124386. */
  124387. static MODEL_FILENAME: string;
  124388. /**
  124389. * Gamepad Id prefix used to identify this controller.
  124390. */
  124391. static readonly GAMEPAD_ID_PREFIX: string;
  124392. private readonly _buttonIndexToObservableNameMap;
  124393. /**
  124394. * Creates a new GearVRController from a gamepad
  124395. * @param vrGamepad the gamepad that the controller should be created from
  124396. */
  124397. constructor(vrGamepad: any);
  124398. /**
  124399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124400. * @param scene scene in which to add meshes
  124401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124402. */
  124403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124404. /**
  124405. * Called once for each button that changed state since the last frame
  124406. * @param buttonIdx Which button index changed
  124407. * @param state New state of the button
  124408. * @param changes Which properties on the state changed since last frame
  124409. */
  124410. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124411. }
  124412. }
  124413. declare module BABYLON {
  124414. /**
  124415. * Generic Controller
  124416. */
  124417. export class GenericController extends WebVRController {
  124418. /**
  124419. * Base Url for the controller model.
  124420. */
  124421. static readonly MODEL_BASE_URL: string;
  124422. /**
  124423. * File name for the controller model.
  124424. */
  124425. static readonly MODEL_FILENAME: string;
  124426. /**
  124427. * Creates a new GenericController from a gamepad
  124428. * @param vrGamepad the gamepad that the controller should be created from
  124429. */
  124430. constructor(vrGamepad: any);
  124431. /**
  124432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124433. * @param scene scene in which to add meshes
  124434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124435. */
  124436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124437. /**
  124438. * Called once for each button that changed state since the last frame
  124439. * @param buttonIdx Which button index changed
  124440. * @param state New state of the button
  124441. * @param changes Which properties on the state changed since last frame
  124442. */
  124443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124444. }
  124445. }
  124446. declare module BABYLON {
  124447. /**
  124448. * Oculus Touch Controller
  124449. */
  124450. export class OculusTouchController extends WebVRController {
  124451. /**
  124452. * Base Url for the controller model.
  124453. */
  124454. static MODEL_BASE_URL: string;
  124455. /**
  124456. * File name for the left controller model.
  124457. */
  124458. static MODEL_LEFT_FILENAME: string;
  124459. /**
  124460. * File name for the right controller model.
  124461. */
  124462. static MODEL_RIGHT_FILENAME: string;
  124463. /**
  124464. * Base Url for the Quest controller model.
  124465. */
  124466. static QUEST_MODEL_BASE_URL: string;
  124467. /**
  124468. * @hidden
  124469. * If the controllers are running on a device that needs the updated Quest controller models
  124470. */
  124471. static _IsQuest: boolean;
  124472. /**
  124473. * Fired when the secondary trigger on this controller is modified
  124474. */
  124475. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124476. /**
  124477. * Fired when the thumb rest on this controller is modified
  124478. */
  124479. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124480. /**
  124481. * Creates a new OculusTouchController from a gamepad
  124482. * @param vrGamepad the gamepad that the controller should be created from
  124483. */
  124484. constructor(vrGamepad: any);
  124485. /**
  124486. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124487. * @param scene scene in which to add meshes
  124488. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124489. */
  124490. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124491. /**
  124492. * Fired when the A button on this controller is modified
  124493. */
  124494. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124495. /**
  124496. * Fired when the B button on this controller is modified
  124497. */
  124498. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124499. /**
  124500. * Fired when the X button on this controller is modified
  124501. */
  124502. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124503. /**
  124504. * Fired when the Y button on this controller is modified
  124505. */
  124506. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124507. /**
  124508. * Called once for each button that changed state since the last frame
  124509. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124510. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124511. * 2) secondary trigger (same)
  124512. * 3) A (right) X (left), touch, pressed = value
  124513. * 4) B / Y
  124514. * 5) thumb rest
  124515. * @param buttonIdx Which button index changed
  124516. * @param state New state of the button
  124517. * @param changes Which properties on the state changed since last frame
  124518. */
  124519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124520. }
  124521. }
  124522. declare module BABYLON {
  124523. /**
  124524. * Vive Controller
  124525. */
  124526. export class ViveController extends WebVRController {
  124527. /**
  124528. * Base Url for the controller model.
  124529. */
  124530. static MODEL_BASE_URL: string;
  124531. /**
  124532. * File name for the controller model.
  124533. */
  124534. static MODEL_FILENAME: string;
  124535. /**
  124536. * Creates a new ViveController from a gamepad
  124537. * @param vrGamepad the gamepad that the controller should be created from
  124538. */
  124539. constructor(vrGamepad: any);
  124540. /**
  124541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124542. * @param scene scene in which to add meshes
  124543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124544. */
  124545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124546. /**
  124547. * Fired when the left button on this controller is modified
  124548. */
  124549. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124550. /**
  124551. * Fired when the right button on this controller is modified
  124552. */
  124553. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124554. /**
  124555. * Fired when the menu button on this controller is modified
  124556. */
  124557. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124558. /**
  124559. * Called once for each button that changed state since the last frame
  124560. * Vive mapping:
  124561. * 0: touchpad
  124562. * 1: trigger
  124563. * 2: left AND right buttons
  124564. * 3: menu button
  124565. * @param buttonIdx Which button index changed
  124566. * @param state New state of the button
  124567. * @param changes Which properties on the state changed since last frame
  124568. */
  124569. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124570. }
  124571. }
  124572. declare module BABYLON {
  124573. /**
  124574. * Defines the WindowsMotionController object that the state of the windows motion controller
  124575. */
  124576. export class WindowsMotionController extends WebVRController {
  124577. /**
  124578. * The base url used to load the left and right controller models
  124579. */
  124580. static MODEL_BASE_URL: string;
  124581. /**
  124582. * The name of the left controller model file
  124583. */
  124584. static MODEL_LEFT_FILENAME: string;
  124585. /**
  124586. * The name of the right controller model file
  124587. */
  124588. static MODEL_RIGHT_FILENAME: string;
  124589. /**
  124590. * The controller name prefix for this controller type
  124591. */
  124592. static readonly GAMEPAD_ID_PREFIX: string;
  124593. /**
  124594. * The controller id pattern for this controller type
  124595. */
  124596. private static readonly GAMEPAD_ID_PATTERN;
  124597. private _loadedMeshInfo;
  124598. protected readonly _mapping: {
  124599. buttons: string[];
  124600. buttonMeshNames: {
  124601. trigger: string;
  124602. menu: string;
  124603. grip: string;
  124604. thumbstick: string;
  124605. trackpad: string;
  124606. };
  124607. buttonObservableNames: {
  124608. trigger: string;
  124609. menu: string;
  124610. grip: string;
  124611. thumbstick: string;
  124612. trackpad: string;
  124613. };
  124614. axisMeshNames: string[];
  124615. pointingPoseMeshName: string;
  124616. };
  124617. /**
  124618. * Fired when the trackpad on this controller is clicked
  124619. */
  124620. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124621. /**
  124622. * Fired when the trackpad on this controller is modified
  124623. */
  124624. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124625. /**
  124626. * The current x and y values of this controller's trackpad
  124627. */
  124628. trackpad: StickValues;
  124629. /**
  124630. * Creates a new WindowsMotionController from a gamepad
  124631. * @param vrGamepad the gamepad that the controller should be created from
  124632. */
  124633. constructor(vrGamepad: any);
  124634. /**
  124635. * Fired when the trigger on this controller is modified
  124636. */
  124637. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124638. /**
  124639. * Fired when the menu button on this controller is modified
  124640. */
  124641. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124642. /**
  124643. * Fired when the grip button on this controller is modified
  124644. */
  124645. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124646. /**
  124647. * Fired when the thumbstick button on this controller is modified
  124648. */
  124649. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124650. /**
  124651. * Fired when the touchpad button on this controller is modified
  124652. */
  124653. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124654. /**
  124655. * Fired when the touchpad values on this controller are modified
  124656. */
  124657. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124658. protected _updateTrackpad(): void;
  124659. /**
  124660. * Called once per frame by the engine.
  124661. */
  124662. update(): void;
  124663. /**
  124664. * Called once for each button that changed state since the last frame
  124665. * @param buttonIdx Which button index changed
  124666. * @param state New state of the button
  124667. * @param changes Which properties on the state changed since last frame
  124668. */
  124669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124670. /**
  124671. * Moves the buttons on the controller mesh based on their current state
  124672. * @param buttonName the name of the button to move
  124673. * @param buttonValue the value of the button which determines the buttons new position
  124674. */
  124675. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124676. /**
  124677. * Moves the axis on the controller mesh based on its current state
  124678. * @param axis the index of the axis
  124679. * @param axisValue the value of the axis which determines the meshes new position
  124680. * @hidden
  124681. */
  124682. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124683. /**
  124684. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124685. * @param scene scene in which to add meshes
  124686. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124687. */
  124688. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124689. /**
  124690. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124691. * can be transformed by button presses and axes values, based on this._mapping.
  124692. *
  124693. * @param scene scene in which the meshes exist
  124694. * @param meshes list of meshes that make up the controller model to process
  124695. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124696. */
  124697. private processModel;
  124698. private createMeshInfo;
  124699. /**
  124700. * Gets the ray of the controller in the direction the controller is pointing
  124701. * @param length the length the resulting ray should be
  124702. * @returns a ray in the direction the controller is pointing
  124703. */
  124704. getForwardRay(length?: number): Ray;
  124705. /**
  124706. * Disposes of the controller
  124707. */
  124708. dispose(): void;
  124709. }
  124710. /**
  124711. * This class represents a new windows motion controller in XR.
  124712. */
  124713. export class XRWindowsMotionController extends WindowsMotionController {
  124714. /**
  124715. * Changing the original WIndowsMotionController mapping to fir the new mapping
  124716. */
  124717. protected readonly _mapping: {
  124718. buttons: string[];
  124719. buttonMeshNames: {
  124720. trigger: string;
  124721. menu: string;
  124722. grip: string;
  124723. thumbstick: string;
  124724. trackpad: string;
  124725. };
  124726. buttonObservableNames: {
  124727. trigger: string;
  124728. menu: string;
  124729. grip: string;
  124730. thumbstick: string;
  124731. trackpad: string;
  124732. };
  124733. axisMeshNames: string[];
  124734. pointingPoseMeshName: string;
  124735. };
  124736. /**
  124737. * Construct a new XR-Based windows motion controller
  124738. *
  124739. * @param gamepadInfo the gamepad object from the browser
  124740. */
  124741. constructor(gamepadInfo: any);
  124742. /**
  124743. * holds the thumbstick values (X,Y)
  124744. */
  124745. thumbstickValues: StickValues;
  124746. /**
  124747. * Fired when the thumbstick on this controller is clicked
  124748. */
  124749. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  124750. /**
  124751. * Fired when the thumbstick on this controller is modified
  124752. */
  124753. onThumbstickValuesChangedObservable: Observable<StickValues>;
  124754. /**
  124755. * Fired when the touchpad button on this controller is modified
  124756. */
  124757. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124758. /**
  124759. * Fired when the touchpad values on this controller are modified
  124760. */
  124761. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124762. /**
  124763. * Fired when the thumbstick button on this controller is modified
  124764. * here to prevent breaking changes
  124765. */
  124766. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124767. /**
  124768. * updating the thumbstick(!) and not the trackpad.
  124769. * This is named this way due to the difference between WebVR and XR and to avoid
  124770. * changing the parent class.
  124771. */
  124772. protected _updateTrackpad(): void;
  124773. /**
  124774. * Disposes the class with joy
  124775. */
  124776. dispose(): void;
  124777. }
  124778. }
  124779. declare module BABYLON {
  124780. /**
  124781. * Class containing static functions to help procedurally build meshes
  124782. */
  124783. export class PolyhedronBuilder {
  124784. /**
  124785. * Creates a polyhedron mesh
  124786. * * 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
  124787. * * The parameter `size` (positive float, default 1) sets the polygon size
  124788. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124789. * * 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`
  124790. * * 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
  124791. * * 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)`)
  124792. * * 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
  124793. * * 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
  124794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124797. * @param name defines the name of the mesh
  124798. * @param options defines the options used to create the mesh
  124799. * @param scene defines the hosting scene
  124800. * @returns the polyhedron mesh
  124801. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124802. */
  124803. static CreatePolyhedron(name: string, options: {
  124804. type?: number;
  124805. size?: number;
  124806. sizeX?: number;
  124807. sizeY?: number;
  124808. sizeZ?: number;
  124809. custom?: any;
  124810. faceUV?: Vector4[];
  124811. faceColors?: Color4[];
  124812. flat?: boolean;
  124813. updatable?: boolean;
  124814. sideOrientation?: number;
  124815. frontUVs?: Vector4;
  124816. backUVs?: Vector4;
  124817. }, scene?: Nullable<Scene>): Mesh;
  124818. }
  124819. }
  124820. declare module BABYLON {
  124821. /**
  124822. * Gizmo that enables scaling a mesh along 3 axis
  124823. */
  124824. export class ScaleGizmo extends Gizmo {
  124825. /**
  124826. * Internal gizmo used for interactions on the x axis
  124827. */
  124828. xGizmo: AxisScaleGizmo;
  124829. /**
  124830. * Internal gizmo used for interactions on the y axis
  124831. */
  124832. yGizmo: AxisScaleGizmo;
  124833. /**
  124834. * Internal gizmo used for interactions on the z axis
  124835. */
  124836. zGizmo: AxisScaleGizmo;
  124837. /**
  124838. * Internal gizmo used to scale all axis equally
  124839. */
  124840. uniformScaleGizmo: AxisScaleGizmo;
  124841. private _meshAttached;
  124842. private _updateGizmoRotationToMatchAttachedMesh;
  124843. private _snapDistance;
  124844. private _scaleRatio;
  124845. private _uniformScalingMesh;
  124846. private _octahedron;
  124847. private _sensitivity;
  124848. /** Fires an event when any of it's sub gizmos are dragged */
  124849. onDragStartObservable: Observable<unknown>;
  124850. /** Fires an event when any of it's sub gizmos are released from dragging */
  124851. onDragEndObservable: Observable<unknown>;
  124852. get attachedMesh(): Nullable<AbstractMesh>;
  124853. set attachedMesh(mesh: Nullable<AbstractMesh>);
  124854. /**
  124855. * Creates a ScaleGizmo
  124856. * @param gizmoLayer The utility layer the gizmo will be added to
  124857. */
  124858. constructor(gizmoLayer?: UtilityLayerRenderer);
  124859. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  124860. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  124861. /**
  124862. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124863. */
  124864. set snapDistance(value: number);
  124865. get snapDistance(): number;
  124866. /**
  124867. * Ratio for the scale of the gizmo (Default: 1)
  124868. */
  124869. set scaleRatio(value: number);
  124870. get scaleRatio(): number;
  124871. /**
  124872. * Sensitivity factor for dragging (Default: 1)
  124873. */
  124874. set sensitivity(value: number);
  124875. get sensitivity(): number;
  124876. /**
  124877. * Disposes of the gizmo
  124878. */
  124879. dispose(): void;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. /**
  124884. * Single axis scale gizmo
  124885. */
  124886. export class AxisScaleGizmo extends Gizmo {
  124887. /**
  124888. * Drag behavior responsible for the gizmos dragging interactions
  124889. */
  124890. dragBehavior: PointerDragBehavior;
  124891. private _pointerObserver;
  124892. /**
  124893. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124894. */
  124895. snapDistance: number;
  124896. /**
  124897. * Event that fires each time the gizmo snaps to a new location.
  124898. * * snapDistance is the the change in distance
  124899. */
  124900. onSnapObservable: Observable<{
  124901. snapDistance: number;
  124902. }>;
  124903. /**
  124904. * If the scaling operation should be done on all axis (default: false)
  124905. */
  124906. uniformScaling: boolean;
  124907. /**
  124908. * Custom sensitivity value for the drag strength
  124909. */
  124910. sensitivity: number;
  124911. private _isEnabled;
  124912. private _parent;
  124913. private _arrow;
  124914. private _coloredMaterial;
  124915. private _hoverMaterial;
  124916. /**
  124917. * Creates an AxisScaleGizmo
  124918. * @param gizmoLayer The utility layer the gizmo will be added to
  124919. * @param dragAxis The axis which the gizmo will be able to scale on
  124920. * @param color The color of the gizmo
  124921. */
  124922. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  124923. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  124924. /**
  124925. * If the gizmo is enabled
  124926. */
  124927. set isEnabled(value: boolean);
  124928. get isEnabled(): boolean;
  124929. /**
  124930. * Disposes of the gizmo
  124931. */
  124932. dispose(): void;
  124933. /**
  124934. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  124935. * @param mesh The mesh to replace the default mesh of the gizmo
  124936. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  124937. */
  124938. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  124939. }
  124940. }
  124941. declare module BABYLON {
  124942. /**
  124943. * Bounding box gizmo
  124944. */
  124945. export class BoundingBoxGizmo extends Gizmo {
  124946. private _lineBoundingBox;
  124947. private _rotateSpheresParent;
  124948. private _scaleBoxesParent;
  124949. private _boundingDimensions;
  124950. private _renderObserver;
  124951. private _pointerObserver;
  124952. private _scaleDragSpeed;
  124953. private _tmpQuaternion;
  124954. private _tmpVector;
  124955. private _tmpRotationMatrix;
  124956. /**
  124957. * 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)
  124958. */
  124959. ignoreChildren: boolean;
  124960. /**
  124961. * 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)
  124962. */
  124963. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  124964. /**
  124965. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  124966. */
  124967. rotationSphereSize: number;
  124968. /**
  124969. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  124970. */
  124971. scaleBoxSize: number;
  124972. /**
  124973. * 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)
  124974. */
  124975. fixedDragMeshScreenSize: boolean;
  124976. /**
  124977. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  124978. */
  124979. fixedDragMeshScreenSizeDistanceFactor: number;
  124980. /**
  124981. * Fired when a rotation sphere or scale box is dragged
  124982. */
  124983. onDragStartObservable: Observable<{}>;
  124984. /**
  124985. * Fired when a scale box is dragged
  124986. */
  124987. onScaleBoxDragObservable: Observable<{}>;
  124988. /**
  124989. * Fired when a scale box drag is ended
  124990. */
  124991. onScaleBoxDragEndObservable: Observable<{}>;
  124992. /**
  124993. * Fired when a rotation sphere is dragged
  124994. */
  124995. onRotationSphereDragObservable: Observable<{}>;
  124996. /**
  124997. * Fired when a rotation sphere drag is ended
  124998. */
  124999. onRotationSphereDragEndObservable: Observable<{}>;
  125000. /**
  125001. * 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)
  125002. */
  125003. scalePivot: Nullable<Vector3>;
  125004. /**
  125005. * Mesh used as a pivot to rotate the attached mesh
  125006. */
  125007. private _anchorMesh;
  125008. private _existingMeshScale;
  125009. private _dragMesh;
  125010. private pointerDragBehavior;
  125011. private coloredMaterial;
  125012. private hoverColoredMaterial;
  125013. /**
  125014. * Sets the color of the bounding box gizmo
  125015. * @param color the color to set
  125016. */
  125017. setColor(color: Color3): void;
  125018. /**
  125019. * Creates an BoundingBoxGizmo
  125020. * @param gizmoLayer The utility layer the gizmo will be added to
  125021. * @param color The color of the gizmo
  125022. */
  125023. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125024. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125025. private _selectNode;
  125026. /**
  125027. * Updates the bounding box information for the Gizmo
  125028. */
  125029. updateBoundingBox(): void;
  125030. private _updateRotationSpheres;
  125031. private _updateScaleBoxes;
  125032. /**
  125033. * Enables rotation on the specified axis and disables rotation on the others
  125034. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125035. */
  125036. setEnabledRotationAxis(axis: string): void;
  125037. /**
  125038. * Enables/disables scaling
  125039. * @param enable if scaling should be enabled
  125040. * @param homogeneousScaling defines if scaling should only be homogeneous
  125041. */
  125042. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125043. private _updateDummy;
  125044. /**
  125045. * Enables a pointer drag behavior on the bounding box of the gizmo
  125046. */
  125047. enableDragBehavior(): void;
  125048. /**
  125049. * Disposes of the gizmo
  125050. */
  125051. dispose(): void;
  125052. /**
  125053. * 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)
  125054. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125055. * @returns the bounding box mesh with the passed in mesh as a child
  125056. */
  125057. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125058. /**
  125059. * CustomMeshes are not supported by this gizmo
  125060. * @param mesh The mesh to replace the default mesh of the gizmo
  125061. */
  125062. setCustomMesh(mesh: Mesh): void;
  125063. }
  125064. }
  125065. declare module BABYLON {
  125066. /**
  125067. * Single plane rotation gizmo
  125068. */
  125069. export class PlaneRotationGizmo extends Gizmo {
  125070. /**
  125071. * Drag behavior responsible for the gizmos dragging interactions
  125072. */
  125073. dragBehavior: PointerDragBehavior;
  125074. private _pointerObserver;
  125075. /**
  125076. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125077. */
  125078. snapDistance: number;
  125079. /**
  125080. * Event that fires each time the gizmo snaps to a new location.
  125081. * * snapDistance is the the change in distance
  125082. */
  125083. onSnapObservable: Observable<{
  125084. snapDistance: number;
  125085. }>;
  125086. private _isEnabled;
  125087. private _parent;
  125088. /**
  125089. * Creates a PlaneRotationGizmo
  125090. * @param gizmoLayer The utility layer the gizmo will be added to
  125091. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125092. * @param color The color of the gizmo
  125093. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125094. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125095. */
  125096. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125097. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125098. /**
  125099. * If the gizmo is enabled
  125100. */
  125101. set isEnabled(value: boolean);
  125102. get isEnabled(): boolean;
  125103. /**
  125104. * Disposes of the gizmo
  125105. */
  125106. dispose(): void;
  125107. }
  125108. }
  125109. declare module BABYLON {
  125110. /**
  125111. * Gizmo that enables rotating a mesh along 3 axis
  125112. */
  125113. export class RotationGizmo extends Gizmo {
  125114. /**
  125115. * Internal gizmo used for interactions on the x axis
  125116. */
  125117. xGizmo: PlaneRotationGizmo;
  125118. /**
  125119. * Internal gizmo used for interactions on the y axis
  125120. */
  125121. yGizmo: PlaneRotationGizmo;
  125122. /**
  125123. * Internal gizmo used for interactions on the z axis
  125124. */
  125125. zGizmo: PlaneRotationGizmo;
  125126. /** Fires an event when any of it's sub gizmos are dragged */
  125127. onDragStartObservable: Observable<unknown>;
  125128. /** Fires an event when any of it's sub gizmos are released from dragging */
  125129. onDragEndObservable: Observable<unknown>;
  125130. private _meshAttached;
  125131. get attachedMesh(): Nullable<AbstractMesh>;
  125132. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125133. /**
  125134. * Creates a RotationGizmo
  125135. * @param gizmoLayer The utility layer the gizmo will be added to
  125136. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125137. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125138. */
  125139. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125140. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125141. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125142. /**
  125143. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125144. */
  125145. set snapDistance(value: number);
  125146. get snapDistance(): number;
  125147. /**
  125148. * Ratio for the scale of the gizmo (Default: 1)
  125149. */
  125150. set scaleRatio(value: number);
  125151. get scaleRatio(): number;
  125152. /**
  125153. * Disposes of the gizmo
  125154. */
  125155. dispose(): void;
  125156. /**
  125157. * CustomMeshes are not supported by this gizmo
  125158. * @param mesh The mesh to replace the default mesh of the gizmo
  125159. */
  125160. setCustomMesh(mesh: Mesh): void;
  125161. }
  125162. }
  125163. declare module BABYLON {
  125164. /**
  125165. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125166. */
  125167. export class GizmoManager implements IDisposable {
  125168. private scene;
  125169. /**
  125170. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125171. */
  125172. gizmos: {
  125173. positionGizmo: Nullable<PositionGizmo>;
  125174. rotationGizmo: Nullable<RotationGizmo>;
  125175. scaleGizmo: Nullable<ScaleGizmo>;
  125176. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125177. };
  125178. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125179. clearGizmoOnEmptyPointerEvent: boolean;
  125180. /** Fires an event when the manager is attached to a mesh */
  125181. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125182. private _gizmosEnabled;
  125183. private _pointerObserver;
  125184. private _attachedMesh;
  125185. private _boundingBoxColor;
  125186. private _defaultUtilityLayer;
  125187. private _defaultKeepDepthUtilityLayer;
  125188. /**
  125189. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125190. */
  125191. boundingBoxDragBehavior: SixDofDragBehavior;
  125192. /**
  125193. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125194. */
  125195. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125196. /**
  125197. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125198. */
  125199. usePointerToAttachGizmos: boolean;
  125200. /**
  125201. * Utility layer that the bounding box gizmo belongs to
  125202. */
  125203. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125204. /**
  125205. * Utility layer that all gizmos besides bounding box belong to
  125206. */
  125207. get utilityLayer(): UtilityLayerRenderer;
  125208. /**
  125209. * Instatiates a gizmo manager
  125210. * @param scene the scene to overlay the gizmos on top of
  125211. */
  125212. constructor(scene: Scene);
  125213. /**
  125214. * Attaches a set of gizmos to the specified mesh
  125215. * @param mesh The mesh the gizmo's should be attached to
  125216. */
  125217. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125218. /**
  125219. * If the position gizmo is enabled
  125220. */
  125221. set positionGizmoEnabled(value: boolean);
  125222. get positionGizmoEnabled(): boolean;
  125223. /**
  125224. * If the rotation gizmo is enabled
  125225. */
  125226. set rotationGizmoEnabled(value: boolean);
  125227. get rotationGizmoEnabled(): boolean;
  125228. /**
  125229. * If the scale gizmo is enabled
  125230. */
  125231. set scaleGizmoEnabled(value: boolean);
  125232. get scaleGizmoEnabled(): boolean;
  125233. /**
  125234. * If the boundingBox gizmo is enabled
  125235. */
  125236. set boundingBoxGizmoEnabled(value: boolean);
  125237. get boundingBoxGizmoEnabled(): boolean;
  125238. /**
  125239. * Disposes of the gizmo manager
  125240. */
  125241. dispose(): void;
  125242. }
  125243. }
  125244. declare module BABYLON {
  125245. /**
  125246. * A directional light is defined by a direction (what a surprise!).
  125247. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125248. * 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.
  125249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125250. */
  125251. export class DirectionalLight extends ShadowLight {
  125252. private _shadowFrustumSize;
  125253. /**
  125254. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125255. */
  125256. get shadowFrustumSize(): number;
  125257. /**
  125258. * Specifies a fix frustum size for the shadow generation.
  125259. */
  125260. set shadowFrustumSize(value: number);
  125261. private _shadowOrthoScale;
  125262. /**
  125263. * Gets the shadow projection scale against the optimal computed one.
  125264. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125265. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125266. */
  125267. get shadowOrthoScale(): number;
  125268. /**
  125269. * Sets the shadow projection scale against the optimal computed one.
  125270. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125271. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125272. */
  125273. set shadowOrthoScale(value: number);
  125274. /**
  125275. * Automatically compute the projection matrix to best fit (including all the casters)
  125276. * on each frame.
  125277. */
  125278. autoUpdateExtends: boolean;
  125279. /**
  125280. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125281. * on each frame. autoUpdateExtends must be set to true for this to work
  125282. */
  125283. autoCalcShadowZBounds: boolean;
  125284. private _orthoLeft;
  125285. private _orthoRight;
  125286. private _orthoTop;
  125287. private _orthoBottom;
  125288. /**
  125289. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125290. * The directional light is emitted from everywhere in the given direction.
  125291. * It can cast shadows.
  125292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125293. * @param name The friendly name of the light
  125294. * @param direction The direction of the light
  125295. * @param scene The scene the light belongs to
  125296. */
  125297. constructor(name: string, direction: Vector3, scene: Scene);
  125298. /**
  125299. * Returns the string "DirectionalLight".
  125300. * @return The class name
  125301. */
  125302. getClassName(): string;
  125303. /**
  125304. * Returns the integer 1.
  125305. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125306. */
  125307. getTypeID(): number;
  125308. /**
  125309. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125310. * Returns the DirectionalLight Shadow projection matrix.
  125311. */
  125312. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125313. /**
  125314. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125315. * Returns the DirectionalLight Shadow projection matrix.
  125316. */
  125317. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125318. /**
  125319. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125320. * Returns the DirectionalLight Shadow projection matrix.
  125321. */
  125322. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125323. protected _buildUniformLayout(): void;
  125324. /**
  125325. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125326. * @param effect The effect to update
  125327. * @param lightIndex The index of the light in the effect to update
  125328. * @returns The directional light
  125329. */
  125330. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125331. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125332. /**
  125333. * Gets the minZ used for shadow according to both the scene and the light.
  125334. *
  125335. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125336. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125337. * @param activeCamera The camera we are returning the min for
  125338. * @returns the depth min z
  125339. */
  125340. getDepthMinZ(activeCamera: Camera): number;
  125341. /**
  125342. * Gets the maxZ used for shadow according to both the scene and the light.
  125343. *
  125344. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125345. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125346. * @param activeCamera The camera we are returning the max for
  125347. * @returns the depth max z
  125348. */
  125349. getDepthMaxZ(activeCamera: Camera): number;
  125350. /**
  125351. * Prepares the list of defines specific to the light type.
  125352. * @param defines the list of defines
  125353. * @param lightIndex defines the index of the light for the effect
  125354. */
  125355. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125356. }
  125357. }
  125358. declare module BABYLON {
  125359. /**
  125360. * Class containing static functions to help procedurally build meshes
  125361. */
  125362. export class HemisphereBuilder {
  125363. /**
  125364. * Creates a hemisphere mesh
  125365. * @param name defines the name of the mesh
  125366. * @param options defines the options used to create the mesh
  125367. * @param scene defines the hosting scene
  125368. * @returns the hemisphere mesh
  125369. */
  125370. static CreateHemisphere(name: string, options: {
  125371. segments?: number;
  125372. diameter?: number;
  125373. sideOrientation?: number;
  125374. }, scene: any): Mesh;
  125375. }
  125376. }
  125377. declare module BABYLON {
  125378. /**
  125379. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125380. * These values define a cone of light starting from the position, emitting toward the direction.
  125381. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125382. * and the exponent defines the speed of the decay of the light with distance (reach).
  125383. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125384. */
  125385. export class SpotLight extends ShadowLight {
  125386. private _angle;
  125387. private _innerAngle;
  125388. private _cosHalfAngle;
  125389. private _lightAngleScale;
  125390. private _lightAngleOffset;
  125391. /**
  125392. * Gets the cone angle of the spot light in Radians.
  125393. */
  125394. get angle(): number;
  125395. /**
  125396. * Sets the cone angle of the spot light in Radians.
  125397. */
  125398. set angle(value: number);
  125399. /**
  125400. * Only used in gltf falloff mode, this defines the angle where
  125401. * the directional falloff will start before cutting at angle which could be seen
  125402. * as outer angle.
  125403. */
  125404. get innerAngle(): number;
  125405. /**
  125406. * Only used in gltf falloff mode, this defines the angle where
  125407. * the directional falloff will start before cutting at angle which could be seen
  125408. * as outer angle.
  125409. */
  125410. set innerAngle(value: number);
  125411. private _shadowAngleScale;
  125412. /**
  125413. * Allows scaling the angle of the light for shadow generation only.
  125414. */
  125415. get shadowAngleScale(): number;
  125416. /**
  125417. * Allows scaling the angle of the light for shadow generation only.
  125418. */
  125419. set shadowAngleScale(value: number);
  125420. /**
  125421. * The light decay speed with the distance from the emission spot.
  125422. */
  125423. exponent: number;
  125424. private _projectionTextureMatrix;
  125425. /**
  125426. * Allows reading the projecton texture
  125427. */
  125428. get projectionTextureMatrix(): Matrix;
  125429. protected _projectionTextureLightNear: number;
  125430. /**
  125431. * Gets the near clip of the Spotlight for texture projection.
  125432. */
  125433. get projectionTextureLightNear(): number;
  125434. /**
  125435. * Sets the near clip of the Spotlight for texture projection.
  125436. */
  125437. set projectionTextureLightNear(value: number);
  125438. protected _projectionTextureLightFar: number;
  125439. /**
  125440. * Gets the far clip of the Spotlight for texture projection.
  125441. */
  125442. get projectionTextureLightFar(): number;
  125443. /**
  125444. * Sets the far clip of the Spotlight for texture projection.
  125445. */
  125446. set projectionTextureLightFar(value: number);
  125447. protected _projectionTextureUpDirection: Vector3;
  125448. /**
  125449. * Gets the Up vector of the Spotlight for texture projection.
  125450. */
  125451. get projectionTextureUpDirection(): Vector3;
  125452. /**
  125453. * Sets the Up vector of the Spotlight for texture projection.
  125454. */
  125455. set projectionTextureUpDirection(value: Vector3);
  125456. private _projectionTexture;
  125457. /**
  125458. * Gets the projection texture of the light.
  125459. */
  125460. get projectionTexture(): Nullable<BaseTexture>;
  125461. /**
  125462. * Sets the projection texture of the light.
  125463. */
  125464. set projectionTexture(value: Nullable<BaseTexture>);
  125465. private _projectionTextureViewLightDirty;
  125466. private _projectionTextureProjectionLightDirty;
  125467. private _projectionTextureDirty;
  125468. private _projectionTextureViewTargetVector;
  125469. private _projectionTextureViewLightMatrix;
  125470. private _projectionTextureProjectionLightMatrix;
  125471. private _projectionTextureScalingMatrix;
  125472. /**
  125473. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125474. * It can cast shadows.
  125475. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125476. * @param name The light friendly name
  125477. * @param position The position of the spot light in the scene
  125478. * @param direction The direction of the light in the scene
  125479. * @param angle The cone angle of the light in Radians
  125480. * @param exponent The light decay speed with the distance from the emission spot
  125481. * @param scene The scene the lights belongs to
  125482. */
  125483. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125484. /**
  125485. * Returns the string "SpotLight".
  125486. * @returns the class name
  125487. */
  125488. getClassName(): string;
  125489. /**
  125490. * Returns the integer 2.
  125491. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125492. */
  125493. getTypeID(): number;
  125494. /**
  125495. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125496. */
  125497. protected _setDirection(value: Vector3): void;
  125498. /**
  125499. * Overrides the position setter to recompute the projection texture view light Matrix.
  125500. */
  125501. protected _setPosition(value: Vector3): void;
  125502. /**
  125503. * 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.
  125504. * Returns the SpotLight.
  125505. */
  125506. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125507. protected _computeProjectionTextureViewLightMatrix(): void;
  125508. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125509. /**
  125510. * Main function for light texture projection matrix computing.
  125511. */
  125512. protected _computeProjectionTextureMatrix(): void;
  125513. protected _buildUniformLayout(): void;
  125514. private _computeAngleValues;
  125515. /**
  125516. * Sets the passed Effect "effect" with the Light textures.
  125517. * @param effect The effect to update
  125518. * @param lightIndex The index of the light in the effect to update
  125519. * @returns The light
  125520. */
  125521. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125522. /**
  125523. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125524. * @param effect The effect to update
  125525. * @param lightIndex The index of the light in the effect to update
  125526. * @returns The spot light
  125527. */
  125528. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125529. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125530. /**
  125531. * Disposes the light and the associated resources.
  125532. */
  125533. dispose(): void;
  125534. /**
  125535. * Prepares the list of defines specific to the light type.
  125536. * @param defines the list of defines
  125537. * @param lightIndex defines the index of the light for the effect
  125538. */
  125539. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125540. }
  125541. }
  125542. declare module BABYLON {
  125543. /**
  125544. * Gizmo that enables viewing a light
  125545. */
  125546. export class LightGizmo extends Gizmo {
  125547. private _lightMesh;
  125548. private _material;
  125549. private _cachedPosition;
  125550. private _cachedForward;
  125551. private _attachedMeshParent;
  125552. /**
  125553. * Creates a LightGizmo
  125554. * @param gizmoLayer The utility layer the gizmo will be added to
  125555. */
  125556. constructor(gizmoLayer?: UtilityLayerRenderer);
  125557. private _light;
  125558. /**
  125559. * The light that the gizmo is attached to
  125560. */
  125561. set light(light: Nullable<Light>);
  125562. get light(): Nullable<Light>;
  125563. /**
  125564. * Gets the material used to render the light gizmo
  125565. */
  125566. get material(): StandardMaterial;
  125567. /**
  125568. * @hidden
  125569. * Updates the gizmo to match the attached mesh's position/rotation
  125570. */
  125571. protected _update(): void;
  125572. private static _Scale;
  125573. /**
  125574. * Creates the lines for a light mesh
  125575. */
  125576. private static _CreateLightLines;
  125577. /**
  125578. * Disposes of the light gizmo
  125579. */
  125580. dispose(): void;
  125581. private static _CreateHemisphericLightMesh;
  125582. private static _CreatePointLightMesh;
  125583. private static _CreateSpotLightMesh;
  125584. private static _CreateDirectionalLightMesh;
  125585. }
  125586. }
  125587. declare module BABYLON {
  125588. /** @hidden */
  125589. export var backgroundFragmentDeclaration: {
  125590. name: string;
  125591. shader: string;
  125592. };
  125593. }
  125594. declare module BABYLON {
  125595. /** @hidden */
  125596. export var backgroundUboDeclaration: {
  125597. name: string;
  125598. shader: string;
  125599. };
  125600. }
  125601. declare module BABYLON {
  125602. /** @hidden */
  125603. export var backgroundPixelShader: {
  125604. name: string;
  125605. shader: string;
  125606. };
  125607. }
  125608. declare module BABYLON {
  125609. /** @hidden */
  125610. export var backgroundVertexDeclaration: {
  125611. name: string;
  125612. shader: string;
  125613. };
  125614. }
  125615. declare module BABYLON {
  125616. /** @hidden */
  125617. export var backgroundVertexShader: {
  125618. name: string;
  125619. shader: string;
  125620. };
  125621. }
  125622. declare module BABYLON {
  125623. /**
  125624. * Background material used to create an efficient environement around your scene.
  125625. */
  125626. export class BackgroundMaterial extends PushMaterial {
  125627. /**
  125628. * Standard reflectance value at parallel view angle.
  125629. */
  125630. static StandardReflectance0: number;
  125631. /**
  125632. * Standard reflectance value at grazing angle.
  125633. */
  125634. static StandardReflectance90: number;
  125635. protected _primaryColor: Color3;
  125636. /**
  125637. * Key light Color (multiply against the environement texture)
  125638. */
  125639. primaryColor: Color3;
  125640. protected __perceptualColor: Nullable<Color3>;
  125641. /**
  125642. * Experimental Internal Use Only.
  125643. *
  125644. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125645. * This acts as a helper to set the primary color to a more "human friendly" value.
  125646. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125647. * output color as close as possible from the chosen value.
  125648. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125649. * part of lighting setup.)
  125650. */
  125651. get _perceptualColor(): Nullable<Color3>;
  125652. set _perceptualColor(value: Nullable<Color3>);
  125653. protected _primaryColorShadowLevel: float;
  125654. /**
  125655. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125656. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125657. */
  125658. get primaryColorShadowLevel(): float;
  125659. set primaryColorShadowLevel(value: float);
  125660. protected _primaryColorHighlightLevel: float;
  125661. /**
  125662. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125663. * The primary color is used at the level chosen to define what the white area would look.
  125664. */
  125665. get primaryColorHighlightLevel(): float;
  125666. set primaryColorHighlightLevel(value: float);
  125667. protected _reflectionTexture: Nullable<BaseTexture>;
  125668. /**
  125669. * Reflection Texture used in the material.
  125670. * Should be author in a specific way for the best result (refer to the documentation).
  125671. */
  125672. reflectionTexture: Nullable<BaseTexture>;
  125673. protected _reflectionBlur: float;
  125674. /**
  125675. * Reflection Texture level of blur.
  125676. *
  125677. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125678. * texture twice.
  125679. */
  125680. reflectionBlur: float;
  125681. protected _diffuseTexture: Nullable<BaseTexture>;
  125682. /**
  125683. * Diffuse Texture used in the material.
  125684. * Should be author in a specific way for the best result (refer to the documentation).
  125685. */
  125686. diffuseTexture: Nullable<BaseTexture>;
  125687. protected _shadowLights: Nullable<IShadowLight[]>;
  125688. /**
  125689. * Specify the list of lights casting shadow on the material.
  125690. * All scene shadow lights will be included if null.
  125691. */
  125692. shadowLights: Nullable<IShadowLight[]>;
  125693. protected _shadowLevel: float;
  125694. /**
  125695. * Helps adjusting the shadow to a softer level if required.
  125696. * 0 means black shadows and 1 means no shadows.
  125697. */
  125698. shadowLevel: float;
  125699. protected _sceneCenter: Vector3;
  125700. /**
  125701. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125702. * It is usually zero but might be interesting to modify according to your setup.
  125703. */
  125704. sceneCenter: Vector3;
  125705. protected _opacityFresnel: boolean;
  125706. /**
  125707. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125708. * This helps ensuring a nice transition when the camera goes under the ground.
  125709. */
  125710. opacityFresnel: boolean;
  125711. protected _reflectionFresnel: boolean;
  125712. /**
  125713. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  125714. * This helps adding a mirror texture on the ground.
  125715. */
  125716. reflectionFresnel: boolean;
  125717. protected _reflectionFalloffDistance: number;
  125718. /**
  125719. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  125720. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  125721. */
  125722. reflectionFalloffDistance: number;
  125723. protected _reflectionAmount: number;
  125724. /**
  125725. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  125726. */
  125727. reflectionAmount: number;
  125728. protected _reflectionReflectance0: number;
  125729. /**
  125730. * This specifies the weight of the reflection at grazing angle.
  125731. */
  125732. reflectionReflectance0: number;
  125733. protected _reflectionReflectance90: number;
  125734. /**
  125735. * This specifies the weight of the reflection at a perpendicular point of view.
  125736. */
  125737. reflectionReflectance90: number;
  125738. /**
  125739. * Sets the reflection reflectance fresnel values according to the default standard
  125740. * empirically know to work well :-)
  125741. */
  125742. set reflectionStandardFresnelWeight(value: number);
  125743. protected _useRGBColor: boolean;
  125744. /**
  125745. * Helps to directly use the maps channels instead of their level.
  125746. */
  125747. useRGBColor: boolean;
  125748. protected _enableNoise: boolean;
  125749. /**
  125750. * This helps reducing the banding effect that could occur on the background.
  125751. */
  125752. enableNoise: boolean;
  125753. /**
  125754. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125755. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  125756. * Recommended to be keep at 1.0 except for special cases.
  125757. */
  125758. get fovMultiplier(): number;
  125759. set fovMultiplier(value: number);
  125760. private _fovMultiplier;
  125761. /**
  125762. * Enable the FOV adjustment feature controlled by fovMultiplier.
  125763. */
  125764. useEquirectangularFOV: boolean;
  125765. private _maxSimultaneousLights;
  125766. /**
  125767. * Number of Simultaneous lights allowed on the material.
  125768. */
  125769. maxSimultaneousLights: int;
  125770. /**
  125771. * Default configuration related to image processing available in the Background Material.
  125772. */
  125773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125774. /**
  125775. * Keep track of the image processing observer to allow dispose and replace.
  125776. */
  125777. private _imageProcessingObserver;
  125778. /**
  125779. * Attaches a new image processing configuration to the PBR Material.
  125780. * @param configuration (if null the scene configuration will be use)
  125781. */
  125782. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125783. /**
  125784. * Gets the image processing configuration used either in this material.
  125785. */
  125786. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  125787. /**
  125788. * Sets the Default image processing configuration used either in the this material.
  125789. *
  125790. * If sets to null, the scene one is in use.
  125791. */
  125792. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  125793. /**
  125794. * Gets wether the color curves effect is enabled.
  125795. */
  125796. get cameraColorCurvesEnabled(): boolean;
  125797. /**
  125798. * Sets wether the color curves effect is enabled.
  125799. */
  125800. set cameraColorCurvesEnabled(value: boolean);
  125801. /**
  125802. * Gets wether the color grading effect is enabled.
  125803. */
  125804. get cameraColorGradingEnabled(): boolean;
  125805. /**
  125806. * Gets wether the color grading effect is enabled.
  125807. */
  125808. set cameraColorGradingEnabled(value: boolean);
  125809. /**
  125810. * Gets wether tonemapping is enabled or not.
  125811. */
  125812. get cameraToneMappingEnabled(): boolean;
  125813. /**
  125814. * Sets wether tonemapping is enabled or not
  125815. */
  125816. set cameraToneMappingEnabled(value: boolean);
  125817. /**
  125818. * The camera exposure used on this material.
  125819. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125820. * This corresponds to a photographic exposure.
  125821. */
  125822. get cameraExposure(): float;
  125823. /**
  125824. * The camera exposure used on this material.
  125825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125826. * This corresponds to a photographic exposure.
  125827. */
  125828. set cameraExposure(value: float);
  125829. /**
  125830. * Gets The camera contrast used on this material.
  125831. */
  125832. get cameraContrast(): float;
  125833. /**
  125834. * Sets The camera contrast used on this material.
  125835. */
  125836. set cameraContrast(value: float);
  125837. /**
  125838. * Gets the Color Grading 2D Lookup Texture.
  125839. */
  125840. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125841. /**
  125842. * Sets the Color Grading 2D Lookup Texture.
  125843. */
  125844. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125845. /**
  125846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125848. * 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;
  125849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125850. */
  125851. get cameraColorCurves(): Nullable<ColorCurves>;
  125852. /**
  125853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125855. * 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;
  125856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125857. */
  125858. set cameraColorCurves(value: Nullable<ColorCurves>);
  125859. /**
  125860. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  125861. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  125862. */
  125863. switchToBGR: boolean;
  125864. private _renderTargets;
  125865. private _reflectionControls;
  125866. private _white;
  125867. private _primaryShadowColor;
  125868. private _primaryHighlightColor;
  125869. /**
  125870. * Instantiates a Background Material in the given scene
  125871. * @param name The friendly name of the material
  125872. * @param scene The scene to add the material to
  125873. */
  125874. constructor(name: string, scene: Scene);
  125875. /**
  125876. * Gets a boolean indicating that current material needs to register RTT
  125877. */
  125878. get hasRenderTargetTextures(): boolean;
  125879. /**
  125880. * The entire material has been created in order to prevent overdraw.
  125881. * @returns false
  125882. */
  125883. needAlphaTesting(): boolean;
  125884. /**
  125885. * The entire material has been created in order to prevent overdraw.
  125886. * @returns true if blending is enable
  125887. */
  125888. needAlphaBlending(): boolean;
  125889. /**
  125890. * Checks wether the material is ready to be rendered for a given mesh.
  125891. * @param mesh The mesh to render
  125892. * @param subMesh The submesh to check against
  125893. * @param useInstances Specify wether or not the material is used with instances
  125894. * @returns true if all the dependencies are ready (Textures, Effects...)
  125895. */
  125896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125897. /**
  125898. * Compute the primary color according to the chosen perceptual color.
  125899. */
  125900. private _computePrimaryColorFromPerceptualColor;
  125901. /**
  125902. * Compute the highlights and shadow colors according to their chosen levels.
  125903. */
  125904. private _computePrimaryColors;
  125905. /**
  125906. * Build the uniform buffer used in the material.
  125907. */
  125908. buildUniformLayout(): void;
  125909. /**
  125910. * Unbind the material.
  125911. */
  125912. unbind(): void;
  125913. /**
  125914. * Bind only the world matrix to the material.
  125915. * @param world The world matrix to bind.
  125916. */
  125917. bindOnlyWorldMatrix(world: Matrix): void;
  125918. /**
  125919. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  125920. * @param world The world matrix to bind.
  125921. * @param subMesh The submesh to bind for.
  125922. */
  125923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125924. /**
  125925. * Checks to see if a texture is used in the material.
  125926. * @param texture - Base texture to use.
  125927. * @returns - Boolean specifying if a texture is used in the material.
  125928. */
  125929. hasTexture(texture: BaseTexture): boolean;
  125930. /**
  125931. * Dispose the material.
  125932. * @param forceDisposeEffect Force disposal of the associated effect.
  125933. * @param forceDisposeTextures Force disposal of the associated textures.
  125934. */
  125935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125936. /**
  125937. * Clones the material.
  125938. * @param name The cloned name.
  125939. * @returns The cloned material.
  125940. */
  125941. clone(name: string): BackgroundMaterial;
  125942. /**
  125943. * Serializes the current material to its JSON representation.
  125944. * @returns The JSON representation.
  125945. */
  125946. serialize(): any;
  125947. /**
  125948. * Gets the class name of the material
  125949. * @returns "BackgroundMaterial"
  125950. */
  125951. getClassName(): string;
  125952. /**
  125953. * Parse a JSON input to create back a background material.
  125954. * @param source The JSON data to parse
  125955. * @param scene The scene to create the parsed material in
  125956. * @param rootUrl The root url of the assets the material depends upon
  125957. * @returns the instantiated BackgroundMaterial.
  125958. */
  125959. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  125960. }
  125961. }
  125962. declare module BABYLON {
  125963. /**
  125964. * Represents the different options available during the creation of
  125965. * a Environment helper.
  125966. *
  125967. * This can control the default ground, skybox and image processing setup of your scene.
  125968. */
  125969. export interface IEnvironmentHelperOptions {
  125970. /**
  125971. * Specifies whether or not to create a ground.
  125972. * True by default.
  125973. */
  125974. createGround: boolean;
  125975. /**
  125976. * Specifies the ground size.
  125977. * 15 by default.
  125978. */
  125979. groundSize: number;
  125980. /**
  125981. * The texture used on the ground for the main color.
  125982. * Comes from the BabylonJS CDN by default.
  125983. *
  125984. * Remarks: Can be either a texture or a url.
  125985. */
  125986. groundTexture: string | BaseTexture;
  125987. /**
  125988. * The color mixed in the ground texture by default.
  125989. * BabylonJS clearColor by default.
  125990. */
  125991. groundColor: Color3;
  125992. /**
  125993. * Specifies the ground opacity.
  125994. * 1 by default.
  125995. */
  125996. groundOpacity: number;
  125997. /**
  125998. * Enables the ground to receive shadows.
  125999. * True by default.
  126000. */
  126001. enableGroundShadow: boolean;
  126002. /**
  126003. * Helps preventing the shadow to be fully black on the ground.
  126004. * 0.5 by default.
  126005. */
  126006. groundShadowLevel: number;
  126007. /**
  126008. * Creates a mirror texture attach to the ground.
  126009. * false by default.
  126010. */
  126011. enableGroundMirror: boolean;
  126012. /**
  126013. * Specifies the ground mirror size ratio.
  126014. * 0.3 by default as the default kernel is 64.
  126015. */
  126016. groundMirrorSizeRatio: number;
  126017. /**
  126018. * Specifies the ground mirror blur kernel size.
  126019. * 64 by default.
  126020. */
  126021. groundMirrorBlurKernel: number;
  126022. /**
  126023. * Specifies the ground mirror visibility amount.
  126024. * 1 by default
  126025. */
  126026. groundMirrorAmount: number;
  126027. /**
  126028. * Specifies the ground mirror reflectance weight.
  126029. * This uses the standard weight of the background material to setup the fresnel effect
  126030. * of the mirror.
  126031. * 1 by default.
  126032. */
  126033. groundMirrorFresnelWeight: number;
  126034. /**
  126035. * Specifies the ground mirror Falloff distance.
  126036. * This can helps reducing the size of the reflection.
  126037. * 0 by Default.
  126038. */
  126039. groundMirrorFallOffDistance: number;
  126040. /**
  126041. * Specifies the ground mirror texture type.
  126042. * Unsigned Int by Default.
  126043. */
  126044. groundMirrorTextureType: number;
  126045. /**
  126046. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126047. * the shown objects.
  126048. */
  126049. groundYBias: number;
  126050. /**
  126051. * Specifies whether or not to create a skybox.
  126052. * True by default.
  126053. */
  126054. createSkybox: boolean;
  126055. /**
  126056. * Specifies the skybox size.
  126057. * 20 by default.
  126058. */
  126059. skyboxSize: number;
  126060. /**
  126061. * The texture used on the skybox for the main color.
  126062. * Comes from the BabylonJS CDN by default.
  126063. *
  126064. * Remarks: Can be either a texture or a url.
  126065. */
  126066. skyboxTexture: string | BaseTexture;
  126067. /**
  126068. * The color mixed in the skybox texture by default.
  126069. * BabylonJS clearColor by default.
  126070. */
  126071. skyboxColor: Color3;
  126072. /**
  126073. * The background rotation around the Y axis of the scene.
  126074. * This helps aligning the key lights of your scene with the background.
  126075. * 0 by default.
  126076. */
  126077. backgroundYRotation: number;
  126078. /**
  126079. * Compute automatically the size of the elements to best fit with the scene.
  126080. */
  126081. sizeAuto: boolean;
  126082. /**
  126083. * Default position of the rootMesh if autoSize is not true.
  126084. */
  126085. rootPosition: Vector3;
  126086. /**
  126087. * Sets up the image processing in the scene.
  126088. * true by default.
  126089. */
  126090. setupImageProcessing: boolean;
  126091. /**
  126092. * The texture used as your environment texture in the scene.
  126093. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126094. *
  126095. * Remarks: Can be either a texture or a url.
  126096. */
  126097. environmentTexture: string | BaseTexture;
  126098. /**
  126099. * The value of the exposure to apply to the scene.
  126100. * 0.6 by default if setupImageProcessing is true.
  126101. */
  126102. cameraExposure: number;
  126103. /**
  126104. * The value of the contrast to apply to the scene.
  126105. * 1.6 by default if setupImageProcessing is true.
  126106. */
  126107. cameraContrast: number;
  126108. /**
  126109. * Specifies whether or not tonemapping should be enabled in the scene.
  126110. * true by default if setupImageProcessing is true.
  126111. */
  126112. toneMappingEnabled: boolean;
  126113. }
  126114. /**
  126115. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126116. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126117. * It also helps with the default setup of your imageProcessing configuration.
  126118. */
  126119. export class EnvironmentHelper {
  126120. /**
  126121. * Default ground texture URL.
  126122. */
  126123. private static _groundTextureCDNUrl;
  126124. /**
  126125. * Default skybox texture URL.
  126126. */
  126127. private static _skyboxTextureCDNUrl;
  126128. /**
  126129. * Default environment texture URL.
  126130. */
  126131. private static _environmentTextureCDNUrl;
  126132. /**
  126133. * Creates the default options for the helper.
  126134. */
  126135. private static _getDefaultOptions;
  126136. private _rootMesh;
  126137. /**
  126138. * Gets the root mesh created by the helper.
  126139. */
  126140. get rootMesh(): Mesh;
  126141. private _skybox;
  126142. /**
  126143. * Gets the skybox created by the helper.
  126144. */
  126145. get skybox(): Nullable<Mesh>;
  126146. private _skyboxTexture;
  126147. /**
  126148. * Gets the skybox texture created by the helper.
  126149. */
  126150. get skyboxTexture(): Nullable<BaseTexture>;
  126151. private _skyboxMaterial;
  126152. /**
  126153. * Gets the skybox material created by the helper.
  126154. */
  126155. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126156. private _ground;
  126157. /**
  126158. * Gets the ground mesh created by the helper.
  126159. */
  126160. get ground(): Nullable<Mesh>;
  126161. private _groundTexture;
  126162. /**
  126163. * Gets the ground texture created by the helper.
  126164. */
  126165. get groundTexture(): Nullable<BaseTexture>;
  126166. private _groundMirror;
  126167. /**
  126168. * Gets the ground mirror created by the helper.
  126169. */
  126170. get groundMirror(): Nullable<MirrorTexture>;
  126171. /**
  126172. * Gets the ground mirror render list to helps pushing the meshes
  126173. * you wish in the ground reflection.
  126174. */
  126175. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126176. private _groundMaterial;
  126177. /**
  126178. * Gets the ground material created by the helper.
  126179. */
  126180. get groundMaterial(): Nullable<BackgroundMaterial>;
  126181. /**
  126182. * Stores the creation options.
  126183. */
  126184. private readonly _scene;
  126185. private _options;
  126186. /**
  126187. * This observable will be notified with any error during the creation of the environment,
  126188. * mainly texture creation errors.
  126189. */
  126190. onErrorObservable: Observable<{
  126191. message?: string;
  126192. exception?: any;
  126193. }>;
  126194. /**
  126195. * constructor
  126196. * @param options Defines the options we want to customize the helper
  126197. * @param scene The scene to add the material to
  126198. */
  126199. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126200. /**
  126201. * Updates the background according to the new options
  126202. * @param options
  126203. */
  126204. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126205. /**
  126206. * Sets the primary color of all the available elements.
  126207. * @param color the main color to affect to the ground and the background
  126208. */
  126209. setMainColor(color: Color3): void;
  126210. /**
  126211. * Setup the image processing according to the specified options.
  126212. */
  126213. private _setupImageProcessing;
  126214. /**
  126215. * Setup the environment texture according to the specified options.
  126216. */
  126217. private _setupEnvironmentTexture;
  126218. /**
  126219. * Setup the background according to the specified options.
  126220. */
  126221. private _setupBackground;
  126222. /**
  126223. * Get the scene sizes according to the setup.
  126224. */
  126225. private _getSceneSize;
  126226. /**
  126227. * Setup the ground according to the specified options.
  126228. */
  126229. private _setupGround;
  126230. /**
  126231. * Setup the ground material according to the specified options.
  126232. */
  126233. private _setupGroundMaterial;
  126234. /**
  126235. * Setup the ground diffuse texture according to the specified options.
  126236. */
  126237. private _setupGroundDiffuseTexture;
  126238. /**
  126239. * Setup the ground mirror texture according to the specified options.
  126240. */
  126241. private _setupGroundMirrorTexture;
  126242. /**
  126243. * Setup the ground to receive the mirror texture.
  126244. */
  126245. private _setupMirrorInGroundMaterial;
  126246. /**
  126247. * Setup the skybox according to the specified options.
  126248. */
  126249. private _setupSkybox;
  126250. /**
  126251. * Setup the skybox material according to the specified options.
  126252. */
  126253. private _setupSkyboxMaterial;
  126254. /**
  126255. * Setup the skybox reflection texture according to the specified options.
  126256. */
  126257. private _setupSkyboxReflectionTexture;
  126258. private _errorHandler;
  126259. /**
  126260. * Dispose all the elements created by the Helper.
  126261. */
  126262. dispose(): void;
  126263. }
  126264. }
  126265. declare module BABYLON {
  126266. /**
  126267. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126268. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126269. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126270. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126271. */
  126272. export class PhotoDome extends TransformNode {
  126273. /**
  126274. * Define the image as a Monoscopic panoramic 360 image.
  126275. */
  126276. static readonly MODE_MONOSCOPIC: number;
  126277. /**
  126278. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126279. */
  126280. static readonly MODE_TOPBOTTOM: number;
  126281. /**
  126282. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126283. */
  126284. static readonly MODE_SIDEBYSIDE: number;
  126285. private _useDirectMapping;
  126286. /**
  126287. * The texture being displayed on the sphere
  126288. */
  126289. protected _photoTexture: Texture;
  126290. /**
  126291. * Gets or sets the texture being displayed on the sphere
  126292. */
  126293. get photoTexture(): Texture;
  126294. set photoTexture(value: Texture);
  126295. /**
  126296. * Observable raised when an error occured while loading the 360 image
  126297. */
  126298. onLoadErrorObservable: Observable<string>;
  126299. /**
  126300. * The skybox material
  126301. */
  126302. protected _material: BackgroundMaterial;
  126303. /**
  126304. * The surface used for the skybox
  126305. */
  126306. protected _mesh: Mesh;
  126307. /**
  126308. * Gets the mesh used for the skybox.
  126309. */
  126310. get mesh(): Mesh;
  126311. /**
  126312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126313. * Also see the options.resolution property.
  126314. */
  126315. get fovMultiplier(): number;
  126316. set fovMultiplier(value: number);
  126317. private _imageMode;
  126318. /**
  126319. * Gets or set the current video mode for the video. It can be:
  126320. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126321. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126322. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126323. */
  126324. get imageMode(): number;
  126325. set imageMode(value: number);
  126326. /**
  126327. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126328. * @param name Element's name, child elements will append suffixes for their own names.
  126329. * @param urlsOfPhoto defines the url of the photo to display
  126330. * @param options defines an object containing optional or exposed sub element properties
  126331. * @param onError defines a callback called when an error occured while loading the texture
  126332. */
  126333. constructor(name: string, urlOfPhoto: string, options: {
  126334. resolution?: number;
  126335. size?: number;
  126336. useDirectMapping?: boolean;
  126337. faceForward?: boolean;
  126338. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126339. private _onBeforeCameraRenderObserver;
  126340. private _changeImageMode;
  126341. /**
  126342. * Releases resources associated with this node.
  126343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126345. */
  126346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126347. }
  126348. }
  126349. declare module BABYLON {
  126350. /**
  126351. * Class used to host RGBD texture specific utilities
  126352. */
  126353. export class RGBDTextureTools {
  126354. /**
  126355. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126356. * @param texture the texture to expand.
  126357. */
  126358. static ExpandRGBDTexture(texture: Texture): void;
  126359. }
  126360. }
  126361. declare module BABYLON {
  126362. /**
  126363. * Class used to host texture specific utilities
  126364. */
  126365. export class BRDFTextureTools {
  126366. /**
  126367. * Prevents texture cache collision
  126368. */
  126369. private static _instanceNumber;
  126370. /**
  126371. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126372. * @param scene defines the hosting scene
  126373. * @returns the environment BRDF texture
  126374. */
  126375. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126376. private static _environmentBRDFBase64Texture;
  126377. }
  126378. }
  126379. declare module BABYLON {
  126380. /**
  126381. * @hidden
  126382. */
  126383. export interface IMaterialClearCoatDefines {
  126384. CLEARCOAT: boolean;
  126385. CLEARCOAT_DEFAULTIOR: boolean;
  126386. CLEARCOAT_TEXTURE: boolean;
  126387. CLEARCOAT_TEXTUREDIRECTUV: number;
  126388. CLEARCOAT_BUMP: boolean;
  126389. CLEARCOAT_BUMPDIRECTUV: number;
  126390. CLEARCOAT_TINT: boolean;
  126391. CLEARCOAT_TINT_TEXTURE: boolean;
  126392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126393. /** @hidden */
  126394. _areTexturesDirty: boolean;
  126395. }
  126396. /**
  126397. * Define the code related to the clear coat parameters of the pbr material.
  126398. */
  126399. export class PBRClearCoatConfiguration {
  126400. /**
  126401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126402. * The default fits with a polyurethane material.
  126403. */
  126404. private static readonly _DefaultIndexOfRefraction;
  126405. private _isEnabled;
  126406. /**
  126407. * Defines if the clear coat is enabled in the material.
  126408. */
  126409. isEnabled: boolean;
  126410. /**
  126411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126412. */
  126413. intensity: number;
  126414. /**
  126415. * Defines the clear coat layer roughness.
  126416. */
  126417. roughness: number;
  126418. private _indexOfRefraction;
  126419. /**
  126420. * Defines the index of refraction of the clear coat.
  126421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126422. * The default fits with a polyurethane material.
  126423. * Changing the default value is more performance intensive.
  126424. */
  126425. indexOfRefraction: number;
  126426. private _texture;
  126427. /**
  126428. * Stores the clear coat values in a texture.
  126429. */
  126430. texture: Nullable<BaseTexture>;
  126431. private _bumpTexture;
  126432. /**
  126433. * Define the clear coat specific bump texture.
  126434. */
  126435. bumpTexture: Nullable<BaseTexture>;
  126436. private _isTintEnabled;
  126437. /**
  126438. * Defines if the clear coat tint is enabled in the material.
  126439. */
  126440. isTintEnabled: boolean;
  126441. /**
  126442. * Defines the clear coat tint of the material.
  126443. * This is only use if tint is enabled
  126444. */
  126445. tintColor: Color3;
  126446. /**
  126447. * Defines the distance at which the tint color should be found in the
  126448. * clear coat media.
  126449. * This is only use if tint is enabled
  126450. */
  126451. tintColorAtDistance: number;
  126452. /**
  126453. * Defines the clear coat layer thickness.
  126454. * This is only use if tint is enabled
  126455. */
  126456. tintThickness: number;
  126457. private _tintTexture;
  126458. /**
  126459. * Stores the clear tint values in a texture.
  126460. * rgb is tint
  126461. * a is a thickness factor
  126462. */
  126463. tintTexture: Nullable<BaseTexture>;
  126464. /** @hidden */
  126465. private _internalMarkAllSubMeshesAsTexturesDirty;
  126466. /** @hidden */
  126467. _markAllSubMeshesAsTexturesDirty(): void;
  126468. /**
  126469. * Instantiate a new istance of clear coat configuration.
  126470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126471. */
  126472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126473. /**
  126474. * Gets wehter the submesh is ready to be used or not.
  126475. * @param defines the list of "defines" to update.
  126476. * @param scene defines the scene the material belongs to.
  126477. * @param engine defines the engine the material belongs to.
  126478. * @param disableBumpMap defines wether the material disables bump or not.
  126479. * @returns - boolean indicating that the submesh is ready or not.
  126480. */
  126481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126482. /**
  126483. * Checks to see if a texture is used in the material.
  126484. * @param defines the list of "defines" to update.
  126485. * @param scene defines the scene to the material belongs to.
  126486. */
  126487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126488. /**
  126489. * Binds the material data.
  126490. * @param uniformBuffer defines the Uniform buffer to fill in.
  126491. * @param scene defines the scene the material belongs to.
  126492. * @param engine defines the engine the material belongs to.
  126493. * @param disableBumpMap defines wether the material disables bump or not.
  126494. * @param isFrozen defines wether the material is frozen or not.
  126495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126497. */
  126498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126499. /**
  126500. * Checks to see if a texture is used in the material.
  126501. * @param texture - Base texture to use.
  126502. * @returns - Boolean specifying if a texture is used in the material.
  126503. */
  126504. hasTexture(texture: BaseTexture): boolean;
  126505. /**
  126506. * Returns an array of the actively used textures.
  126507. * @param activeTextures Array of BaseTextures
  126508. */
  126509. getActiveTextures(activeTextures: BaseTexture[]): void;
  126510. /**
  126511. * Returns the animatable textures.
  126512. * @param animatables Array of animatable textures.
  126513. */
  126514. getAnimatables(animatables: IAnimatable[]): void;
  126515. /**
  126516. * Disposes the resources of the material.
  126517. * @param forceDisposeTextures - Forces the disposal of all textures.
  126518. */
  126519. dispose(forceDisposeTextures?: boolean): void;
  126520. /**
  126521. * Get the current class name of the texture useful for serialization or dynamic coding.
  126522. * @returns "PBRClearCoatConfiguration"
  126523. */
  126524. getClassName(): string;
  126525. /**
  126526. * Add fallbacks to the effect fallbacks list.
  126527. * @param defines defines the Base texture to use.
  126528. * @param fallbacks defines the current fallback list.
  126529. * @param currentRank defines the current fallback rank.
  126530. * @returns the new fallback rank.
  126531. */
  126532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126533. /**
  126534. * Add the required uniforms to the current list.
  126535. * @param uniforms defines the current uniform list.
  126536. */
  126537. static AddUniforms(uniforms: string[]): void;
  126538. /**
  126539. * Add the required samplers to the current list.
  126540. * @param samplers defines the current sampler list.
  126541. */
  126542. static AddSamplers(samplers: string[]): void;
  126543. /**
  126544. * Add the required uniforms to the current buffer.
  126545. * @param uniformBuffer defines the current uniform buffer.
  126546. */
  126547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126548. /**
  126549. * Makes a duplicate of the current configuration into another one.
  126550. * @param clearCoatConfiguration define the config where to copy the info
  126551. */
  126552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126553. /**
  126554. * Serializes this clear coat configuration.
  126555. * @returns - An object with the serialized config.
  126556. */
  126557. serialize(): any;
  126558. /**
  126559. * Parses a anisotropy Configuration from a serialized object.
  126560. * @param source - Serialized object.
  126561. * @param scene Defines the scene we are parsing for
  126562. * @param rootUrl Defines the rootUrl to load from
  126563. */
  126564. parse(source: any, scene: Scene, rootUrl: string): void;
  126565. }
  126566. }
  126567. declare module BABYLON {
  126568. /**
  126569. * @hidden
  126570. */
  126571. export interface IMaterialAnisotropicDefines {
  126572. ANISOTROPIC: boolean;
  126573. ANISOTROPIC_TEXTURE: boolean;
  126574. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126575. MAINUV1: boolean;
  126576. _areTexturesDirty: boolean;
  126577. _needUVs: boolean;
  126578. }
  126579. /**
  126580. * Define the code related to the anisotropic parameters of the pbr material.
  126581. */
  126582. export class PBRAnisotropicConfiguration {
  126583. private _isEnabled;
  126584. /**
  126585. * Defines if the anisotropy is enabled in the material.
  126586. */
  126587. isEnabled: boolean;
  126588. /**
  126589. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126590. */
  126591. intensity: number;
  126592. /**
  126593. * Defines if the effect is along the tangents, bitangents or in between.
  126594. * By default, the effect is "strectching" the highlights along the tangents.
  126595. */
  126596. direction: Vector2;
  126597. private _texture;
  126598. /**
  126599. * Stores the anisotropy values in a texture.
  126600. * rg is direction (like normal from -1 to 1)
  126601. * b is a intensity
  126602. */
  126603. texture: Nullable<BaseTexture>;
  126604. /** @hidden */
  126605. private _internalMarkAllSubMeshesAsTexturesDirty;
  126606. /** @hidden */
  126607. _markAllSubMeshesAsTexturesDirty(): void;
  126608. /**
  126609. * Instantiate a new istance of anisotropy configuration.
  126610. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126611. */
  126612. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126613. /**
  126614. * Specifies that the submesh is ready to be used.
  126615. * @param defines the list of "defines" to update.
  126616. * @param scene defines the scene the material belongs to.
  126617. * @returns - boolean indicating that the submesh is ready or not.
  126618. */
  126619. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126620. /**
  126621. * Checks to see if a texture is used in the material.
  126622. * @param defines the list of "defines" to update.
  126623. * @param mesh the mesh we are preparing the defines for.
  126624. * @param scene defines the scene the material belongs to.
  126625. */
  126626. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126627. /**
  126628. * Binds the material data.
  126629. * @param uniformBuffer defines the Uniform buffer to fill in.
  126630. * @param scene defines the scene the material belongs to.
  126631. * @param isFrozen defines wether the material is frozen or not.
  126632. */
  126633. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126634. /**
  126635. * Checks to see if a texture is used in the material.
  126636. * @param texture - Base texture to use.
  126637. * @returns - Boolean specifying if a texture is used in the material.
  126638. */
  126639. hasTexture(texture: BaseTexture): boolean;
  126640. /**
  126641. * Returns an array of the actively used textures.
  126642. * @param activeTextures Array of BaseTextures
  126643. */
  126644. getActiveTextures(activeTextures: BaseTexture[]): void;
  126645. /**
  126646. * Returns the animatable textures.
  126647. * @param animatables Array of animatable textures.
  126648. */
  126649. getAnimatables(animatables: IAnimatable[]): void;
  126650. /**
  126651. * Disposes the resources of the material.
  126652. * @param forceDisposeTextures - Forces the disposal of all textures.
  126653. */
  126654. dispose(forceDisposeTextures?: boolean): void;
  126655. /**
  126656. * Get the current class name of the texture useful for serialization or dynamic coding.
  126657. * @returns "PBRAnisotropicConfiguration"
  126658. */
  126659. getClassName(): string;
  126660. /**
  126661. * Add fallbacks to the effect fallbacks list.
  126662. * @param defines defines the Base texture to use.
  126663. * @param fallbacks defines the current fallback list.
  126664. * @param currentRank defines the current fallback rank.
  126665. * @returns the new fallback rank.
  126666. */
  126667. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126668. /**
  126669. * Add the required uniforms to the current list.
  126670. * @param uniforms defines the current uniform list.
  126671. */
  126672. static AddUniforms(uniforms: string[]): void;
  126673. /**
  126674. * Add the required uniforms to the current buffer.
  126675. * @param uniformBuffer defines the current uniform buffer.
  126676. */
  126677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126678. /**
  126679. * Add the required samplers to the current list.
  126680. * @param samplers defines the current sampler list.
  126681. */
  126682. static AddSamplers(samplers: string[]): void;
  126683. /**
  126684. * Makes a duplicate of the current configuration into another one.
  126685. * @param anisotropicConfiguration define the config where to copy the info
  126686. */
  126687. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126688. /**
  126689. * Serializes this anisotropy configuration.
  126690. * @returns - An object with the serialized config.
  126691. */
  126692. serialize(): any;
  126693. /**
  126694. * Parses a anisotropy Configuration from a serialized object.
  126695. * @param source - Serialized object.
  126696. * @param scene Defines the scene we are parsing for
  126697. * @param rootUrl Defines the rootUrl to load from
  126698. */
  126699. parse(source: any, scene: Scene, rootUrl: string): void;
  126700. }
  126701. }
  126702. declare module BABYLON {
  126703. /**
  126704. * @hidden
  126705. */
  126706. export interface IMaterialBRDFDefines {
  126707. BRDF_V_HEIGHT_CORRELATED: boolean;
  126708. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126709. SPHERICAL_HARMONICS: boolean;
  126710. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126711. /** @hidden */
  126712. _areMiscDirty: boolean;
  126713. }
  126714. /**
  126715. * Define the code related to the BRDF parameters of the pbr material.
  126716. */
  126717. export class PBRBRDFConfiguration {
  126718. /**
  126719. * Default value used for the energy conservation.
  126720. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126721. */
  126722. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  126723. /**
  126724. * Default value used for the Smith Visibility Height Correlated mode.
  126725. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126726. */
  126727. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  126728. /**
  126729. * Default value used for the IBL diffuse part.
  126730. * This can help switching back to the polynomials mode globally which is a tiny bit
  126731. * less GPU intensive at the drawback of a lower quality.
  126732. */
  126733. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  126734. /**
  126735. * Default value used for activating energy conservation for the specular workflow.
  126736. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126737. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126738. */
  126739. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  126740. private _useEnergyConservation;
  126741. /**
  126742. * Defines if the material uses energy conservation.
  126743. */
  126744. useEnergyConservation: boolean;
  126745. private _useSmithVisibilityHeightCorrelated;
  126746. /**
  126747. * LEGACY Mode set to false
  126748. * Defines if the material uses height smith correlated visibility term.
  126749. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  126750. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  126751. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  126752. * Not relying on height correlated will also disable energy conservation.
  126753. */
  126754. useSmithVisibilityHeightCorrelated: boolean;
  126755. private _useSphericalHarmonics;
  126756. /**
  126757. * LEGACY Mode set to false
  126758. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  126759. * diffuse part of the IBL.
  126760. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  126761. * to the ground truth.
  126762. */
  126763. useSphericalHarmonics: boolean;
  126764. private _useSpecularGlossinessInputEnergyConservation;
  126765. /**
  126766. * Defines if the material uses energy conservation, when the specular workflow is active.
  126767. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126768. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126769. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  126770. */
  126771. useSpecularGlossinessInputEnergyConservation: boolean;
  126772. /** @hidden */
  126773. private _internalMarkAllSubMeshesAsMiscDirty;
  126774. /** @hidden */
  126775. _markAllSubMeshesAsMiscDirty(): void;
  126776. /**
  126777. * Instantiate a new istance of clear coat configuration.
  126778. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  126779. */
  126780. constructor(markAllSubMeshesAsMiscDirty: () => void);
  126781. /**
  126782. * Checks to see if a texture is used in the material.
  126783. * @param defines the list of "defines" to update.
  126784. */
  126785. prepareDefines(defines: IMaterialBRDFDefines): void;
  126786. /**
  126787. * Get the current class name of the texture useful for serialization or dynamic coding.
  126788. * @returns "PBRClearCoatConfiguration"
  126789. */
  126790. getClassName(): string;
  126791. /**
  126792. * Makes a duplicate of the current configuration into another one.
  126793. * @param brdfConfiguration define the config where to copy the info
  126794. */
  126795. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  126796. /**
  126797. * Serializes this BRDF configuration.
  126798. * @returns - An object with the serialized config.
  126799. */
  126800. serialize(): any;
  126801. /**
  126802. * Parses a anisotropy Configuration from a serialized object.
  126803. * @param source - Serialized object.
  126804. * @param scene Defines the scene we are parsing for
  126805. * @param rootUrl Defines the rootUrl to load from
  126806. */
  126807. parse(source: any, scene: Scene, rootUrl: string): void;
  126808. }
  126809. }
  126810. declare module BABYLON {
  126811. /**
  126812. * @hidden
  126813. */
  126814. export interface IMaterialSheenDefines {
  126815. SHEEN: boolean;
  126816. SHEEN_TEXTURE: boolean;
  126817. SHEEN_TEXTUREDIRECTUV: number;
  126818. SHEEN_LINKWITHALBEDO: boolean;
  126819. SHEEN_ROUGHNESS: boolean;
  126820. SHEEN_ALBEDOSCALING: boolean;
  126821. /** @hidden */
  126822. _areTexturesDirty: boolean;
  126823. }
  126824. /**
  126825. * Define the code related to the Sheen parameters of the pbr material.
  126826. */
  126827. export class PBRSheenConfiguration {
  126828. private _isEnabled;
  126829. /**
  126830. * Defines if the material uses sheen.
  126831. */
  126832. isEnabled: boolean;
  126833. private _linkSheenWithAlbedo;
  126834. /**
  126835. * Defines if the sheen is linked to the sheen color.
  126836. */
  126837. linkSheenWithAlbedo: boolean;
  126838. /**
  126839. * Defines the sheen intensity.
  126840. */
  126841. intensity: number;
  126842. /**
  126843. * Defines the sheen color.
  126844. */
  126845. color: Color3;
  126846. private _texture;
  126847. /**
  126848. * Stores the sheen tint values in a texture.
  126849. * rgb is tint
  126850. * a is a intensity
  126851. */
  126852. texture: Nullable<BaseTexture>;
  126853. private _roughness;
  126854. /**
  126855. * Defines the sheen roughness.
  126856. * It is not taken into account if linkSheenWithAlbedo is true.
  126857. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  126858. */
  126859. roughness: Nullable<number>;
  126860. private _albedoScaling;
  126861. /**
  126862. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  126863. * It allows the strength of the sheen effect to not depend on the base color of the material,
  126864. * making it easier to setup and tweak the effect
  126865. */
  126866. albedoScaling: boolean;
  126867. /** @hidden */
  126868. private _internalMarkAllSubMeshesAsTexturesDirty;
  126869. /** @hidden */
  126870. _markAllSubMeshesAsTexturesDirty(): void;
  126871. /**
  126872. * Instantiate a new istance of clear coat configuration.
  126873. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126874. */
  126875. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126876. /**
  126877. * Specifies that the submesh is ready to be used.
  126878. * @param defines the list of "defines" to update.
  126879. * @param scene defines the scene the material belongs to.
  126880. * @returns - boolean indicating that the submesh is ready or not.
  126881. */
  126882. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  126883. /**
  126884. * Checks to see if a texture is used in the material.
  126885. * @param defines the list of "defines" to update.
  126886. * @param scene defines the scene the material belongs to.
  126887. */
  126888. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  126889. /**
  126890. * Binds the material data.
  126891. * @param uniformBuffer defines the Uniform buffer to fill in.
  126892. * @param scene defines the scene the material belongs to.
  126893. * @param isFrozen defines wether the material is frozen or not.
  126894. */
  126895. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126896. /**
  126897. * Checks to see if a texture is used in the material.
  126898. * @param texture - Base texture to use.
  126899. * @returns - Boolean specifying if a texture is used in the material.
  126900. */
  126901. hasTexture(texture: BaseTexture): boolean;
  126902. /**
  126903. * Returns an array of the actively used textures.
  126904. * @param activeTextures Array of BaseTextures
  126905. */
  126906. getActiveTextures(activeTextures: BaseTexture[]): void;
  126907. /**
  126908. * Returns the animatable textures.
  126909. * @param animatables Array of animatable textures.
  126910. */
  126911. getAnimatables(animatables: IAnimatable[]): void;
  126912. /**
  126913. * Disposes the resources of the material.
  126914. * @param forceDisposeTextures - Forces the disposal of all textures.
  126915. */
  126916. dispose(forceDisposeTextures?: boolean): void;
  126917. /**
  126918. * Get the current class name of the texture useful for serialization or dynamic coding.
  126919. * @returns "PBRSheenConfiguration"
  126920. */
  126921. getClassName(): string;
  126922. /**
  126923. * Add fallbacks to the effect fallbacks list.
  126924. * @param defines defines the Base texture to use.
  126925. * @param fallbacks defines the current fallback list.
  126926. * @param currentRank defines the current fallback rank.
  126927. * @returns the new fallback rank.
  126928. */
  126929. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126930. /**
  126931. * Add the required uniforms to the current list.
  126932. * @param uniforms defines the current uniform list.
  126933. */
  126934. static AddUniforms(uniforms: string[]): void;
  126935. /**
  126936. * Add the required uniforms to the current buffer.
  126937. * @param uniformBuffer defines the current uniform buffer.
  126938. */
  126939. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126940. /**
  126941. * Add the required samplers to the current list.
  126942. * @param samplers defines the current sampler list.
  126943. */
  126944. static AddSamplers(samplers: string[]): void;
  126945. /**
  126946. * Makes a duplicate of the current configuration into another one.
  126947. * @param sheenConfiguration define the config where to copy the info
  126948. */
  126949. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  126950. /**
  126951. * Serializes this BRDF configuration.
  126952. * @returns - An object with the serialized config.
  126953. */
  126954. serialize(): any;
  126955. /**
  126956. * Parses a anisotropy Configuration from a serialized object.
  126957. * @param source - Serialized object.
  126958. * @param scene Defines the scene we are parsing for
  126959. * @param rootUrl Defines the rootUrl to load from
  126960. */
  126961. parse(source: any, scene: Scene, rootUrl: string): void;
  126962. }
  126963. }
  126964. declare module BABYLON {
  126965. /**
  126966. * @hidden
  126967. */
  126968. export interface IMaterialSubSurfaceDefines {
  126969. SUBSURFACE: boolean;
  126970. SS_REFRACTION: boolean;
  126971. SS_TRANSLUCENCY: boolean;
  126972. SS_SCATERRING: boolean;
  126973. SS_THICKNESSANDMASK_TEXTURE: boolean;
  126974. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  126975. SS_REFRACTIONMAP_3D: boolean;
  126976. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  126977. SS_LODINREFRACTIONALPHA: boolean;
  126978. SS_GAMMAREFRACTION: boolean;
  126979. SS_RGBDREFRACTION: boolean;
  126980. SS_LINEARSPECULARREFRACTION: boolean;
  126981. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  126982. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  126983. /** @hidden */
  126984. _areTexturesDirty: boolean;
  126985. }
  126986. /**
  126987. * Define the code related to the sub surface parameters of the pbr material.
  126988. */
  126989. export class PBRSubSurfaceConfiguration {
  126990. private _isRefractionEnabled;
  126991. /**
  126992. * Defines if the refraction is enabled in the material.
  126993. */
  126994. isRefractionEnabled: boolean;
  126995. private _isTranslucencyEnabled;
  126996. /**
  126997. * Defines if the translucency is enabled in the material.
  126998. */
  126999. isTranslucencyEnabled: boolean;
  127000. private _isScatteringEnabled;
  127001. /**
  127002. * Defines the refraction intensity of the material.
  127003. * The refraction when enabled replaces the Diffuse part of the material.
  127004. * The intensity helps transitionning between diffuse and refraction.
  127005. */
  127006. refractionIntensity: number;
  127007. /**
  127008. * Defines the translucency intensity of the material.
  127009. * When translucency has been enabled, this defines how much of the "translucency"
  127010. * is addded to the diffuse part of the material.
  127011. */
  127012. translucencyIntensity: number;
  127013. /**
  127014. * Defines the scattering intensity of the material.
  127015. * When scattering has been enabled, this defines how much of the "scattered light"
  127016. * is addded to the diffuse part of the material.
  127017. */
  127018. scatteringIntensity: number;
  127019. private _thicknessTexture;
  127020. /**
  127021. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127022. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127023. * 0 would mean minimumThickness
  127024. * 1 would mean maximumThickness
  127025. * The other channels might be use as a mask to vary the different effects intensity.
  127026. */
  127027. thicknessTexture: Nullable<BaseTexture>;
  127028. private _refractionTexture;
  127029. /**
  127030. * Defines the texture to use for refraction.
  127031. */
  127032. refractionTexture: Nullable<BaseTexture>;
  127033. private _indexOfRefraction;
  127034. /**
  127035. * Defines the index of refraction used in the material.
  127036. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127037. */
  127038. indexOfRefraction: number;
  127039. private _invertRefractionY;
  127040. /**
  127041. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127042. */
  127043. invertRefractionY: boolean;
  127044. private _linkRefractionWithTransparency;
  127045. /**
  127046. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127047. * Materials half opaque for instance using refraction could benefit from this control.
  127048. */
  127049. linkRefractionWithTransparency: boolean;
  127050. /**
  127051. * Defines the minimum thickness stored in the thickness map.
  127052. * If no thickness map is defined, this value will be used to simulate thickness.
  127053. */
  127054. minimumThickness: number;
  127055. /**
  127056. * Defines the maximum thickness stored in the thickness map.
  127057. */
  127058. maximumThickness: number;
  127059. /**
  127060. * Defines the volume tint of the material.
  127061. * This is used for both translucency and scattering.
  127062. */
  127063. tintColor: Color3;
  127064. /**
  127065. * Defines the distance at which the tint color should be found in the media.
  127066. * This is used for refraction only.
  127067. */
  127068. tintColorAtDistance: number;
  127069. /**
  127070. * Defines how far each channel transmit through the media.
  127071. * It is defined as a color to simplify it selection.
  127072. */
  127073. diffusionDistance: Color3;
  127074. private _useMaskFromThicknessTexture;
  127075. /**
  127076. * Stores the intensity of the different subsurface effects in the thickness texture.
  127077. * * the green channel is the translucency intensity.
  127078. * * the blue channel is the scattering intensity.
  127079. * * the alpha channel is the refraction intensity.
  127080. */
  127081. useMaskFromThicknessTexture: boolean;
  127082. /** @hidden */
  127083. private _internalMarkAllSubMeshesAsTexturesDirty;
  127084. /** @hidden */
  127085. _markAllSubMeshesAsTexturesDirty(): void;
  127086. /**
  127087. * Instantiate a new istance of sub surface configuration.
  127088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127089. */
  127090. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127091. /**
  127092. * Gets wehter the submesh is ready to be used or not.
  127093. * @param defines the list of "defines" to update.
  127094. * @param scene defines the scene the material belongs to.
  127095. * @returns - boolean indicating that the submesh is ready or not.
  127096. */
  127097. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127098. /**
  127099. * Checks to see if a texture is used in the material.
  127100. * @param defines the list of "defines" to update.
  127101. * @param scene defines the scene to the material belongs to.
  127102. */
  127103. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127104. /**
  127105. * Binds the material data.
  127106. * @param uniformBuffer defines the Uniform buffer to fill in.
  127107. * @param scene defines the scene the material belongs to.
  127108. * @param engine defines the engine the material belongs to.
  127109. * @param isFrozen defines wether the material is frozen or not.
  127110. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127111. */
  127112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127113. /**
  127114. * Unbinds the material from the mesh.
  127115. * @param activeEffect defines the effect that should be unbound from.
  127116. * @returns true if unbound, otherwise false
  127117. */
  127118. unbind(activeEffect: Effect): boolean;
  127119. /**
  127120. * Returns the texture used for refraction or null if none is used.
  127121. * @param scene defines the scene the material belongs to.
  127122. * @returns - Refraction texture if present. If no refraction texture and refraction
  127123. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127124. */
  127125. private _getRefractionTexture;
  127126. /**
  127127. * Returns true if alpha blending should be disabled.
  127128. */
  127129. get disableAlphaBlending(): boolean;
  127130. /**
  127131. * Fills the list of render target textures.
  127132. * @param renderTargets the list of render targets to update
  127133. */
  127134. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127135. /**
  127136. * Checks to see if a texture is used in the material.
  127137. * @param texture - Base texture to use.
  127138. * @returns - Boolean specifying if a texture is used in the material.
  127139. */
  127140. hasTexture(texture: BaseTexture): boolean;
  127141. /**
  127142. * Gets a boolean indicating that current material needs to register RTT
  127143. * @returns true if this uses a render target otherwise false.
  127144. */
  127145. hasRenderTargetTextures(): boolean;
  127146. /**
  127147. * Returns an array of the actively used textures.
  127148. * @param activeTextures Array of BaseTextures
  127149. */
  127150. getActiveTextures(activeTextures: BaseTexture[]): void;
  127151. /**
  127152. * Returns the animatable textures.
  127153. * @param animatables Array of animatable textures.
  127154. */
  127155. getAnimatables(animatables: IAnimatable[]): void;
  127156. /**
  127157. * Disposes the resources of the material.
  127158. * @param forceDisposeTextures - Forces the disposal of all textures.
  127159. */
  127160. dispose(forceDisposeTextures?: boolean): void;
  127161. /**
  127162. * Get the current class name of the texture useful for serialization or dynamic coding.
  127163. * @returns "PBRSubSurfaceConfiguration"
  127164. */
  127165. getClassName(): string;
  127166. /**
  127167. * Add fallbacks to the effect fallbacks list.
  127168. * @param defines defines the Base texture to use.
  127169. * @param fallbacks defines the current fallback list.
  127170. * @param currentRank defines the current fallback rank.
  127171. * @returns the new fallback rank.
  127172. */
  127173. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127174. /**
  127175. * Add the required uniforms to the current list.
  127176. * @param uniforms defines the current uniform list.
  127177. */
  127178. static AddUniforms(uniforms: string[]): void;
  127179. /**
  127180. * Add the required samplers to the current list.
  127181. * @param samplers defines the current sampler list.
  127182. */
  127183. static AddSamplers(samplers: string[]): void;
  127184. /**
  127185. * Add the required uniforms to the current buffer.
  127186. * @param uniformBuffer defines the current uniform buffer.
  127187. */
  127188. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127189. /**
  127190. * Makes a duplicate of the current configuration into another one.
  127191. * @param configuration define the config where to copy the info
  127192. */
  127193. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127194. /**
  127195. * Serializes this Sub Surface configuration.
  127196. * @returns - An object with the serialized config.
  127197. */
  127198. serialize(): any;
  127199. /**
  127200. * Parses a anisotropy Configuration from a serialized object.
  127201. * @param source - Serialized object.
  127202. * @param scene Defines the scene we are parsing for
  127203. * @param rootUrl Defines the rootUrl to load from
  127204. */
  127205. parse(source: any, scene: Scene, rootUrl: string): void;
  127206. }
  127207. }
  127208. declare module BABYLON {
  127209. /** @hidden */
  127210. export var pbrFragmentDeclaration: {
  127211. name: string;
  127212. shader: string;
  127213. };
  127214. }
  127215. declare module BABYLON {
  127216. /** @hidden */
  127217. export var pbrUboDeclaration: {
  127218. name: string;
  127219. shader: string;
  127220. };
  127221. }
  127222. declare module BABYLON {
  127223. /** @hidden */
  127224. export var pbrFragmentExtraDeclaration: {
  127225. name: string;
  127226. shader: string;
  127227. };
  127228. }
  127229. declare module BABYLON {
  127230. /** @hidden */
  127231. export var pbrFragmentSamplersDeclaration: {
  127232. name: string;
  127233. shader: string;
  127234. };
  127235. }
  127236. declare module BABYLON {
  127237. /** @hidden */
  127238. export var pbrHelperFunctions: {
  127239. name: string;
  127240. shader: string;
  127241. };
  127242. }
  127243. declare module BABYLON {
  127244. /** @hidden */
  127245. export var harmonicsFunctions: {
  127246. name: string;
  127247. shader: string;
  127248. };
  127249. }
  127250. declare module BABYLON {
  127251. /** @hidden */
  127252. export var pbrDirectLightingSetupFunctions: {
  127253. name: string;
  127254. shader: string;
  127255. };
  127256. }
  127257. declare module BABYLON {
  127258. /** @hidden */
  127259. export var pbrDirectLightingFalloffFunctions: {
  127260. name: string;
  127261. shader: string;
  127262. };
  127263. }
  127264. declare module BABYLON {
  127265. /** @hidden */
  127266. export var pbrBRDFFunctions: {
  127267. name: string;
  127268. shader: string;
  127269. };
  127270. }
  127271. declare module BABYLON {
  127272. /** @hidden */
  127273. export var pbrDirectLightingFunctions: {
  127274. name: string;
  127275. shader: string;
  127276. };
  127277. }
  127278. declare module BABYLON {
  127279. /** @hidden */
  127280. export var pbrIBLFunctions: {
  127281. name: string;
  127282. shader: string;
  127283. };
  127284. }
  127285. declare module BABYLON {
  127286. /** @hidden */
  127287. export var pbrBlockAlbedoOpacity: {
  127288. name: string;
  127289. shader: string;
  127290. };
  127291. }
  127292. declare module BABYLON {
  127293. /** @hidden */
  127294. export var pbrBlockReflectivity: {
  127295. name: string;
  127296. shader: string;
  127297. };
  127298. }
  127299. declare module BABYLON {
  127300. /** @hidden */
  127301. export var pbrBlockAmbientOcclusion: {
  127302. name: string;
  127303. shader: string;
  127304. };
  127305. }
  127306. declare module BABYLON {
  127307. /** @hidden */
  127308. export var pbrBlockAlphaFresnel: {
  127309. name: string;
  127310. shader: string;
  127311. };
  127312. }
  127313. declare module BABYLON {
  127314. /** @hidden */
  127315. export var pbrBlockAnisotropic: {
  127316. name: string;
  127317. shader: string;
  127318. };
  127319. }
  127320. declare module BABYLON {
  127321. /** @hidden */
  127322. export var pbrBlockReflection: {
  127323. name: string;
  127324. shader: string;
  127325. };
  127326. }
  127327. declare module BABYLON {
  127328. /** @hidden */
  127329. export var pbrBlockSheen: {
  127330. name: string;
  127331. shader: string;
  127332. };
  127333. }
  127334. declare module BABYLON {
  127335. /** @hidden */
  127336. export var pbrBlockClearcoat: {
  127337. name: string;
  127338. shader: string;
  127339. };
  127340. }
  127341. declare module BABYLON {
  127342. /** @hidden */
  127343. export var pbrBlockSubSurface: {
  127344. name: string;
  127345. shader: string;
  127346. };
  127347. }
  127348. declare module BABYLON {
  127349. /** @hidden */
  127350. export var pbrBlockNormalGeometric: {
  127351. name: string;
  127352. shader: string;
  127353. };
  127354. }
  127355. declare module BABYLON {
  127356. /** @hidden */
  127357. export var pbrBlockNormalFinal: {
  127358. name: string;
  127359. shader: string;
  127360. };
  127361. }
  127362. declare module BABYLON {
  127363. /** @hidden */
  127364. export var pbrBlockGeometryInfo: {
  127365. name: string;
  127366. shader: string;
  127367. };
  127368. }
  127369. declare module BABYLON {
  127370. /** @hidden */
  127371. export var pbrBlockReflectance0: {
  127372. name: string;
  127373. shader: string;
  127374. };
  127375. }
  127376. declare module BABYLON {
  127377. /** @hidden */
  127378. export var pbrBlockReflectance: {
  127379. name: string;
  127380. shader: string;
  127381. };
  127382. }
  127383. declare module BABYLON {
  127384. /** @hidden */
  127385. export var pbrBlockDirectLighting: {
  127386. name: string;
  127387. shader: string;
  127388. };
  127389. }
  127390. declare module BABYLON {
  127391. /** @hidden */
  127392. export var pbrBlockFinalLitComponents: {
  127393. name: string;
  127394. shader: string;
  127395. };
  127396. }
  127397. declare module BABYLON {
  127398. /** @hidden */
  127399. export var pbrBlockFinalUnlitComponents: {
  127400. name: string;
  127401. shader: string;
  127402. };
  127403. }
  127404. declare module BABYLON {
  127405. /** @hidden */
  127406. export var pbrBlockFinalColorComposition: {
  127407. name: string;
  127408. shader: string;
  127409. };
  127410. }
  127411. declare module BABYLON {
  127412. /** @hidden */
  127413. export var pbrBlockImageProcessing: {
  127414. name: string;
  127415. shader: string;
  127416. };
  127417. }
  127418. declare module BABYLON {
  127419. /** @hidden */
  127420. export var pbrDebug: {
  127421. name: string;
  127422. shader: string;
  127423. };
  127424. }
  127425. declare module BABYLON {
  127426. /** @hidden */
  127427. export var pbrPixelShader: {
  127428. name: string;
  127429. shader: string;
  127430. };
  127431. }
  127432. declare module BABYLON {
  127433. /** @hidden */
  127434. export var pbrVertexDeclaration: {
  127435. name: string;
  127436. shader: string;
  127437. };
  127438. }
  127439. declare module BABYLON {
  127440. /** @hidden */
  127441. export var pbrVertexShader: {
  127442. name: string;
  127443. shader: string;
  127444. };
  127445. }
  127446. declare module BABYLON {
  127447. /**
  127448. * Manages the defines for the PBR Material.
  127449. * @hidden
  127450. */
  127451. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127452. PBR: boolean;
  127453. MAINUV1: boolean;
  127454. MAINUV2: boolean;
  127455. UV1: boolean;
  127456. UV2: boolean;
  127457. ALBEDO: boolean;
  127458. GAMMAALBEDO: boolean;
  127459. ALBEDODIRECTUV: number;
  127460. VERTEXCOLOR: boolean;
  127461. AMBIENT: boolean;
  127462. AMBIENTDIRECTUV: number;
  127463. AMBIENTINGRAYSCALE: boolean;
  127464. OPACITY: boolean;
  127465. VERTEXALPHA: boolean;
  127466. OPACITYDIRECTUV: number;
  127467. OPACITYRGB: boolean;
  127468. ALPHATEST: boolean;
  127469. DEPTHPREPASS: boolean;
  127470. ALPHABLEND: boolean;
  127471. ALPHAFROMALBEDO: boolean;
  127472. ALPHATESTVALUE: string;
  127473. SPECULAROVERALPHA: boolean;
  127474. RADIANCEOVERALPHA: boolean;
  127475. ALPHAFRESNEL: boolean;
  127476. LINEARALPHAFRESNEL: boolean;
  127477. PREMULTIPLYALPHA: boolean;
  127478. EMISSIVE: boolean;
  127479. EMISSIVEDIRECTUV: number;
  127480. REFLECTIVITY: boolean;
  127481. REFLECTIVITYDIRECTUV: number;
  127482. SPECULARTERM: boolean;
  127483. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127484. MICROSURFACEAUTOMATIC: boolean;
  127485. LODBASEDMICROSFURACE: boolean;
  127486. MICROSURFACEMAP: boolean;
  127487. MICROSURFACEMAPDIRECTUV: number;
  127488. METALLICWORKFLOW: boolean;
  127489. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127490. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127491. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127492. AOSTOREINMETALMAPRED: boolean;
  127493. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127494. ENVIRONMENTBRDF: boolean;
  127495. ENVIRONMENTBRDF_RGBD: boolean;
  127496. NORMAL: boolean;
  127497. TANGENT: boolean;
  127498. BUMP: boolean;
  127499. BUMPDIRECTUV: number;
  127500. OBJECTSPACE_NORMALMAP: boolean;
  127501. PARALLAX: boolean;
  127502. PARALLAXOCCLUSION: boolean;
  127503. NORMALXYSCALE: boolean;
  127504. LIGHTMAP: boolean;
  127505. LIGHTMAPDIRECTUV: number;
  127506. USELIGHTMAPASSHADOWMAP: boolean;
  127507. GAMMALIGHTMAP: boolean;
  127508. RGBDLIGHTMAP: boolean;
  127509. REFLECTION: boolean;
  127510. REFLECTIONMAP_3D: boolean;
  127511. REFLECTIONMAP_SPHERICAL: boolean;
  127512. REFLECTIONMAP_PLANAR: boolean;
  127513. REFLECTIONMAP_CUBIC: boolean;
  127514. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127515. REFLECTIONMAP_PROJECTION: boolean;
  127516. REFLECTIONMAP_SKYBOX: boolean;
  127517. REFLECTIONMAP_EXPLICIT: boolean;
  127518. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127519. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127520. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127521. INVERTCUBICMAP: boolean;
  127522. USESPHERICALFROMREFLECTIONMAP: boolean;
  127523. USEIRRADIANCEMAP: boolean;
  127524. SPHERICAL_HARMONICS: boolean;
  127525. USESPHERICALINVERTEX: boolean;
  127526. REFLECTIONMAP_OPPOSITEZ: boolean;
  127527. LODINREFLECTIONALPHA: boolean;
  127528. GAMMAREFLECTION: boolean;
  127529. RGBDREFLECTION: boolean;
  127530. LINEARSPECULARREFLECTION: boolean;
  127531. RADIANCEOCCLUSION: boolean;
  127532. HORIZONOCCLUSION: boolean;
  127533. INSTANCES: boolean;
  127534. NUM_BONE_INFLUENCERS: number;
  127535. BonesPerMesh: number;
  127536. BONETEXTURE: boolean;
  127537. NONUNIFORMSCALING: boolean;
  127538. MORPHTARGETS: boolean;
  127539. MORPHTARGETS_NORMAL: boolean;
  127540. MORPHTARGETS_TANGENT: boolean;
  127541. MORPHTARGETS_UV: boolean;
  127542. NUM_MORPH_INFLUENCERS: number;
  127543. IMAGEPROCESSING: boolean;
  127544. VIGNETTE: boolean;
  127545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127546. VIGNETTEBLENDMODEOPAQUE: boolean;
  127547. TONEMAPPING: boolean;
  127548. TONEMAPPING_ACES: boolean;
  127549. CONTRAST: boolean;
  127550. COLORCURVES: boolean;
  127551. COLORGRADING: boolean;
  127552. COLORGRADING3D: boolean;
  127553. SAMPLER3DGREENDEPTH: boolean;
  127554. SAMPLER3DBGRMAP: boolean;
  127555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127556. EXPOSURE: boolean;
  127557. MULTIVIEW: boolean;
  127558. USEPHYSICALLIGHTFALLOFF: boolean;
  127559. USEGLTFLIGHTFALLOFF: boolean;
  127560. TWOSIDEDLIGHTING: boolean;
  127561. SHADOWFLOAT: boolean;
  127562. CLIPPLANE: boolean;
  127563. CLIPPLANE2: boolean;
  127564. CLIPPLANE3: boolean;
  127565. CLIPPLANE4: boolean;
  127566. CLIPPLANE5: boolean;
  127567. CLIPPLANE6: boolean;
  127568. POINTSIZE: boolean;
  127569. FOG: boolean;
  127570. LOGARITHMICDEPTH: boolean;
  127571. FORCENORMALFORWARD: boolean;
  127572. SPECULARAA: boolean;
  127573. CLEARCOAT: boolean;
  127574. CLEARCOAT_DEFAULTIOR: boolean;
  127575. CLEARCOAT_TEXTURE: boolean;
  127576. CLEARCOAT_TEXTUREDIRECTUV: number;
  127577. CLEARCOAT_BUMP: boolean;
  127578. CLEARCOAT_BUMPDIRECTUV: number;
  127579. CLEARCOAT_TINT: boolean;
  127580. CLEARCOAT_TINT_TEXTURE: boolean;
  127581. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127582. ANISOTROPIC: boolean;
  127583. ANISOTROPIC_TEXTURE: boolean;
  127584. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127585. BRDF_V_HEIGHT_CORRELATED: boolean;
  127586. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127587. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127588. SHEEN: boolean;
  127589. SHEEN_TEXTURE: boolean;
  127590. SHEEN_TEXTUREDIRECTUV: number;
  127591. SHEEN_LINKWITHALBEDO: boolean;
  127592. SHEEN_ROUGHNESS: boolean;
  127593. SHEEN_ALBEDOSCALING: boolean;
  127594. SUBSURFACE: boolean;
  127595. SS_REFRACTION: boolean;
  127596. SS_TRANSLUCENCY: boolean;
  127597. SS_SCATERRING: boolean;
  127598. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127599. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127600. SS_REFRACTIONMAP_3D: boolean;
  127601. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127602. SS_LODINREFRACTIONALPHA: boolean;
  127603. SS_GAMMAREFRACTION: boolean;
  127604. SS_RGBDREFRACTION: boolean;
  127605. SS_LINEARSPECULARREFRACTION: boolean;
  127606. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127607. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127608. UNLIT: boolean;
  127609. DEBUGMODE: number;
  127610. /**
  127611. * Initializes the PBR Material defines.
  127612. */
  127613. constructor();
  127614. /**
  127615. * Resets the PBR Material defines.
  127616. */
  127617. reset(): void;
  127618. }
  127619. /**
  127620. * The Physically based material base class of BJS.
  127621. *
  127622. * This offers the main features of a standard PBR material.
  127623. * For more information, please refer to the documentation :
  127624. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127625. */
  127626. export abstract class PBRBaseMaterial extends PushMaterial {
  127627. /**
  127628. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127629. */
  127630. static readonly PBRMATERIAL_OPAQUE: number;
  127631. /**
  127632. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127633. */
  127634. static readonly PBRMATERIAL_ALPHATEST: number;
  127635. /**
  127636. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127637. */
  127638. static readonly PBRMATERIAL_ALPHABLEND: number;
  127639. /**
  127640. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127641. * They are also discarded below the alpha cutoff threshold to improve performances.
  127642. */
  127643. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127644. /**
  127645. * Defines the default value of how much AO map is occluding the analytical lights
  127646. * (point spot...).
  127647. */
  127648. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127649. /**
  127650. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127651. */
  127652. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127653. /**
  127654. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127655. * to enhance interoperability with other engines.
  127656. */
  127657. static readonly LIGHTFALLOFF_GLTF: number;
  127658. /**
  127659. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127660. * to enhance interoperability with other materials.
  127661. */
  127662. static readonly LIGHTFALLOFF_STANDARD: number;
  127663. /**
  127664. * Intensity of the direct lights e.g. the four lights available in your scene.
  127665. * This impacts both the direct diffuse and specular highlights.
  127666. */
  127667. protected _directIntensity: number;
  127668. /**
  127669. * Intensity of the emissive part of the material.
  127670. * This helps controlling the emissive effect without modifying the emissive color.
  127671. */
  127672. protected _emissiveIntensity: number;
  127673. /**
  127674. * Intensity of the environment e.g. how much the environment will light the object
  127675. * either through harmonics for rough material or through the refelction for shiny ones.
  127676. */
  127677. protected _environmentIntensity: number;
  127678. /**
  127679. * This is a special control allowing the reduction of the specular highlights coming from the
  127680. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127681. */
  127682. protected _specularIntensity: number;
  127683. /**
  127684. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127685. */
  127686. private _lightingInfos;
  127687. /**
  127688. * Debug Control allowing disabling the bump map on this material.
  127689. */
  127690. protected _disableBumpMap: boolean;
  127691. /**
  127692. * AKA Diffuse Texture in standard nomenclature.
  127693. */
  127694. protected _albedoTexture: Nullable<BaseTexture>;
  127695. /**
  127696. * AKA Occlusion Texture in other nomenclature.
  127697. */
  127698. protected _ambientTexture: Nullable<BaseTexture>;
  127699. /**
  127700. * AKA Occlusion Texture Intensity in other nomenclature.
  127701. */
  127702. protected _ambientTextureStrength: number;
  127703. /**
  127704. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127705. * 1 means it completely occludes it
  127706. * 0 mean it has no impact
  127707. */
  127708. protected _ambientTextureImpactOnAnalyticalLights: number;
  127709. /**
  127710. * Stores the alpha values in a texture.
  127711. */
  127712. protected _opacityTexture: Nullable<BaseTexture>;
  127713. /**
  127714. * Stores the reflection values in a texture.
  127715. */
  127716. protected _reflectionTexture: Nullable<BaseTexture>;
  127717. /**
  127718. * Stores the emissive values in a texture.
  127719. */
  127720. protected _emissiveTexture: Nullable<BaseTexture>;
  127721. /**
  127722. * AKA Specular texture in other nomenclature.
  127723. */
  127724. protected _reflectivityTexture: Nullable<BaseTexture>;
  127725. /**
  127726. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127727. */
  127728. protected _metallicTexture: Nullable<BaseTexture>;
  127729. /**
  127730. * Specifies the metallic scalar of the metallic/roughness workflow.
  127731. * Can also be used to scale the metalness values of the metallic texture.
  127732. */
  127733. protected _metallic: Nullable<number>;
  127734. /**
  127735. * Specifies the roughness scalar of the metallic/roughness workflow.
  127736. * Can also be used to scale the roughness values of the metallic texture.
  127737. */
  127738. protected _roughness: Nullable<number>;
  127739. /**
  127740. * Specifies the an F0 factor to help configuring the material F0.
  127741. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127742. * to 0.5 the previously hard coded value stays the same.
  127743. * Can also be used to scale the F0 values of the metallic texture.
  127744. */
  127745. protected _metallicF0Factor: number;
  127746. /**
  127747. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127748. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127749. * your expectation as it multiplies with the texture data.
  127750. */
  127751. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  127752. /**
  127753. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127754. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127755. */
  127756. protected _microSurfaceTexture: Nullable<BaseTexture>;
  127757. /**
  127758. * Stores surface normal data used to displace a mesh in a texture.
  127759. */
  127760. protected _bumpTexture: Nullable<BaseTexture>;
  127761. /**
  127762. * Stores the pre-calculated light information of a mesh in a texture.
  127763. */
  127764. protected _lightmapTexture: Nullable<BaseTexture>;
  127765. /**
  127766. * The color of a material in ambient lighting.
  127767. */
  127768. protected _ambientColor: Color3;
  127769. /**
  127770. * AKA Diffuse Color in other nomenclature.
  127771. */
  127772. protected _albedoColor: Color3;
  127773. /**
  127774. * AKA Specular Color in other nomenclature.
  127775. */
  127776. protected _reflectivityColor: Color3;
  127777. /**
  127778. * The color applied when light is reflected from a material.
  127779. */
  127780. protected _reflectionColor: Color3;
  127781. /**
  127782. * The color applied when light is emitted from a material.
  127783. */
  127784. protected _emissiveColor: Color3;
  127785. /**
  127786. * AKA Glossiness in other nomenclature.
  127787. */
  127788. protected _microSurface: number;
  127789. /**
  127790. * Specifies that the material will use the light map as a show map.
  127791. */
  127792. protected _useLightmapAsShadowmap: boolean;
  127793. /**
  127794. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  127795. * makes the reflect vector face the model (under horizon).
  127796. */
  127797. protected _useHorizonOcclusion: boolean;
  127798. /**
  127799. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  127800. * too much the area relying on ambient texture to define their ambient occlusion.
  127801. */
  127802. protected _useRadianceOcclusion: boolean;
  127803. /**
  127804. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  127805. */
  127806. protected _useAlphaFromAlbedoTexture: boolean;
  127807. /**
  127808. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  127809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  127810. */
  127811. protected _useSpecularOverAlpha: boolean;
  127812. /**
  127813. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  127814. */
  127815. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  127816. /**
  127817. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  127818. */
  127819. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  127820. /**
  127821. * Specifies if the metallic texture contains the roughness information in its green channel.
  127822. */
  127823. protected _useRoughnessFromMetallicTextureGreen: boolean;
  127824. /**
  127825. * Specifies if the metallic texture contains the metallness information in its blue channel.
  127826. */
  127827. protected _useMetallnessFromMetallicTextureBlue: boolean;
  127828. /**
  127829. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  127830. */
  127831. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  127832. /**
  127833. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  127834. */
  127835. protected _useAmbientInGrayScale: boolean;
  127836. /**
  127837. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  127838. * The material will try to infer what glossiness each pixel should be.
  127839. */
  127840. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  127841. /**
  127842. * Defines the falloff type used in this material.
  127843. * It by default is Physical.
  127844. */
  127845. protected _lightFalloff: number;
  127846. /**
  127847. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  127848. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  127849. */
  127850. protected _useRadianceOverAlpha: boolean;
  127851. /**
  127852. * Allows using an object space normal map (instead of tangent space).
  127853. */
  127854. protected _useObjectSpaceNormalMap: boolean;
  127855. /**
  127856. * Allows using the bump map in parallax mode.
  127857. */
  127858. protected _useParallax: boolean;
  127859. /**
  127860. * Allows using the bump map in parallax occlusion mode.
  127861. */
  127862. protected _useParallaxOcclusion: boolean;
  127863. /**
  127864. * Controls the scale bias of the parallax mode.
  127865. */
  127866. protected _parallaxScaleBias: number;
  127867. /**
  127868. * If sets to true, disables all the lights affecting the material.
  127869. */
  127870. protected _disableLighting: boolean;
  127871. /**
  127872. * Number of Simultaneous lights allowed on the material.
  127873. */
  127874. protected _maxSimultaneousLights: number;
  127875. /**
  127876. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  127877. */
  127878. protected _invertNormalMapX: boolean;
  127879. /**
  127880. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  127881. */
  127882. protected _invertNormalMapY: boolean;
  127883. /**
  127884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  127885. */
  127886. protected _twoSidedLighting: boolean;
  127887. /**
  127888. * Defines the alpha limits in alpha test mode.
  127889. */
  127890. protected _alphaCutOff: number;
  127891. /**
  127892. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  127893. */
  127894. protected _forceAlphaTest: boolean;
  127895. /**
  127896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127897. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  127898. */
  127899. protected _useAlphaFresnel: boolean;
  127900. /**
  127901. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127902. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  127903. */
  127904. protected _useLinearAlphaFresnel: boolean;
  127905. /**
  127906. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  127907. * from cos thetav and roughness:
  127908. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  127909. */
  127910. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  127911. /**
  127912. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  127913. */
  127914. protected _forceIrradianceInFragment: boolean;
  127915. /**
  127916. * Force normal to face away from face.
  127917. */
  127918. protected _forceNormalForward: boolean;
  127919. /**
  127920. * Enables specular anti aliasing in the PBR shader.
  127921. * It will both interacts on the Geometry for analytical and IBL lighting.
  127922. * It also prefilter the roughness map based on the bump values.
  127923. */
  127924. protected _enableSpecularAntiAliasing: boolean;
  127925. /**
  127926. * Default configuration related to image processing available in the PBR Material.
  127927. */
  127928. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127929. /**
  127930. * Keep track of the image processing observer to allow dispose and replace.
  127931. */
  127932. private _imageProcessingObserver;
  127933. /**
  127934. * Attaches a new image processing configuration to the PBR Material.
  127935. * @param configuration
  127936. */
  127937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127938. /**
  127939. * Stores the available render targets.
  127940. */
  127941. private _renderTargets;
  127942. /**
  127943. * Sets the global ambient color for the material used in lighting calculations.
  127944. */
  127945. private _globalAmbientColor;
  127946. /**
  127947. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  127948. */
  127949. private _useLogarithmicDepth;
  127950. /**
  127951. * If set to true, no lighting calculations will be applied.
  127952. */
  127953. private _unlit;
  127954. private _debugMode;
  127955. /**
  127956. * @hidden
  127957. * This is reserved for the inspector.
  127958. * Defines the material debug mode.
  127959. * It helps seeing only some components of the material while troubleshooting.
  127960. */
  127961. debugMode: number;
  127962. /**
  127963. * @hidden
  127964. * This is reserved for the inspector.
  127965. * Specify from where on screen the debug mode should start.
  127966. * The value goes from -1 (full screen) to 1 (not visible)
  127967. * It helps with side by side comparison against the final render
  127968. * This defaults to -1
  127969. */
  127970. private debugLimit;
  127971. /**
  127972. * @hidden
  127973. * This is reserved for the inspector.
  127974. * As the default viewing range might not be enough (if the ambient is really small for instance)
  127975. * You can use the factor to better multiply the final value.
  127976. */
  127977. private debugFactor;
  127978. /**
  127979. * Defines the clear coat layer parameters for the material.
  127980. */
  127981. readonly clearCoat: PBRClearCoatConfiguration;
  127982. /**
  127983. * Defines the anisotropic parameters for the material.
  127984. */
  127985. readonly anisotropy: PBRAnisotropicConfiguration;
  127986. /**
  127987. * Defines the BRDF parameters for the material.
  127988. */
  127989. readonly brdf: PBRBRDFConfiguration;
  127990. /**
  127991. * Defines the Sheen parameters for the material.
  127992. */
  127993. readonly sheen: PBRSheenConfiguration;
  127994. /**
  127995. * Defines the SubSurface parameters for the material.
  127996. */
  127997. readonly subSurface: PBRSubSurfaceConfiguration;
  127998. protected _rebuildInParallel: boolean;
  127999. /**
  128000. * Instantiates a new PBRMaterial instance.
  128001. *
  128002. * @param name The material name
  128003. * @param scene The scene the material will be use in.
  128004. */
  128005. constructor(name: string, scene: Scene);
  128006. /**
  128007. * Gets a boolean indicating that current material needs to register RTT
  128008. */
  128009. get hasRenderTargetTextures(): boolean;
  128010. /**
  128011. * Gets the name of the material class.
  128012. */
  128013. getClassName(): string;
  128014. /**
  128015. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128016. */
  128017. get useLogarithmicDepth(): boolean;
  128018. /**
  128019. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128020. */
  128021. set useLogarithmicDepth(value: boolean);
  128022. /**
  128023. * Returns true if alpha blending should be disabled.
  128024. */
  128025. protected get _disableAlphaBlending(): boolean;
  128026. /**
  128027. * Specifies whether or not this material should be rendered in alpha blend mode.
  128028. */
  128029. needAlphaBlending(): boolean;
  128030. /**
  128031. * Specifies whether or not this material should be rendered in alpha test mode.
  128032. */
  128033. needAlphaTesting(): boolean;
  128034. /**
  128035. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128036. */
  128037. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128038. /**
  128039. * Gets the texture used for the alpha test.
  128040. */
  128041. getAlphaTestTexture(): Nullable<BaseTexture>;
  128042. /**
  128043. * Specifies that the submesh is ready to be used.
  128044. * @param mesh - BJS mesh.
  128045. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128046. * @param useInstances - Specifies that instances should be used.
  128047. * @returns - boolean indicating that the submesh is ready or not.
  128048. */
  128049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128050. /**
  128051. * Specifies if the material uses metallic roughness workflow.
  128052. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128053. */
  128054. isMetallicWorkflow(): boolean;
  128055. private _prepareEffect;
  128056. private _prepareDefines;
  128057. /**
  128058. * Force shader compilation
  128059. */
  128060. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128061. /**
  128062. * Initializes the uniform buffer layout for the shader.
  128063. */
  128064. buildUniformLayout(): void;
  128065. /**
  128066. * Unbinds the material from the mesh
  128067. */
  128068. unbind(): void;
  128069. /**
  128070. * Binds the submesh data.
  128071. * @param world - The world matrix.
  128072. * @param mesh - The BJS mesh.
  128073. * @param subMesh - A submesh of the BJS mesh.
  128074. */
  128075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128076. /**
  128077. * Returns the animatable textures.
  128078. * @returns - Array of animatable textures.
  128079. */
  128080. getAnimatables(): IAnimatable[];
  128081. /**
  128082. * Returns the texture used for reflections.
  128083. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128084. */
  128085. private _getReflectionTexture;
  128086. /**
  128087. * Returns an array of the actively used textures.
  128088. * @returns - Array of BaseTextures
  128089. */
  128090. getActiveTextures(): BaseTexture[];
  128091. /**
  128092. * Checks to see if a texture is used in the material.
  128093. * @param texture - Base texture to use.
  128094. * @returns - Boolean specifying if a texture is used in the material.
  128095. */
  128096. hasTexture(texture: BaseTexture): boolean;
  128097. /**
  128098. * Disposes the resources of the material.
  128099. * @param forceDisposeEffect - Forces the disposal of effects.
  128100. * @param forceDisposeTextures - Forces the disposal of all textures.
  128101. */
  128102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128103. }
  128104. }
  128105. declare module BABYLON {
  128106. /**
  128107. * The Physically based material of BJS.
  128108. *
  128109. * This offers the main features of a standard PBR material.
  128110. * For more information, please refer to the documentation :
  128111. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128112. */
  128113. export class PBRMaterial extends PBRBaseMaterial {
  128114. /**
  128115. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128116. */
  128117. static readonly PBRMATERIAL_OPAQUE: number;
  128118. /**
  128119. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128120. */
  128121. static readonly PBRMATERIAL_ALPHATEST: number;
  128122. /**
  128123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128124. */
  128125. static readonly PBRMATERIAL_ALPHABLEND: number;
  128126. /**
  128127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128128. * They are also discarded below the alpha cutoff threshold to improve performances.
  128129. */
  128130. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128131. /**
  128132. * Defines the default value of how much AO map is occluding the analytical lights
  128133. * (point spot...).
  128134. */
  128135. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128136. /**
  128137. * Intensity of the direct lights e.g. the four lights available in your scene.
  128138. * This impacts both the direct diffuse and specular highlights.
  128139. */
  128140. directIntensity: number;
  128141. /**
  128142. * Intensity of the emissive part of the material.
  128143. * This helps controlling the emissive effect without modifying the emissive color.
  128144. */
  128145. emissiveIntensity: number;
  128146. /**
  128147. * Intensity of the environment e.g. how much the environment will light the object
  128148. * either through harmonics for rough material or through the refelction for shiny ones.
  128149. */
  128150. environmentIntensity: number;
  128151. /**
  128152. * This is a special control allowing the reduction of the specular highlights coming from the
  128153. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128154. */
  128155. specularIntensity: number;
  128156. /**
  128157. * Debug Control allowing disabling the bump map on this material.
  128158. */
  128159. disableBumpMap: boolean;
  128160. /**
  128161. * AKA Diffuse Texture in standard nomenclature.
  128162. */
  128163. albedoTexture: BaseTexture;
  128164. /**
  128165. * AKA Occlusion Texture in other nomenclature.
  128166. */
  128167. ambientTexture: BaseTexture;
  128168. /**
  128169. * AKA Occlusion Texture Intensity in other nomenclature.
  128170. */
  128171. ambientTextureStrength: number;
  128172. /**
  128173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128174. * 1 means it completely occludes it
  128175. * 0 mean it has no impact
  128176. */
  128177. ambientTextureImpactOnAnalyticalLights: number;
  128178. /**
  128179. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128180. */
  128181. opacityTexture: BaseTexture;
  128182. /**
  128183. * Stores the reflection values in a texture.
  128184. */
  128185. reflectionTexture: Nullable<BaseTexture>;
  128186. /**
  128187. * Stores the emissive values in a texture.
  128188. */
  128189. emissiveTexture: BaseTexture;
  128190. /**
  128191. * AKA Specular texture in other nomenclature.
  128192. */
  128193. reflectivityTexture: BaseTexture;
  128194. /**
  128195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128196. */
  128197. metallicTexture: BaseTexture;
  128198. /**
  128199. * Specifies the metallic scalar of the metallic/roughness workflow.
  128200. * Can also be used to scale the metalness values of the metallic texture.
  128201. */
  128202. metallic: Nullable<number>;
  128203. /**
  128204. * Specifies the roughness scalar of the metallic/roughness workflow.
  128205. * Can also be used to scale the roughness values of the metallic texture.
  128206. */
  128207. roughness: Nullable<number>;
  128208. /**
  128209. * Specifies the an F0 factor to help configuring the material F0.
  128210. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128211. * to 0.5 the previously hard coded value stays the same.
  128212. * Can also be used to scale the F0 values of the metallic texture.
  128213. */
  128214. metallicF0Factor: number;
  128215. /**
  128216. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128217. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128218. * your expectation as it multiplies with the texture data.
  128219. */
  128220. useMetallicF0FactorFromMetallicTexture: boolean;
  128221. /**
  128222. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128223. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128224. */
  128225. microSurfaceTexture: BaseTexture;
  128226. /**
  128227. * Stores surface normal data used to displace a mesh in a texture.
  128228. */
  128229. bumpTexture: BaseTexture;
  128230. /**
  128231. * Stores the pre-calculated light information of a mesh in a texture.
  128232. */
  128233. lightmapTexture: BaseTexture;
  128234. /**
  128235. * Stores the refracted light information in a texture.
  128236. */
  128237. get refractionTexture(): Nullable<BaseTexture>;
  128238. set refractionTexture(value: Nullable<BaseTexture>);
  128239. /**
  128240. * The color of a material in ambient lighting.
  128241. */
  128242. ambientColor: Color3;
  128243. /**
  128244. * AKA Diffuse Color in other nomenclature.
  128245. */
  128246. albedoColor: Color3;
  128247. /**
  128248. * AKA Specular Color in other nomenclature.
  128249. */
  128250. reflectivityColor: Color3;
  128251. /**
  128252. * The color reflected from the material.
  128253. */
  128254. reflectionColor: Color3;
  128255. /**
  128256. * The color emitted from the material.
  128257. */
  128258. emissiveColor: Color3;
  128259. /**
  128260. * AKA Glossiness in other nomenclature.
  128261. */
  128262. microSurface: number;
  128263. /**
  128264. * source material index of refraction (IOR)' / 'destination material IOR.
  128265. */
  128266. get indexOfRefraction(): number;
  128267. set indexOfRefraction(value: number);
  128268. /**
  128269. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128270. */
  128271. get invertRefractionY(): boolean;
  128272. set invertRefractionY(value: boolean);
  128273. /**
  128274. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128275. * Materials half opaque for instance using refraction could benefit from this control.
  128276. */
  128277. get linkRefractionWithTransparency(): boolean;
  128278. set linkRefractionWithTransparency(value: boolean);
  128279. /**
  128280. * If true, the light map contains occlusion information instead of lighting info.
  128281. */
  128282. useLightmapAsShadowmap: boolean;
  128283. /**
  128284. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128285. */
  128286. useAlphaFromAlbedoTexture: boolean;
  128287. /**
  128288. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128289. */
  128290. forceAlphaTest: boolean;
  128291. /**
  128292. * Defines the alpha limits in alpha test mode.
  128293. */
  128294. alphaCutOff: number;
  128295. /**
  128296. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128297. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128298. */
  128299. useSpecularOverAlpha: boolean;
  128300. /**
  128301. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128302. */
  128303. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128304. /**
  128305. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128306. */
  128307. useRoughnessFromMetallicTextureAlpha: boolean;
  128308. /**
  128309. * Specifies if the metallic texture contains the roughness information in its green channel.
  128310. */
  128311. useRoughnessFromMetallicTextureGreen: boolean;
  128312. /**
  128313. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128314. */
  128315. useMetallnessFromMetallicTextureBlue: boolean;
  128316. /**
  128317. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128318. */
  128319. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128320. /**
  128321. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128322. */
  128323. useAmbientInGrayScale: boolean;
  128324. /**
  128325. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128326. * The material will try to infer what glossiness each pixel should be.
  128327. */
  128328. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128329. /**
  128330. * BJS is using an harcoded light falloff based on a manually sets up range.
  128331. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128332. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128333. */
  128334. get usePhysicalLightFalloff(): boolean;
  128335. /**
  128336. * BJS is using an harcoded light falloff based on a manually sets up range.
  128337. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128338. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128339. */
  128340. set usePhysicalLightFalloff(value: boolean);
  128341. /**
  128342. * In order to support the falloff compatibility with gltf, a special mode has been added
  128343. * to reproduce the gltf light falloff.
  128344. */
  128345. get useGLTFLightFalloff(): boolean;
  128346. /**
  128347. * In order to support the falloff compatibility with gltf, a special mode has been added
  128348. * to reproduce the gltf light falloff.
  128349. */
  128350. set useGLTFLightFalloff(value: boolean);
  128351. /**
  128352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128354. */
  128355. useRadianceOverAlpha: boolean;
  128356. /**
  128357. * Allows using an object space normal map (instead of tangent space).
  128358. */
  128359. useObjectSpaceNormalMap: boolean;
  128360. /**
  128361. * Allows using the bump map in parallax mode.
  128362. */
  128363. useParallax: boolean;
  128364. /**
  128365. * Allows using the bump map in parallax occlusion mode.
  128366. */
  128367. useParallaxOcclusion: boolean;
  128368. /**
  128369. * Controls the scale bias of the parallax mode.
  128370. */
  128371. parallaxScaleBias: number;
  128372. /**
  128373. * If sets to true, disables all the lights affecting the material.
  128374. */
  128375. disableLighting: boolean;
  128376. /**
  128377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128378. */
  128379. forceIrradianceInFragment: boolean;
  128380. /**
  128381. * Number of Simultaneous lights allowed on the material.
  128382. */
  128383. maxSimultaneousLights: number;
  128384. /**
  128385. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128386. */
  128387. invertNormalMapX: boolean;
  128388. /**
  128389. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128390. */
  128391. invertNormalMapY: boolean;
  128392. /**
  128393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128394. */
  128395. twoSidedLighting: boolean;
  128396. /**
  128397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128398. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128399. */
  128400. useAlphaFresnel: boolean;
  128401. /**
  128402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128403. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128404. */
  128405. useLinearAlphaFresnel: boolean;
  128406. /**
  128407. * Let user defines the brdf lookup texture used for IBL.
  128408. * A default 8bit version is embedded but you could point at :
  128409. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128410. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128411. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128412. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128413. */
  128414. environmentBRDFTexture: Nullable<BaseTexture>;
  128415. /**
  128416. * Force normal to face away from face.
  128417. */
  128418. forceNormalForward: boolean;
  128419. /**
  128420. * Enables specular anti aliasing in the PBR shader.
  128421. * It will both interacts on the Geometry for analytical and IBL lighting.
  128422. * It also prefilter the roughness map based on the bump values.
  128423. */
  128424. enableSpecularAntiAliasing: boolean;
  128425. /**
  128426. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128427. * makes the reflect vector face the model (under horizon).
  128428. */
  128429. useHorizonOcclusion: boolean;
  128430. /**
  128431. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128432. * too much the area relying on ambient texture to define their ambient occlusion.
  128433. */
  128434. useRadianceOcclusion: boolean;
  128435. /**
  128436. * If set to true, no lighting calculations will be applied.
  128437. */
  128438. unlit: boolean;
  128439. /**
  128440. * Gets the image processing configuration used either in this material.
  128441. */
  128442. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128443. /**
  128444. * Sets the Default image processing configuration used either in the this material.
  128445. *
  128446. * If sets to null, the scene one is in use.
  128447. */
  128448. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128449. /**
  128450. * Gets wether the color curves effect is enabled.
  128451. */
  128452. get cameraColorCurvesEnabled(): boolean;
  128453. /**
  128454. * Sets wether the color curves effect is enabled.
  128455. */
  128456. set cameraColorCurvesEnabled(value: boolean);
  128457. /**
  128458. * Gets wether the color grading effect is enabled.
  128459. */
  128460. get cameraColorGradingEnabled(): boolean;
  128461. /**
  128462. * Gets wether the color grading effect is enabled.
  128463. */
  128464. set cameraColorGradingEnabled(value: boolean);
  128465. /**
  128466. * Gets wether tonemapping is enabled or not.
  128467. */
  128468. get cameraToneMappingEnabled(): boolean;
  128469. /**
  128470. * Sets wether tonemapping is enabled or not
  128471. */
  128472. set cameraToneMappingEnabled(value: boolean);
  128473. /**
  128474. * The camera exposure used on this material.
  128475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128476. * This corresponds to a photographic exposure.
  128477. */
  128478. get cameraExposure(): number;
  128479. /**
  128480. * The camera exposure used on this material.
  128481. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128482. * This corresponds to a photographic exposure.
  128483. */
  128484. set cameraExposure(value: number);
  128485. /**
  128486. * Gets The camera contrast used on this material.
  128487. */
  128488. get cameraContrast(): number;
  128489. /**
  128490. * Sets The camera contrast used on this material.
  128491. */
  128492. set cameraContrast(value: number);
  128493. /**
  128494. * Gets the Color Grading 2D Lookup Texture.
  128495. */
  128496. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128497. /**
  128498. * Sets the Color Grading 2D Lookup Texture.
  128499. */
  128500. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128501. /**
  128502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128504. * 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;
  128505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128506. */
  128507. get cameraColorCurves(): Nullable<ColorCurves>;
  128508. /**
  128509. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128510. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128511. * 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;
  128512. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128513. */
  128514. set cameraColorCurves(value: Nullable<ColorCurves>);
  128515. /**
  128516. * Instantiates a new PBRMaterial instance.
  128517. *
  128518. * @param name The material name
  128519. * @param scene The scene the material will be use in.
  128520. */
  128521. constructor(name: string, scene: Scene);
  128522. /**
  128523. * Returns the name of this material class.
  128524. */
  128525. getClassName(): string;
  128526. /**
  128527. * Makes a duplicate of the current material.
  128528. * @param name - name to use for the new material.
  128529. */
  128530. clone(name: string): PBRMaterial;
  128531. /**
  128532. * Serializes this PBR Material.
  128533. * @returns - An object with the serialized material.
  128534. */
  128535. serialize(): any;
  128536. /**
  128537. * Parses a PBR Material from a serialized object.
  128538. * @param source - Serialized object.
  128539. * @param scene - BJS scene instance.
  128540. * @param rootUrl - url for the scene object
  128541. * @returns - PBRMaterial
  128542. */
  128543. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128544. }
  128545. }
  128546. declare module BABYLON {
  128547. /**
  128548. * Direct draw surface info
  128549. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128550. */
  128551. export interface DDSInfo {
  128552. /**
  128553. * Width of the texture
  128554. */
  128555. width: number;
  128556. /**
  128557. * Width of the texture
  128558. */
  128559. height: number;
  128560. /**
  128561. * Number of Mipmaps for the texture
  128562. * @see https://en.wikipedia.org/wiki/Mipmap
  128563. */
  128564. mipmapCount: number;
  128565. /**
  128566. * If the textures format is a known fourCC format
  128567. * @see https://www.fourcc.org/
  128568. */
  128569. isFourCC: boolean;
  128570. /**
  128571. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128572. */
  128573. isRGB: boolean;
  128574. /**
  128575. * If the texture is a lumincance format
  128576. */
  128577. isLuminance: boolean;
  128578. /**
  128579. * If this is a cube texture
  128580. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128581. */
  128582. isCube: boolean;
  128583. /**
  128584. * If the texture is a compressed format eg. FOURCC_DXT1
  128585. */
  128586. isCompressed: boolean;
  128587. /**
  128588. * The dxgiFormat of the texture
  128589. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128590. */
  128591. dxgiFormat: number;
  128592. /**
  128593. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128594. */
  128595. textureType: number;
  128596. /**
  128597. * Sphericle polynomial created for the dds texture
  128598. */
  128599. sphericalPolynomial?: SphericalPolynomial;
  128600. }
  128601. /**
  128602. * Class used to provide DDS decompression tools
  128603. */
  128604. export class DDSTools {
  128605. /**
  128606. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128607. */
  128608. static StoreLODInAlphaChannel: boolean;
  128609. /**
  128610. * Gets DDS information from an array buffer
  128611. * @param data defines the array buffer view to read data from
  128612. * @returns the DDS information
  128613. */
  128614. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128615. private static _FloatView;
  128616. private static _Int32View;
  128617. private static _ToHalfFloat;
  128618. private static _FromHalfFloat;
  128619. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128620. private static _GetHalfFloatRGBAArrayBuffer;
  128621. private static _GetFloatRGBAArrayBuffer;
  128622. private static _GetFloatAsUIntRGBAArrayBuffer;
  128623. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128624. private static _GetRGBAArrayBuffer;
  128625. private static _ExtractLongWordOrder;
  128626. private static _GetRGBArrayBuffer;
  128627. private static _GetLuminanceArrayBuffer;
  128628. /**
  128629. * Uploads DDS Levels to a Babylon Texture
  128630. * @hidden
  128631. */
  128632. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128633. }
  128634. interface ThinEngine {
  128635. /**
  128636. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128637. * @param rootUrl defines the url where the file to load is located
  128638. * @param scene defines the current scene
  128639. * @param lodScale defines scale to apply to the mip map selection
  128640. * @param lodOffset defines offset to apply to the mip map selection
  128641. * @param onLoad defines an optional callback raised when the texture is loaded
  128642. * @param onError defines an optional callback raised if there is an issue to load the texture
  128643. * @param format defines the format of the data
  128644. * @param forcedExtension defines the extension to use to pick the right loader
  128645. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128646. * @returns the cube texture as an InternalTexture
  128647. */
  128648. 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;
  128649. }
  128650. }
  128651. declare module BABYLON {
  128652. /**
  128653. * Implementation of the DDS Texture Loader.
  128654. * @hidden
  128655. */
  128656. export class _DDSTextureLoader implements IInternalTextureLoader {
  128657. /**
  128658. * Defines wether the loader supports cascade loading the different faces.
  128659. */
  128660. readonly supportCascades: boolean;
  128661. /**
  128662. * This returns if the loader support the current file information.
  128663. * @param extension defines the file extension of the file being loaded
  128664. * @returns true if the loader can load the specified file
  128665. */
  128666. canLoad(extension: string): boolean;
  128667. /**
  128668. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128669. * @param data contains the texture data
  128670. * @param texture defines the BabylonJS internal texture
  128671. * @param createPolynomials will be true if polynomials have been requested
  128672. * @param onLoad defines the callback to trigger once the texture is ready
  128673. * @param onError defines the callback to trigger in case of error
  128674. */
  128675. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128676. /**
  128677. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128678. * @param data contains the texture data
  128679. * @param texture defines the BabylonJS internal texture
  128680. * @param callback defines the method to call once ready to upload
  128681. */
  128682. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128683. }
  128684. }
  128685. declare module BABYLON {
  128686. /**
  128687. * Implementation of the ENV Texture Loader.
  128688. * @hidden
  128689. */
  128690. export class _ENVTextureLoader implements IInternalTextureLoader {
  128691. /**
  128692. * Defines wether the loader supports cascade loading the different faces.
  128693. */
  128694. readonly supportCascades: boolean;
  128695. /**
  128696. * This returns if the loader support the current file information.
  128697. * @param extension defines the file extension of the file being loaded
  128698. * @returns true if the loader can load the specified file
  128699. */
  128700. canLoad(extension: string): boolean;
  128701. /**
  128702. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128703. * @param data contains the texture data
  128704. * @param texture defines the BabylonJS internal texture
  128705. * @param createPolynomials will be true if polynomials have been requested
  128706. * @param onLoad defines the callback to trigger once the texture is ready
  128707. * @param onError defines the callback to trigger in case of error
  128708. */
  128709. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128710. /**
  128711. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128712. * @param data contains the texture data
  128713. * @param texture defines the BabylonJS internal texture
  128714. * @param callback defines the method to call once ready to upload
  128715. */
  128716. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128717. }
  128718. }
  128719. declare module BABYLON {
  128720. /**
  128721. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128722. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128723. */
  128724. export class KhronosTextureContainer {
  128725. /** contents of the KTX container file */
  128726. data: ArrayBufferView;
  128727. private static HEADER_LEN;
  128728. private static COMPRESSED_2D;
  128729. private static COMPRESSED_3D;
  128730. private static TEX_2D;
  128731. private static TEX_3D;
  128732. /**
  128733. * Gets the openGL type
  128734. */
  128735. glType: number;
  128736. /**
  128737. * Gets the openGL type size
  128738. */
  128739. glTypeSize: number;
  128740. /**
  128741. * Gets the openGL format
  128742. */
  128743. glFormat: number;
  128744. /**
  128745. * Gets the openGL internal format
  128746. */
  128747. glInternalFormat: number;
  128748. /**
  128749. * Gets the base internal format
  128750. */
  128751. glBaseInternalFormat: number;
  128752. /**
  128753. * Gets image width in pixel
  128754. */
  128755. pixelWidth: number;
  128756. /**
  128757. * Gets image height in pixel
  128758. */
  128759. pixelHeight: number;
  128760. /**
  128761. * Gets image depth in pixels
  128762. */
  128763. pixelDepth: number;
  128764. /**
  128765. * Gets the number of array elements
  128766. */
  128767. numberOfArrayElements: number;
  128768. /**
  128769. * Gets the number of faces
  128770. */
  128771. numberOfFaces: number;
  128772. /**
  128773. * Gets the number of mipmap levels
  128774. */
  128775. numberOfMipmapLevels: number;
  128776. /**
  128777. * Gets the bytes of key value data
  128778. */
  128779. bytesOfKeyValueData: number;
  128780. /**
  128781. * Gets the load type
  128782. */
  128783. loadType: number;
  128784. /**
  128785. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  128786. */
  128787. isInvalid: boolean;
  128788. /**
  128789. * Creates a new KhronosTextureContainer
  128790. * @param data contents of the KTX container file
  128791. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  128792. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  128793. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  128794. */
  128795. constructor(
  128796. /** contents of the KTX container file */
  128797. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  128798. /**
  128799. * Uploads KTX content to a Babylon Texture.
  128800. * It is assumed that the texture has already been created & is currently bound
  128801. * @hidden
  128802. */
  128803. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  128804. private _upload2DCompressedLevels;
  128805. /**
  128806. * Checks if the given data starts with a KTX file identifier.
  128807. * @param data the data to check
  128808. * @returns true if the data is a KTX file or false otherwise
  128809. */
  128810. static IsValid(data: ArrayBufferView): boolean;
  128811. }
  128812. }
  128813. declare module BABYLON {
  128814. /**
  128815. * Class for loading KTX2 files
  128816. * !!! Experimental Extension Subject to Changes !!!
  128817. * @hidden
  128818. */
  128819. export class KhronosTextureContainer2 {
  128820. private static _ModulePromise;
  128821. private static _TranscodeFormat;
  128822. constructor(engine: ThinEngine);
  128823. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  128824. private _determineTranscodeFormat;
  128825. /**
  128826. * Checks if the given data starts with a KTX2 file identifier.
  128827. * @param data the data to check
  128828. * @returns true if the data is a KTX2 file or false otherwise
  128829. */
  128830. static IsValid(data: ArrayBufferView): boolean;
  128831. }
  128832. }
  128833. declare module BABYLON {
  128834. /**
  128835. * Implementation of the KTX Texture Loader.
  128836. * @hidden
  128837. */
  128838. export class _KTXTextureLoader implements IInternalTextureLoader {
  128839. /**
  128840. * Defines wether the loader supports cascade loading the different faces.
  128841. */
  128842. readonly supportCascades: boolean;
  128843. /**
  128844. * This returns if the loader support the current file information.
  128845. * @param extension defines the file extension of the file being loaded
  128846. * @returns true if the loader can load the specified file
  128847. */
  128848. canLoad(extension: string): boolean;
  128849. /**
  128850. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128851. * @param data contains the texture data
  128852. * @param texture defines the BabylonJS internal texture
  128853. * @param createPolynomials will be true if polynomials have been requested
  128854. * @param onLoad defines the callback to trigger once the texture is ready
  128855. * @param onError defines the callback to trigger in case of error
  128856. */
  128857. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128858. /**
  128859. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128860. * @param data contains the texture data
  128861. * @param texture defines the BabylonJS internal texture
  128862. * @param callback defines the method to call once ready to upload
  128863. */
  128864. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  128865. }
  128866. }
  128867. declare module BABYLON {
  128868. /** @hidden */
  128869. export var _forceSceneHelpersToBundle: boolean;
  128870. interface Scene {
  128871. /**
  128872. * Creates a default light for the scene.
  128873. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  128874. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  128875. */
  128876. createDefaultLight(replace?: boolean): void;
  128877. /**
  128878. * Creates a default camera for the scene.
  128879. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  128880. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128881. * @param replace has default false, when true replaces the active camera in the scene
  128882. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  128883. */
  128884. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128885. /**
  128886. * Creates a default camera and a default light.
  128887. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  128888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128889. * @param replace has the default false, when true replaces the active camera/light in the scene
  128890. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  128891. */
  128892. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128893. /**
  128894. * Creates a new sky box
  128895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  128896. * @param environmentTexture defines the texture to use as environment texture
  128897. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  128898. * @param scale defines the overall scale of the skybox
  128899. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  128900. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  128901. * @returns a new mesh holding the sky box
  128902. */
  128903. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  128904. /**
  128905. * Creates a new environment
  128906. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  128907. * @param options defines the options you can use to configure the environment
  128908. * @returns the new EnvironmentHelper
  128909. */
  128910. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  128911. /**
  128912. * Creates a new VREXperienceHelper
  128913. * @see http://doc.babylonjs.com/how_to/webvr_helper
  128914. * @param webVROptions defines the options used to create the new VREXperienceHelper
  128915. * @returns a new VREXperienceHelper
  128916. */
  128917. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  128918. /**
  128919. * Creates a new WebXRDefaultExperience
  128920. * @see http://doc.babylonjs.com/how_to/webxr
  128921. * @param options experience options
  128922. * @returns a promise for a new WebXRDefaultExperience
  128923. */
  128924. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128925. }
  128926. }
  128927. declare module BABYLON {
  128928. /**
  128929. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  128930. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  128931. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  128932. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  128933. */
  128934. export class VideoDome extends TransformNode {
  128935. /**
  128936. * Define the video source as a Monoscopic panoramic 360 video.
  128937. */
  128938. static readonly MODE_MONOSCOPIC: number;
  128939. /**
  128940. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128941. */
  128942. static readonly MODE_TOPBOTTOM: number;
  128943. /**
  128944. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128945. */
  128946. static readonly MODE_SIDEBYSIDE: number;
  128947. private _halfDome;
  128948. private _useDirectMapping;
  128949. /**
  128950. * The video texture being displayed on the sphere
  128951. */
  128952. protected _videoTexture: VideoTexture;
  128953. /**
  128954. * Gets the video texture being displayed on the sphere
  128955. */
  128956. get videoTexture(): VideoTexture;
  128957. /**
  128958. * The skybox material
  128959. */
  128960. protected _material: BackgroundMaterial;
  128961. /**
  128962. * The surface used for the skybox
  128963. */
  128964. protected _mesh: Mesh;
  128965. /**
  128966. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  128967. */
  128968. private _halfDomeMask;
  128969. /**
  128970. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  128971. * Also see the options.resolution property.
  128972. */
  128973. get fovMultiplier(): number;
  128974. set fovMultiplier(value: number);
  128975. private _videoMode;
  128976. /**
  128977. * Gets or set the current video mode for the video. It can be:
  128978. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  128979. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128980. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128981. */
  128982. get videoMode(): number;
  128983. set videoMode(value: number);
  128984. /**
  128985. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  128986. *
  128987. */
  128988. get halfDome(): boolean;
  128989. /**
  128990. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  128991. */
  128992. set halfDome(enabled: boolean);
  128993. /**
  128994. * Oberserver used in Stereoscopic VR Mode.
  128995. */
  128996. private _onBeforeCameraRenderObserver;
  128997. /**
  128998. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  128999. * @param name Element's name, child elements will append suffixes for their own names.
  129000. * @param urlsOrVideo defines the url(s) or the video element to use
  129001. * @param options An object containing optional or exposed sub element properties
  129002. */
  129003. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  129004. resolution?: number;
  129005. clickToPlay?: boolean;
  129006. autoPlay?: boolean;
  129007. loop?: boolean;
  129008. size?: number;
  129009. poster?: string;
  129010. faceForward?: boolean;
  129011. useDirectMapping?: boolean;
  129012. halfDomeMode?: boolean;
  129013. }, scene: Scene);
  129014. private _changeVideoMode;
  129015. /**
  129016. * Releases resources associated with this node.
  129017. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129018. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129019. */
  129020. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129021. }
  129022. }
  129023. declare module BABYLON {
  129024. /**
  129025. * This class can be used to get instrumentation data from a Babylon engine
  129026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129027. */
  129028. export class EngineInstrumentation implements IDisposable {
  129029. /**
  129030. * Define the instrumented engine.
  129031. */
  129032. engine: Engine;
  129033. private _captureGPUFrameTime;
  129034. private _gpuFrameTimeToken;
  129035. private _gpuFrameTime;
  129036. private _captureShaderCompilationTime;
  129037. private _shaderCompilationTime;
  129038. private _onBeginFrameObserver;
  129039. private _onEndFrameObserver;
  129040. private _onBeforeShaderCompilationObserver;
  129041. private _onAfterShaderCompilationObserver;
  129042. /**
  129043. * Gets the perf counter used for GPU frame time
  129044. */
  129045. get gpuFrameTimeCounter(): PerfCounter;
  129046. /**
  129047. * Gets the GPU frame time capture status
  129048. */
  129049. get captureGPUFrameTime(): boolean;
  129050. /**
  129051. * Enable or disable the GPU frame time capture
  129052. */
  129053. set captureGPUFrameTime(value: boolean);
  129054. /**
  129055. * Gets the perf counter used for shader compilation time
  129056. */
  129057. get shaderCompilationTimeCounter(): PerfCounter;
  129058. /**
  129059. * Gets the shader compilation time capture status
  129060. */
  129061. get captureShaderCompilationTime(): boolean;
  129062. /**
  129063. * Enable or disable the shader compilation time capture
  129064. */
  129065. set captureShaderCompilationTime(value: boolean);
  129066. /**
  129067. * Instantiates a new engine instrumentation.
  129068. * This class can be used to get instrumentation data from a Babylon engine
  129069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129070. * @param engine Defines the engine to instrument
  129071. */
  129072. constructor(
  129073. /**
  129074. * Define the instrumented engine.
  129075. */
  129076. engine: Engine);
  129077. /**
  129078. * Dispose and release associated resources.
  129079. */
  129080. dispose(): void;
  129081. }
  129082. }
  129083. declare module BABYLON {
  129084. /**
  129085. * This class can be used to get instrumentation data from a Babylon engine
  129086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129087. */
  129088. export class SceneInstrumentation implements IDisposable {
  129089. /**
  129090. * Defines the scene to instrument
  129091. */
  129092. scene: Scene;
  129093. private _captureActiveMeshesEvaluationTime;
  129094. private _activeMeshesEvaluationTime;
  129095. private _captureRenderTargetsRenderTime;
  129096. private _renderTargetsRenderTime;
  129097. private _captureFrameTime;
  129098. private _frameTime;
  129099. private _captureRenderTime;
  129100. private _renderTime;
  129101. private _captureInterFrameTime;
  129102. private _interFrameTime;
  129103. private _captureParticlesRenderTime;
  129104. private _particlesRenderTime;
  129105. private _captureSpritesRenderTime;
  129106. private _spritesRenderTime;
  129107. private _capturePhysicsTime;
  129108. private _physicsTime;
  129109. private _captureAnimationsTime;
  129110. private _animationsTime;
  129111. private _captureCameraRenderTime;
  129112. private _cameraRenderTime;
  129113. private _onBeforeActiveMeshesEvaluationObserver;
  129114. private _onAfterActiveMeshesEvaluationObserver;
  129115. private _onBeforeRenderTargetsRenderObserver;
  129116. private _onAfterRenderTargetsRenderObserver;
  129117. private _onAfterRenderObserver;
  129118. private _onBeforeDrawPhaseObserver;
  129119. private _onAfterDrawPhaseObserver;
  129120. private _onBeforeAnimationsObserver;
  129121. private _onBeforeParticlesRenderingObserver;
  129122. private _onAfterParticlesRenderingObserver;
  129123. private _onBeforeSpritesRenderingObserver;
  129124. private _onAfterSpritesRenderingObserver;
  129125. private _onBeforePhysicsObserver;
  129126. private _onAfterPhysicsObserver;
  129127. private _onAfterAnimationsObserver;
  129128. private _onBeforeCameraRenderObserver;
  129129. private _onAfterCameraRenderObserver;
  129130. /**
  129131. * Gets the perf counter used for active meshes evaluation time
  129132. */
  129133. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129134. /**
  129135. * Gets the active meshes evaluation time capture status
  129136. */
  129137. get captureActiveMeshesEvaluationTime(): boolean;
  129138. /**
  129139. * Enable or disable the active meshes evaluation time capture
  129140. */
  129141. set captureActiveMeshesEvaluationTime(value: boolean);
  129142. /**
  129143. * Gets the perf counter used for render targets render time
  129144. */
  129145. get renderTargetsRenderTimeCounter(): PerfCounter;
  129146. /**
  129147. * Gets the render targets render time capture status
  129148. */
  129149. get captureRenderTargetsRenderTime(): boolean;
  129150. /**
  129151. * Enable or disable the render targets render time capture
  129152. */
  129153. set captureRenderTargetsRenderTime(value: boolean);
  129154. /**
  129155. * Gets the perf counter used for particles render time
  129156. */
  129157. get particlesRenderTimeCounter(): PerfCounter;
  129158. /**
  129159. * Gets the particles render time capture status
  129160. */
  129161. get captureParticlesRenderTime(): boolean;
  129162. /**
  129163. * Enable or disable the particles render time capture
  129164. */
  129165. set captureParticlesRenderTime(value: boolean);
  129166. /**
  129167. * Gets the perf counter used for sprites render time
  129168. */
  129169. get spritesRenderTimeCounter(): PerfCounter;
  129170. /**
  129171. * Gets the sprites render time capture status
  129172. */
  129173. get captureSpritesRenderTime(): boolean;
  129174. /**
  129175. * Enable or disable the sprites render time capture
  129176. */
  129177. set captureSpritesRenderTime(value: boolean);
  129178. /**
  129179. * Gets the perf counter used for physics time
  129180. */
  129181. get physicsTimeCounter(): PerfCounter;
  129182. /**
  129183. * Gets the physics time capture status
  129184. */
  129185. get capturePhysicsTime(): boolean;
  129186. /**
  129187. * Enable or disable the physics time capture
  129188. */
  129189. set capturePhysicsTime(value: boolean);
  129190. /**
  129191. * Gets the perf counter used for animations time
  129192. */
  129193. get animationsTimeCounter(): PerfCounter;
  129194. /**
  129195. * Gets the animations time capture status
  129196. */
  129197. get captureAnimationsTime(): boolean;
  129198. /**
  129199. * Enable or disable the animations time capture
  129200. */
  129201. set captureAnimationsTime(value: boolean);
  129202. /**
  129203. * Gets the perf counter used for frame time capture
  129204. */
  129205. get frameTimeCounter(): PerfCounter;
  129206. /**
  129207. * Gets the frame time capture status
  129208. */
  129209. get captureFrameTime(): boolean;
  129210. /**
  129211. * Enable or disable the frame time capture
  129212. */
  129213. set captureFrameTime(value: boolean);
  129214. /**
  129215. * Gets the perf counter used for inter-frames time capture
  129216. */
  129217. get interFrameTimeCounter(): PerfCounter;
  129218. /**
  129219. * Gets the inter-frames time capture status
  129220. */
  129221. get captureInterFrameTime(): boolean;
  129222. /**
  129223. * Enable or disable the inter-frames time capture
  129224. */
  129225. set captureInterFrameTime(value: boolean);
  129226. /**
  129227. * Gets the perf counter used for render time capture
  129228. */
  129229. get renderTimeCounter(): PerfCounter;
  129230. /**
  129231. * Gets the render time capture status
  129232. */
  129233. get captureRenderTime(): boolean;
  129234. /**
  129235. * Enable or disable the render time capture
  129236. */
  129237. set captureRenderTime(value: boolean);
  129238. /**
  129239. * Gets the perf counter used for camera render time capture
  129240. */
  129241. get cameraRenderTimeCounter(): PerfCounter;
  129242. /**
  129243. * Gets the camera render time capture status
  129244. */
  129245. get captureCameraRenderTime(): boolean;
  129246. /**
  129247. * Enable or disable the camera render time capture
  129248. */
  129249. set captureCameraRenderTime(value: boolean);
  129250. /**
  129251. * Gets the perf counter used for draw calls
  129252. */
  129253. get drawCallsCounter(): PerfCounter;
  129254. /**
  129255. * Instantiates a new scene instrumentation.
  129256. * This class can be used to get instrumentation data from a Babylon engine
  129257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129258. * @param scene Defines the scene to instrument
  129259. */
  129260. constructor(
  129261. /**
  129262. * Defines the scene to instrument
  129263. */
  129264. scene: Scene);
  129265. /**
  129266. * Dispose and release associated resources.
  129267. */
  129268. dispose(): void;
  129269. }
  129270. }
  129271. declare module BABYLON {
  129272. /** @hidden */
  129273. export var glowMapGenerationPixelShader: {
  129274. name: string;
  129275. shader: string;
  129276. };
  129277. }
  129278. declare module BABYLON {
  129279. /** @hidden */
  129280. export var glowMapGenerationVertexShader: {
  129281. name: string;
  129282. shader: string;
  129283. };
  129284. }
  129285. declare module BABYLON {
  129286. /**
  129287. * Effect layer options. This helps customizing the behaviour
  129288. * of the effect layer.
  129289. */
  129290. export interface IEffectLayerOptions {
  129291. /**
  129292. * Multiplication factor apply to the canvas size to compute the render target size
  129293. * used to generated the objects (the smaller the faster).
  129294. */
  129295. mainTextureRatio: number;
  129296. /**
  129297. * Enforces a fixed size texture to ensure effect stability across devices.
  129298. */
  129299. mainTextureFixedSize?: number;
  129300. /**
  129301. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129302. */
  129303. alphaBlendingMode: number;
  129304. /**
  129305. * The camera attached to the layer.
  129306. */
  129307. camera: Nullable<Camera>;
  129308. /**
  129309. * The rendering group to draw the layer in.
  129310. */
  129311. renderingGroupId: number;
  129312. }
  129313. /**
  129314. * The effect layer Helps adding post process effect blended with the main pass.
  129315. *
  129316. * This can be for instance use to generate glow or higlight effects on the scene.
  129317. *
  129318. * The effect layer class can not be used directly and is intented to inherited from to be
  129319. * customized per effects.
  129320. */
  129321. export abstract class EffectLayer {
  129322. private _vertexBuffers;
  129323. private _indexBuffer;
  129324. private _cachedDefines;
  129325. private _effectLayerMapGenerationEffect;
  129326. private _effectLayerOptions;
  129327. private _mergeEffect;
  129328. protected _scene: Scene;
  129329. protected _engine: Engine;
  129330. protected _maxSize: number;
  129331. protected _mainTextureDesiredSize: ISize;
  129332. protected _mainTexture: RenderTargetTexture;
  129333. protected _shouldRender: boolean;
  129334. protected _postProcesses: PostProcess[];
  129335. protected _textures: BaseTexture[];
  129336. protected _emissiveTextureAndColor: {
  129337. texture: Nullable<BaseTexture>;
  129338. color: Color4;
  129339. };
  129340. /**
  129341. * The name of the layer
  129342. */
  129343. name: string;
  129344. /**
  129345. * The clear color of the texture used to generate the glow map.
  129346. */
  129347. neutralColor: Color4;
  129348. /**
  129349. * Specifies whether the highlight layer is enabled or not.
  129350. */
  129351. isEnabled: boolean;
  129352. /**
  129353. * Gets the camera attached to the layer.
  129354. */
  129355. get camera(): Nullable<Camera>;
  129356. /**
  129357. * Gets the rendering group id the layer should render in.
  129358. */
  129359. get renderingGroupId(): number;
  129360. set renderingGroupId(renderingGroupId: number);
  129361. /**
  129362. * An event triggered when the effect layer has been disposed.
  129363. */
  129364. onDisposeObservable: Observable<EffectLayer>;
  129365. /**
  129366. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129367. */
  129368. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129369. /**
  129370. * An event triggered when the generated texture is being merged in the scene.
  129371. */
  129372. onBeforeComposeObservable: Observable<EffectLayer>;
  129373. /**
  129374. * An event triggered when the mesh is rendered into the effect render target.
  129375. */
  129376. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129377. /**
  129378. * An event triggered after the mesh has been rendered into the effect render target.
  129379. */
  129380. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129381. /**
  129382. * An event triggered when the generated texture has been merged in the scene.
  129383. */
  129384. onAfterComposeObservable: Observable<EffectLayer>;
  129385. /**
  129386. * An event triggered when the efffect layer changes its size.
  129387. */
  129388. onSizeChangedObservable: Observable<EffectLayer>;
  129389. /** @hidden */
  129390. static _SceneComponentInitialization: (scene: Scene) => void;
  129391. /**
  129392. * Instantiates a new effect Layer and references it in the scene.
  129393. * @param name The name of the layer
  129394. * @param scene The scene to use the layer in
  129395. */
  129396. constructor(
  129397. /** The Friendly of the effect in the scene */
  129398. name: string, scene: Scene);
  129399. /**
  129400. * Get the effect name of the layer.
  129401. * @return The effect name
  129402. */
  129403. abstract getEffectName(): string;
  129404. /**
  129405. * Checks for the readiness of the element composing the layer.
  129406. * @param subMesh the mesh to check for
  129407. * @param useInstances specify whether or not to use instances to render the mesh
  129408. * @return true if ready otherwise, false
  129409. */
  129410. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129411. /**
  129412. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129413. * @returns true if the effect requires stencil during the main canvas render pass.
  129414. */
  129415. abstract needStencil(): boolean;
  129416. /**
  129417. * Create the merge effect. This is the shader use to blit the information back
  129418. * to the main canvas at the end of the scene rendering.
  129419. * @returns The effect containing the shader used to merge the effect on the main canvas
  129420. */
  129421. protected abstract _createMergeEffect(): Effect;
  129422. /**
  129423. * Creates the render target textures and post processes used in the effect layer.
  129424. */
  129425. protected abstract _createTextureAndPostProcesses(): void;
  129426. /**
  129427. * Implementation specific of rendering the generating effect on the main canvas.
  129428. * @param effect The effect used to render through
  129429. */
  129430. protected abstract _internalRender(effect: Effect): void;
  129431. /**
  129432. * Sets the required values for both the emissive texture and and the main color.
  129433. */
  129434. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129435. /**
  129436. * Free any resources and references associated to a mesh.
  129437. * Internal use
  129438. * @param mesh The mesh to free.
  129439. */
  129440. abstract _disposeMesh(mesh: Mesh): void;
  129441. /**
  129442. * Serializes this layer (Glow or Highlight for example)
  129443. * @returns a serialized layer object
  129444. */
  129445. abstract serialize?(): any;
  129446. /**
  129447. * Initializes the effect layer with the required options.
  129448. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129449. */
  129450. protected _init(options: Partial<IEffectLayerOptions>): void;
  129451. /**
  129452. * Generates the index buffer of the full screen quad blending to the main canvas.
  129453. */
  129454. private _generateIndexBuffer;
  129455. /**
  129456. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129457. */
  129458. private _generateVertexBuffer;
  129459. /**
  129460. * Sets the main texture desired size which is the closest power of two
  129461. * of the engine canvas size.
  129462. */
  129463. private _setMainTextureSize;
  129464. /**
  129465. * Creates the main texture for the effect layer.
  129466. */
  129467. protected _createMainTexture(): void;
  129468. /**
  129469. * Adds specific effects defines.
  129470. * @param defines The defines to add specifics to.
  129471. */
  129472. protected _addCustomEffectDefines(defines: string[]): void;
  129473. /**
  129474. * Checks for the readiness of the element composing the layer.
  129475. * @param subMesh the mesh to check for
  129476. * @param useInstances specify whether or not to use instances to render the mesh
  129477. * @param emissiveTexture the associated emissive texture used to generate the glow
  129478. * @return true if ready otherwise, false
  129479. */
  129480. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129481. /**
  129482. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129483. */
  129484. render(): void;
  129485. /**
  129486. * Determine if a given mesh will be used in the current effect.
  129487. * @param mesh mesh to test
  129488. * @returns true if the mesh will be used
  129489. */
  129490. hasMesh(mesh: AbstractMesh): boolean;
  129491. /**
  129492. * Returns true if the layer contains information to display, otherwise false.
  129493. * @returns true if the glow layer should be rendered
  129494. */
  129495. shouldRender(): boolean;
  129496. /**
  129497. * Returns true if the mesh should render, otherwise false.
  129498. * @param mesh The mesh to render
  129499. * @returns true if it should render otherwise false
  129500. */
  129501. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129502. /**
  129503. * Returns true if the mesh can be rendered, otherwise false.
  129504. * @param mesh The mesh to render
  129505. * @param material The material used on the mesh
  129506. * @returns true if it can be rendered otherwise false
  129507. */
  129508. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129509. /**
  129510. * Returns true if the mesh should render, otherwise false.
  129511. * @param mesh The mesh to render
  129512. * @returns true if it should render otherwise false
  129513. */
  129514. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129515. /**
  129516. * Renders the submesh passed in parameter to the generation map.
  129517. */
  129518. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129519. /**
  129520. * Defines whether the current material of the mesh should be use to render the effect.
  129521. * @param mesh defines the current mesh to render
  129522. */
  129523. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129524. /**
  129525. * Rebuild the required buffers.
  129526. * @hidden Internal use only.
  129527. */
  129528. _rebuild(): void;
  129529. /**
  129530. * Dispose only the render target textures and post process.
  129531. */
  129532. private _disposeTextureAndPostProcesses;
  129533. /**
  129534. * Dispose the highlight layer and free resources.
  129535. */
  129536. dispose(): void;
  129537. /**
  129538. * Gets the class name of the effect layer
  129539. * @returns the string with the class name of the effect layer
  129540. */
  129541. getClassName(): string;
  129542. /**
  129543. * Creates an effect layer from parsed effect layer data
  129544. * @param parsedEffectLayer defines effect layer data
  129545. * @param scene defines the current scene
  129546. * @param rootUrl defines the root URL containing the effect layer information
  129547. * @returns a parsed effect Layer
  129548. */
  129549. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129550. }
  129551. }
  129552. declare module BABYLON {
  129553. interface AbstractScene {
  129554. /**
  129555. * The list of effect layers (highlights/glow) added to the scene
  129556. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129557. * @see http://doc.babylonjs.com/how_to/glow_layer
  129558. */
  129559. effectLayers: Array<EffectLayer>;
  129560. /**
  129561. * Removes the given effect layer from this scene.
  129562. * @param toRemove defines the effect layer to remove
  129563. * @returns the index of the removed effect layer
  129564. */
  129565. removeEffectLayer(toRemove: EffectLayer): number;
  129566. /**
  129567. * Adds the given effect layer to this scene
  129568. * @param newEffectLayer defines the effect layer to add
  129569. */
  129570. addEffectLayer(newEffectLayer: EffectLayer): void;
  129571. }
  129572. /**
  129573. * Defines the layer scene component responsible to manage any effect layers
  129574. * in a given scene.
  129575. */
  129576. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129577. /**
  129578. * The component name helpfull to identify the component in the list of scene components.
  129579. */
  129580. readonly name: string;
  129581. /**
  129582. * The scene the component belongs to.
  129583. */
  129584. scene: Scene;
  129585. private _engine;
  129586. private _renderEffects;
  129587. private _needStencil;
  129588. private _previousStencilState;
  129589. /**
  129590. * Creates a new instance of the component for the given scene
  129591. * @param scene Defines the scene to register the component in
  129592. */
  129593. constructor(scene: Scene);
  129594. /**
  129595. * Registers the component in a given scene
  129596. */
  129597. register(): void;
  129598. /**
  129599. * Rebuilds the elements related to this component in case of
  129600. * context lost for instance.
  129601. */
  129602. rebuild(): void;
  129603. /**
  129604. * Serializes the component data to the specified json object
  129605. * @param serializationObject The object to serialize to
  129606. */
  129607. serialize(serializationObject: any): void;
  129608. /**
  129609. * Adds all the elements from the container to the scene
  129610. * @param container the container holding the elements
  129611. */
  129612. addFromContainer(container: AbstractScene): void;
  129613. /**
  129614. * Removes all the elements in the container from the scene
  129615. * @param container contains the elements to remove
  129616. * @param dispose if the removed element should be disposed (default: false)
  129617. */
  129618. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129619. /**
  129620. * Disposes the component and the associated ressources.
  129621. */
  129622. dispose(): void;
  129623. private _isReadyForMesh;
  129624. private _renderMainTexture;
  129625. private _setStencil;
  129626. private _setStencilBack;
  129627. private _draw;
  129628. private _drawCamera;
  129629. private _drawRenderingGroup;
  129630. }
  129631. }
  129632. declare module BABYLON {
  129633. /** @hidden */
  129634. export var glowMapMergePixelShader: {
  129635. name: string;
  129636. shader: string;
  129637. };
  129638. }
  129639. declare module BABYLON {
  129640. /** @hidden */
  129641. export var glowMapMergeVertexShader: {
  129642. name: string;
  129643. shader: string;
  129644. };
  129645. }
  129646. declare module BABYLON {
  129647. interface AbstractScene {
  129648. /**
  129649. * Return a the first highlight layer of the scene with a given name.
  129650. * @param name The name of the highlight layer to look for.
  129651. * @return The highlight layer if found otherwise null.
  129652. */
  129653. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129654. }
  129655. /**
  129656. * Glow layer options. This helps customizing the behaviour
  129657. * of the glow layer.
  129658. */
  129659. export interface IGlowLayerOptions {
  129660. /**
  129661. * Multiplication factor apply to the canvas size to compute the render target size
  129662. * used to generated the glowing objects (the smaller the faster).
  129663. */
  129664. mainTextureRatio: number;
  129665. /**
  129666. * Enforces a fixed size texture to ensure resize independant blur.
  129667. */
  129668. mainTextureFixedSize?: number;
  129669. /**
  129670. * How big is the kernel of the blur texture.
  129671. */
  129672. blurKernelSize: number;
  129673. /**
  129674. * The camera attached to the layer.
  129675. */
  129676. camera: Nullable<Camera>;
  129677. /**
  129678. * Enable MSAA by chosing the number of samples.
  129679. */
  129680. mainTextureSamples?: number;
  129681. /**
  129682. * The rendering group to draw the layer in.
  129683. */
  129684. renderingGroupId: number;
  129685. }
  129686. /**
  129687. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129688. *
  129689. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129690. *
  129691. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129692. */
  129693. export class GlowLayer extends EffectLayer {
  129694. /**
  129695. * Effect Name of the layer.
  129696. */
  129697. static readonly EffectName: string;
  129698. /**
  129699. * The default blur kernel size used for the glow.
  129700. */
  129701. static DefaultBlurKernelSize: number;
  129702. /**
  129703. * The default texture size ratio used for the glow.
  129704. */
  129705. static DefaultTextureRatio: number;
  129706. /**
  129707. * Sets the kernel size of the blur.
  129708. */
  129709. set blurKernelSize(value: number);
  129710. /**
  129711. * Gets the kernel size of the blur.
  129712. */
  129713. get blurKernelSize(): number;
  129714. /**
  129715. * Sets the glow intensity.
  129716. */
  129717. set intensity(value: number);
  129718. /**
  129719. * Gets the glow intensity.
  129720. */
  129721. get intensity(): number;
  129722. private _options;
  129723. private _intensity;
  129724. private _horizontalBlurPostprocess1;
  129725. private _verticalBlurPostprocess1;
  129726. private _horizontalBlurPostprocess2;
  129727. private _verticalBlurPostprocess2;
  129728. private _blurTexture1;
  129729. private _blurTexture2;
  129730. private _postProcesses1;
  129731. private _postProcesses2;
  129732. private _includedOnlyMeshes;
  129733. private _excludedMeshes;
  129734. private _meshesUsingTheirOwnMaterials;
  129735. /**
  129736. * Callback used to let the user override the color selection on a per mesh basis
  129737. */
  129738. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  129739. /**
  129740. * Callback used to let the user override the texture selection on a per mesh basis
  129741. */
  129742. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  129743. /**
  129744. * Instantiates a new glow Layer and references it to the scene.
  129745. * @param name The name of the layer
  129746. * @param scene The scene to use the layer in
  129747. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  129748. */
  129749. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  129750. /**
  129751. * Get the effect name of the layer.
  129752. * @return The effect name
  129753. */
  129754. getEffectName(): string;
  129755. /**
  129756. * Create the merge effect. This is the shader use to blit the information back
  129757. * to the main canvas at the end of the scene rendering.
  129758. */
  129759. protected _createMergeEffect(): Effect;
  129760. /**
  129761. * Creates the render target textures and post processes used in the glow layer.
  129762. */
  129763. protected _createTextureAndPostProcesses(): void;
  129764. /**
  129765. * Checks for the readiness of the element composing the layer.
  129766. * @param subMesh the mesh to check for
  129767. * @param useInstances specify wether or not to use instances to render the mesh
  129768. * @param emissiveTexture the associated emissive texture used to generate the glow
  129769. * @return true if ready otherwise, false
  129770. */
  129771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129772. /**
  129773. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129774. */
  129775. needStencil(): boolean;
  129776. /**
  129777. * Returns true if the mesh can be rendered, otherwise false.
  129778. * @param mesh The mesh to render
  129779. * @param material The material used on the mesh
  129780. * @returns true if it can be rendered otherwise false
  129781. */
  129782. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129783. /**
  129784. * Implementation specific of rendering the generating effect on the main canvas.
  129785. * @param effect The effect used to render through
  129786. */
  129787. protected _internalRender(effect: Effect): void;
  129788. /**
  129789. * Sets the required values for both the emissive texture and and the main color.
  129790. */
  129791. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129792. /**
  129793. * Returns true if the mesh should render, otherwise false.
  129794. * @param mesh The mesh to render
  129795. * @returns true if it should render otherwise false
  129796. */
  129797. protected _shouldRenderMesh(mesh: Mesh): boolean;
  129798. /**
  129799. * Adds specific effects defines.
  129800. * @param defines The defines to add specifics to.
  129801. */
  129802. protected _addCustomEffectDefines(defines: string[]): void;
  129803. /**
  129804. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  129805. * @param mesh The mesh to exclude from the glow layer
  129806. */
  129807. addExcludedMesh(mesh: Mesh): void;
  129808. /**
  129809. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  129810. * @param mesh The mesh to remove
  129811. */
  129812. removeExcludedMesh(mesh: Mesh): void;
  129813. /**
  129814. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  129815. * @param mesh The mesh to include in the glow layer
  129816. */
  129817. addIncludedOnlyMesh(mesh: Mesh): void;
  129818. /**
  129819. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  129820. * @param mesh The mesh to remove
  129821. */
  129822. removeIncludedOnlyMesh(mesh: Mesh): void;
  129823. /**
  129824. * Determine if a given mesh will be used in the glow layer
  129825. * @param mesh The mesh to test
  129826. * @returns true if the mesh will be highlighted by the current glow layer
  129827. */
  129828. hasMesh(mesh: AbstractMesh): boolean;
  129829. /**
  129830. * Defines whether the current material of the mesh should be use to render the effect.
  129831. * @param mesh defines the current mesh to render
  129832. */
  129833. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129834. /**
  129835. * Add a mesh to be rendered through its own material and not with emissive only.
  129836. * @param mesh The mesh for which we need to use its material
  129837. */
  129838. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  129839. /**
  129840. * Remove a mesh from being rendered through its own material and not with emissive only.
  129841. * @param mesh The mesh for which we need to not use its material
  129842. */
  129843. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  129844. /**
  129845. * Free any resources and references associated to a mesh.
  129846. * Internal use
  129847. * @param mesh The mesh to free.
  129848. * @hidden
  129849. */
  129850. _disposeMesh(mesh: Mesh): void;
  129851. /**
  129852. * Gets the class name of the effect layer
  129853. * @returns the string with the class name of the effect layer
  129854. */
  129855. getClassName(): string;
  129856. /**
  129857. * Serializes this glow layer
  129858. * @returns a serialized glow layer object
  129859. */
  129860. serialize(): any;
  129861. /**
  129862. * Creates a Glow Layer from parsed glow layer data
  129863. * @param parsedGlowLayer defines glow layer data
  129864. * @param scene defines the current scene
  129865. * @param rootUrl defines the root URL containing the glow layer information
  129866. * @returns a parsed Glow Layer
  129867. */
  129868. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  129869. }
  129870. }
  129871. declare module BABYLON {
  129872. /** @hidden */
  129873. export var glowBlurPostProcessPixelShader: {
  129874. name: string;
  129875. shader: string;
  129876. };
  129877. }
  129878. declare module BABYLON {
  129879. interface AbstractScene {
  129880. /**
  129881. * Return a the first highlight layer of the scene with a given name.
  129882. * @param name The name of the highlight layer to look for.
  129883. * @return The highlight layer if found otherwise null.
  129884. */
  129885. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  129886. }
  129887. /**
  129888. * Highlight layer options. This helps customizing the behaviour
  129889. * of the highlight layer.
  129890. */
  129891. export interface IHighlightLayerOptions {
  129892. /**
  129893. * Multiplication factor apply to the canvas size to compute the render target size
  129894. * used to generated the glowing objects (the smaller the faster).
  129895. */
  129896. mainTextureRatio: number;
  129897. /**
  129898. * Enforces a fixed size texture to ensure resize independant blur.
  129899. */
  129900. mainTextureFixedSize?: number;
  129901. /**
  129902. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  129903. * of the picture to blur (the smaller the faster).
  129904. */
  129905. blurTextureSizeRatio: number;
  129906. /**
  129907. * How big in texel of the blur texture is the vertical blur.
  129908. */
  129909. blurVerticalSize: number;
  129910. /**
  129911. * How big in texel of the blur texture is the horizontal blur.
  129912. */
  129913. blurHorizontalSize: number;
  129914. /**
  129915. * Alpha blending mode used to apply the blur. Default is combine.
  129916. */
  129917. alphaBlendingMode: number;
  129918. /**
  129919. * The camera attached to the layer.
  129920. */
  129921. camera: Nullable<Camera>;
  129922. /**
  129923. * Should we display highlight as a solid stroke?
  129924. */
  129925. isStroke?: boolean;
  129926. /**
  129927. * The rendering group to draw the layer in.
  129928. */
  129929. renderingGroupId: number;
  129930. }
  129931. /**
  129932. * The highlight layer Helps adding a glow effect around a mesh.
  129933. *
  129934. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  129935. * glowy meshes to your scene.
  129936. *
  129937. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  129938. */
  129939. export class HighlightLayer extends EffectLayer {
  129940. name: string;
  129941. /**
  129942. * Effect Name of the highlight layer.
  129943. */
  129944. static readonly EffectName: string;
  129945. /**
  129946. * The neutral color used during the preparation of the glow effect.
  129947. * This is black by default as the blend operation is a blend operation.
  129948. */
  129949. static NeutralColor: Color4;
  129950. /**
  129951. * Stencil value used for glowing meshes.
  129952. */
  129953. static GlowingMeshStencilReference: number;
  129954. /**
  129955. * Stencil value used for the other meshes in the scene.
  129956. */
  129957. static NormalMeshStencilReference: number;
  129958. /**
  129959. * Specifies whether or not the inner glow is ACTIVE in the layer.
  129960. */
  129961. innerGlow: boolean;
  129962. /**
  129963. * Specifies whether or not the outer glow is ACTIVE in the layer.
  129964. */
  129965. outerGlow: boolean;
  129966. /**
  129967. * Specifies the horizontal size of the blur.
  129968. */
  129969. set blurHorizontalSize(value: number);
  129970. /**
  129971. * Specifies the vertical size of the blur.
  129972. */
  129973. set blurVerticalSize(value: number);
  129974. /**
  129975. * Gets the horizontal size of the blur.
  129976. */
  129977. get blurHorizontalSize(): number;
  129978. /**
  129979. * Gets the vertical size of the blur.
  129980. */
  129981. get blurVerticalSize(): number;
  129982. /**
  129983. * An event triggered when the highlight layer is being blurred.
  129984. */
  129985. onBeforeBlurObservable: Observable<HighlightLayer>;
  129986. /**
  129987. * An event triggered when the highlight layer has been blurred.
  129988. */
  129989. onAfterBlurObservable: Observable<HighlightLayer>;
  129990. private _instanceGlowingMeshStencilReference;
  129991. private _options;
  129992. private _downSamplePostprocess;
  129993. private _horizontalBlurPostprocess;
  129994. private _verticalBlurPostprocess;
  129995. private _blurTexture;
  129996. private _meshes;
  129997. private _excludedMeshes;
  129998. /**
  129999. * Instantiates a new highlight Layer and references it to the scene..
  130000. * @param name The name of the layer
  130001. * @param scene The scene to use the layer in
  130002. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  130003. */
  130004. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  130005. /**
  130006. * Get the effect name of the layer.
  130007. * @return The effect name
  130008. */
  130009. getEffectName(): string;
  130010. /**
  130011. * Create the merge effect. This is the shader use to blit the information back
  130012. * to the main canvas at the end of the scene rendering.
  130013. */
  130014. protected _createMergeEffect(): Effect;
  130015. /**
  130016. * Creates the render target textures and post processes used in the highlight layer.
  130017. */
  130018. protected _createTextureAndPostProcesses(): void;
  130019. /**
  130020. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130021. */
  130022. needStencil(): boolean;
  130023. /**
  130024. * Checks for the readiness of the element composing the layer.
  130025. * @param subMesh the mesh to check for
  130026. * @param useInstances specify wether or not to use instances to render the mesh
  130027. * @param emissiveTexture the associated emissive texture used to generate the glow
  130028. * @return true if ready otherwise, false
  130029. */
  130030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130031. /**
  130032. * Implementation specific of rendering the generating effect on the main canvas.
  130033. * @param effect The effect used to render through
  130034. */
  130035. protected _internalRender(effect: Effect): void;
  130036. /**
  130037. * Returns true if the layer contains information to display, otherwise false.
  130038. */
  130039. shouldRender(): boolean;
  130040. /**
  130041. * Returns true if the mesh should render, otherwise false.
  130042. * @param mesh The mesh to render
  130043. * @returns true if it should render otherwise false
  130044. */
  130045. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130046. /**
  130047. * Adds specific effects defines.
  130048. * @param defines The defines to add specifics to.
  130049. */
  130050. protected _addCustomEffectDefines(defines: string[]): void;
  130051. /**
  130052. * Sets the required values for both the emissive texture and and the main color.
  130053. */
  130054. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130055. /**
  130056. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130057. * @param mesh The mesh to exclude from the highlight layer
  130058. */
  130059. addExcludedMesh(mesh: Mesh): void;
  130060. /**
  130061. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130062. * @param mesh The mesh to highlight
  130063. */
  130064. removeExcludedMesh(mesh: Mesh): void;
  130065. /**
  130066. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130067. * @param mesh mesh to test
  130068. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130069. */
  130070. hasMesh(mesh: AbstractMesh): boolean;
  130071. /**
  130072. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130073. * @param mesh The mesh to highlight
  130074. * @param color The color of the highlight
  130075. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130076. */
  130077. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130078. /**
  130079. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130080. * @param mesh The mesh to highlight
  130081. */
  130082. removeMesh(mesh: Mesh): void;
  130083. /**
  130084. * Remove all the meshes currently referenced in the highlight layer
  130085. */
  130086. removeAllMeshes(): void;
  130087. /**
  130088. * Force the stencil to the normal expected value for none glowing parts
  130089. */
  130090. private _defaultStencilReference;
  130091. /**
  130092. * Free any resources and references associated to a mesh.
  130093. * Internal use
  130094. * @param mesh The mesh to free.
  130095. * @hidden
  130096. */
  130097. _disposeMesh(mesh: Mesh): void;
  130098. /**
  130099. * Dispose the highlight layer and free resources.
  130100. */
  130101. dispose(): void;
  130102. /**
  130103. * Gets the class name of the effect layer
  130104. * @returns the string with the class name of the effect layer
  130105. */
  130106. getClassName(): string;
  130107. /**
  130108. * Serializes this Highlight layer
  130109. * @returns a serialized Highlight layer object
  130110. */
  130111. serialize(): any;
  130112. /**
  130113. * Creates a Highlight layer from parsed Highlight layer data
  130114. * @param parsedHightlightLayer defines the Highlight layer data
  130115. * @param scene defines the current scene
  130116. * @param rootUrl defines the root URL containing the Highlight layer information
  130117. * @returns a parsed Highlight layer
  130118. */
  130119. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130120. }
  130121. }
  130122. declare module BABYLON {
  130123. interface AbstractScene {
  130124. /**
  130125. * The list of layers (background and foreground) of the scene
  130126. */
  130127. layers: Array<Layer>;
  130128. }
  130129. /**
  130130. * Defines the layer scene component responsible to manage any layers
  130131. * in a given scene.
  130132. */
  130133. export class LayerSceneComponent implements ISceneComponent {
  130134. /**
  130135. * The component name helpfull to identify the component in the list of scene components.
  130136. */
  130137. readonly name: string;
  130138. /**
  130139. * The scene the component belongs to.
  130140. */
  130141. scene: Scene;
  130142. private _engine;
  130143. /**
  130144. * Creates a new instance of the component for the given scene
  130145. * @param scene Defines the scene to register the component in
  130146. */
  130147. constructor(scene: Scene);
  130148. /**
  130149. * Registers the component in a given scene
  130150. */
  130151. register(): void;
  130152. /**
  130153. * Rebuilds the elements related to this component in case of
  130154. * context lost for instance.
  130155. */
  130156. rebuild(): void;
  130157. /**
  130158. * Disposes the component and the associated ressources.
  130159. */
  130160. dispose(): void;
  130161. private _draw;
  130162. private _drawCameraPredicate;
  130163. private _drawCameraBackground;
  130164. private _drawCameraForeground;
  130165. private _drawRenderTargetPredicate;
  130166. private _drawRenderTargetBackground;
  130167. private _drawRenderTargetForeground;
  130168. /**
  130169. * Adds all the elements from the container to the scene
  130170. * @param container the container holding the elements
  130171. */
  130172. addFromContainer(container: AbstractScene): void;
  130173. /**
  130174. * Removes all the elements in the container from the scene
  130175. * @param container contains the elements to remove
  130176. * @param dispose if the removed element should be disposed (default: false)
  130177. */
  130178. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130179. }
  130180. }
  130181. declare module BABYLON {
  130182. /** @hidden */
  130183. export var layerPixelShader: {
  130184. name: string;
  130185. shader: string;
  130186. };
  130187. }
  130188. declare module BABYLON {
  130189. /** @hidden */
  130190. export var layerVertexShader: {
  130191. name: string;
  130192. shader: string;
  130193. };
  130194. }
  130195. declare module BABYLON {
  130196. /**
  130197. * This represents a full screen 2d layer.
  130198. * This can be useful to display a picture in the background of your scene for instance.
  130199. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130200. */
  130201. export class Layer {
  130202. /**
  130203. * Define the name of the layer.
  130204. */
  130205. name: string;
  130206. /**
  130207. * Define the texture the layer should display.
  130208. */
  130209. texture: Nullable<Texture>;
  130210. /**
  130211. * Is the layer in background or foreground.
  130212. */
  130213. isBackground: boolean;
  130214. /**
  130215. * Define the color of the layer (instead of texture).
  130216. */
  130217. color: Color4;
  130218. /**
  130219. * Define the scale of the layer in order to zoom in out of the texture.
  130220. */
  130221. scale: Vector2;
  130222. /**
  130223. * Define an offset for the layer in order to shift the texture.
  130224. */
  130225. offset: Vector2;
  130226. /**
  130227. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130228. */
  130229. alphaBlendingMode: number;
  130230. /**
  130231. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130232. * Alpha test will not mix with the background color in case of transparency.
  130233. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130234. */
  130235. alphaTest: boolean;
  130236. /**
  130237. * Define a mask to restrict the layer to only some of the scene cameras.
  130238. */
  130239. layerMask: number;
  130240. /**
  130241. * Define the list of render target the layer is visible into.
  130242. */
  130243. renderTargetTextures: RenderTargetTexture[];
  130244. /**
  130245. * Define if the layer is only used in renderTarget or if it also
  130246. * renders in the main frame buffer of the canvas.
  130247. */
  130248. renderOnlyInRenderTargetTextures: boolean;
  130249. private _scene;
  130250. private _vertexBuffers;
  130251. private _indexBuffer;
  130252. private _effect;
  130253. private _previousDefines;
  130254. /**
  130255. * An event triggered when the layer is disposed.
  130256. */
  130257. onDisposeObservable: Observable<Layer>;
  130258. private _onDisposeObserver;
  130259. /**
  130260. * Back compatibility with callback before the onDisposeObservable existed.
  130261. * The set callback will be triggered when the layer has been disposed.
  130262. */
  130263. set onDispose(callback: () => void);
  130264. /**
  130265. * An event triggered before rendering the scene
  130266. */
  130267. onBeforeRenderObservable: Observable<Layer>;
  130268. private _onBeforeRenderObserver;
  130269. /**
  130270. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130271. * The set callback will be triggered just before rendering the layer.
  130272. */
  130273. set onBeforeRender(callback: () => void);
  130274. /**
  130275. * An event triggered after rendering the scene
  130276. */
  130277. onAfterRenderObservable: Observable<Layer>;
  130278. private _onAfterRenderObserver;
  130279. /**
  130280. * Back compatibility with callback before the onAfterRenderObservable existed.
  130281. * The set callback will be triggered just after rendering the layer.
  130282. */
  130283. set onAfterRender(callback: () => void);
  130284. /**
  130285. * Instantiates a new layer.
  130286. * This represents a full screen 2d layer.
  130287. * This can be useful to display a picture in the background of your scene for instance.
  130288. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130289. * @param name Define the name of the layer in the scene
  130290. * @param imgUrl Define the url of the texture to display in the layer
  130291. * @param scene Define the scene the layer belongs to
  130292. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130293. * @param color Defines a color for the layer
  130294. */
  130295. constructor(
  130296. /**
  130297. * Define the name of the layer.
  130298. */
  130299. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130300. private _createIndexBuffer;
  130301. /** @hidden */
  130302. _rebuild(): void;
  130303. /**
  130304. * Renders the layer in the scene.
  130305. */
  130306. render(): void;
  130307. /**
  130308. * Disposes and releases the associated ressources.
  130309. */
  130310. dispose(): void;
  130311. }
  130312. }
  130313. declare module BABYLON {
  130314. /** @hidden */
  130315. export var lensFlarePixelShader: {
  130316. name: string;
  130317. shader: string;
  130318. };
  130319. }
  130320. declare module BABYLON {
  130321. /** @hidden */
  130322. export var lensFlareVertexShader: {
  130323. name: string;
  130324. shader: string;
  130325. };
  130326. }
  130327. declare module BABYLON {
  130328. /**
  130329. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130330. * It is usually composed of several `lensFlare`.
  130331. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130332. */
  130333. export class LensFlareSystem {
  130334. /**
  130335. * Define the name of the lens flare system
  130336. */
  130337. name: string;
  130338. /**
  130339. * List of lens flares used in this system.
  130340. */
  130341. lensFlares: LensFlare[];
  130342. /**
  130343. * Define a limit from the border the lens flare can be visible.
  130344. */
  130345. borderLimit: number;
  130346. /**
  130347. * Define a viewport border we do not want to see the lens flare in.
  130348. */
  130349. viewportBorder: number;
  130350. /**
  130351. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130352. */
  130353. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130354. /**
  130355. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130356. */
  130357. layerMask: number;
  130358. /**
  130359. * Define the id of the lens flare system in the scene.
  130360. * (equal to name by default)
  130361. */
  130362. id: string;
  130363. private _scene;
  130364. private _emitter;
  130365. private _vertexBuffers;
  130366. private _indexBuffer;
  130367. private _effect;
  130368. private _positionX;
  130369. private _positionY;
  130370. private _isEnabled;
  130371. /** @hidden */
  130372. static _SceneComponentInitialization: (scene: Scene) => void;
  130373. /**
  130374. * Instantiates a lens flare system.
  130375. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130376. * It is usually composed of several `lensFlare`.
  130377. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130378. * @param name Define the name of the lens flare system in the scene
  130379. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130380. * @param scene Define the scene the lens flare system belongs to
  130381. */
  130382. constructor(
  130383. /**
  130384. * Define the name of the lens flare system
  130385. */
  130386. name: string, emitter: any, scene: Scene);
  130387. /**
  130388. * Define if the lens flare system is enabled.
  130389. */
  130390. get isEnabled(): boolean;
  130391. set isEnabled(value: boolean);
  130392. /**
  130393. * Get the scene the effects belongs to.
  130394. * @returns the scene holding the lens flare system
  130395. */
  130396. getScene(): Scene;
  130397. /**
  130398. * Get the emitter of the lens flare system.
  130399. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130400. * @returns the emitter of the lens flare system
  130401. */
  130402. getEmitter(): any;
  130403. /**
  130404. * Set the emitter of the lens flare system.
  130405. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130406. * @param newEmitter Define the new emitter of the system
  130407. */
  130408. setEmitter(newEmitter: any): void;
  130409. /**
  130410. * Get the lens flare system emitter position.
  130411. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130412. * @returns the position
  130413. */
  130414. getEmitterPosition(): Vector3;
  130415. /**
  130416. * @hidden
  130417. */
  130418. computeEffectivePosition(globalViewport: Viewport): boolean;
  130419. /** @hidden */
  130420. _isVisible(): boolean;
  130421. /**
  130422. * @hidden
  130423. */
  130424. render(): boolean;
  130425. /**
  130426. * Dispose and release the lens flare with its associated resources.
  130427. */
  130428. dispose(): void;
  130429. /**
  130430. * Parse a lens flare system from a JSON repressentation
  130431. * @param parsedLensFlareSystem Define the JSON to parse
  130432. * @param scene Define the scene the parsed system should be instantiated in
  130433. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130434. * @returns the parsed system
  130435. */
  130436. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130437. /**
  130438. * Serialize the current Lens Flare System into a JSON representation.
  130439. * @returns the serialized JSON
  130440. */
  130441. serialize(): any;
  130442. }
  130443. }
  130444. declare module BABYLON {
  130445. /**
  130446. * This represents one of the lens effect in a `lensFlareSystem`.
  130447. * It controls one of the indiviual texture used in the effect.
  130448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130449. */
  130450. export class LensFlare {
  130451. /**
  130452. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130453. */
  130454. size: number;
  130455. /**
  130456. * 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.
  130457. */
  130458. position: number;
  130459. /**
  130460. * Define the lens color.
  130461. */
  130462. color: Color3;
  130463. /**
  130464. * Define the lens texture.
  130465. */
  130466. texture: Nullable<Texture>;
  130467. /**
  130468. * Define the alpha mode to render this particular lens.
  130469. */
  130470. alphaMode: number;
  130471. private _system;
  130472. /**
  130473. * Creates a new Lens Flare.
  130474. * This represents one of the lens effect in a `lensFlareSystem`.
  130475. * It controls one of the indiviual texture used in the effect.
  130476. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130477. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130478. * @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.
  130479. * @param color Define the lens color
  130480. * @param imgUrl Define the lens texture url
  130481. * @param system Define the `lensFlareSystem` this flare is part of
  130482. * @returns The newly created Lens Flare
  130483. */
  130484. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130485. /**
  130486. * Instantiates a new Lens Flare.
  130487. * This represents one of the lens effect in a `lensFlareSystem`.
  130488. * It controls one of the indiviual texture used in the effect.
  130489. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130490. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130491. * @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.
  130492. * @param color Define the lens color
  130493. * @param imgUrl Define the lens texture url
  130494. * @param system Define the `lensFlareSystem` this flare is part of
  130495. */
  130496. constructor(
  130497. /**
  130498. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130499. */
  130500. size: number,
  130501. /**
  130502. * 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.
  130503. */
  130504. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130505. /**
  130506. * Dispose and release the lens flare with its associated resources.
  130507. */
  130508. dispose(): void;
  130509. }
  130510. }
  130511. declare module BABYLON {
  130512. interface AbstractScene {
  130513. /**
  130514. * The list of lens flare system added to the scene
  130515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130516. */
  130517. lensFlareSystems: Array<LensFlareSystem>;
  130518. /**
  130519. * Removes the given lens flare system from this scene.
  130520. * @param toRemove The lens flare system to remove
  130521. * @returns The index of the removed lens flare system
  130522. */
  130523. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130524. /**
  130525. * Adds the given lens flare system to this scene
  130526. * @param newLensFlareSystem The lens flare system to add
  130527. */
  130528. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130529. /**
  130530. * Gets a lens flare system using its name
  130531. * @param name defines the name to look for
  130532. * @returns the lens flare system or null if not found
  130533. */
  130534. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130535. /**
  130536. * Gets a lens flare system using its id
  130537. * @param id defines the id to look for
  130538. * @returns the lens flare system or null if not found
  130539. */
  130540. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130541. }
  130542. /**
  130543. * Defines the lens flare scene component responsible to manage any lens flares
  130544. * in a given scene.
  130545. */
  130546. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130547. /**
  130548. * The component name helpfull to identify the component in the list of scene components.
  130549. */
  130550. readonly name: string;
  130551. /**
  130552. * The scene the component belongs to.
  130553. */
  130554. scene: Scene;
  130555. /**
  130556. * Creates a new instance of the component for the given scene
  130557. * @param scene Defines the scene to register the component in
  130558. */
  130559. constructor(scene: Scene);
  130560. /**
  130561. * Registers the component in a given scene
  130562. */
  130563. register(): void;
  130564. /**
  130565. * Rebuilds the elements related to this component in case of
  130566. * context lost for instance.
  130567. */
  130568. rebuild(): void;
  130569. /**
  130570. * Adds all the elements from the container to the scene
  130571. * @param container the container holding the elements
  130572. */
  130573. addFromContainer(container: AbstractScene): void;
  130574. /**
  130575. * Removes all the elements in the container from the scene
  130576. * @param container contains the elements to remove
  130577. * @param dispose if the removed element should be disposed (default: false)
  130578. */
  130579. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130580. /**
  130581. * Serializes the component data to the specified json object
  130582. * @param serializationObject The object to serialize to
  130583. */
  130584. serialize(serializationObject: any): void;
  130585. /**
  130586. * Disposes the component and the associated ressources.
  130587. */
  130588. dispose(): void;
  130589. private _draw;
  130590. }
  130591. }
  130592. declare module BABYLON {
  130593. /** @hidden */
  130594. export var depthPixelShader: {
  130595. name: string;
  130596. shader: string;
  130597. };
  130598. }
  130599. declare module BABYLON {
  130600. /** @hidden */
  130601. export var depthVertexShader: {
  130602. name: string;
  130603. shader: string;
  130604. };
  130605. }
  130606. declare module BABYLON {
  130607. /**
  130608. * This represents a depth renderer in Babylon.
  130609. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130610. */
  130611. export class DepthRenderer {
  130612. private _scene;
  130613. private _depthMap;
  130614. private _effect;
  130615. private readonly _storeNonLinearDepth;
  130616. private readonly _clearColor;
  130617. /** Get if the depth renderer is using packed depth or not */
  130618. readonly isPacked: boolean;
  130619. private _cachedDefines;
  130620. private _camera;
  130621. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130622. enabled: boolean;
  130623. /**
  130624. * Specifiess that the depth renderer will only be used within
  130625. * the camera it is created for.
  130626. * This can help forcing its rendering during the camera processing.
  130627. */
  130628. useOnlyInActiveCamera: boolean;
  130629. /** @hidden */
  130630. static _SceneComponentInitialization: (scene: Scene) => void;
  130631. /**
  130632. * Instantiates a depth renderer
  130633. * @param scene The scene the renderer belongs to
  130634. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130635. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130636. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130637. */
  130638. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130639. /**
  130640. * Creates the depth rendering effect and checks if the effect is ready.
  130641. * @param subMesh The submesh to be used to render the depth map of
  130642. * @param useInstances If multiple world instances should be used
  130643. * @returns if the depth renderer is ready to render the depth map
  130644. */
  130645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130646. /**
  130647. * Gets the texture which the depth map will be written to.
  130648. * @returns The depth map texture
  130649. */
  130650. getDepthMap(): RenderTargetTexture;
  130651. /**
  130652. * Disposes of the depth renderer.
  130653. */
  130654. dispose(): void;
  130655. }
  130656. }
  130657. declare module BABYLON {
  130658. /** @hidden */
  130659. export var minmaxReduxPixelShader: {
  130660. name: string;
  130661. shader: string;
  130662. };
  130663. }
  130664. declare module BABYLON {
  130665. /**
  130666. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130667. * and maximum values from all values of the texture.
  130668. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130669. * The source values are read from the red channel of the texture.
  130670. */
  130671. export class MinMaxReducer {
  130672. /**
  130673. * Observable triggered when the computation has been performed
  130674. */
  130675. onAfterReductionPerformed: Observable<{
  130676. min: number;
  130677. max: number;
  130678. }>;
  130679. protected _camera: Camera;
  130680. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130681. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130682. protected _postProcessManager: PostProcessManager;
  130683. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130684. protected _forceFullscreenViewport: boolean;
  130685. /**
  130686. * Creates a min/max reducer
  130687. * @param camera The camera to use for the post processes
  130688. */
  130689. constructor(camera: Camera);
  130690. /**
  130691. * Gets the texture used to read the values from.
  130692. */
  130693. get sourceTexture(): Nullable<RenderTargetTexture>;
  130694. /**
  130695. * Sets the source texture to read the values from.
  130696. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130697. * because in such textures '1' value must not be taken into account to compute the maximum
  130698. * as this value is used to clear the texture.
  130699. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130700. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130701. * @param depthRedux Indicates if the texture is a depth texture or not
  130702. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130703. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130704. */
  130705. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130706. /**
  130707. * Defines the refresh rate of the computation.
  130708. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130709. */
  130710. get refreshRate(): number;
  130711. set refreshRate(value: number);
  130712. protected _activated: boolean;
  130713. /**
  130714. * Gets the activation status of the reducer
  130715. */
  130716. get activated(): boolean;
  130717. /**
  130718. * Activates the reduction computation.
  130719. * When activated, the observers registered in onAfterReductionPerformed are
  130720. * called after the compuation is performed
  130721. */
  130722. activate(): void;
  130723. /**
  130724. * Deactivates the reduction computation.
  130725. */
  130726. deactivate(): void;
  130727. /**
  130728. * Disposes the min/max reducer
  130729. * @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.
  130730. */
  130731. dispose(disposeAll?: boolean): void;
  130732. }
  130733. }
  130734. declare module BABYLON {
  130735. /**
  130736. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  130737. */
  130738. export class DepthReducer extends MinMaxReducer {
  130739. private _depthRenderer;
  130740. private _depthRendererId;
  130741. /**
  130742. * Gets the depth renderer used for the computation.
  130743. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  130744. */
  130745. get depthRenderer(): Nullable<DepthRenderer>;
  130746. /**
  130747. * Creates a depth reducer
  130748. * @param camera The camera used to render the depth texture
  130749. */
  130750. constructor(camera: Camera);
  130751. /**
  130752. * Sets the depth renderer to use to generate the depth map
  130753. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  130754. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  130755. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130756. */
  130757. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  130758. /** @hidden */
  130759. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130760. /**
  130761. * Activates the reduction computation.
  130762. * When activated, the observers registered in onAfterReductionPerformed are
  130763. * called after the compuation is performed
  130764. */
  130765. activate(): void;
  130766. /**
  130767. * Deactivates the reduction computation.
  130768. */
  130769. deactivate(): void;
  130770. /**
  130771. * Disposes the depth reducer
  130772. * @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.
  130773. */
  130774. dispose(disposeAll?: boolean): void;
  130775. }
  130776. }
  130777. declare module BABYLON {
  130778. /**
  130779. * A CSM implementation allowing casting shadows on large scenes.
  130780. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  130781. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  130782. */
  130783. export class CascadedShadowGenerator extends ShadowGenerator {
  130784. private static readonly frustumCornersNDCSpace;
  130785. /**
  130786. * Name of the CSM class
  130787. */
  130788. static CLASSNAME: string;
  130789. /**
  130790. * Defines the default number of cascades used by the CSM.
  130791. */
  130792. static readonly DEFAULT_CASCADES_COUNT: number;
  130793. /**
  130794. * Defines the minimum number of cascades used by the CSM.
  130795. */
  130796. static readonly MIN_CASCADES_COUNT: number;
  130797. /**
  130798. * Defines the maximum number of cascades used by the CSM.
  130799. */
  130800. static readonly MAX_CASCADES_COUNT: number;
  130801. protected _validateFilter(filter: number): number;
  130802. /**
  130803. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  130804. */
  130805. penumbraDarkness: number;
  130806. private _numCascades;
  130807. /**
  130808. * Gets or set the number of cascades used by the CSM.
  130809. */
  130810. get numCascades(): number;
  130811. set numCascades(value: number);
  130812. /**
  130813. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  130814. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  130815. */
  130816. stabilizeCascades: boolean;
  130817. private _freezeShadowCastersBoundingInfo;
  130818. private _freezeShadowCastersBoundingInfoObservable;
  130819. /**
  130820. * Enables or disables the shadow casters bounding info computation.
  130821. * If your shadow casters don't move, you can disable this feature.
  130822. * If it is enabled, the bounding box computation is done every frame.
  130823. */
  130824. get freezeShadowCastersBoundingInfo(): boolean;
  130825. set freezeShadowCastersBoundingInfo(freeze: boolean);
  130826. private _scbiMin;
  130827. private _scbiMax;
  130828. protected _computeShadowCastersBoundingInfo(): void;
  130829. protected _shadowCastersBoundingInfo: BoundingInfo;
  130830. /**
  130831. * Gets or sets the shadow casters bounding info.
  130832. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  130833. * so that the system won't overwrite the bounds you provide
  130834. */
  130835. get shadowCastersBoundingInfo(): BoundingInfo;
  130836. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  130837. protected _breaksAreDirty: boolean;
  130838. protected _minDistance: number;
  130839. protected _maxDistance: number;
  130840. /**
  130841. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  130842. *
  130843. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  130844. * If you don't know these values, simply leave them to their defaults and don't call this function.
  130845. * @param min minimal distance for the breaks (default to 0.)
  130846. * @param max maximal distance for the breaks (default to 1.)
  130847. */
  130848. setMinMaxDistance(min: number, max: number): void;
  130849. /** Gets the minimal distance used in the cascade break computation */
  130850. get minDistance(): number;
  130851. /** Gets the maximal distance used in the cascade break computation */
  130852. get maxDistance(): number;
  130853. /**
  130854. * Gets the class name of that object
  130855. * @returns "CascadedShadowGenerator"
  130856. */
  130857. getClassName(): string;
  130858. private _cascadeMinExtents;
  130859. private _cascadeMaxExtents;
  130860. /**
  130861. * Gets a cascade minimum extents
  130862. * @param cascadeIndex index of the cascade
  130863. * @returns the minimum cascade extents
  130864. */
  130865. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  130866. /**
  130867. * Gets a cascade maximum extents
  130868. * @param cascadeIndex index of the cascade
  130869. * @returns the maximum cascade extents
  130870. */
  130871. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  130872. private _cascades;
  130873. private _currentLayer;
  130874. private _viewSpaceFrustumsZ;
  130875. private _viewMatrices;
  130876. private _projectionMatrices;
  130877. private _transformMatrices;
  130878. private _transformMatricesAsArray;
  130879. private _frustumLengths;
  130880. private _lightSizeUVCorrection;
  130881. private _depthCorrection;
  130882. private _frustumCornersWorldSpace;
  130883. private _frustumCenter;
  130884. private _shadowCameraPos;
  130885. private _shadowMaxZ;
  130886. /**
  130887. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  130888. * It defaults to camera.maxZ
  130889. */
  130890. get shadowMaxZ(): number;
  130891. /**
  130892. * Sets the shadow max z distance.
  130893. */
  130894. set shadowMaxZ(value: number);
  130895. protected _debug: boolean;
  130896. /**
  130897. * Gets or sets the debug flag.
  130898. * When enabled, the cascades are materialized by different colors on the screen.
  130899. */
  130900. get debug(): boolean;
  130901. set debug(dbg: boolean);
  130902. private _depthClamp;
  130903. /**
  130904. * Gets or sets the depth clamping value.
  130905. *
  130906. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  130907. * to account for the shadow casters far away.
  130908. *
  130909. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  130910. */
  130911. get depthClamp(): boolean;
  130912. set depthClamp(value: boolean);
  130913. private _cascadeBlendPercentage;
  130914. /**
  130915. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  130916. * It defaults to 0.1 (10% blending).
  130917. */
  130918. get cascadeBlendPercentage(): number;
  130919. set cascadeBlendPercentage(value: number);
  130920. private _lambda;
  130921. /**
  130922. * Gets or set the lambda parameter.
  130923. * This parameter is used to split the camera frustum and create the cascades.
  130924. * 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.
  130925. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  130926. */
  130927. get lambda(): number;
  130928. set lambda(value: number);
  130929. /**
  130930. * Gets the view matrix corresponding to a given cascade
  130931. * @param cascadeNum cascade to retrieve the view matrix from
  130932. * @returns the cascade view matrix
  130933. */
  130934. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  130935. /**
  130936. * Gets the projection matrix corresponding to a given cascade
  130937. * @param cascadeNum cascade to retrieve the projection matrix from
  130938. * @returns the cascade projection matrix
  130939. */
  130940. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  130941. /**
  130942. * Gets the transformation matrix corresponding to a given cascade
  130943. * @param cascadeNum cascade to retrieve the transformation matrix from
  130944. * @returns the cascade transformation matrix
  130945. */
  130946. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  130947. private _depthRenderer;
  130948. /**
  130949. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  130950. *
  130951. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  130952. *
  130953. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  130954. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  130955. * @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
  130956. */
  130957. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  130958. private _depthReducer;
  130959. private _autoCalcDepthBounds;
  130960. /**
  130961. * Gets or sets the autoCalcDepthBounds property.
  130962. *
  130963. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  130964. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  130965. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  130966. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  130967. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  130968. */
  130969. get autoCalcDepthBounds(): boolean;
  130970. set autoCalcDepthBounds(value: boolean);
  130971. /**
  130972. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  130973. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130974. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  130975. * for setting the refresh rate on the renderer yourself!
  130976. */
  130977. get autoCalcDepthBoundsRefreshRate(): number;
  130978. set autoCalcDepthBoundsRefreshRate(value: number);
  130979. /**
  130980. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  130981. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  130982. * you change the camera near/far planes!
  130983. */
  130984. splitFrustum(): void;
  130985. private _splitFrustum;
  130986. private _computeMatrices;
  130987. private _computeFrustumInWorldSpace;
  130988. private _computeCascadeFrustum;
  130989. /**
  130990. * Support test.
  130991. */
  130992. static get IsSupported(): boolean;
  130993. /** @hidden */
  130994. static _SceneComponentInitialization: (scene: Scene) => void;
  130995. /**
  130996. * Creates a Cascaded Shadow Generator object.
  130997. * A ShadowGenerator is the required tool to use the shadows.
  130998. * Each directional light casting shadows needs to use its own ShadowGenerator.
  130999. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  131000. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  131001. * @param light The directional light object generating the shadows.
  131002. * @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.
  131003. */
  131004. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  131005. protected _initializeGenerator(): void;
  131006. protected _createTargetRenderTexture(): void;
  131007. protected _initializeShadowMap(): void;
  131008. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131009. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131010. /**
  131011. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131012. * @param defines Defines of the material we want to update
  131013. * @param lightIndex Index of the light in the enabled light list of the material
  131014. */
  131015. prepareDefines(defines: any, lightIndex: number): void;
  131016. /**
  131017. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131018. * defined in the generator but impacting the effect).
  131019. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131020. * @param effect The effect we are binfing the information for
  131021. */
  131022. bindShadowLight(lightIndex: string, effect: Effect): void;
  131023. /**
  131024. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131025. * (eq to view projection * shadow projection matrices)
  131026. * @returns The transform matrix used to create the shadow map
  131027. */
  131028. getTransformMatrix(): Matrix;
  131029. /**
  131030. * Disposes the ShadowGenerator.
  131031. * Returns nothing.
  131032. */
  131033. dispose(): void;
  131034. /**
  131035. * Serializes the shadow generator setup to a json object.
  131036. * @returns The serialized JSON object
  131037. */
  131038. serialize(): any;
  131039. /**
  131040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131041. * @param parsedShadowGenerator The JSON object to parse
  131042. * @param scene The scene to create the shadow map for
  131043. * @returns The parsed shadow generator
  131044. */
  131045. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131046. }
  131047. }
  131048. declare module BABYLON {
  131049. /**
  131050. * Defines the shadow generator component responsible to manage any shadow generators
  131051. * in a given scene.
  131052. */
  131053. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131054. /**
  131055. * The component name helpfull to identify the component in the list of scene components.
  131056. */
  131057. readonly name: string;
  131058. /**
  131059. * The scene the component belongs to.
  131060. */
  131061. scene: Scene;
  131062. /**
  131063. * Creates a new instance of the component for the given scene
  131064. * @param scene Defines the scene to register the component in
  131065. */
  131066. constructor(scene: Scene);
  131067. /**
  131068. * Registers the component in a given scene
  131069. */
  131070. register(): void;
  131071. /**
  131072. * Rebuilds the elements related to this component in case of
  131073. * context lost for instance.
  131074. */
  131075. rebuild(): void;
  131076. /**
  131077. * Serializes the component data to the specified json object
  131078. * @param serializationObject The object to serialize to
  131079. */
  131080. serialize(serializationObject: any): void;
  131081. /**
  131082. * Adds all the elements from the container to the scene
  131083. * @param container the container holding the elements
  131084. */
  131085. addFromContainer(container: AbstractScene): void;
  131086. /**
  131087. * Removes all the elements in the container from the scene
  131088. * @param container contains the elements to remove
  131089. * @param dispose if the removed element should be disposed (default: false)
  131090. */
  131091. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131092. /**
  131093. * Rebuilds the elements related to this component in case of
  131094. * context lost for instance.
  131095. */
  131096. dispose(): void;
  131097. private _gatherRenderTargets;
  131098. }
  131099. }
  131100. declare module BABYLON {
  131101. /**
  131102. * A point light is a light defined by an unique point in world space.
  131103. * The light is emitted in every direction from this point.
  131104. * A good example of a point light is a standard light bulb.
  131105. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131106. */
  131107. export class PointLight extends ShadowLight {
  131108. private _shadowAngle;
  131109. /**
  131110. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131111. * This specifies what angle the shadow will use to be created.
  131112. *
  131113. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131114. */
  131115. get shadowAngle(): number;
  131116. /**
  131117. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131118. * This specifies what angle the shadow will use to be created.
  131119. *
  131120. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131121. */
  131122. set shadowAngle(value: number);
  131123. /**
  131124. * Gets the direction if it has been set.
  131125. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131126. */
  131127. get direction(): Vector3;
  131128. /**
  131129. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131130. */
  131131. set direction(value: Vector3);
  131132. /**
  131133. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131134. * A PointLight emits the light in every direction.
  131135. * It can cast shadows.
  131136. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131137. * ```javascript
  131138. * var pointLight = new PointLight("pl", camera.position, scene);
  131139. * ```
  131140. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131141. * @param name The light friendly name
  131142. * @param position The position of the point light in the scene
  131143. * @param scene The scene the lights belongs to
  131144. */
  131145. constructor(name: string, position: Vector3, scene: Scene);
  131146. /**
  131147. * Returns the string "PointLight"
  131148. * @returns the class name
  131149. */
  131150. getClassName(): string;
  131151. /**
  131152. * Returns the integer 0.
  131153. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131154. */
  131155. getTypeID(): number;
  131156. /**
  131157. * Specifies wether or not the shadowmap should be a cube texture.
  131158. * @returns true if the shadowmap needs to be a cube texture.
  131159. */
  131160. needCube(): boolean;
  131161. /**
  131162. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131163. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131164. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131165. */
  131166. getShadowDirection(faceIndex?: number): Vector3;
  131167. /**
  131168. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131169. * - fov = PI / 2
  131170. * - aspect ratio : 1.0
  131171. * - z-near and far equal to the active camera minZ and maxZ.
  131172. * Returns the PointLight.
  131173. */
  131174. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131175. protected _buildUniformLayout(): void;
  131176. /**
  131177. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131178. * @param effect The effect to update
  131179. * @param lightIndex The index of the light in the effect to update
  131180. * @returns The point light
  131181. */
  131182. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131183. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131184. /**
  131185. * Prepares the list of defines specific to the light type.
  131186. * @param defines the list of defines
  131187. * @param lightIndex defines the index of the light for the effect
  131188. */
  131189. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131190. }
  131191. }
  131192. declare module BABYLON {
  131193. /**
  131194. * Header information of HDR texture files.
  131195. */
  131196. export interface HDRInfo {
  131197. /**
  131198. * The height of the texture in pixels.
  131199. */
  131200. height: number;
  131201. /**
  131202. * The width of the texture in pixels.
  131203. */
  131204. width: number;
  131205. /**
  131206. * The index of the beginning of the data in the binary file.
  131207. */
  131208. dataPosition: number;
  131209. }
  131210. /**
  131211. * This groups tools to convert HDR texture to native colors array.
  131212. */
  131213. export class HDRTools {
  131214. private static Ldexp;
  131215. private static Rgbe2float;
  131216. private static readStringLine;
  131217. /**
  131218. * Reads header information from an RGBE texture stored in a native array.
  131219. * More information on this format are available here:
  131220. * https://en.wikipedia.org/wiki/RGBE_image_format
  131221. *
  131222. * @param uint8array The binary file stored in native array.
  131223. * @return The header information.
  131224. */
  131225. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131226. /**
  131227. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131228. * This RGBE texture needs to store the information as a panorama.
  131229. *
  131230. * More information on this format are available here:
  131231. * https://en.wikipedia.org/wiki/RGBE_image_format
  131232. *
  131233. * @param buffer The binary file stored in an array buffer.
  131234. * @param size The expected size of the extracted cubemap.
  131235. * @return The Cube Map information.
  131236. */
  131237. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131238. /**
  131239. * Returns the pixels data extracted from an RGBE texture.
  131240. * This pixels will be stored left to right up to down in the R G B order in one array.
  131241. *
  131242. * More information on this format are available here:
  131243. * https://en.wikipedia.org/wiki/RGBE_image_format
  131244. *
  131245. * @param uint8array The binary file stored in an array buffer.
  131246. * @param hdrInfo The header information of the file.
  131247. * @return The pixels data in RGB right to left up to down order.
  131248. */
  131249. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131250. private static RGBE_ReadPixels_RLE;
  131251. }
  131252. }
  131253. declare module BABYLON {
  131254. /**
  131255. * This represents a texture coming from an HDR input.
  131256. *
  131257. * The only supported format is currently panorama picture stored in RGBE format.
  131258. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131259. */
  131260. export class HDRCubeTexture extends BaseTexture {
  131261. private static _facesMapping;
  131262. private _generateHarmonics;
  131263. private _noMipmap;
  131264. private _textureMatrix;
  131265. private _size;
  131266. private _onLoad;
  131267. private _onError;
  131268. /**
  131269. * The texture URL.
  131270. */
  131271. url: string;
  131272. /**
  131273. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131274. */
  131275. coordinatesMode: number;
  131276. protected _isBlocking: boolean;
  131277. /**
  131278. * Sets wether or not the texture is blocking during loading.
  131279. */
  131280. set isBlocking(value: boolean);
  131281. /**
  131282. * Gets wether or not the texture is blocking during loading.
  131283. */
  131284. get isBlocking(): boolean;
  131285. protected _rotationY: number;
  131286. /**
  131287. * Sets texture matrix rotation angle around Y axis in radians.
  131288. */
  131289. set rotationY(value: number);
  131290. /**
  131291. * Gets texture matrix rotation angle around Y axis radians.
  131292. */
  131293. get rotationY(): number;
  131294. /**
  131295. * Gets or sets the center of the bounding box associated with the cube texture
  131296. * It must define where the camera used to render the texture was set
  131297. */
  131298. boundingBoxPosition: Vector3;
  131299. private _boundingBoxSize;
  131300. /**
  131301. * Gets or sets the size of the bounding box associated with the cube texture
  131302. * When defined, the cubemap will switch to local mode
  131303. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131304. * @example https://www.babylonjs-playground.com/#RNASML
  131305. */
  131306. set boundingBoxSize(value: Vector3);
  131307. get boundingBoxSize(): Vector3;
  131308. /**
  131309. * Instantiates an HDRTexture from the following parameters.
  131310. *
  131311. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131312. * @param scene The scene the texture will be used in
  131313. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131314. * @param noMipmap Forces to not generate the mipmap if true
  131315. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131316. * @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)
  131317. * @param reserved Reserved flag for internal use.
  131318. */
  131319. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  131320. /**
  131321. * Get the current class name of the texture useful for serialization or dynamic coding.
  131322. * @returns "HDRCubeTexture"
  131323. */
  131324. getClassName(): string;
  131325. /**
  131326. * Occurs when the file is raw .hdr file.
  131327. */
  131328. private loadTexture;
  131329. clone(): HDRCubeTexture;
  131330. delayLoad(): void;
  131331. /**
  131332. * Get the texture reflection matrix used to rotate/transform the reflection.
  131333. * @returns the reflection matrix
  131334. */
  131335. getReflectionTextureMatrix(): Matrix;
  131336. /**
  131337. * Set the texture reflection matrix used to rotate/transform the reflection.
  131338. * @param value Define the reflection matrix to set
  131339. */
  131340. setReflectionTextureMatrix(value: Matrix): void;
  131341. /**
  131342. * Parses a JSON representation of an HDR Texture in order to create the texture
  131343. * @param parsedTexture Define the JSON representation
  131344. * @param scene Define the scene the texture should be created in
  131345. * @param rootUrl Define the root url in case we need to load relative dependencies
  131346. * @returns the newly created texture after parsing
  131347. */
  131348. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131349. serialize(): any;
  131350. }
  131351. }
  131352. declare module BABYLON {
  131353. /**
  131354. * Class used to control physics engine
  131355. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131356. */
  131357. export class PhysicsEngine implements IPhysicsEngine {
  131358. private _physicsPlugin;
  131359. /**
  131360. * Global value used to control the smallest number supported by the simulation
  131361. */
  131362. static Epsilon: number;
  131363. private _impostors;
  131364. private _joints;
  131365. private _subTimeStep;
  131366. /**
  131367. * Gets the gravity vector used by the simulation
  131368. */
  131369. gravity: Vector3;
  131370. /**
  131371. * Factory used to create the default physics plugin.
  131372. * @returns The default physics plugin
  131373. */
  131374. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131375. /**
  131376. * Creates a new Physics Engine
  131377. * @param gravity defines the gravity vector used by the simulation
  131378. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131379. */
  131380. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131381. /**
  131382. * Sets the gravity vector used by the simulation
  131383. * @param gravity defines the gravity vector to use
  131384. */
  131385. setGravity(gravity: Vector3): void;
  131386. /**
  131387. * Set the time step of the physics engine.
  131388. * Default is 1/60.
  131389. * To slow it down, enter 1/600 for example.
  131390. * To speed it up, 1/30
  131391. * @param newTimeStep defines the new timestep to apply to this world.
  131392. */
  131393. setTimeStep(newTimeStep?: number): void;
  131394. /**
  131395. * Get the time step of the physics engine.
  131396. * @returns the current time step
  131397. */
  131398. getTimeStep(): number;
  131399. /**
  131400. * Set the sub time step of the physics engine.
  131401. * Default is 0 meaning there is no sub steps
  131402. * To increase physics resolution precision, set a small value (like 1 ms)
  131403. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131404. */
  131405. setSubTimeStep(subTimeStep?: number): void;
  131406. /**
  131407. * Get the sub time step of the physics engine.
  131408. * @returns the current sub time step
  131409. */
  131410. getSubTimeStep(): number;
  131411. /**
  131412. * Release all resources
  131413. */
  131414. dispose(): void;
  131415. /**
  131416. * Gets the name of the current physics plugin
  131417. * @returns the name of the plugin
  131418. */
  131419. getPhysicsPluginName(): string;
  131420. /**
  131421. * Adding a new impostor for the impostor tracking.
  131422. * This will be done by the impostor itself.
  131423. * @param impostor the impostor to add
  131424. */
  131425. addImpostor(impostor: PhysicsImpostor): void;
  131426. /**
  131427. * Remove an impostor from the engine.
  131428. * This impostor and its mesh will not longer be updated by the physics engine.
  131429. * @param impostor the impostor to remove
  131430. */
  131431. removeImpostor(impostor: PhysicsImpostor): void;
  131432. /**
  131433. * Add a joint to the physics engine
  131434. * @param mainImpostor defines the main impostor to which the joint is added.
  131435. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131436. * @param joint defines the joint that will connect both impostors.
  131437. */
  131438. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131439. /**
  131440. * Removes a joint from the simulation
  131441. * @param mainImpostor defines the impostor used with the joint
  131442. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131443. * @param joint defines the joint to remove
  131444. */
  131445. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131446. /**
  131447. * Called by the scene. No need to call it.
  131448. * @param delta defines the timespam between frames
  131449. */
  131450. _step(delta: number): void;
  131451. /**
  131452. * Gets the current plugin used to run the simulation
  131453. * @returns current plugin
  131454. */
  131455. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131456. /**
  131457. * Gets the list of physic impostors
  131458. * @returns an array of PhysicsImpostor
  131459. */
  131460. getImpostors(): Array<PhysicsImpostor>;
  131461. /**
  131462. * Gets the impostor for a physics enabled object
  131463. * @param object defines the object impersonated by the impostor
  131464. * @returns the PhysicsImpostor or null if not found
  131465. */
  131466. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131467. /**
  131468. * Gets the impostor for a physics body object
  131469. * @param body defines physics body used by the impostor
  131470. * @returns the PhysicsImpostor or null if not found
  131471. */
  131472. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131473. /**
  131474. * Does a raycast in the physics world
  131475. * @param from when should the ray start?
  131476. * @param to when should the ray end?
  131477. * @returns PhysicsRaycastResult
  131478. */
  131479. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131480. }
  131481. }
  131482. declare module BABYLON {
  131483. /** @hidden */
  131484. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131485. private _useDeltaForWorldStep;
  131486. world: any;
  131487. name: string;
  131488. private _physicsMaterials;
  131489. private _fixedTimeStep;
  131490. private _cannonRaycastResult;
  131491. private _raycastResult;
  131492. private _physicsBodysToRemoveAfterStep;
  131493. BJSCANNON: any;
  131494. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131495. setGravity(gravity: Vector3): void;
  131496. setTimeStep(timeStep: number): void;
  131497. getTimeStep(): number;
  131498. executeStep(delta: number): void;
  131499. private _removeMarkedPhysicsBodiesFromWorld;
  131500. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131501. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131502. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131503. private _processChildMeshes;
  131504. removePhysicsBody(impostor: PhysicsImpostor): void;
  131505. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131506. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131507. private _addMaterial;
  131508. private _checkWithEpsilon;
  131509. private _createShape;
  131510. private _createHeightmap;
  131511. private _minus90X;
  131512. private _plus90X;
  131513. private _tmpPosition;
  131514. private _tmpDeltaPosition;
  131515. private _tmpUnityRotation;
  131516. private _updatePhysicsBodyTransformation;
  131517. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131518. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131519. isSupported(): boolean;
  131520. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131521. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131522. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131523. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131524. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131525. getBodyMass(impostor: PhysicsImpostor): number;
  131526. getBodyFriction(impostor: PhysicsImpostor): number;
  131527. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131528. getBodyRestitution(impostor: PhysicsImpostor): number;
  131529. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131530. sleepBody(impostor: PhysicsImpostor): void;
  131531. wakeUpBody(impostor: PhysicsImpostor): void;
  131532. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131533. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131534. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131535. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131536. getRadius(impostor: PhysicsImpostor): number;
  131537. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131538. dispose(): void;
  131539. private _extendNamespace;
  131540. /**
  131541. * Does a raycast in the physics world
  131542. * @param from when should the ray start?
  131543. * @param to when should the ray end?
  131544. * @returns PhysicsRaycastResult
  131545. */
  131546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131547. }
  131548. }
  131549. declare module BABYLON {
  131550. /** @hidden */
  131551. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131552. private _useDeltaForWorldStep;
  131553. world: any;
  131554. name: string;
  131555. BJSOIMO: any;
  131556. private _raycastResult;
  131557. private _fixedTimeStep;
  131558. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131559. setGravity(gravity: Vector3): void;
  131560. setTimeStep(timeStep: number): void;
  131561. getTimeStep(): number;
  131562. private _tmpImpostorsArray;
  131563. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131564. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131565. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131566. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131567. private _tmpPositionVector;
  131568. removePhysicsBody(impostor: PhysicsImpostor): void;
  131569. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131570. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131571. isSupported(): boolean;
  131572. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131573. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131574. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131576. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131577. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131578. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131579. getBodyMass(impostor: PhysicsImpostor): number;
  131580. getBodyFriction(impostor: PhysicsImpostor): number;
  131581. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131582. getBodyRestitution(impostor: PhysicsImpostor): number;
  131583. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131584. sleepBody(impostor: PhysicsImpostor): void;
  131585. wakeUpBody(impostor: PhysicsImpostor): void;
  131586. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131587. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131588. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131589. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131590. getRadius(impostor: PhysicsImpostor): number;
  131591. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131592. dispose(): void;
  131593. /**
  131594. * Does a raycast in the physics world
  131595. * @param from when should the ray start?
  131596. * @param to when should the ray end?
  131597. * @returns PhysicsRaycastResult
  131598. */
  131599. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131600. }
  131601. }
  131602. declare module BABYLON {
  131603. /**
  131604. * Class containing static functions to help procedurally build meshes
  131605. */
  131606. export class RibbonBuilder {
  131607. /**
  131608. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131609. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131610. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131611. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131612. * * 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
  131613. * * 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
  131614. * * 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
  131615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131617. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131618. * * 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
  131619. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131620. * * 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
  131621. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131623. * @param name defines the name of the mesh
  131624. * @param options defines the options used to create the mesh
  131625. * @param scene defines the hosting scene
  131626. * @returns the ribbon mesh
  131627. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131629. */
  131630. static CreateRibbon(name: string, options: {
  131631. pathArray: Vector3[][];
  131632. closeArray?: boolean;
  131633. closePath?: boolean;
  131634. offset?: number;
  131635. updatable?: boolean;
  131636. sideOrientation?: number;
  131637. frontUVs?: Vector4;
  131638. backUVs?: Vector4;
  131639. instance?: Mesh;
  131640. invertUV?: boolean;
  131641. uvs?: Vector2[];
  131642. colors?: Color4[];
  131643. }, scene?: Nullable<Scene>): Mesh;
  131644. }
  131645. }
  131646. declare module BABYLON {
  131647. /**
  131648. * Class containing static functions to help procedurally build meshes
  131649. */
  131650. export class ShapeBuilder {
  131651. /**
  131652. * 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.
  131653. * * 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.
  131654. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131655. * * 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.
  131656. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131657. * * 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
  131658. * * 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
  131659. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131664. * @param name defines the name of the mesh
  131665. * @param options defines the options used to create the mesh
  131666. * @param scene defines the hosting scene
  131667. * @returns the extruded shape mesh
  131668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131670. */
  131671. static ExtrudeShape(name: string, options: {
  131672. shape: Vector3[];
  131673. path: Vector3[];
  131674. scale?: number;
  131675. rotation?: number;
  131676. cap?: number;
  131677. updatable?: boolean;
  131678. sideOrientation?: number;
  131679. frontUVs?: Vector4;
  131680. backUVs?: Vector4;
  131681. instance?: Mesh;
  131682. invertUV?: boolean;
  131683. }, scene?: Nullable<Scene>): Mesh;
  131684. /**
  131685. * Creates an custom extruded shape mesh.
  131686. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131687. * * 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.
  131688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131689. * * 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
  131690. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131691. * * 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
  131692. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131693. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131694. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131695. * * 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
  131696. * * 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
  131697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131702. * @param name defines the name of the mesh
  131703. * @param options defines the options used to create the mesh
  131704. * @param scene defines the hosting scene
  131705. * @returns the custom extruded shape mesh
  131706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131709. */
  131710. static ExtrudeShapeCustom(name: string, options: {
  131711. shape: Vector3[];
  131712. path: Vector3[];
  131713. scaleFunction?: any;
  131714. rotationFunction?: any;
  131715. ribbonCloseArray?: boolean;
  131716. ribbonClosePath?: boolean;
  131717. cap?: number;
  131718. updatable?: boolean;
  131719. sideOrientation?: number;
  131720. frontUVs?: Vector4;
  131721. backUVs?: Vector4;
  131722. instance?: Mesh;
  131723. invertUV?: boolean;
  131724. }, scene?: Nullable<Scene>): Mesh;
  131725. private static _ExtrudeShapeGeneric;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /**
  131730. * AmmoJS Physics plugin
  131731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131732. * @see https://github.com/kripken/ammo.js/
  131733. */
  131734. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  131735. private _useDeltaForWorldStep;
  131736. /**
  131737. * Reference to the Ammo library
  131738. */
  131739. bjsAMMO: any;
  131740. /**
  131741. * Created ammoJS world which physics bodies are added to
  131742. */
  131743. world: any;
  131744. /**
  131745. * Name of the plugin
  131746. */
  131747. name: string;
  131748. private _timeStep;
  131749. private _fixedTimeStep;
  131750. private _maxSteps;
  131751. private _tmpQuaternion;
  131752. private _tmpAmmoTransform;
  131753. private _tmpAmmoQuaternion;
  131754. private _tmpAmmoConcreteContactResultCallback;
  131755. private _collisionConfiguration;
  131756. private _dispatcher;
  131757. private _overlappingPairCache;
  131758. private _solver;
  131759. private _softBodySolver;
  131760. private _tmpAmmoVectorA;
  131761. private _tmpAmmoVectorB;
  131762. private _tmpAmmoVectorC;
  131763. private _tmpAmmoVectorD;
  131764. private _tmpContactCallbackResult;
  131765. private _tmpAmmoVectorRCA;
  131766. private _tmpAmmoVectorRCB;
  131767. private _raycastResult;
  131768. private static readonly DISABLE_COLLISION_FLAG;
  131769. private static readonly KINEMATIC_FLAG;
  131770. private static readonly DISABLE_DEACTIVATION_FLAG;
  131771. /**
  131772. * Initializes the ammoJS plugin
  131773. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  131774. * @param ammoInjection can be used to inject your own ammo reference
  131775. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  131776. */
  131777. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  131778. /**
  131779. * Sets the gravity of the physics world (m/(s^2))
  131780. * @param gravity Gravity to set
  131781. */
  131782. setGravity(gravity: Vector3): void;
  131783. /**
  131784. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  131785. * @param timeStep timestep to use in seconds
  131786. */
  131787. setTimeStep(timeStep: number): void;
  131788. /**
  131789. * 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)
  131790. * @param fixedTimeStep fixedTimeStep to use in seconds
  131791. */
  131792. setFixedTimeStep(fixedTimeStep: number): void;
  131793. /**
  131794. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  131795. * @param maxSteps the maximum number of steps by the physics engine per frame
  131796. */
  131797. setMaxSteps(maxSteps: number): void;
  131798. /**
  131799. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  131800. * @returns the current timestep in seconds
  131801. */
  131802. getTimeStep(): number;
  131803. /**
  131804. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  131805. */
  131806. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  131807. private _isImpostorInContact;
  131808. private _isImpostorPairInContact;
  131809. private _stepSimulation;
  131810. /**
  131811. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  131812. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  131813. * After the step the babylon meshes are set to the position of the physics imposters
  131814. * @param delta amount of time to step forward
  131815. * @param impostors array of imposters to update before/after the step
  131816. */
  131817. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131818. /**
  131819. * Update babylon mesh to match physics world object
  131820. * @param impostor imposter to match
  131821. */
  131822. private _afterSoftStep;
  131823. /**
  131824. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131825. * @param impostor imposter to match
  131826. */
  131827. private _ropeStep;
  131828. /**
  131829. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131830. * @param impostor imposter to match
  131831. */
  131832. private _softbodyOrClothStep;
  131833. private _tmpMatrix;
  131834. /**
  131835. * Applies an impulse on the imposter
  131836. * @param impostor imposter to apply impulse to
  131837. * @param force amount of force to be applied to the imposter
  131838. * @param contactPoint the location to apply the impulse on the imposter
  131839. */
  131840. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131841. /**
  131842. * Applies a force on the imposter
  131843. * @param impostor imposter to apply force
  131844. * @param force amount of force to be applied to the imposter
  131845. * @param contactPoint the location to apply the force on the imposter
  131846. */
  131847. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131848. /**
  131849. * Creates a physics body using the plugin
  131850. * @param impostor the imposter to create the physics body on
  131851. */
  131852. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131853. /**
  131854. * Removes the physics body from the imposter and disposes of the body's memory
  131855. * @param impostor imposter to remove the physics body from
  131856. */
  131857. removePhysicsBody(impostor: PhysicsImpostor): void;
  131858. /**
  131859. * Generates a joint
  131860. * @param impostorJoint the imposter joint to create the joint with
  131861. */
  131862. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131863. /**
  131864. * Removes a joint
  131865. * @param impostorJoint the imposter joint to remove the joint from
  131866. */
  131867. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131868. private _addMeshVerts;
  131869. /**
  131870. * Initialise the soft body vertices to match its object's (mesh) vertices
  131871. * Softbody vertices (nodes) are in world space and to match this
  131872. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  131873. * @param impostor to create the softbody for
  131874. */
  131875. private _softVertexData;
  131876. /**
  131877. * Create an impostor's soft body
  131878. * @param impostor to create the softbody for
  131879. */
  131880. private _createSoftbody;
  131881. /**
  131882. * Create cloth for an impostor
  131883. * @param impostor to create the softbody for
  131884. */
  131885. private _createCloth;
  131886. /**
  131887. * Create rope for an impostor
  131888. * @param impostor to create the softbody for
  131889. */
  131890. private _createRope;
  131891. /**
  131892. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  131893. * @param impostor to create the custom physics shape for
  131894. */
  131895. private _createCustom;
  131896. private _addHullVerts;
  131897. private _createShape;
  131898. /**
  131899. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  131900. * @param impostor imposter containing the physics body and babylon object
  131901. */
  131902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131903. /**
  131904. * Sets the babylon object's position/rotation from the physics body's position/rotation
  131905. * @param impostor imposter containing the physics body and babylon object
  131906. * @param newPosition new position
  131907. * @param newRotation new rotation
  131908. */
  131909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131910. /**
  131911. * If this plugin is supported
  131912. * @returns true if its supported
  131913. */
  131914. isSupported(): boolean;
  131915. /**
  131916. * Sets the linear velocity of the physics body
  131917. * @param impostor imposter to set the velocity on
  131918. * @param velocity velocity to set
  131919. */
  131920. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131921. /**
  131922. * Sets the angular velocity of the physics body
  131923. * @param impostor imposter to set the velocity on
  131924. * @param velocity velocity to set
  131925. */
  131926. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131927. /**
  131928. * gets the linear velocity
  131929. * @param impostor imposter to get linear velocity from
  131930. * @returns linear velocity
  131931. */
  131932. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131933. /**
  131934. * gets the angular velocity
  131935. * @param impostor imposter to get angular velocity from
  131936. * @returns angular velocity
  131937. */
  131938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131939. /**
  131940. * Sets the mass of physics body
  131941. * @param impostor imposter to set the mass on
  131942. * @param mass mass to set
  131943. */
  131944. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131945. /**
  131946. * Gets the mass of the physics body
  131947. * @param impostor imposter to get the mass from
  131948. * @returns mass
  131949. */
  131950. getBodyMass(impostor: PhysicsImpostor): number;
  131951. /**
  131952. * Gets friction of the impostor
  131953. * @param impostor impostor to get friction from
  131954. * @returns friction value
  131955. */
  131956. getBodyFriction(impostor: PhysicsImpostor): number;
  131957. /**
  131958. * Sets friction of the impostor
  131959. * @param impostor impostor to set friction on
  131960. * @param friction friction value
  131961. */
  131962. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131963. /**
  131964. * Gets restitution of the impostor
  131965. * @param impostor impostor to get restitution from
  131966. * @returns restitution value
  131967. */
  131968. getBodyRestitution(impostor: PhysicsImpostor): number;
  131969. /**
  131970. * Sets resitution of the impostor
  131971. * @param impostor impostor to set resitution on
  131972. * @param restitution resitution value
  131973. */
  131974. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131975. /**
  131976. * Gets pressure inside the impostor
  131977. * @param impostor impostor to get pressure from
  131978. * @returns pressure value
  131979. */
  131980. getBodyPressure(impostor: PhysicsImpostor): number;
  131981. /**
  131982. * Sets pressure inside a soft body impostor
  131983. * Cloth and rope must remain 0 pressure
  131984. * @param impostor impostor to set pressure on
  131985. * @param pressure pressure value
  131986. */
  131987. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  131988. /**
  131989. * Gets stiffness of the impostor
  131990. * @param impostor impostor to get stiffness from
  131991. * @returns pressure value
  131992. */
  131993. getBodyStiffness(impostor: PhysicsImpostor): number;
  131994. /**
  131995. * Sets stiffness of the impostor
  131996. * @param impostor impostor to set stiffness on
  131997. * @param stiffness stiffness value from 0 to 1
  131998. */
  131999. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  132000. /**
  132001. * Gets velocityIterations of the impostor
  132002. * @param impostor impostor to get velocity iterations from
  132003. * @returns velocityIterations value
  132004. */
  132005. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  132006. /**
  132007. * Sets velocityIterations of the impostor
  132008. * @param impostor impostor to set velocity iterations on
  132009. * @param velocityIterations velocityIterations value
  132010. */
  132011. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132012. /**
  132013. * Gets positionIterations of the impostor
  132014. * @param impostor impostor to get position iterations from
  132015. * @returns positionIterations value
  132016. */
  132017. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132018. /**
  132019. * Sets positionIterations of the impostor
  132020. * @param impostor impostor to set position on
  132021. * @param positionIterations positionIterations value
  132022. */
  132023. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132024. /**
  132025. * Append an anchor to a cloth object
  132026. * @param impostor is the cloth impostor to add anchor to
  132027. * @param otherImpostor is the rigid impostor to anchor to
  132028. * @param width ratio across width from 0 to 1
  132029. * @param height ratio up height from 0 to 1
  132030. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132032. */
  132033. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132034. /**
  132035. * Append an hook to a rope object
  132036. * @param impostor is the rope impostor to add hook to
  132037. * @param otherImpostor is the rigid impostor to hook to
  132038. * @param length ratio along the rope from 0 to 1
  132039. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132040. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132041. */
  132042. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132043. /**
  132044. * Sleeps the physics body and stops it from being active
  132045. * @param impostor impostor to sleep
  132046. */
  132047. sleepBody(impostor: PhysicsImpostor): void;
  132048. /**
  132049. * Activates the physics body
  132050. * @param impostor impostor to activate
  132051. */
  132052. wakeUpBody(impostor: PhysicsImpostor): void;
  132053. /**
  132054. * Updates the distance parameters of the joint
  132055. * @param joint joint to update
  132056. * @param maxDistance maximum distance of the joint
  132057. * @param minDistance minimum distance of the joint
  132058. */
  132059. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132060. /**
  132061. * Sets a motor on the joint
  132062. * @param joint joint to set motor on
  132063. * @param speed speed of the motor
  132064. * @param maxForce maximum force of the motor
  132065. * @param motorIndex index of the motor
  132066. */
  132067. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132068. /**
  132069. * Sets the motors limit
  132070. * @param joint joint to set limit on
  132071. * @param upperLimit upper limit
  132072. * @param lowerLimit lower limit
  132073. */
  132074. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132075. /**
  132076. * Syncs the position and rotation of a mesh with the impostor
  132077. * @param mesh mesh to sync
  132078. * @param impostor impostor to update the mesh with
  132079. */
  132080. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132081. /**
  132082. * Gets the radius of the impostor
  132083. * @param impostor impostor to get radius from
  132084. * @returns the radius
  132085. */
  132086. getRadius(impostor: PhysicsImpostor): number;
  132087. /**
  132088. * Gets the box size of the impostor
  132089. * @param impostor impostor to get box size from
  132090. * @param result the resulting box size
  132091. */
  132092. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132093. /**
  132094. * Disposes of the impostor
  132095. */
  132096. dispose(): void;
  132097. /**
  132098. * Does a raycast in the physics world
  132099. * @param from when should the ray start?
  132100. * @param to when should the ray end?
  132101. * @returns PhysicsRaycastResult
  132102. */
  132103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132104. }
  132105. }
  132106. declare module BABYLON {
  132107. interface AbstractScene {
  132108. /**
  132109. * The list of reflection probes added to the scene
  132110. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132111. */
  132112. reflectionProbes: Array<ReflectionProbe>;
  132113. /**
  132114. * Removes the given reflection probe from this scene.
  132115. * @param toRemove The reflection probe to remove
  132116. * @returns The index of the removed reflection probe
  132117. */
  132118. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132119. /**
  132120. * Adds the given reflection probe to this scene.
  132121. * @param newReflectionProbe The reflection probe to add
  132122. */
  132123. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132124. }
  132125. /**
  132126. * Class used to generate realtime reflection / refraction cube textures
  132127. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132128. */
  132129. export class ReflectionProbe {
  132130. /** defines the name of the probe */
  132131. name: string;
  132132. private _scene;
  132133. private _renderTargetTexture;
  132134. private _projectionMatrix;
  132135. private _viewMatrix;
  132136. private _target;
  132137. private _add;
  132138. private _attachedMesh;
  132139. private _invertYAxis;
  132140. /** Gets or sets probe position (center of the cube map) */
  132141. position: Vector3;
  132142. /**
  132143. * Creates a new reflection probe
  132144. * @param name defines the name of the probe
  132145. * @param size defines the texture resolution (for each face)
  132146. * @param scene defines the hosting scene
  132147. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132148. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132149. */
  132150. constructor(
  132151. /** defines the name of the probe */
  132152. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132153. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132154. get samples(): number;
  132155. set samples(value: number);
  132156. /** Gets or sets the refresh rate to use (on every frame by default) */
  132157. get refreshRate(): number;
  132158. set refreshRate(value: number);
  132159. /**
  132160. * Gets the hosting scene
  132161. * @returns a Scene
  132162. */
  132163. getScene(): Scene;
  132164. /** Gets the internal CubeTexture used to render to */
  132165. get cubeTexture(): RenderTargetTexture;
  132166. /** Gets the list of meshes to render */
  132167. get renderList(): Nullable<AbstractMesh[]>;
  132168. /**
  132169. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132170. * @param mesh defines the mesh to attach to
  132171. */
  132172. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132173. /**
  132174. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132175. * @param renderingGroupId The rendering group id corresponding to its index
  132176. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132177. */
  132178. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132179. /**
  132180. * Clean all associated resources
  132181. */
  132182. dispose(): void;
  132183. /**
  132184. * Converts the reflection probe information to a readable string for debug purpose.
  132185. * @param fullDetails Supports for multiple levels of logging within scene loading
  132186. * @returns the human readable reflection probe info
  132187. */
  132188. toString(fullDetails?: boolean): string;
  132189. /**
  132190. * Get the class name of the relfection probe.
  132191. * @returns "ReflectionProbe"
  132192. */
  132193. getClassName(): string;
  132194. /**
  132195. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132196. * @returns The JSON representation of the texture
  132197. */
  132198. serialize(): any;
  132199. /**
  132200. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132201. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132202. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132203. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132204. * @returns The parsed reflection probe if successful
  132205. */
  132206. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132207. }
  132208. }
  132209. declare module BABYLON {
  132210. /** @hidden */
  132211. export var _BabylonLoaderRegistered: boolean;
  132212. /**
  132213. * Helps setting up some configuration for the babylon file loader.
  132214. */
  132215. export class BabylonFileLoaderConfiguration {
  132216. /**
  132217. * The loader does not allow injecting custom physix engine into the plugins.
  132218. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132219. * So you could set this variable to your engine import to make it work.
  132220. */
  132221. static LoaderInjectedPhysicsEngine: any;
  132222. }
  132223. }
  132224. declare module BABYLON {
  132225. /**
  132226. * The Physically based simple base material of BJS.
  132227. *
  132228. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132229. * It is used as the base class for both the specGloss and metalRough conventions.
  132230. */
  132231. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132232. /**
  132233. * Number of Simultaneous lights allowed on the material.
  132234. */
  132235. maxSimultaneousLights: number;
  132236. /**
  132237. * If sets to true, disables all the lights affecting the material.
  132238. */
  132239. disableLighting: boolean;
  132240. /**
  132241. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132242. */
  132243. environmentTexture: BaseTexture;
  132244. /**
  132245. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132246. */
  132247. invertNormalMapX: boolean;
  132248. /**
  132249. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132250. */
  132251. invertNormalMapY: boolean;
  132252. /**
  132253. * Normal map used in the model.
  132254. */
  132255. normalTexture: BaseTexture;
  132256. /**
  132257. * Emissivie color used to self-illuminate the model.
  132258. */
  132259. emissiveColor: Color3;
  132260. /**
  132261. * Emissivie texture used to self-illuminate the model.
  132262. */
  132263. emissiveTexture: BaseTexture;
  132264. /**
  132265. * Occlusion Channel Strenght.
  132266. */
  132267. occlusionStrength: number;
  132268. /**
  132269. * Occlusion Texture of the material (adding extra occlusion effects).
  132270. */
  132271. occlusionTexture: BaseTexture;
  132272. /**
  132273. * Defines the alpha limits in alpha test mode.
  132274. */
  132275. alphaCutOff: number;
  132276. /**
  132277. * Gets the current double sided mode.
  132278. */
  132279. get doubleSided(): boolean;
  132280. /**
  132281. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132282. */
  132283. set doubleSided(value: boolean);
  132284. /**
  132285. * Stores the pre-calculated light information of a mesh in a texture.
  132286. */
  132287. lightmapTexture: BaseTexture;
  132288. /**
  132289. * If true, the light map contains occlusion information instead of lighting info.
  132290. */
  132291. useLightmapAsShadowmap: boolean;
  132292. /**
  132293. * Instantiates a new PBRMaterial instance.
  132294. *
  132295. * @param name The material name
  132296. * @param scene The scene the material will be use in.
  132297. */
  132298. constructor(name: string, scene: Scene);
  132299. getClassName(): string;
  132300. }
  132301. }
  132302. declare module BABYLON {
  132303. /**
  132304. * The PBR material of BJS following the metal roughness convention.
  132305. *
  132306. * This fits to the PBR convention in the GLTF definition:
  132307. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132308. */
  132309. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132310. /**
  132311. * The base color has two different interpretations depending on the value of metalness.
  132312. * When the material is a metal, the base color is the specific measured reflectance value
  132313. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132314. * of the material.
  132315. */
  132316. baseColor: Color3;
  132317. /**
  132318. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132319. * well as opacity information in the alpha channel.
  132320. */
  132321. baseTexture: BaseTexture;
  132322. /**
  132323. * Specifies the metallic scalar value of the material.
  132324. * Can also be used to scale the metalness values of the metallic texture.
  132325. */
  132326. metallic: number;
  132327. /**
  132328. * Specifies the roughness scalar value of the material.
  132329. * Can also be used to scale the roughness values of the metallic texture.
  132330. */
  132331. roughness: number;
  132332. /**
  132333. * Texture containing both the metallic value in the B channel and the
  132334. * roughness value in the G channel to keep better precision.
  132335. */
  132336. metallicRoughnessTexture: BaseTexture;
  132337. /**
  132338. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132339. *
  132340. * @param name The material name
  132341. * @param scene The scene the material will be use in.
  132342. */
  132343. constructor(name: string, scene: Scene);
  132344. /**
  132345. * Return the currrent class name of the material.
  132346. */
  132347. getClassName(): string;
  132348. /**
  132349. * Makes a duplicate of the current material.
  132350. * @param name - name to use for the new material.
  132351. */
  132352. clone(name: string): PBRMetallicRoughnessMaterial;
  132353. /**
  132354. * Serialize the material to a parsable JSON object.
  132355. */
  132356. serialize(): any;
  132357. /**
  132358. * Parses a JSON object correponding to the serialize function.
  132359. */
  132360. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * The PBR material of BJS following the specular glossiness convention.
  132366. *
  132367. * This fits to the PBR convention in the GLTF definition:
  132368. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132369. */
  132370. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132371. /**
  132372. * Specifies the diffuse color of the material.
  132373. */
  132374. diffuseColor: Color3;
  132375. /**
  132376. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132377. * channel.
  132378. */
  132379. diffuseTexture: BaseTexture;
  132380. /**
  132381. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132382. */
  132383. specularColor: Color3;
  132384. /**
  132385. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132386. */
  132387. glossiness: number;
  132388. /**
  132389. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132390. */
  132391. specularGlossinessTexture: BaseTexture;
  132392. /**
  132393. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132394. *
  132395. * @param name The material name
  132396. * @param scene The scene the material will be use in.
  132397. */
  132398. constructor(name: string, scene: Scene);
  132399. /**
  132400. * Return the currrent class name of the material.
  132401. */
  132402. getClassName(): string;
  132403. /**
  132404. * Makes a duplicate of the current material.
  132405. * @param name - name to use for the new material.
  132406. */
  132407. clone(name: string): PBRSpecularGlossinessMaterial;
  132408. /**
  132409. * Serialize the material to a parsable JSON object.
  132410. */
  132411. serialize(): any;
  132412. /**
  132413. * Parses a JSON object correponding to the serialize function.
  132414. */
  132415. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132416. }
  132417. }
  132418. declare module BABYLON {
  132419. /**
  132420. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132421. * It can help converting any input color in a desired output one. This can then be used to create effects
  132422. * from sepia, black and white to sixties or futuristic rendering...
  132423. *
  132424. * The only supported format is currently 3dl.
  132425. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132426. */
  132427. export class ColorGradingTexture extends BaseTexture {
  132428. /**
  132429. * The texture URL.
  132430. */
  132431. url: string;
  132432. /**
  132433. * Empty line regex stored for GC.
  132434. */
  132435. private static _noneEmptyLineRegex;
  132436. private _textureMatrix;
  132437. private _engine;
  132438. private _onLoad;
  132439. /**
  132440. * Instantiates a ColorGradingTexture from the following parameters.
  132441. *
  132442. * @param url The location of the color gradind data (currently only supporting 3dl)
  132443. * @param sceneOrEngine The scene or engine the texture will be used in
  132444. * @param onLoad defines a callback triggered when the texture has been loaded
  132445. */
  132446. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132447. /**
  132448. * Fires the onload event from the constructor if requested.
  132449. */
  132450. private _triggerOnLoad;
  132451. /**
  132452. * Returns the texture matrix used in most of the material.
  132453. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132454. */
  132455. getTextureMatrix(): Matrix;
  132456. /**
  132457. * Occurs when the file being loaded is a .3dl LUT file.
  132458. */
  132459. private load3dlTexture;
  132460. /**
  132461. * Starts the loading process of the texture.
  132462. */
  132463. private loadTexture;
  132464. /**
  132465. * Clones the color gradind texture.
  132466. */
  132467. clone(): ColorGradingTexture;
  132468. /**
  132469. * Called during delayed load for textures.
  132470. */
  132471. delayLoad(): void;
  132472. /**
  132473. * Parses a color grading texture serialized by Babylon.
  132474. * @param parsedTexture The texture information being parsedTexture
  132475. * @param scene The scene to load the texture in
  132476. * @param rootUrl The root url of the data assets to load
  132477. * @return A color gradind texture
  132478. */
  132479. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132480. /**
  132481. * Serializes the LUT texture to json format.
  132482. */
  132483. serialize(): any;
  132484. /**
  132485. * Returns true if the passed parameter is a scene object (can be use for typings)
  132486. * @param sceneOrEngine The object to test.
  132487. */
  132488. private static _isScene;
  132489. }
  132490. }
  132491. declare module BABYLON {
  132492. /**
  132493. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132494. */
  132495. export class EquiRectangularCubeTexture extends BaseTexture {
  132496. /** The six faces of the cube. */
  132497. private static _FacesMapping;
  132498. private _noMipmap;
  132499. private _onLoad;
  132500. private _onError;
  132501. /** The size of the cubemap. */
  132502. private _size;
  132503. /** The buffer of the image. */
  132504. private _buffer;
  132505. /** The width of the input image. */
  132506. private _width;
  132507. /** The height of the input image. */
  132508. private _height;
  132509. /** The URL to the image. */
  132510. url: string;
  132511. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132512. coordinatesMode: number;
  132513. /**
  132514. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132515. * @param url The location of the image
  132516. * @param scene The scene the texture will be used in
  132517. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132518. * @param noMipmap Forces to not generate the mipmap if true
  132519. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132520. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132521. * @param onLoad — defines a callback called when texture is loaded
  132522. * @param onError — defines a callback called if there is an error
  132523. */
  132524. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132525. /**
  132526. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132527. */
  132528. private loadImage;
  132529. /**
  132530. * Convert the image buffer into a cubemap and create a CubeTexture.
  132531. */
  132532. private loadTexture;
  132533. /**
  132534. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132535. * @param buffer The ArrayBuffer that should be converted.
  132536. * @returns The buffer as Float32Array.
  132537. */
  132538. private getFloat32ArrayFromArrayBuffer;
  132539. /**
  132540. * Get the current class name of the texture useful for serialization or dynamic coding.
  132541. * @returns "EquiRectangularCubeTexture"
  132542. */
  132543. getClassName(): string;
  132544. /**
  132545. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132546. * @returns A clone of the current EquiRectangularCubeTexture.
  132547. */
  132548. clone(): EquiRectangularCubeTexture;
  132549. }
  132550. }
  132551. declare module BABYLON {
  132552. /**
  132553. * Based on jsTGALoader - Javascript loader for TGA file
  132554. * By Vincent Thibault
  132555. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132556. */
  132557. export class TGATools {
  132558. private static _TYPE_INDEXED;
  132559. private static _TYPE_RGB;
  132560. private static _TYPE_GREY;
  132561. private static _TYPE_RLE_INDEXED;
  132562. private static _TYPE_RLE_RGB;
  132563. private static _TYPE_RLE_GREY;
  132564. private static _ORIGIN_MASK;
  132565. private static _ORIGIN_SHIFT;
  132566. private static _ORIGIN_BL;
  132567. private static _ORIGIN_BR;
  132568. private static _ORIGIN_UL;
  132569. private static _ORIGIN_UR;
  132570. /**
  132571. * Gets the header of a TGA file
  132572. * @param data defines the TGA data
  132573. * @returns the header
  132574. */
  132575. static GetTGAHeader(data: Uint8Array): any;
  132576. /**
  132577. * Uploads TGA content to a Babylon Texture
  132578. * @hidden
  132579. */
  132580. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132581. /** @hidden */
  132582. 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;
  132583. /** @hidden */
  132584. 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;
  132585. /** @hidden */
  132586. 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;
  132587. /** @hidden */
  132588. 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;
  132589. /** @hidden */
  132590. 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;
  132591. /** @hidden */
  132592. 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;
  132593. }
  132594. }
  132595. declare module BABYLON {
  132596. /**
  132597. * Implementation of the TGA Texture Loader.
  132598. * @hidden
  132599. */
  132600. export class _TGATextureLoader implements IInternalTextureLoader {
  132601. /**
  132602. * Defines wether the loader supports cascade loading the different faces.
  132603. */
  132604. readonly supportCascades: boolean;
  132605. /**
  132606. * This returns if the loader support the current file information.
  132607. * @param extension defines the file extension of the file being loaded
  132608. * @returns true if the loader can load the specified file
  132609. */
  132610. canLoad(extension: string): boolean;
  132611. /**
  132612. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132613. * @param data contains the texture data
  132614. * @param texture defines the BabylonJS internal texture
  132615. * @param createPolynomials will be true if polynomials have been requested
  132616. * @param onLoad defines the callback to trigger once the texture is ready
  132617. * @param onError defines the callback to trigger in case of error
  132618. */
  132619. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132620. /**
  132621. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132622. * @param data contains the texture data
  132623. * @param texture defines the BabylonJS internal texture
  132624. * @param callback defines the method to call once ready to upload
  132625. */
  132626. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132627. }
  132628. }
  132629. declare module BABYLON {
  132630. /**
  132631. * Info about the .basis files
  132632. */
  132633. class BasisFileInfo {
  132634. /**
  132635. * If the file has alpha
  132636. */
  132637. hasAlpha: boolean;
  132638. /**
  132639. * Info about each image of the basis file
  132640. */
  132641. images: Array<{
  132642. levels: Array<{
  132643. width: number;
  132644. height: number;
  132645. transcodedPixels: ArrayBufferView;
  132646. }>;
  132647. }>;
  132648. }
  132649. /**
  132650. * Result of transcoding a basis file
  132651. */
  132652. class TranscodeResult {
  132653. /**
  132654. * Info about the .basis file
  132655. */
  132656. fileInfo: BasisFileInfo;
  132657. /**
  132658. * Format to use when loading the file
  132659. */
  132660. format: number;
  132661. }
  132662. /**
  132663. * Configuration options for the Basis transcoder
  132664. */
  132665. export class BasisTranscodeConfiguration {
  132666. /**
  132667. * Supported compression formats used to determine the supported output format of the transcoder
  132668. */
  132669. supportedCompressionFormats?: {
  132670. /**
  132671. * etc1 compression format
  132672. */
  132673. etc1?: boolean;
  132674. /**
  132675. * s3tc compression format
  132676. */
  132677. s3tc?: boolean;
  132678. /**
  132679. * pvrtc compression format
  132680. */
  132681. pvrtc?: boolean;
  132682. /**
  132683. * etc2 compression format
  132684. */
  132685. etc2?: boolean;
  132686. };
  132687. /**
  132688. * If mipmap levels should be loaded for transcoded images (Default: true)
  132689. */
  132690. loadMipmapLevels?: boolean;
  132691. /**
  132692. * Index of a single image to load (Default: all images)
  132693. */
  132694. loadSingleImage?: number;
  132695. }
  132696. /**
  132697. * Used to load .Basis files
  132698. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132699. */
  132700. export class BasisTools {
  132701. private static _IgnoreSupportedFormats;
  132702. /**
  132703. * URL to use when loading the basis transcoder
  132704. */
  132705. static JSModuleURL: string;
  132706. /**
  132707. * URL to use when loading the wasm module for the transcoder
  132708. */
  132709. static WasmModuleURL: string;
  132710. /**
  132711. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132712. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132713. * @returns internal format corresponding to the Basis format
  132714. */
  132715. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132716. private static _WorkerPromise;
  132717. private static _Worker;
  132718. private static _actionId;
  132719. private static _CreateWorkerAsync;
  132720. /**
  132721. * Transcodes a loaded image file to compressed pixel data
  132722. * @param data image data to transcode
  132723. * @param config configuration options for the transcoding
  132724. * @returns a promise resulting in the transcoded image
  132725. */
  132726. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  132727. /**
  132728. * Loads a texture from the transcode result
  132729. * @param texture texture load to
  132730. * @param transcodeResult the result of transcoding the basis file to load from
  132731. */
  132732. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  132733. }
  132734. }
  132735. declare module BABYLON {
  132736. /**
  132737. * Loader for .basis file format
  132738. */
  132739. export class _BasisTextureLoader implements IInternalTextureLoader {
  132740. /**
  132741. * Defines whether the loader supports cascade loading the different faces.
  132742. */
  132743. readonly supportCascades: boolean;
  132744. /**
  132745. * This returns if the loader support the current file information.
  132746. * @param extension defines the file extension of the file being loaded
  132747. * @returns true if the loader can load the specified file
  132748. */
  132749. canLoad(extension: string): boolean;
  132750. /**
  132751. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132752. * @param data contains the texture data
  132753. * @param texture defines the BabylonJS internal texture
  132754. * @param createPolynomials will be true if polynomials have been requested
  132755. * @param onLoad defines the callback to trigger once the texture is ready
  132756. * @param onError defines the callback to trigger in case of error
  132757. */
  132758. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132759. /**
  132760. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132761. * @param data contains the texture data
  132762. * @param texture defines the BabylonJS internal texture
  132763. * @param callback defines the method to call once ready to upload
  132764. */
  132765. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132766. }
  132767. }
  132768. declare module BABYLON {
  132769. /**
  132770. * 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.
  132771. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132772. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132773. */
  132774. export class CustomProceduralTexture extends ProceduralTexture {
  132775. private _animate;
  132776. private _time;
  132777. private _config;
  132778. private _texturePath;
  132779. /**
  132780. * Instantiates a new Custom Procedural Texture.
  132781. * 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.
  132782. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132783. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132784. * @param name Define the name of the texture
  132785. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  132786. * @param size Define the size of the texture to create
  132787. * @param scene Define the scene the texture belongs to
  132788. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  132789. * @param generateMipMaps Define if the texture should creates mip maps or not
  132790. */
  132791. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132792. private _loadJson;
  132793. /**
  132794. * Is the texture ready to be used ? (rendered at least once)
  132795. * @returns true if ready, otherwise, false.
  132796. */
  132797. isReady(): boolean;
  132798. /**
  132799. * Render the texture to its associated render target.
  132800. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  132801. */
  132802. render(useCameraPostProcess?: boolean): void;
  132803. /**
  132804. * Update the list of dependant textures samplers in the shader.
  132805. */
  132806. updateTextures(): void;
  132807. /**
  132808. * Update the uniform values of the procedural texture in the shader.
  132809. */
  132810. updateShaderUniforms(): void;
  132811. /**
  132812. * Define if the texture animates or not.
  132813. */
  132814. get animate(): boolean;
  132815. set animate(value: boolean);
  132816. }
  132817. }
  132818. declare module BABYLON {
  132819. /** @hidden */
  132820. export var noisePixelShader: {
  132821. name: string;
  132822. shader: string;
  132823. };
  132824. }
  132825. declare module BABYLON {
  132826. /**
  132827. * Class used to generate noise procedural textures
  132828. */
  132829. export class NoiseProceduralTexture extends ProceduralTexture {
  132830. private _time;
  132831. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  132832. brightness: number;
  132833. /** Defines the number of octaves to process */
  132834. octaves: number;
  132835. /** Defines the level of persistence (0.8 by default) */
  132836. persistence: number;
  132837. /** Gets or sets animation speed factor (default is 1) */
  132838. animationSpeedFactor: number;
  132839. /**
  132840. * Creates a new NoiseProceduralTexture
  132841. * @param name defines the name fo the texture
  132842. * @param size defines the size of the texture (default is 256)
  132843. * @param scene defines the hosting scene
  132844. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  132845. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  132846. */
  132847. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132848. private _updateShaderUniforms;
  132849. protected _getDefines(): string;
  132850. /** Generate the current state of the procedural texture */
  132851. render(useCameraPostProcess?: boolean): void;
  132852. /**
  132853. * Serializes this noise procedural texture
  132854. * @returns a serialized noise procedural texture object
  132855. */
  132856. serialize(): any;
  132857. /**
  132858. * Clone the texture.
  132859. * @returns the cloned texture
  132860. */
  132861. clone(): NoiseProceduralTexture;
  132862. /**
  132863. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  132864. * @param parsedTexture defines parsed texture data
  132865. * @param scene defines the current scene
  132866. * @param rootUrl defines the root URL containing noise procedural texture information
  132867. * @returns a parsed NoiseProceduralTexture
  132868. */
  132869. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  132870. }
  132871. }
  132872. declare module BABYLON {
  132873. /**
  132874. * Raw cube texture where the raw buffers are passed in
  132875. */
  132876. export class RawCubeTexture extends CubeTexture {
  132877. /**
  132878. * Creates a cube texture where the raw buffers are passed in.
  132879. * @param scene defines the scene the texture is attached to
  132880. * @param data defines the array of data to use to create each face
  132881. * @param size defines the size of the textures
  132882. * @param format defines the format of the data
  132883. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  132884. * @param generateMipMaps defines if the engine should generate the mip levels
  132885. * @param invertY defines if data must be stored with Y axis inverted
  132886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  132887. * @param compression defines the compression used (null by default)
  132888. */
  132889. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  132890. /**
  132891. * Updates the raw cube texture.
  132892. * @param data defines the data to store
  132893. * @param format defines the data format
  132894. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132895. * @param invertY defines if data must be stored with Y axis inverted
  132896. * @param compression defines the compression used (null by default)
  132897. * @param level defines which level of the texture to update
  132898. */
  132899. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  132900. /**
  132901. * Updates a raw cube texture with RGBD encoded data.
  132902. * @param data defines the array of data [mipmap][face] to use to create each face
  132903. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  132904. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132905. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132906. * @returns a promsie that resolves when the operation is complete
  132907. */
  132908. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  132909. /**
  132910. * Clones the raw cube texture.
  132911. * @return a new cube texture
  132912. */
  132913. clone(): CubeTexture;
  132914. /** @hidden */
  132915. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132916. }
  132917. }
  132918. declare module BABYLON {
  132919. /**
  132920. * Class used to store 3D textures containing user data
  132921. */
  132922. export class RawTexture3D extends Texture {
  132923. /** Gets or sets the texture format to use */
  132924. format: number;
  132925. private _engine;
  132926. /**
  132927. * Create a new RawTexture3D
  132928. * @param data defines the data of the texture
  132929. * @param width defines the width of the texture
  132930. * @param height defines the height of the texture
  132931. * @param depth defines the depth of the texture
  132932. * @param format defines the texture format to use
  132933. * @param scene defines the hosting scene
  132934. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132935. * @param invertY defines if texture must be stored with Y axis inverted
  132936. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132937. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132938. */
  132939. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132940. /** Gets or sets the texture format to use */
  132941. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132942. /**
  132943. * Update the texture with new data
  132944. * @param data defines the data to store in the texture
  132945. */
  132946. update(data: ArrayBufferView): void;
  132947. }
  132948. }
  132949. declare module BABYLON {
  132950. /**
  132951. * Class used to store 2D array textures containing user data
  132952. */
  132953. export class RawTexture2DArray extends Texture {
  132954. /** Gets or sets the texture format to use */
  132955. format: number;
  132956. private _engine;
  132957. /**
  132958. * Create a new RawTexture2DArray
  132959. * @param data defines the data of the texture
  132960. * @param width defines the width of the texture
  132961. * @param height defines the height of the texture
  132962. * @param depth defines the number of layers of the texture
  132963. * @param format defines the texture format to use
  132964. * @param scene defines the hosting scene
  132965. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132966. * @param invertY defines if texture must be stored with Y axis inverted
  132967. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132968. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132969. */
  132970. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132971. /** Gets or sets the texture format to use */
  132972. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132973. /**
  132974. * Update the texture with new data
  132975. * @param data defines the data to store in the texture
  132976. */
  132977. update(data: ArrayBufferView): void;
  132978. }
  132979. }
  132980. declare module BABYLON {
  132981. /**
  132982. * Creates a refraction texture used by refraction channel of the standard material.
  132983. * It is like a mirror but to see through a material.
  132984. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132985. */
  132986. export class RefractionTexture extends RenderTargetTexture {
  132987. /**
  132988. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  132989. * 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.
  132990. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132991. */
  132992. refractionPlane: Plane;
  132993. /**
  132994. * Define how deep under the surface we should see.
  132995. */
  132996. depth: number;
  132997. /**
  132998. * Creates a refraction texture used by refraction channel of the standard material.
  132999. * It is like a mirror but to see through a material.
  133000. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  133001. * @param name Define the texture name
  133002. * @param size Define the size of the underlying texture
  133003. * @param scene Define the scene the refraction belongs to
  133004. * @param generateMipMaps Define if we need to generate mips level for the refraction
  133005. */
  133006. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  133007. /**
  133008. * Clone the refraction texture.
  133009. * @returns the cloned texture
  133010. */
  133011. clone(): RefractionTexture;
  133012. /**
  133013. * Serialize the texture to a JSON representation you could use in Parse later on
  133014. * @returns the serialized JSON representation
  133015. */
  133016. serialize(): any;
  133017. }
  133018. }
  133019. declare module BABYLON {
  133020. /**
  133021. * Defines the options related to the creation of an HtmlElementTexture
  133022. */
  133023. export interface IHtmlElementTextureOptions {
  133024. /**
  133025. * Defines wether mip maps should be created or not.
  133026. */
  133027. generateMipMaps?: boolean;
  133028. /**
  133029. * Defines the sampling mode of the texture.
  133030. */
  133031. samplingMode?: number;
  133032. /**
  133033. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133034. */
  133035. engine: Nullable<ThinEngine>;
  133036. /**
  133037. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133038. */
  133039. scene: Nullable<Scene>;
  133040. }
  133041. /**
  133042. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133043. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133044. * is automatically managed.
  133045. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133046. * in your application.
  133047. *
  133048. * As the update is not automatic, you need to call them manually.
  133049. */
  133050. export class HtmlElementTexture extends BaseTexture {
  133051. /**
  133052. * The texture URL.
  133053. */
  133054. element: HTMLVideoElement | HTMLCanvasElement;
  133055. private static readonly DefaultOptions;
  133056. private _textureMatrix;
  133057. private _engine;
  133058. private _isVideo;
  133059. private _generateMipMaps;
  133060. private _samplingMode;
  133061. /**
  133062. * Instantiates a HtmlElementTexture from the following parameters.
  133063. *
  133064. * @param name Defines the name of the texture
  133065. * @param element Defines the video or canvas the texture is filled with
  133066. * @param options Defines the other none mandatory texture creation options
  133067. */
  133068. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133069. private _createInternalTexture;
  133070. /**
  133071. * Returns the texture matrix used in most of the material.
  133072. */
  133073. getTextureMatrix(): Matrix;
  133074. /**
  133075. * Updates the content of the texture.
  133076. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133077. */
  133078. update(invertY?: Nullable<boolean>): void;
  133079. }
  133080. }
  133081. declare module BABYLON {
  133082. /**
  133083. * Defines the basic options interface of a TexturePacker Frame
  133084. */
  133085. export interface ITexturePackerFrame {
  133086. /**
  133087. * The frame ID
  133088. */
  133089. id: number;
  133090. /**
  133091. * The frames Scale
  133092. */
  133093. scale: Vector2;
  133094. /**
  133095. * The Frames offset
  133096. */
  133097. offset: Vector2;
  133098. }
  133099. /**
  133100. * This is a support class for frame Data on texture packer sets.
  133101. */
  133102. export class TexturePackerFrame implements ITexturePackerFrame {
  133103. /**
  133104. * The frame ID
  133105. */
  133106. id: number;
  133107. /**
  133108. * The frames Scale
  133109. */
  133110. scale: Vector2;
  133111. /**
  133112. * The Frames offset
  133113. */
  133114. offset: Vector2;
  133115. /**
  133116. * Initializes a texture package frame.
  133117. * @param id The numerical frame identifier
  133118. * @param scale Scalar Vector2 for UV frame
  133119. * @param offset Vector2 for the frame position in UV units.
  133120. * @returns TexturePackerFrame
  133121. */
  133122. constructor(id: number, scale: Vector2, offset: Vector2);
  133123. }
  133124. }
  133125. declare module BABYLON {
  133126. /**
  133127. * Defines the basic options interface of a TexturePacker
  133128. */
  133129. export interface ITexturePackerOptions {
  133130. /**
  133131. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133132. */
  133133. map?: string[];
  133134. /**
  133135. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133136. */
  133137. uvsIn?: string;
  133138. /**
  133139. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133140. */
  133141. uvsOut?: string;
  133142. /**
  133143. * number representing the layout style. Defaults to LAYOUT_STRIP
  133144. */
  133145. layout?: number;
  133146. /**
  133147. * number of columns if using custom column count layout(2). This defaults to 4.
  133148. */
  133149. colnum?: number;
  133150. /**
  133151. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133152. */
  133153. updateInputMeshes?: boolean;
  133154. /**
  133155. * boolean flag to dispose all the source textures. Defaults to true.
  133156. */
  133157. disposeSources?: boolean;
  133158. /**
  133159. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133160. */
  133161. fillBlanks?: boolean;
  133162. /**
  133163. * string value representing the context fill style color. Defaults to 'black'.
  133164. */
  133165. customFillColor?: string;
  133166. /**
  133167. * Width and Height Value of each Frame in the TexturePacker Sets
  133168. */
  133169. frameSize?: number;
  133170. /**
  133171. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133172. */
  133173. paddingRatio?: number;
  133174. /**
  133175. * Number that declares the fill method for the padding gutter.
  133176. */
  133177. paddingMode?: number;
  133178. /**
  133179. * If in SUBUV_COLOR padding mode what color to use.
  133180. */
  133181. paddingColor?: Color3 | Color4;
  133182. }
  133183. /**
  133184. * Defines the basic interface of a TexturePacker JSON File
  133185. */
  133186. export interface ITexturePackerJSON {
  133187. /**
  133188. * The frame ID
  133189. */
  133190. name: string;
  133191. /**
  133192. * The base64 channel data
  133193. */
  133194. sets: any;
  133195. /**
  133196. * The options of the Packer
  133197. */
  133198. options: ITexturePackerOptions;
  133199. /**
  133200. * The frame data of the Packer
  133201. */
  133202. frames: Array<number>;
  133203. }
  133204. /**
  133205. * This is a support class that generates a series of packed texture sets.
  133206. * @see https://doc.babylonjs.com/babylon101/materials
  133207. */
  133208. export class TexturePacker {
  133209. /** Packer Layout Constant 0 */
  133210. static readonly LAYOUT_STRIP: number;
  133211. /** Packer Layout Constant 1 */
  133212. static readonly LAYOUT_POWER2: number;
  133213. /** Packer Layout Constant 2 */
  133214. static readonly LAYOUT_COLNUM: number;
  133215. /** Packer Layout Constant 0 */
  133216. static readonly SUBUV_WRAP: number;
  133217. /** Packer Layout Constant 1 */
  133218. static readonly SUBUV_EXTEND: number;
  133219. /** Packer Layout Constant 2 */
  133220. static readonly SUBUV_COLOR: number;
  133221. /** The Name of the Texture Package */
  133222. name: string;
  133223. /** The scene scope of the TexturePacker */
  133224. scene: Scene;
  133225. /** The Meshes to target */
  133226. meshes: AbstractMesh[];
  133227. /** Arguments passed with the Constructor */
  133228. options: ITexturePackerOptions;
  133229. /** The promise that is started upon initialization */
  133230. promise: Nullable<Promise<TexturePacker | string>>;
  133231. /** The Container object for the channel sets that are generated */
  133232. sets: object;
  133233. /** The Container array for the frames that are generated */
  133234. frames: TexturePackerFrame[];
  133235. /** The expected number of textures the system is parsing. */
  133236. private _expecting;
  133237. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133238. private _paddingValue;
  133239. /**
  133240. * Initializes a texture package series from an array of meshes or a single mesh.
  133241. * @param name The name of the package
  133242. * @param meshes The target meshes to compose the package from
  133243. * @param options The arguments that texture packer should follow while building.
  133244. * @param scene The scene which the textures are scoped to.
  133245. * @returns TexturePacker
  133246. */
  133247. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133248. /**
  133249. * Starts the package process
  133250. * @param resolve The promises resolution function
  133251. * @returns TexturePacker
  133252. */
  133253. private _createFrames;
  133254. /**
  133255. * Calculates the Size of the Channel Sets
  133256. * @returns Vector2
  133257. */
  133258. private _calculateSize;
  133259. /**
  133260. * Calculates the UV data for the frames.
  133261. * @param baseSize the base frameSize
  133262. * @param padding the base frame padding
  133263. * @param dtSize size of the Dynamic Texture for that channel
  133264. * @param dtUnits is 1/dtSize
  133265. * @param update flag to update the input meshes
  133266. */
  133267. private _calculateMeshUVFrames;
  133268. /**
  133269. * Calculates the frames Offset.
  133270. * @param index of the frame
  133271. * @returns Vector2
  133272. */
  133273. private _getFrameOffset;
  133274. /**
  133275. * Updates a Mesh to the frame data
  133276. * @param mesh that is the target
  133277. * @param frameID or the frame index
  133278. */
  133279. private _updateMeshUV;
  133280. /**
  133281. * Updates a Meshes materials to use the texture packer channels
  133282. * @param m is the mesh to target
  133283. * @param force all channels on the packer to be set.
  133284. */
  133285. private _updateTextureReferences;
  133286. /**
  133287. * Public method to set a Mesh to a frame
  133288. * @param m that is the target
  133289. * @param frameID or the frame index
  133290. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133291. */
  133292. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133293. /**
  133294. * Starts the async promise to compile the texture packer.
  133295. * @returns Promise<void>
  133296. */
  133297. processAsync(): Promise<void>;
  133298. /**
  133299. * Disposes all textures associated with this packer
  133300. */
  133301. dispose(): void;
  133302. /**
  133303. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133304. * @param imageType is the image type to use.
  133305. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133306. */
  133307. download(imageType?: string, quality?: number): void;
  133308. /**
  133309. * Public method to load a texturePacker JSON file.
  133310. * @param data of the JSON file in string format.
  133311. */
  133312. updateFromJSON(data: string): void;
  133313. }
  133314. }
  133315. declare module BABYLON {
  133316. /**
  133317. * Enum used to define the target of a block
  133318. */
  133319. export enum NodeMaterialBlockTargets {
  133320. /** Vertex shader */
  133321. Vertex = 1,
  133322. /** Fragment shader */
  133323. Fragment = 2,
  133324. /** Neutral */
  133325. Neutral = 4,
  133326. /** Vertex and Fragment */
  133327. VertexAndFragment = 3
  133328. }
  133329. }
  133330. declare module BABYLON {
  133331. /**
  133332. * Defines the kind of connection point for node based material
  133333. */
  133334. export enum NodeMaterialBlockConnectionPointTypes {
  133335. /** Float */
  133336. Float = 1,
  133337. /** Int */
  133338. Int = 2,
  133339. /** Vector2 */
  133340. Vector2 = 4,
  133341. /** Vector3 */
  133342. Vector3 = 8,
  133343. /** Vector4 */
  133344. Vector4 = 16,
  133345. /** Color3 */
  133346. Color3 = 32,
  133347. /** Color4 */
  133348. Color4 = 64,
  133349. /** Matrix */
  133350. Matrix = 128,
  133351. /** Custom object */
  133352. Object = 256,
  133353. /** Detect type based on connection */
  133354. AutoDetect = 1024,
  133355. /** Output type that will be defined by input type */
  133356. BasedOnInput = 2048
  133357. }
  133358. }
  133359. declare module BABYLON {
  133360. /**
  133361. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133362. */
  133363. export enum NodeMaterialBlockConnectionPointMode {
  133364. /** Value is an uniform */
  133365. Uniform = 0,
  133366. /** Value is a mesh attribute */
  133367. Attribute = 1,
  133368. /** Value is a varying between vertex and fragment shaders */
  133369. Varying = 2,
  133370. /** Mode is undefined */
  133371. Undefined = 3
  133372. }
  133373. }
  133374. declare module BABYLON {
  133375. /**
  133376. * Enum used to define system values e.g. values automatically provided by the system
  133377. */
  133378. export enum NodeMaterialSystemValues {
  133379. /** World */
  133380. World = 1,
  133381. /** View */
  133382. View = 2,
  133383. /** Projection */
  133384. Projection = 3,
  133385. /** ViewProjection */
  133386. ViewProjection = 4,
  133387. /** WorldView */
  133388. WorldView = 5,
  133389. /** WorldViewProjection */
  133390. WorldViewProjection = 6,
  133391. /** CameraPosition */
  133392. CameraPosition = 7,
  133393. /** Fog Color */
  133394. FogColor = 8,
  133395. /** Delta time */
  133396. DeltaTime = 9
  133397. }
  133398. }
  133399. declare module BABYLON {
  133400. /**
  133401. * Root class for all node material optimizers
  133402. */
  133403. export class NodeMaterialOptimizer {
  133404. /**
  133405. * Function used to optimize a NodeMaterial graph
  133406. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133407. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133408. */
  133409. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133410. }
  133411. }
  133412. declare module BABYLON {
  133413. /**
  133414. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133415. */
  133416. export class TransformBlock extends NodeMaterialBlock {
  133417. /**
  133418. * Defines the value to use to complement W value to transform it to a Vector4
  133419. */
  133420. complementW: number;
  133421. /**
  133422. * Defines the value to use to complement z value to transform it to a Vector4
  133423. */
  133424. complementZ: number;
  133425. /**
  133426. * Creates a new TransformBlock
  133427. * @param name defines the block name
  133428. */
  133429. constructor(name: string);
  133430. /**
  133431. * Gets the current class name
  133432. * @returns the class name
  133433. */
  133434. getClassName(): string;
  133435. /**
  133436. * Gets the vector input
  133437. */
  133438. get vector(): NodeMaterialConnectionPoint;
  133439. /**
  133440. * Gets the output component
  133441. */
  133442. get output(): NodeMaterialConnectionPoint;
  133443. /**
  133444. * Gets the xyz output component
  133445. */
  133446. get xyz(): NodeMaterialConnectionPoint;
  133447. /**
  133448. * Gets the matrix transform input
  133449. */
  133450. get transform(): NodeMaterialConnectionPoint;
  133451. protected _buildBlock(state: NodeMaterialBuildState): this;
  133452. serialize(): any;
  133453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133454. protected _dumpPropertiesCode(): string;
  133455. }
  133456. }
  133457. declare module BABYLON {
  133458. /**
  133459. * Block used to output the vertex position
  133460. */
  133461. export class VertexOutputBlock extends NodeMaterialBlock {
  133462. /**
  133463. * Creates a new VertexOutputBlock
  133464. * @param name defines the block name
  133465. */
  133466. constructor(name: string);
  133467. /**
  133468. * Gets the current class name
  133469. * @returns the class name
  133470. */
  133471. getClassName(): string;
  133472. /**
  133473. * Gets the vector input component
  133474. */
  133475. get vector(): NodeMaterialConnectionPoint;
  133476. protected _buildBlock(state: NodeMaterialBuildState): this;
  133477. }
  133478. }
  133479. declare module BABYLON {
  133480. /**
  133481. * Block used to output the final color
  133482. */
  133483. export class FragmentOutputBlock extends NodeMaterialBlock {
  133484. /**
  133485. * Create a new FragmentOutputBlock
  133486. * @param name defines the block name
  133487. */
  133488. constructor(name: string);
  133489. /**
  133490. * Gets the current class name
  133491. * @returns the class name
  133492. */
  133493. getClassName(): string;
  133494. /**
  133495. * Gets the rgba input component
  133496. */
  133497. get rgba(): NodeMaterialConnectionPoint;
  133498. /**
  133499. * Gets the rgb input component
  133500. */
  133501. get rgb(): NodeMaterialConnectionPoint;
  133502. /**
  133503. * Gets the a input component
  133504. */
  133505. get a(): NodeMaterialConnectionPoint;
  133506. protected _buildBlock(state: NodeMaterialBuildState): this;
  133507. }
  133508. }
  133509. declare module BABYLON {
  133510. /**
  133511. * Base block used to read a reflection texture from a sampler
  133512. */
  133513. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133514. /** @hidden */
  133515. _define3DName: string;
  133516. /** @hidden */
  133517. _defineCubicName: string;
  133518. /** @hidden */
  133519. _defineExplicitName: string;
  133520. /** @hidden */
  133521. _defineProjectionName: string;
  133522. /** @hidden */
  133523. _defineLocalCubicName: string;
  133524. /** @hidden */
  133525. _defineSphericalName: string;
  133526. /** @hidden */
  133527. _definePlanarName: string;
  133528. /** @hidden */
  133529. _defineEquirectangularName: string;
  133530. /** @hidden */
  133531. _defineMirroredEquirectangularFixedName: string;
  133532. /** @hidden */
  133533. _defineEquirectangularFixedName: string;
  133534. /** @hidden */
  133535. _defineSkyboxName: string;
  133536. /** @hidden */
  133537. _defineOppositeZ: string;
  133538. /** @hidden */
  133539. _cubeSamplerName: string;
  133540. /** @hidden */
  133541. _2DSamplerName: string;
  133542. protected _positionUVWName: string;
  133543. protected _directionWName: string;
  133544. protected _reflectionVectorName: string;
  133545. /** @hidden */
  133546. _reflectionCoordsName: string;
  133547. /** @hidden */
  133548. _reflectionMatrixName: string;
  133549. protected _reflectionColorName: string;
  133550. /**
  133551. * Gets or sets the texture associated with the node
  133552. */
  133553. texture: Nullable<BaseTexture>;
  133554. /**
  133555. * Create a new ReflectionTextureBaseBlock
  133556. * @param name defines the block name
  133557. */
  133558. constructor(name: string);
  133559. /**
  133560. * Gets the current class name
  133561. * @returns the class name
  133562. */
  133563. getClassName(): string;
  133564. /**
  133565. * Gets the world position input component
  133566. */
  133567. abstract get position(): NodeMaterialConnectionPoint;
  133568. /**
  133569. * Gets the world position input component
  133570. */
  133571. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133572. /**
  133573. * Gets the world normal input component
  133574. */
  133575. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133576. /**
  133577. * Gets the world input component
  133578. */
  133579. abstract get world(): NodeMaterialConnectionPoint;
  133580. /**
  133581. * Gets the camera (or eye) position component
  133582. */
  133583. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133584. /**
  133585. * Gets the view input component
  133586. */
  133587. abstract get view(): NodeMaterialConnectionPoint;
  133588. protected _getTexture(): Nullable<BaseTexture>;
  133589. autoConfigure(material: NodeMaterial): void;
  133590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133591. isReady(): boolean;
  133592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133593. /**
  133594. * Gets the code to inject in the vertex shader
  133595. * @param state current state of the node material building
  133596. * @returns the shader code
  133597. */
  133598. handleVertexSide(state: NodeMaterialBuildState): string;
  133599. /**
  133600. * Handles the inits for the fragment code path
  133601. * @param state node material build state
  133602. */
  133603. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133604. /**
  133605. * Generates the reflection coords code for the fragment code path
  133606. * @param worldNormalVarName name of the world normal variable
  133607. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133608. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133609. * @returns the shader code
  133610. */
  133611. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133612. /**
  133613. * Generates the reflection color code for the fragment code path
  133614. * @param lodVarName name of the lod variable
  133615. * @param swizzleLookupTexture swizzle to use for the final color variable
  133616. * @returns the shader code
  133617. */
  133618. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133619. /**
  133620. * Generates the code corresponding to the connected output points
  133621. * @param state node material build state
  133622. * @param varName name of the variable to output
  133623. * @returns the shader code
  133624. */
  133625. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133626. protected _buildBlock(state: NodeMaterialBuildState): this;
  133627. protected _dumpPropertiesCode(): string;
  133628. serialize(): any;
  133629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133630. }
  133631. }
  133632. declare module BABYLON {
  133633. /**
  133634. * Defines a connection point to be used for points with a custom object type
  133635. */
  133636. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133637. private _blockType;
  133638. private _blockName;
  133639. private _nameForCheking?;
  133640. /**
  133641. * Creates a new connection point
  133642. * @param name defines the connection point name
  133643. * @param ownerBlock defines the block hosting this connection point
  133644. * @param direction defines the direction of the connection point
  133645. */
  133646. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  133647. /**
  133648. * Gets a number indicating if the current point can be connected to another point
  133649. * @param connectionPoint defines the other connection point
  133650. * @returns a number defining the compatibility state
  133651. */
  133652. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133653. /**
  133654. * Creates a block suitable to be used as an input for this input point.
  133655. * If null is returned, a block based on the point type will be created.
  133656. * @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
  133657. */
  133658. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  133659. }
  133660. }
  133661. declare module BABYLON {
  133662. /**
  133663. * Enum defining the type of properties that can be edited in the property pages in the NME
  133664. */
  133665. export enum PropertyTypeForEdition {
  133666. /** property is a boolean */
  133667. Boolean = 0,
  133668. /** property is a float */
  133669. Float = 1,
  133670. /** property is a Vector2 */
  133671. Vector2 = 2,
  133672. /** property is a list of values */
  133673. List = 3
  133674. }
  133675. /**
  133676. * Interface that defines an option in a variable of type list
  133677. */
  133678. export interface IEditablePropertyListOption {
  133679. /** label of the option */
  133680. "label": string;
  133681. /** value of the option */
  133682. "value": number;
  133683. }
  133684. /**
  133685. * Interface that defines the options available for an editable property
  133686. */
  133687. export interface IEditablePropertyOption {
  133688. /** min value */
  133689. "min"?: number;
  133690. /** max value */
  133691. "max"?: number;
  133692. /** notifiers: indicates which actions to take when the property is changed */
  133693. "notifiers"?: {
  133694. /** the material should be rebuilt */
  133695. "rebuild"?: boolean;
  133696. /** the preview should be updated */
  133697. "update"?: boolean;
  133698. };
  133699. /** list of the options for a variable of type list */
  133700. "options"?: IEditablePropertyListOption[];
  133701. }
  133702. /**
  133703. * Interface that describes an editable property
  133704. */
  133705. export interface IPropertyDescriptionForEdition {
  133706. /** name of the property */
  133707. "propertyName": string;
  133708. /** display name of the property */
  133709. "displayName": string;
  133710. /** type of the property */
  133711. "type": PropertyTypeForEdition;
  133712. /** group of the property - all properties with the same group value will be displayed in a specific section */
  133713. "groupName": string;
  133714. /** options for the property */
  133715. "options": IEditablePropertyOption;
  133716. }
  133717. /**
  133718. * Decorator that flags a property in a node material block as being editable
  133719. */
  133720. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  133721. }
  133722. declare module BABYLON {
  133723. /**
  133724. * Block used to implement the refraction part of the sub surface module of the PBR material
  133725. */
  133726. export class RefractionBlock extends NodeMaterialBlock {
  133727. /** @hidden */
  133728. _define3DName: string;
  133729. /** @hidden */
  133730. _refractionMatrixName: string;
  133731. /** @hidden */
  133732. _defineLODRefractionAlpha: string;
  133733. /** @hidden */
  133734. _defineLinearSpecularRefraction: string;
  133735. /** @hidden */
  133736. _defineOppositeZ: string;
  133737. /** @hidden */
  133738. _cubeSamplerName: string;
  133739. /** @hidden */
  133740. _2DSamplerName: string;
  133741. /** @hidden */
  133742. _vRefractionMicrosurfaceInfosName: string;
  133743. /** @hidden */
  133744. _vRefractionInfosName: string;
  133745. private _scene;
  133746. /**
  133747. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133748. * Materials half opaque for instance using refraction could benefit from this control.
  133749. */
  133750. linkRefractionWithTransparency: boolean;
  133751. /**
  133752. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133753. */
  133754. invertRefractionY: boolean;
  133755. /**
  133756. * Gets or sets the texture associated with the node
  133757. */
  133758. texture: Nullable<BaseTexture>;
  133759. /**
  133760. * Create a new RefractionBlock
  133761. * @param name defines the block name
  133762. */
  133763. constructor(name: string);
  133764. /**
  133765. * Gets the current class name
  133766. * @returns the class name
  133767. */
  133768. getClassName(): string;
  133769. /**
  133770. * Gets the intensity input component
  133771. */
  133772. get intensity(): NodeMaterialConnectionPoint;
  133773. /**
  133774. * Gets the index of refraction input component
  133775. */
  133776. get indexOfRefraction(): NodeMaterialConnectionPoint;
  133777. /**
  133778. * Gets the tint at distance input component
  133779. */
  133780. get tintAtDistance(): NodeMaterialConnectionPoint;
  133781. /**
  133782. * Gets the view input component
  133783. */
  133784. get view(): NodeMaterialConnectionPoint;
  133785. /**
  133786. * Gets the refraction object output component
  133787. */
  133788. get refraction(): NodeMaterialConnectionPoint;
  133789. /**
  133790. * Returns true if the block has a texture
  133791. */
  133792. get hasTexture(): boolean;
  133793. protected _getTexture(): Nullable<BaseTexture>;
  133794. autoConfigure(material: NodeMaterial): void;
  133795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133796. isReady(): boolean;
  133797. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  133798. /**
  133799. * Gets the main code of the block (fragment side)
  133800. * @param state current state of the node material building
  133801. * @returns the shader code
  133802. */
  133803. getCode(state: NodeMaterialBuildState): string;
  133804. protected _buildBlock(state: NodeMaterialBuildState): this;
  133805. protected _dumpPropertiesCode(): string;
  133806. serialize(): any;
  133807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133808. }
  133809. }
  133810. declare module BABYLON {
  133811. /**
  133812. * Interface used to configure the node material editor
  133813. */
  133814. export interface INodeMaterialEditorOptions {
  133815. /** Define the URl to load node editor script */
  133816. editorURL?: string;
  133817. }
  133818. /** @hidden */
  133819. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  133820. NORMAL: boolean;
  133821. TANGENT: boolean;
  133822. UV1: boolean;
  133823. /** BONES */
  133824. NUM_BONE_INFLUENCERS: number;
  133825. BonesPerMesh: number;
  133826. BONETEXTURE: boolean;
  133827. /** MORPH TARGETS */
  133828. MORPHTARGETS: boolean;
  133829. MORPHTARGETS_NORMAL: boolean;
  133830. MORPHTARGETS_TANGENT: boolean;
  133831. MORPHTARGETS_UV: boolean;
  133832. NUM_MORPH_INFLUENCERS: number;
  133833. /** IMAGE PROCESSING */
  133834. IMAGEPROCESSING: boolean;
  133835. VIGNETTE: boolean;
  133836. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133837. VIGNETTEBLENDMODEOPAQUE: boolean;
  133838. TONEMAPPING: boolean;
  133839. TONEMAPPING_ACES: boolean;
  133840. CONTRAST: boolean;
  133841. EXPOSURE: boolean;
  133842. COLORCURVES: boolean;
  133843. COLORGRADING: boolean;
  133844. COLORGRADING3D: boolean;
  133845. SAMPLER3DGREENDEPTH: boolean;
  133846. SAMPLER3DBGRMAP: boolean;
  133847. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133848. /** MISC. */
  133849. BUMPDIRECTUV: number;
  133850. constructor();
  133851. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  133852. }
  133853. /**
  133854. * Class used to configure NodeMaterial
  133855. */
  133856. export interface INodeMaterialOptions {
  133857. /**
  133858. * Defines if blocks should emit comments
  133859. */
  133860. emitComments: boolean;
  133861. }
  133862. /**
  133863. * Class used to create a node based material built by assembling shader blocks
  133864. */
  133865. export class NodeMaterial extends PushMaterial {
  133866. private static _BuildIdGenerator;
  133867. private _options;
  133868. private _vertexCompilationState;
  133869. private _fragmentCompilationState;
  133870. private _sharedData;
  133871. private _buildId;
  133872. private _buildWasSuccessful;
  133873. private _cachedWorldViewMatrix;
  133874. private _cachedWorldViewProjectionMatrix;
  133875. private _optimizers;
  133876. private _animationFrame;
  133877. /** Define the Url to load node editor script */
  133878. static EditorURL: string;
  133879. /** Define the Url to load snippets */
  133880. static SnippetUrl: string;
  133881. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  133882. static IgnoreTexturesAtLoadTime: boolean;
  133883. private BJSNODEMATERIALEDITOR;
  133884. /** Get the inspector from bundle or global */
  133885. private _getGlobalNodeMaterialEditor;
  133886. /**
  133887. * Snippet ID if the material was created from the snippet server
  133888. */
  133889. snippetId: string;
  133890. /**
  133891. * Gets or sets data used by visual editor
  133892. * @see https://nme.babylonjs.com
  133893. */
  133894. editorData: any;
  133895. /**
  133896. * 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)
  133897. */
  133898. ignoreAlpha: boolean;
  133899. /**
  133900. * Defines the maximum number of lights that can be used in the material
  133901. */
  133902. maxSimultaneousLights: number;
  133903. /**
  133904. * Observable raised when the material is built
  133905. */
  133906. onBuildObservable: Observable<NodeMaterial>;
  133907. /**
  133908. * Gets or sets the root nodes of the material vertex shader
  133909. */
  133910. _vertexOutputNodes: NodeMaterialBlock[];
  133911. /**
  133912. * Gets or sets the root nodes of the material fragment (pixel) shader
  133913. */
  133914. _fragmentOutputNodes: NodeMaterialBlock[];
  133915. /** Gets or sets options to control the node material overall behavior */
  133916. get options(): INodeMaterialOptions;
  133917. set options(options: INodeMaterialOptions);
  133918. /**
  133919. * Default configuration related to image processing available in the standard Material.
  133920. */
  133921. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133922. /**
  133923. * Gets the image processing configuration used either in this material.
  133924. */
  133925. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133926. /**
  133927. * Sets the Default image processing configuration used either in the this material.
  133928. *
  133929. * If sets to null, the scene one is in use.
  133930. */
  133931. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133932. /**
  133933. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  133934. */
  133935. attachedBlocks: NodeMaterialBlock[];
  133936. /**
  133937. * Create a new node based material
  133938. * @param name defines the material name
  133939. * @param scene defines the hosting scene
  133940. * @param options defines creation option
  133941. */
  133942. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  133943. /**
  133944. * Gets the current class name of the material e.g. "NodeMaterial"
  133945. * @returns the class name
  133946. */
  133947. getClassName(): string;
  133948. /**
  133949. * Keep track of the image processing observer to allow dispose and replace.
  133950. */
  133951. private _imageProcessingObserver;
  133952. /**
  133953. * Attaches a new image processing configuration to the Standard Material.
  133954. * @param configuration
  133955. */
  133956. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133957. /**
  133958. * Get a block by its name
  133959. * @param name defines the name of the block to retrieve
  133960. * @returns the required block or null if not found
  133961. */
  133962. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  133963. /**
  133964. * Get a block by its name
  133965. * @param predicate defines the predicate used to find the good candidate
  133966. * @returns the required block or null if not found
  133967. */
  133968. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  133969. /**
  133970. * Get an input block by its name
  133971. * @param predicate defines the predicate used to find the good candidate
  133972. * @returns the required input block or null if not found
  133973. */
  133974. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  133975. /**
  133976. * Gets the list of input blocks attached to this material
  133977. * @returns an array of InputBlocks
  133978. */
  133979. getInputBlocks(): InputBlock[];
  133980. /**
  133981. * Adds a new optimizer to the list of optimizers
  133982. * @param optimizer defines the optimizers to add
  133983. * @returns the current material
  133984. */
  133985. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133986. /**
  133987. * Remove an optimizer from the list of optimizers
  133988. * @param optimizer defines the optimizers to remove
  133989. * @returns the current material
  133990. */
  133991. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133992. /**
  133993. * Add a new block to the list of output nodes
  133994. * @param node defines the node to add
  133995. * @returns the current material
  133996. */
  133997. addOutputNode(node: NodeMaterialBlock): this;
  133998. /**
  133999. * Remove a block from the list of root nodes
  134000. * @param node defines the node to remove
  134001. * @returns the current material
  134002. */
  134003. removeOutputNode(node: NodeMaterialBlock): this;
  134004. private _addVertexOutputNode;
  134005. private _removeVertexOutputNode;
  134006. private _addFragmentOutputNode;
  134007. private _removeFragmentOutputNode;
  134008. /**
  134009. * Specifies if the material will require alpha blending
  134010. * @returns a boolean specifying if alpha blending is needed
  134011. */
  134012. needAlphaBlending(): boolean;
  134013. /**
  134014. * Specifies if this material should be rendered in alpha test mode
  134015. * @returns a boolean specifying if an alpha test is needed.
  134016. */
  134017. needAlphaTesting(): boolean;
  134018. private _initializeBlock;
  134019. private _resetDualBlocks;
  134020. /**
  134021. * Remove a block from the current node material
  134022. * @param block defines the block to remove
  134023. */
  134024. removeBlock(block: NodeMaterialBlock): void;
  134025. /**
  134026. * Build the material and generates the inner effect
  134027. * @param verbose defines if the build should log activity
  134028. */
  134029. build(verbose?: boolean): void;
  134030. /**
  134031. * Runs an otpimization phase to try to improve the shader code
  134032. */
  134033. optimize(): void;
  134034. private _prepareDefinesForAttributes;
  134035. /**
  134036. * Get if the submesh is ready to be used and all its information available.
  134037. * Child classes can use it to update shaders
  134038. * @param mesh defines the mesh to check
  134039. * @param subMesh defines which submesh to check
  134040. * @param useInstances specifies that instances should be used
  134041. * @returns a boolean indicating that the submesh is ready or not
  134042. */
  134043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134044. /**
  134045. * Get a string representing the shaders built by the current node graph
  134046. */
  134047. get compiledShaders(): string;
  134048. /**
  134049. * Binds the world matrix to the material
  134050. * @param world defines the world transformation matrix
  134051. */
  134052. bindOnlyWorldMatrix(world: Matrix): void;
  134053. /**
  134054. * Binds the submesh to this material by preparing the effect and shader to draw
  134055. * @param world defines the world transformation matrix
  134056. * @param mesh defines the mesh containing the submesh
  134057. * @param subMesh defines the submesh to bind the material to
  134058. */
  134059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134060. /**
  134061. * Gets the active textures from the material
  134062. * @returns an array of textures
  134063. */
  134064. getActiveTextures(): BaseTexture[];
  134065. /**
  134066. * Gets the list of texture blocks
  134067. * @returns an array of texture blocks
  134068. */
  134069. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  134070. /**
  134071. * Specifies if the material uses a texture
  134072. * @param texture defines the texture to check against the material
  134073. * @returns a boolean specifying if the material uses the texture
  134074. */
  134075. hasTexture(texture: BaseTexture): boolean;
  134076. /**
  134077. * Disposes the material
  134078. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134079. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134080. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134081. */
  134082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134083. /** Creates the node editor window. */
  134084. private _createNodeEditor;
  134085. /**
  134086. * Launch the node material editor
  134087. * @param config Define the configuration of the editor
  134088. * @return a promise fulfilled when the node editor is visible
  134089. */
  134090. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134091. /**
  134092. * Clear the current material
  134093. */
  134094. clear(): void;
  134095. /**
  134096. * Clear the current material and set it to a default state
  134097. */
  134098. setToDefault(): void;
  134099. /**
  134100. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134101. * @param url defines the url to load from
  134102. * @returns a promise that will fullfil when the material is fully loaded
  134103. */
  134104. loadAsync(url: string): Promise<void>;
  134105. private _gatherBlocks;
  134106. /**
  134107. * Generate a string containing the code declaration required to create an equivalent of this material
  134108. * @returns a string
  134109. */
  134110. generateCode(): string;
  134111. /**
  134112. * Serializes this material in a JSON representation
  134113. * @returns the serialized material object
  134114. */
  134115. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134116. private _restoreConnections;
  134117. /**
  134118. * Clear the current graph and load a new one from a serialization object
  134119. * @param source defines the JSON representation of the material
  134120. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134121. */
  134122. loadFromSerialization(source: any, rootUrl?: string): void;
  134123. /**
  134124. * Makes a duplicate of the current material.
  134125. * @param name - name to use for the new material.
  134126. */
  134127. clone(name: string): NodeMaterial;
  134128. /**
  134129. * Creates a node material from parsed material data
  134130. * @param source defines the JSON representation of the material
  134131. * @param scene defines the hosting scene
  134132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134133. * @returns a new node material
  134134. */
  134135. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134136. /**
  134137. * Creates a node material from a snippet saved in a remote file
  134138. * @param name defines the name of the material to create
  134139. * @param url defines the url to load from
  134140. * @param scene defines the hosting scene
  134141. * @returns a promise that will resolve to the new node material
  134142. */
  134143. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134144. /**
  134145. * Creates a node material from a snippet saved by the node material editor
  134146. * @param snippetId defines the snippet to load
  134147. * @param scene defines the hosting scene
  134148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134149. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134150. * @returns a promise that will resolve to the new node material
  134151. */
  134152. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134153. /**
  134154. * Creates a new node material set to default basic configuration
  134155. * @param name defines the name of the material
  134156. * @param scene defines the hosting scene
  134157. * @returns a new NodeMaterial
  134158. */
  134159. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134160. }
  134161. }
  134162. declare module BABYLON {
  134163. /**
  134164. * Block used to read a texture from a sampler
  134165. */
  134166. export class TextureBlock extends NodeMaterialBlock {
  134167. private _defineName;
  134168. private _linearDefineName;
  134169. private _gammaDefineName;
  134170. private _tempTextureRead;
  134171. private _samplerName;
  134172. private _transformedUVName;
  134173. private _textureTransformName;
  134174. private _textureInfoName;
  134175. private _mainUVName;
  134176. private _mainUVDefineName;
  134177. /**
  134178. * Gets or sets the texture associated with the node
  134179. */
  134180. texture: Nullable<Texture>;
  134181. /**
  134182. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134183. */
  134184. convertToGammaSpace: boolean;
  134185. /**
  134186. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134187. */
  134188. convertToLinearSpace: boolean;
  134189. /**
  134190. * Create a new TextureBlock
  134191. * @param name defines the block name
  134192. */
  134193. constructor(name: string);
  134194. /**
  134195. * Gets the current class name
  134196. * @returns the class name
  134197. */
  134198. getClassName(): string;
  134199. /**
  134200. * Gets the uv input component
  134201. */
  134202. get uv(): NodeMaterialConnectionPoint;
  134203. /**
  134204. * Gets the rgba output component
  134205. */
  134206. get rgba(): NodeMaterialConnectionPoint;
  134207. /**
  134208. * Gets the rgb output component
  134209. */
  134210. get rgb(): NodeMaterialConnectionPoint;
  134211. /**
  134212. * Gets the r output component
  134213. */
  134214. get r(): NodeMaterialConnectionPoint;
  134215. /**
  134216. * Gets the g output component
  134217. */
  134218. get g(): NodeMaterialConnectionPoint;
  134219. /**
  134220. * Gets the b output component
  134221. */
  134222. get b(): NodeMaterialConnectionPoint;
  134223. /**
  134224. * Gets the a output component
  134225. */
  134226. get a(): NodeMaterialConnectionPoint;
  134227. get target(): NodeMaterialBlockTargets;
  134228. autoConfigure(material: NodeMaterial): void;
  134229. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134231. isReady(): boolean;
  134232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134233. private get _isMixed();
  134234. private _injectVertexCode;
  134235. private _writeTextureRead;
  134236. private _writeOutput;
  134237. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134238. protected _dumpPropertiesCode(): string;
  134239. serialize(): any;
  134240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134241. }
  134242. }
  134243. declare module BABYLON {
  134244. /**
  134245. * Class used to store shared data between 2 NodeMaterialBuildState
  134246. */
  134247. export class NodeMaterialBuildStateSharedData {
  134248. /**
  134249. * Gets the list of emitted varyings
  134250. */
  134251. temps: string[];
  134252. /**
  134253. * Gets the list of emitted varyings
  134254. */
  134255. varyings: string[];
  134256. /**
  134257. * Gets the varying declaration string
  134258. */
  134259. varyingDeclaration: string;
  134260. /**
  134261. * Input blocks
  134262. */
  134263. inputBlocks: InputBlock[];
  134264. /**
  134265. * Input blocks
  134266. */
  134267. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  134268. /**
  134269. * Bindable blocks (Blocks that need to set data to the effect)
  134270. */
  134271. bindableBlocks: NodeMaterialBlock[];
  134272. /**
  134273. * List of blocks that can provide a compilation fallback
  134274. */
  134275. blocksWithFallbacks: NodeMaterialBlock[];
  134276. /**
  134277. * List of blocks that can provide a define update
  134278. */
  134279. blocksWithDefines: NodeMaterialBlock[];
  134280. /**
  134281. * List of blocks that can provide a repeatable content
  134282. */
  134283. repeatableContentBlocks: NodeMaterialBlock[];
  134284. /**
  134285. * List of blocks that can provide a dynamic list of uniforms
  134286. */
  134287. dynamicUniformBlocks: NodeMaterialBlock[];
  134288. /**
  134289. * List of blocks that can block the isReady function for the material
  134290. */
  134291. blockingBlocks: NodeMaterialBlock[];
  134292. /**
  134293. * Gets the list of animated inputs
  134294. */
  134295. animatedInputs: InputBlock[];
  134296. /**
  134297. * Build Id used to avoid multiple recompilations
  134298. */
  134299. buildId: number;
  134300. /** List of emitted variables */
  134301. variableNames: {
  134302. [key: string]: number;
  134303. };
  134304. /** List of emitted defines */
  134305. defineNames: {
  134306. [key: string]: number;
  134307. };
  134308. /** Should emit comments? */
  134309. emitComments: boolean;
  134310. /** Emit build activity */
  134311. verbose: boolean;
  134312. /** Gets or sets the hosting scene */
  134313. scene: Scene;
  134314. /**
  134315. * Gets the compilation hints emitted at compilation time
  134316. */
  134317. hints: {
  134318. needWorldViewMatrix: boolean;
  134319. needWorldViewProjectionMatrix: boolean;
  134320. needAlphaBlending: boolean;
  134321. needAlphaTesting: boolean;
  134322. };
  134323. /**
  134324. * List of compilation checks
  134325. */
  134326. checks: {
  134327. emitVertex: boolean;
  134328. emitFragment: boolean;
  134329. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134330. };
  134331. /** Creates a new shared data */
  134332. constructor();
  134333. /**
  134334. * Emits console errors and exceptions if there is a failing check
  134335. */
  134336. emitErrors(): void;
  134337. }
  134338. }
  134339. declare module BABYLON {
  134340. /**
  134341. * Class used to store node based material build state
  134342. */
  134343. export class NodeMaterialBuildState {
  134344. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134345. supportUniformBuffers: boolean;
  134346. /**
  134347. * Gets the list of emitted attributes
  134348. */
  134349. attributes: string[];
  134350. /**
  134351. * Gets the list of emitted uniforms
  134352. */
  134353. uniforms: string[];
  134354. /**
  134355. * Gets the list of emitted constants
  134356. */
  134357. constants: string[];
  134358. /**
  134359. * Gets the list of emitted samplers
  134360. */
  134361. samplers: string[];
  134362. /**
  134363. * Gets the list of emitted functions
  134364. */
  134365. functions: {
  134366. [key: string]: string;
  134367. };
  134368. /**
  134369. * Gets the list of emitted extensions
  134370. */
  134371. extensions: {
  134372. [key: string]: string;
  134373. };
  134374. /**
  134375. * Gets the target of the compilation state
  134376. */
  134377. target: NodeMaterialBlockTargets;
  134378. /**
  134379. * Gets the list of emitted counters
  134380. */
  134381. counters: {
  134382. [key: string]: number;
  134383. };
  134384. /**
  134385. * Shared data between multiple NodeMaterialBuildState instances
  134386. */
  134387. sharedData: NodeMaterialBuildStateSharedData;
  134388. /** @hidden */
  134389. _vertexState: NodeMaterialBuildState;
  134390. /** @hidden */
  134391. _attributeDeclaration: string;
  134392. /** @hidden */
  134393. _uniformDeclaration: string;
  134394. /** @hidden */
  134395. _constantDeclaration: string;
  134396. /** @hidden */
  134397. _samplerDeclaration: string;
  134398. /** @hidden */
  134399. _varyingTransfer: string;
  134400. /** @hidden */
  134401. _injectAtEnd: string;
  134402. private _repeatableContentAnchorIndex;
  134403. /** @hidden */
  134404. _builtCompilationString: string;
  134405. /**
  134406. * Gets the emitted compilation strings
  134407. */
  134408. compilationString: string;
  134409. /**
  134410. * Finalize the compilation strings
  134411. * @param state defines the current compilation state
  134412. */
  134413. finalize(state: NodeMaterialBuildState): void;
  134414. /** @hidden */
  134415. get _repeatableContentAnchor(): string;
  134416. /** @hidden */
  134417. _getFreeVariableName(prefix: string): string;
  134418. /** @hidden */
  134419. _getFreeDefineName(prefix: string): string;
  134420. /** @hidden */
  134421. _excludeVariableName(name: string): void;
  134422. /** @hidden */
  134423. _emit2DSampler(name: string): void;
  134424. /** @hidden */
  134425. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  134426. /** @hidden */
  134427. _emitExtension(name: string, extension: string, define?: string): void;
  134428. /** @hidden */
  134429. _emitFunction(name: string, code: string, comments: string): void;
  134430. /** @hidden */
  134431. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  134432. replaceStrings?: {
  134433. search: RegExp;
  134434. replace: string;
  134435. }[];
  134436. repeatKey?: string;
  134437. }): string;
  134438. /** @hidden */
  134439. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  134440. repeatKey?: string;
  134441. removeAttributes?: boolean;
  134442. removeUniforms?: boolean;
  134443. removeVaryings?: boolean;
  134444. removeIfDef?: boolean;
  134445. replaceStrings?: {
  134446. search: RegExp;
  134447. replace: string;
  134448. }[];
  134449. }, storeKey?: string): void;
  134450. /** @hidden */
  134451. _registerTempVariable(name: string): boolean;
  134452. /** @hidden */
  134453. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  134454. /** @hidden */
  134455. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  134456. /** @hidden */
  134457. _emitFloat(value: number): string;
  134458. }
  134459. }
  134460. declare module BABYLON {
  134461. /**
  134462. * Defines a block that can be used inside a node based material
  134463. */
  134464. export class NodeMaterialBlock {
  134465. private _buildId;
  134466. private _buildTarget;
  134467. private _target;
  134468. private _isFinalMerger;
  134469. private _isInput;
  134470. protected _isUnique: boolean;
  134471. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  134472. inputsAreExclusive: boolean;
  134473. /** @hidden */
  134474. _codeVariableName: string;
  134475. /** @hidden */
  134476. _inputs: NodeMaterialConnectionPoint[];
  134477. /** @hidden */
  134478. _outputs: NodeMaterialConnectionPoint[];
  134479. /** @hidden */
  134480. _preparationId: number;
  134481. /**
  134482. * Gets or sets the name of the block
  134483. */
  134484. name: string;
  134485. /**
  134486. * Gets or sets the unique id of the node
  134487. */
  134488. uniqueId: number;
  134489. /**
  134490. * Gets or sets the comments associated with this block
  134491. */
  134492. comments: string;
  134493. /**
  134494. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  134495. */
  134496. get isUnique(): boolean;
  134497. /**
  134498. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  134499. */
  134500. get isFinalMerger(): boolean;
  134501. /**
  134502. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  134503. */
  134504. get isInput(): boolean;
  134505. /**
  134506. * Gets or sets the build Id
  134507. */
  134508. get buildId(): number;
  134509. set buildId(value: number);
  134510. /**
  134511. * Gets or sets the target of the block
  134512. */
  134513. get target(): NodeMaterialBlockTargets;
  134514. set target(value: NodeMaterialBlockTargets);
  134515. /**
  134516. * Gets the list of input points
  134517. */
  134518. get inputs(): NodeMaterialConnectionPoint[];
  134519. /** Gets the list of output points */
  134520. get outputs(): NodeMaterialConnectionPoint[];
  134521. /**
  134522. * Find an input by its name
  134523. * @param name defines the name of the input to look for
  134524. * @returns the input or null if not found
  134525. */
  134526. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  134527. /**
  134528. * Find an output by its name
  134529. * @param name defines the name of the outputto look for
  134530. * @returns the output or null if not found
  134531. */
  134532. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  134533. /**
  134534. * Creates a new NodeMaterialBlock
  134535. * @param name defines the block name
  134536. * @param target defines the target of that block (Vertex by default)
  134537. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  134538. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  134539. */
  134540. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  134541. /**
  134542. * Initialize the block and prepare the context for build
  134543. * @param state defines the state that will be used for the build
  134544. */
  134545. initialize(state: NodeMaterialBuildState): void;
  134546. /**
  134547. * Bind data to effect. Will only be called for blocks with isBindable === true
  134548. * @param effect defines the effect to bind data to
  134549. * @param nodeMaterial defines the hosting NodeMaterial
  134550. * @param mesh defines the mesh that will be rendered
  134551. * @param subMesh defines the submesh that will be rendered
  134552. */
  134553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134554. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  134555. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  134556. protected _writeFloat(value: number): string;
  134557. /**
  134558. * Gets the current class name e.g. "NodeMaterialBlock"
  134559. * @returns the class name
  134560. */
  134561. getClassName(): string;
  134562. /**
  134563. * Register a new input. Must be called inside a block constructor
  134564. * @param name defines the connection point name
  134565. * @param type defines the connection point type
  134566. * @param isOptional defines a boolean indicating that this input can be omitted
  134567. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  134568. * @param point an already created connection point. If not provided, create a new one
  134569. * @returns the current block
  134570. */
  134571. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  134572. /**
  134573. * Register a new output. Must be called inside a block constructor
  134574. * @param name defines the connection point name
  134575. * @param type defines the connection point type
  134576. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  134577. * @param point an already created connection point. If not provided, create a new one
  134578. * @returns the current block
  134579. */
  134580. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  134581. /**
  134582. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  134583. * @param forOutput defines an optional connection point to check compatibility with
  134584. * @returns the first available input or null
  134585. */
  134586. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  134587. /**
  134588. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  134589. * @param forBlock defines an optional block to check compatibility with
  134590. * @returns the first available input or null
  134591. */
  134592. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  134593. /**
  134594. * Gets the sibling of the given output
  134595. * @param current defines the current output
  134596. * @returns the next output in the list or null
  134597. */
  134598. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  134599. /**
  134600. * Connect current block with another block
  134601. * @param other defines the block to connect with
  134602. * @param options define the various options to help pick the right connections
  134603. * @returns the current block
  134604. */
  134605. connectTo(other: NodeMaterialBlock, options?: {
  134606. input?: string;
  134607. output?: string;
  134608. outputSwizzle?: string;
  134609. }): this | undefined;
  134610. protected _buildBlock(state: NodeMaterialBuildState): void;
  134611. /**
  134612. * Add uniforms, samplers and uniform buffers at compilation time
  134613. * @param state defines the state to update
  134614. * @param nodeMaterial defines the node material requesting the update
  134615. * @param defines defines the material defines to update
  134616. * @param uniformBuffers defines the list of uniform buffer names
  134617. */
  134618. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  134619. /**
  134620. * Add potential fallbacks if shader compilation fails
  134621. * @param mesh defines the mesh to be rendered
  134622. * @param fallbacks defines the current prioritized list of fallbacks
  134623. */
  134624. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  134625. /**
  134626. * Initialize defines for shader compilation
  134627. * @param mesh defines the mesh to be rendered
  134628. * @param nodeMaterial defines the node material requesting the update
  134629. * @param defines defines the material defines to update
  134630. * @param useInstances specifies that instances should be used
  134631. */
  134632. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134633. /**
  134634. * Update defines for shader compilation
  134635. * @param mesh defines the mesh to be rendered
  134636. * @param nodeMaterial defines the node material requesting the update
  134637. * @param defines defines the material defines to update
  134638. * @param useInstances specifies that instances should be used
  134639. */
  134640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134641. /**
  134642. * Lets the block try to connect some inputs automatically
  134643. * @param material defines the hosting NodeMaterial
  134644. */
  134645. autoConfigure(material: NodeMaterial): void;
  134646. /**
  134647. * Function called when a block is declared as repeatable content generator
  134648. * @param vertexShaderState defines the current compilation state for the vertex shader
  134649. * @param fragmentShaderState defines the current compilation state for the fragment shader
  134650. * @param mesh defines the mesh to be rendered
  134651. * @param defines defines the material defines to update
  134652. */
  134653. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  134654. /**
  134655. * Checks if the block is ready
  134656. * @param mesh defines the mesh to be rendered
  134657. * @param nodeMaterial defines the node material requesting the update
  134658. * @param defines defines the material defines to update
  134659. * @param useInstances specifies that instances should be used
  134660. * @returns true if the block is ready
  134661. */
  134662. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  134663. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  134664. private _processBuild;
  134665. /**
  134666. * Compile the current node and generate the shader code
  134667. * @param state defines the current compilation state (uniforms, samplers, current string)
  134668. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  134669. * @returns true if already built
  134670. */
  134671. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  134672. protected _inputRename(name: string): string;
  134673. protected _outputRename(name: string): string;
  134674. protected _dumpPropertiesCode(): string;
  134675. /** @hidden */
  134676. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  134677. /** @hidden */
  134678. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  134679. /**
  134680. * Clone the current block to a new identical block
  134681. * @param scene defines the hosting scene
  134682. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134683. * @returns a copy of the current block
  134684. */
  134685. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  134686. /**
  134687. * Serializes this block in a JSON representation
  134688. * @returns the serialized block object
  134689. */
  134690. serialize(): any;
  134691. /** @hidden */
  134692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134693. private _deserializePortDisplayNames;
  134694. /**
  134695. * Release resources
  134696. */
  134697. dispose(): void;
  134698. }
  134699. }
  134700. declare module BABYLON {
  134701. /**
  134702. * Enum defining the type of animations supported by InputBlock
  134703. */
  134704. export enum AnimatedInputBlockTypes {
  134705. /** No animation */
  134706. None = 0,
  134707. /** Time based animation. Will only work for floats */
  134708. Time = 1
  134709. }
  134710. }
  134711. declare module BABYLON {
  134712. /**
  134713. * Block used to expose an input value
  134714. */
  134715. export class InputBlock extends NodeMaterialBlock {
  134716. private _mode;
  134717. private _associatedVariableName;
  134718. private _storedValue;
  134719. private _valueCallback;
  134720. private _type;
  134721. private _animationType;
  134722. /** Gets or set a value used to limit the range of float values */
  134723. min: number;
  134724. /** Gets or set a value used to limit the range of float values */
  134725. max: number;
  134726. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  134727. isBoolean: boolean;
  134728. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  134729. matrixMode: number;
  134730. /** @hidden */
  134731. _systemValue: Nullable<NodeMaterialSystemValues>;
  134732. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  134733. visibleInInspector: boolean;
  134734. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  134735. isConstant: boolean;
  134736. /** Gets or sets the group to use to display this block in the Inspector */
  134737. groupInInspector: string;
  134738. /** Gets an observable raised when the value is changed */
  134739. onValueChangedObservable: Observable<InputBlock>;
  134740. /**
  134741. * Gets or sets the connection point type (default is float)
  134742. */
  134743. get type(): NodeMaterialBlockConnectionPointTypes;
  134744. /**
  134745. * Creates a new InputBlock
  134746. * @param name defines the block name
  134747. * @param target defines the target of that block (Vertex by default)
  134748. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  134749. */
  134750. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  134751. /**
  134752. * Gets the output component
  134753. */
  134754. get output(): NodeMaterialConnectionPoint;
  134755. /**
  134756. * Set the source of this connection point to a vertex attribute
  134757. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  134758. * @returns the current connection point
  134759. */
  134760. setAsAttribute(attributeName?: string): InputBlock;
  134761. /**
  134762. * Set the source of this connection point to a system value
  134763. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  134764. * @returns the current connection point
  134765. */
  134766. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  134767. /**
  134768. * Gets or sets the value of that point.
  134769. * Please note that this value will be ignored if valueCallback is defined
  134770. */
  134771. get value(): any;
  134772. set value(value: any);
  134773. /**
  134774. * Gets or sets a callback used to get the value of that point.
  134775. * Please note that setting this value will force the connection point to ignore the value property
  134776. */
  134777. get valueCallback(): () => any;
  134778. set valueCallback(value: () => any);
  134779. /**
  134780. * Gets or sets the associated variable name in the shader
  134781. */
  134782. get associatedVariableName(): string;
  134783. set associatedVariableName(value: string);
  134784. /** Gets or sets the type of animation applied to the input */
  134785. get animationType(): AnimatedInputBlockTypes;
  134786. set animationType(value: AnimatedInputBlockTypes);
  134787. /**
  134788. * Gets a boolean indicating that this connection point not defined yet
  134789. */
  134790. get isUndefined(): boolean;
  134791. /**
  134792. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  134793. * In this case the connection point name must be the name of the uniform to use.
  134794. * Can only be set on inputs
  134795. */
  134796. get isUniform(): boolean;
  134797. set isUniform(value: boolean);
  134798. /**
  134799. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  134800. * In this case the connection point name must be the name of the attribute to use
  134801. * Can only be set on inputs
  134802. */
  134803. get isAttribute(): boolean;
  134804. set isAttribute(value: boolean);
  134805. /**
  134806. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  134807. * Can only be set on exit points
  134808. */
  134809. get isVarying(): boolean;
  134810. set isVarying(value: boolean);
  134811. /**
  134812. * Gets a boolean indicating that the current connection point is a system value
  134813. */
  134814. get isSystemValue(): boolean;
  134815. /**
  134816. * Gets or sets the current well known value or null if not defined as a system value
  134817. */
  134818. get systemValue(): Nullable<NodeMaterialSystemValues>;
  134819. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  134820. /**
  134821. * Gets the current class name
  134822. * @returns the class name
  134823. */
  134824. getClassName(): string;
  134825. /**
  134826. * Animate the input if animationType !== None
  134827. * @param scene defines the rendering scene
  134828. */
  134829. animate(scene: Scene): void;
  134830. private _emitDefine;
  134831. initialize(state: NodeMaterialBuildState): void;
  134832. /**
  134833. * Set the input block to its default value (based on its type)
  134834. */
  134835. setDefaultValue(): void;
  134836. private _emitConstant;
  134837. private _emit;
  134838. /** @hidden */
  134839. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  134840. /** @hidden */
  134841. _transmit(effect: Effect, scene: Scene): void;
  134842. protected _buildBlock(state: NodeMaterialBuildState): void;
  134843. protected _dumpPropertiesCode(): string;
  134844. dispose(): void;
  134845. serialize(): any;
  134846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134847. }
  134848. }
  134849. declare module BABYLON {
  134850. /**
  134851. * Enum used to define the compatibility state between two connection points
  134852. */
  134853. export enum NodeMaterialConnectionPointCompatibilityStates {
  134854. /** Points are compatibles */
  134855. Compatible = 0,
  134856. /** Points are incompatible because of their types */
  134857. TypeIncompatible = 1,
  134858. /** Points are incompatible because of their targets (vertex vs fragment) */
  134859. TargetIncompatible = 2
  134860. }
  134861. /**
  134862. * Defines the direction of a connection point
  134863. */
  134864. export enum NodeMaterialConnectionPointDirection {
  134865. /** Input */
  134866. Input = 0,
  134867. /** Output */
  134868. Output = 1
  134869. }
  134870. /**
  134871. * Defines a connection point for a block
  134872. */
  134873. export class NodeMaterialConnectionPoint {
  134874. /** @hidden */
  134875. _ownerBlock: NodeMaterialBlock;
  134876. /** @hidden */
  134877. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  134878. private _endpoints;
  134879. private _associatedVariableName;
  134880. private _direction;
  134881. /** @hidden */
  134882. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134883. /** @hidden */
  134884. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134885. private _type;
  134886. /** @hidden */
  134887. _enforceAssociatedVariableName: boolean;
  134888. /** Gets the direction of the point */
  134889. get direction(): NodeMaterialConnectionPointDirection;
  134890. /** Indicates that this connection point needs dual validation before being connected to another point */
  134891. needDualDirectionValidation: boolean;
  134892. /**
  134893. * Gets or sets the additional types supported by this connection point
  134894. */
  134895. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134896. /**
  134897. * Gets or sets the additional types excluded by this connection point
  134898. */
  134899. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134900. /**
  134901. * Observable triggered when this point is connected
  134902. */
  134903. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  134904. /**
  134905. * Gets or sets the associated variable name in the shader
  134906. */
  134907. get associatedVariableName(): string;
  134908. set associatedVariableName(value: string);
  134909. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  134910. get innerType(): NodeMaterialBlockConnectionPointTypes;
  134911. /**
  134912. * Gets or sets the connection point type (default is float)
  134913. */
  134914. get type(): NodeMaterialBlockConnectionPointTypes;
  134915. set type(value: NodeMaterialBlockConnectionPointTypes);
  134916. /**
  134917. * Gets or sets the connection point name
  134918. */
  134919. name: string;
  134920. /**
  134921. * Gets or sets the connection point name
  134922. */
  134923. displayName: string;
  134924. /**
  134925. * Gets or sets a boolean indicating that this connection point can be omitted
  134926. */
  134927. isOptional: boolean;
  134928. /**
  134929. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  134930. */
  134931. define: string;
  134932. /** @hidden */
  134933. _prioritizeVertex: boolean;
  134934. private _target;
  134935. /** Gets or sets the target of that connection point */
  134936. get target(): NodeMaterialBlockTargets;
  134937. set target(value: NodeMaterialBlockTargets);
  134938. /**
  134939. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  134940. */
  134941. get isConnected(): boolean;
  134942. /**
  134943. * Gets a boolean indicating that the current point is connected to an input block
  134944. */
  134945. get isConnectedToInputBlock(): boolean;
  134946. /**
  134947. * Gets a the connected input block (if any)
  134948. */
  134949. get connectInputBlock(): Nullable<InputBlock>;
  134950. /** Get the other side of the connection (if any) */
  134951. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  134952. /** Get the block that owns this connection point */
  134953. get ownerBlock(): NodeMaterialBlock;
  134954. /** Get the block connected on the other side of this connection (if any) */
  134955. get sourceBlock(): Nullable<NodeMaterialBlock>;
  134956. /** Get the block connected on the endpoints of this connection (if any) */
  134957. get connectedBlocks(): Array<NodeMaterialBlock>;
  134958. /** Gets the list of connected endpoints */
  134959. get endpoints(): NodeMaterialConnectionPoint[];
  134960. /** Gets a boolean indicating if that output point is connected to at least one input */
  134961. get hasEndpoints(): boolean;
  134962. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  134963. get isConnectedInVertexShader(): boolean;
  134964. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  134965. get isConnectedInFragmentShader(): boolean;
  134966. /**
  134967. * Creates a block suitable to be used as an input for this input point.
  134968. * If null is returned, a block based on the point type will be created.
  134969. * @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
  134970. */
  134971. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  134972. /**
  134973. * Creates a new connection point
  134974. * @param name defines the connection point name
  134975. * @param ownerBlock defines the block hosting this connection point
  134976. * @param direction defines the direction of the connection point
  134977. */
  134978. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  134979. /**
  134980. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  134981. * @returns the class name
  134982. */
  134983. getClassName(): string;
  134984. /**
  134985. * Gets a boolean indicating if the current point can be connected to another point
  134986. * @param connectionPoint defines the other connection point
  134987. * @returns a boolean
  134988. */
  134989. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  134990. /**
  134991. * Gets a number indicating if the current point can be connected to another point
  134992. * @param connectionPoint defines the other connection point
  134993. * @returns a number defining the compatibility state
  134994. */
  134995. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  134996. /**
  134997. * Connect this point to another connection point
  134998. * @param connectionPoint defines the other connection point
  134999. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  135000. * @returns the current connection point
  135001. */
  135002. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  135003. /**
  135004. * Disconnect this point from one of his endpoint
  135005. * @param endpoint defines the other connection point
  135006. * @returns the current connection point
  135007. */
  135008. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135009. /**
  135010. * Serializes this point in a JSON representation
  135011. * @param isInput defines if the connection point is an input (default is true)
  135012. * @returns the serialized point object
  135013. */
  135014. serialize(isInput?: boolean): any;
  135015. /**
  135016. * Release resources
  135017. */
  135018. dispose(): void;
  135019. }
  135020. }
  135021. declare module BABYLON {
  135022. /**
  135023. * Block used to add support for vertex skinning (bones)
  135024. */
  135025. export class BonesBlock extends NodeMaterialBlock {
  135026. /**
  135027. * Creates a new BonesBlock
  135028. * @param name defines the block name
  135029. */
  135030. constructor(name: string);
  135031. /**
  135032. * Initialize the block and prepare the context for build
  135033. * @param state defines the state that will be used for the build
  135034. */
  135035. initialize(state: NodeMaterialBuildState): void;
  135036. /**
  135037. * Gets the current class name
  135038. * @returns the class name
  135039. */
  135040. getClassName(): string;
  135041. /**
  135042. * Gets the matrix indices input component
  135043. */
  135044. get matricesIndices(): NodeMaterialConnectionPoint;
  135045. /**
  135046. * Gets the matrix weights input component
  135047. */
  135048. get matricesWeights(): NodeMaterialConnectionPoint;
  135049. /**
  135050. * Gets the extra matrix indices input component
  135051. */
  135052. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135053. /**
  135054. * Gets the extra matrix weights input component
  135055. */
  135056. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135057. /**
  135058. * Gets the world input component
  135059. */
  135060. get world(): NodeMaterialConnectionPoint;
  135061. /**
  135062. * Gets the output component
  135063. */
  135064. get output(): NodeMaterialConnectionPoint;
  135065. autoConfigure(material: NodeMaterial): void;
  135066. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135069. protected _buildBlock(state: NodeMaterialBuildState): this;
  135070. }
  135071. }
  135072. declare module BABYLON {
  135073. /**
  135074. * Block used to add support for instances
  135075. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135076. */
  135077. export class InstancesBlock extends NodeMaterialBlock {
  135078. /**
  135079. * Creates a new InstancesBlock
  135080. * @param name defines the block name
  135081. */
  135082. constructor(name: string);
  135083. /**
  135084. * Gets the current class name
  135085. * @returns the class name
  135086. */
  135087. getClassName(): string;
  135088. /**
  135089. * Gets the first world row input component
  135090. */
  135091. get world0(): NodeMaterialConnectionPoint;
  135092. /**
  135093. * Gets the second world row input component
  135094. */
  135095. get world1(): NodeMaterialConnectionPoint;
  135096. /**
  135097. * Gets the third world row input component
  135098. */
  135099. get world2(): NodeMaterialConnectionPoint;
  135100. /**
  135101. * Gets the forth world row input component
  135102. */
  135103. get world3(): NodeMaterialConnectionPoint;
  135104. /**
  135105. * Gets the world input component
  135106. */
  135107. get world(): NodeMaterialConnectionPoint;
  135108. /**
  135109. * Gets the output component
  135110. */
  135111. get output(): NodeMaterialConnectionPoint;
  135112. /**
  135113. * Gets the isntanceID component
  135114. */
  135115. get instanceID(): NodeMaterialConnectionPoint;
  135116. autoConfigure(material: NodeMaterial): void;
  135117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135118. protected _buildBlock(state: NodeMaterialBuildState): this;
  135119. }
  135120. }
  135121. declare module BABYLON {
  135122. /**
  135123. * Block used to add morph targets support to vertex shader
  135124. */
  135125. export class MorphTargetsBlock extends NodeMaterialBlock {
  135126. private _repeatableContentAnchor;
  135127. /**
  135128. * Create a new MorphTargetsBlock
  135129. * @param name defines the block name
  135130. */
  135131. constructor(name: string);
  135132. /**
  135133. * Gets the current class name
  135134. * @returns the class name
  135135. */
  135136. getClassName(): string;
  135137. /**
  135138. * Gets the position input component
  135139. */
  135140. get position(): NodeMaterialConnectionPoint;
  135141. /**
  135142. * Gets the normal input component
  135143. */
  135144. get normal(): NodeMaterialConnectionPoint;
  135145. /**
  135146. * Gets the tangent input component
  135147. */
  135148. get tangent(): NodeMaterialConnectionPoint;
  135149. /**
  135150. * Gets the tangent input component
  135151. */
  135152. get uv(): NodeMaterialConnectionPoint;
  135153. /**
  135154. * Gets the position output component
  135155. */
  135156. get positionOutput(): NodeMaterialConnectionPoint;
  135157. /**
  135158. * Gets the normal output component
  135159. */
  135160. get normalOutput(): NodeMaterialConnectionPoint;
  135161. /**
  135162. * Gets the tangent output component
  135163. */
  135164. get tangentOutput(): NodeMaterialConnectionPoint;
  135165. /**
  135166. * Gets the tangent output component
  135167. */
  135168. get uvOutput(): NodeMaterialConnectionPoint;
  135169. initialize(state: NodeMaterialBuildState): void;
  135170. autoConfigure(material: NodeMaterial): void;
  135171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135173. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135174. protected _buildBlock(state: NodeMaterialBuildState): this;
  135175. }
  135176. }
  135177. declare module BABYLON {
  135178. /**
  135179. * Block used to get data information from a light
  135180. */
  135181. export class LightInformationBlock extends NodeMaterialBlock {
  135182. private _lightDataUniformName;
  135183. private _lightColorUniformName;
  135184. private _lightTypeDefineName;
  135185. /**
  135186. * Gets or sets the light associated with this block
  135187. */
  135188. light: Nullable<Light>;
  135189. /**
  135190. * Creates a new LightInformationBlock
  135191. * @param name defines the block name
  135192. */
  135193. constructor(name: string);
  135194. /**
  135195. * Gets the current class name
  135196. * @returns the class name
  135197. */
  135198. getClassName(): string;
  135199. /**
  135200. * Gets the world position input component
  135201. */
  135202. get worldPosition(): NodeMaterialConnectionPoint;
  135203. /**
  135204. * Gets the direction output component
  135205. */
  135206. get direction(): NodeMaterialConnectionPoint;
  135207. /**
  135208. * Gets the direction output component
  135209. */
  135210. get color(): NodeMaterialConnectionPoint;
  135211. /**
  135212. * Gets the direction output component
  135213. */
  135214. get intensity(): NodeMaterialConnectionPoint;
  135215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135217. protected _buildBlock(state: NodeMaterialBuildState): this;
  135218. serialize(): any;
  135219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135220. }
  135221. }
  135222. declare module BABYLON {
  135223. /**
  135224. * Block used to add image processing support to fragment shader
  135225. */
  135226. export class ImageProcessingBlock extends NodeMaterialBlock {
  135227. /**
  135228. * Create a new ImageProcessingBlock
  135229. * @param name defines the block name
  135230. */
  135231. constructor(name: string);
  135232. /**
  135233. * Gets the current class name
  135234. * @returns the class name
  135235. */
  135236. getClassName(): string;
  135237. /**
  135238. * Gets the color input component
  135239. */
  135240. get color(): NodeMaterialConnectionPoint;
  135241. /**
  135242. * Gets the output component
  135243. */
  135244. get output(): NodeMaterialConnectionPoint;
  135245. /**
  135246. * Initialize the block and prepare the context for build
  135247. * @param state defines the state that will be used for the build
  135248. */
  135249. initialize(state: NodeMaterialBuildState): void;
  135250. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135252. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135253. protected _buildBlock(state: NodeMaterialBuildState): this;
  135254. }
  135255. }
  135256. declare module BABYLON {
  135257. /**
  135258. * Block used to pertub normals based on a normal map
  135259. */
  135260. export class PerturbNormalBlock extends NodeMaterialBlock {
  135261. private _tangentSpaceParameterName;
  135262. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135263. invertX: boolean;
  135264. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135265. invertY: boolean;
  135266. /**
  135267. * Create a new PerturbNormalBlock
  135268. * @param name defines the block name
  135269. */
  135270. constructor(name: string);
  135271. /**
  135272. * Gets the current class name
  135273. * @returns the class name
  135274. */
  135275. getClassName(): string;
  135276. /**
  135277. * Gets the world position input component
  135278. */
  135279. get worldPosition(): NodeMaterialConnectionPoint;
  135280. /**
  135281. * Gets the world normal input component
  135282. */
  135283. get worldNormal(): NodeMaterialConnectionPoint;
  135284. /**
  135285. * Gets the world tangent input component
  135286. */
  135287. get worldTangent(): NodeMaterialConnectionPoint;
  135288. /**
  135289. * Gets the uv input component
  135290. */
  135291. get uv(): NodeMaterialConnectionPoint;
  135292. /**
  135293. * Gets the normal map color input component
  135294. */
  135295. get normalMapColor(): NodeMaterialConnectionPoint;
  135296. /**
  135297. * Gets the strength input component
  135298. */
  135299. get strength(): NodeMaterialConnectionPoint;
  135300. /**
  135301. * Gets the output component
  135302. */
  135303. get output(): NodeMaterialConnectionPoint;
  135304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135305. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135306. autoConfigure(material: NodeMaterial): void;
  135307. protected _buildBlock(state: NodeMaterialBuildState): this;
  135308. protected _dumpPropertiesCode(): string;
  135309. serialize(): any;
  135310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135311. }
  135312. }
  135313. declare module BABYLON {
  135314. /**
  135315. * Block used to discard a pixel if a value is smaller than a cutoff
  135316. */
  135317. export class DiscardBlock extends NodeMaterialBlock {
  135318. /**
  135319. * Create a new DiscardBlock
  135320. * @param name defines the block name
  135321. */
  135322. constructor(name: string);
  135323. /**
  135324. * Gets the current class name
  135325. * @returns the class name
  135326. */
  135327. getClassName(): string;
  135328. /**
  135329. * Gets the color input component
  135330. */
  135331. get value(): NodeMaterialConnectionPoint;
  135332. /**
  135333. * Gets the cutoff input component
  135334. */
  135335. get cutoff(): NodeMaterialConnectionPoint;
  135336. protected _buildBlock(state: NodeMaterialBuildState): this;
  135337. }
  135338. }
  135339. declare module BABYLON {
  135340. /**
  135341. * Block used to test if the fragment shader is front facing
  135342. */
  135343. export class FrontFacingBlock extends NodeMaterialBlock {
  135344. /**
  135345. * Creates a new FrontFacingBlock
  135346. * @param name defines the block name
  135347. */
  135348. constructor(name: string);
  135349. /**
  135350. * Gets the current class name
  135351. * @returns the class name
  135352. */
  135353. getClassName(): string;
  135354. /**
  135355. * Gets the output component
  135356. */
  135357. get output(): NodeMaterialConnectionPoint;
  135358. protected _buildBlock(state: NodeMaterialBuildState): this;
  135359. }
  135360. }
  135361. declare module BABYLON {
  135362. /**
  135363. * Block used to get the derivative value on x and y of a given input
  135364. */
  135365. export class DerivativeBlock extends NodeMaterialBlock {
  135366. /**
  135367. * Create a new DerivativeBlock
  135368. * @param name defines the block name
  135369. */
  135370. constructor(name: string);
  135371. /**
  135372. * Gets the current class name
  135373. * @returns the class name
  135374. */
  135375. getClassName(): string;
  135376. /**
  135377. * Gets the input component
  135378. */
  135379. get input(): NodeMaterialConnectionPoint;
  135380. /**
  135381. * Gets the derivative output on x
  135382. */
  135383. get dx(): NodeMaterialConnectionPoint;
  135384. /**
  135385. * Gets the derivative output on y
  135386. */
  135387. get dy(): NodeMaterialConnectionPoint;
  135388. protected _buildBlock(state: NodeMaterialBuildState): this;
  135389. }
  135390. }
  135391. declare module BABYLON {
  135392. /**
  135393. * Block used to add support for scene fog
  135394. */
  135395. export class FogBlock extends NodeMaterialBlock {
  135396. private _fogDistanceName;
  135397. private _fogParameters;
  135398. /**
  135399. * Create a new FogBlock
  135400. * @param name defines the block name
  135401. */
  135402. constructor(name: string);
  135403. /**
  135404. * Gets the current class name
  135405. * @returns the class name
  135406. */
  135407. getClassName(): string;
  135408. /**
  135409. * Gets the world position input component
  135410. */
  135411. get worldPosition(): NodeMaterialConnectionPoint;
  135412. /**
  135413. * Gets the view input component
  135414. */
  135415. get view(): NodeMaterialConnectionPoint;
  135416. /**
  135417. * Gets the color input component
  135418. */
  135419. get input(): NodeMaterialConnectionPoint;
  135420. /**
  135421. * Gets the fog color input component
  135422. */
  135423. get fogColor(): NodeMaterialConnectionPoint;
  135424. /**
  135425. * Gets the output component
  135426. */
  135427. get output(): NodeMaterialConnectionPoint;
  135428. autoConfigure(material: NodeMaterial): void;
  135429. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135431. protected _buildBlock(state: NodeMaterialBuildState): this;
  135432. }
  135433. }
  135434. declare module BABYLON {
  135435. /**
  135436. * Block used to add light in the fragment shader
  135437. */
  135438. export class LightBlock extends NodeMaterialBlock {
  135439. private _lightId;
  135440. /**
  135441. * Gets or sets the light associated with this block
  135442. */
  135443. light: Nullable<Light>;
  135444. /**
  135445. * Create a new LightBlock
  135446. * @param name defines the block name
  135447. */
  135448. constructor(name: string);
  135449. /**
  135450. * Gets the current class name
  135451. * @returns the class name
  135452. */
  135453. getClassName(): string;
  135454. /**
  135455. * Gets the world position input component
  135456. */
  135457. get worldPosition(): NodeMaterialConnectionPoint;
  135458. /**
  135459. * Gets the world normal input component
  135460. */
  135461. get worldNormal(): NodeMaterialConnectionPoint;
  135462. /**
  135463. * Gets the camera (or eye) position component
  135464. */
  135465. get cameraPosition(): NodeMaterialConnectionPoint;
  135466. /**
  135467. * Gets the glossiness component
  135468. */
  135469. get glossiness(): NodeMaterialConnectionPoint;
  135470. /**
  135471. * Gets the glossinness power component
  135472. */
  135473. get glossPower(): NodeMaterialConnectionPoint;
  135474. /**
  135475. * Gets the diffuse color component
  135476. */
  135477. get diffuseColor(): NodeMaterialConnectionPoint;
  135478. /**
  135479. * Gets the specular color component
  135480. */
  135481. get specularColor(): NodeMaterialConnectionPoint;
  135482. /**
  135483. * Gets the diffuse output component
  135484. */
  135485. get diffuseOutput(): NodeMaterialConnectionPoint;
  135486. /**
  135487. * Gets the specular output component
  135488. */
  135489. get specularOutput(): NodeMaterialConnectionPoint;
  135490. /**
  135491. * Gets the shadow output component
  135492. */
  135493. get shadow(): NodeMaterialConnectionPoint;
  135494. autoConfigure(material: NodeMaterial): void;
  135495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135496. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135498. private _injectVertexCode;
  135499. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135500. serialize(): any;
  135501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135502. }
  135503. }
  135504. declare module BABYLON {
  135505. /**
  135506. * Block used to read a reflection texture from a sampler
  135507. */
  135508. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  135509. /**
  135510. * Create a new ReflectionTextureBlock
  135511. * @param name defines the block name
  135512. */
  135513. constructor(name: string);
  135514. /**
  135515. * Gets the current class name
  135516. * @returns the class name
  135517. */
  135518. getClassName(): string;
  135519. /**
  135520. * Gets the world position input component
  135521. */
  135522. get position(): NodeMaterialConnectionPoint;
  135523. /**
  135524. * Gets the world position input component
  135525. */
  135526. get worldPosition(): NodeMaterialConnectionPoint;
  135527. /**
  135528. * Gets the world normal input component
  135529. */
  135530. get worldNormal(): NodeMaterialConnectionPoint;
  135531. /**
  135532. * Gets the world input component
  135533. */
  135534. get world(): NodeMaterialConnectionPoint;
  135535. /**
  135536. * Gets the camera (or eye) position component
  135537. */
  135538. get cameraPosition(): NodeMaterialConnectionPoint;
  135539. /**
  135540. * Gets the view input component
  135541. */
  135542. get view(): NodeMaterialConnectionPoint;
  135543. /**
  135544. * Gets the rgb output component
  135545. */
  135546. get rgb(): NodeMaterialConnectionPoint;
  135547. /**
  135548. * Gets the r output component
  135549. */
  135550. get r(): NodeMaterialConnectionPoint;
  135551. /**
  135552. * Gets the g output component
  135553. */
  135554. get g(): NodeMaterialConnectionPoint;
  135555. /**
  135556. * Gets the b output component
  135557. */
  135558. get b(): NodeMaterialConnectionPoint;
  135559. autoConfigure(material: NodeMaterial): void;
  135560. protected _buildBlock(state: NodeMaterialBuildState): this;
  135561. }
  135562. }
  135563. declare module BABYLON {
  135564. /**
  135565. * Block used to multiply 2 values
  135566. */
  135567. export class MultiplyBlock extends NodeMaterialBlock {
  135568. /**
  135569. * Creates a new MultiplyBlock
  135570. * @param name defines the block name
  135571. */
  135572. constructor(name: string);
  135573. /**
  135574. * Gets the current class name
  135575. * @returns the class name
  135576. */
  135577. getClassName(): string;
  135578. /**
  135579. * Gets the left operand input component
  135580. */
  135581. get left(): NodeMaterialConnectionPoint;
  135582. /**
  135583. * Gets the right operand input component
  135584. */
  135585. get right(): NodeMaterialConnectionPoint;
  135586. /**
  135587. * Gets the output component
  135588. */
  135589. get output(): NodeMaterialConnectionPoint;
  135590. protected _buildBlock(state: NodeMaterialBuildState): this;
  135591. }
  135592. }
  135593. declare module BABYLON {
  135594. /**
  135595. * Block used to add 2 vectors
  135596. */
  135597. export class AddBlock extends NodeMaterialBlock {
  135598. /**
  135599. * Creates a new AddBlock
  135600. * @param name defines the block name
  135601. */
  135602. constructor(name: string);
  135603. /**
  135604. * Gets the current class name
  135605. * @returns the class name
  135606. */
  135607. getClassName(): string;
  135608. /**
  135609. * Gets the left operand input component
  135610. */
  135611. get left(): NodeMaterialConnectionPoint;
  135612. /**
  135613. * Gets the right operand input component
  135614. */
  135615. get right(): NodeMaterialConnectionPoint;
  135616. /**
  135617. * Gets the output component
  135618. */
  135619. get output(): NodeMaterialConnectionPoint;
  135620. protected _buildBlock(state: NodeMaterialBuildState): this;
  135621. }
  135622. }
  135623. declare module BABYLON {
  135624. /**
  135625. * Block used to scale a vector by a float
  135626. */
  135627. export class ScaleBlock extends NodeMaterialBlock {
  135628. /**
  135629. * Creates a new ScaleBlock
  135630. * @param name defines the block name
  135631. */
  135632. constructor(name: string);
  135633. /**
  135634. * Gets the current class name
  135635. * @returns the class name
  135636. */
  135637. getClassName(): string;
  135638. /**
  135639. * Gets the input component
  135640. */
  135641. get input(): NodeMaterialConnectionPoint;
  135642. /**
  135643. * Gets the factor input component
  135644. */
  135645. get factor(): NodeMaterialConnectionPoint;
  135646. /**
  135647. * Gets the output component
  135648. */
  135649. get output(): NodeMaterialConnectionPoint;
  135650. protected _buildBlock(state: NodeMaterialBuildState): this;
  135651. }
  135652. }
  135653. declare module BABYLON {
  135654. /**
  135655. * Block used to clamp a float
  135656. */
  135657. export class ClampBlock extends NodeMaterialBlock {
  135658. /** Gets or sets the minimum range */
  135659. minimum: number;
  135660. /** Gets or sets the maximum range */
  135661. maximum: number;
  135662. /**
  135663. * Creates a new ClampBlock
  135664. * @param name defines the block name
  135665. */
  135666. constructor(name: string);
  135667. /**
  135668. * Gets the current class name
  135669. * @returns the class name
  135670. */
  135671. getClassName(): string;
  135672. /**
  135673. * Gets the value input component
  135674. */
  135675. get value(): NodeMaterialConnectionPoint;
  135676. /**
  135677. * Gets the output component
  135678. */
  135679. get output(): NodeMaterialConnectionPoint;
  135680. protected _buildBlock(state: NodeMaterialBuildState): this;
  135681. protected _dumpPropertiesCode(): string;
  135682. serialize(): any;
  135683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135684. }
  135685. }
  135686. declare module BABYLON {
  135687. /**
  135688. * Block used to apply a cross product between 2 vectors
  135689. */
  135690. export class CrossBlock extends NodeMaterialBlock {
  135691. /**
  135692. * Creates a new CrossBlock
  135693. * @param name defines the block name
  135694. */
  135695. constructor(name: string);
  135696. /**
  135697. * Gets the current class name
  135698. * @returns the class name
  135699. */
  135700. getClassName(): string;
  135701. /**
  135702. * Gets the left operand input component
  135703. */
  135704. get left(): NodeMaterialConnectionPoint;
  135705. /**
  135706. * Gets the right operand input component
  135707. */
  135708. get right(): NodeMaterialConnectionPoint;
  135709. /**
  135710. * Gets the output component
  135711. */
  135712. get output(): NodeMaterialConnectionPoint;
  135713. protected _buildBlock(state: NodeMaterialBuildState): this;
  135714. }
  135715. }
  135716. declare module BABYLON {
  135717. /**
  135718. * Block used to apply a dot product between 2 vectors
  135719. */
  135720. export class DotBlock extends NodeMaterialBlock {
  135721. /**
  135722. * Creates a new DotBlock
  135723. * @param name defines the block name
  135724. */
  135725. constructor(name: string);
  135726. /**
  135727. * Gets the current class name
  135728. * @returns the class name
  135729. */
  135730. getClassName(): string;
  135731. /**
  135732. * Gets the left operand input component
  135733. */
  135734. get left(): NodeMaterialConnectionPoint;
  135735. /**
  135736. * Gets the right operand input component
  135737. */
  135738. get right(): NodeMaterialConnectionPoint;
  135739. /**
  135740. * Gets the output component
  135741. */
  135742. get output(): NodeMaterialConnectionPoint;
  135743. protected _buildBlock(state: NodeMaterialBuildState): this;
  135744. }
  135745. }
  135746. declare module BABYLON {
  135747. /**
  135748. * Block used to remap a float from a range to a new one
  135749. */
  135750. export class RemapBlock extends NodeMaterialBlock {
  135751. /**
  135752. * Gets or sets the source range
  135753. */
  135754. sourceRange: Vector2;
  135755. /**
  135756. * Gets or sets the target range
  135757. */
  135758. targetRange: Vector2;
  135759. /**
  135760. * Creates a new RemapBlock
  135761. * @param name defines the block name
  135762. */
  135763. constructor(name: string);
  135764. /**
  135765. * Gets the current class name
  135766. * @returns the class name
  135767. */
  135768. getClassName(): string;
  135769. /**
  135770. * Gets the input component
  135771. */
  135772. get input(): NodeMaterialConnectionPoint;
  135773. /**
  135774. * Gets the source min input component
  135775. */
  135776. get sourceMin(): NodeMaterialConnectionPoint;
  135777. /**
  135778. * Gets the source max input component
  135779. */
  135780. get sourceMax(): NodeMaterialConnectionPoint;
  135781. /**
  135782. * Gets the target min input component
  135783. */
  135784. get targetMin(): NodeMaterialConnectionPoint;
  135785. /**
  135786. * Gets the target max input component
  135787. */
  135788. get targetMax(): NodeMaterialConnectionPoint;
  135789. /**
  135790. * Gets the output component
  135791. */
  135792. get output(): NodeMaterialConnectionPoint;
  135793. protected _buildBlock(state: NodeMaterialBuildState): this;
  135794. protected _dumpPropertiesCode(): string;
  135795. serialize(): any;
  135796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135797. }
  135798. }
  135799. declare module BABYLON {
  135800. /**
  135801. * Block used to normalize a vector
  135802. */
  135803. export class NormalizeBlock extends NodeMaterialBlock {
  135804. /**
  135805. * Creates a new NormalizeBlock
  135806. * @param name defines the block name
  135807. */
  135808. constructor(name: string);
  135809. /**
  135810. * Gets the current class name
  135811. * @returns the class name
  135812. */
  135813. getClassName(): string;
  135814. /**
  135815. * Gets the input component
  135816. */
  135817. get input(): NodeMaterialConnectionPoint;
  135818. /**
  135819. * Gets the output component
  135820. */
  135821. get output(): NodeMaterialConnectionPoint;
  135822. protected _buildBlock(state: NodeMaterialBuildState): this;
  135823. }
  135824. }
  135825. declare module BABYLON {
  135826. /**
  135827. * Operations supported by the Trigonometry block
  135828. */
  135829. export enum TrigonometryBlockOperations {
  135830. /** Cos */
  135831. Cos = 0,
  135832. /** Sin */
  135833. Sin = 1,
  135834. /** Abs */
  135835. Abs = 2,
  135836. /** Exp */
  135837. Exp = 3,
  135838. /** Exp2 */
  135839. Exp2 = 4,
  135840. /** Round */
  135841. Round = 5,
  135842. /** Floor */
  135843. Floor = 6,
  135844. /** Ceiling */
  135845. Ceiling = 7,
  135846. /** Square root */
  135847. Sqrt = 8,
  135848. /** Log */
  135849. Log = 9,
  135850. /** Tangent */
  135851. Tan = 10,
  135852. /** Arc tangent */
  135853. ArcTan = 11,
  135854. /** Arc cosinus */
  135855. ArcCos = 12,
  135856. /** Arc sinus */
  135857. ArcSin = 13,
  135858. /** Fraction */
  135859. Fract = 14,
  135860. /** Sign */
  135861. Sign = 15,
  135862. /** To radians (from degrees) */
  135863. Radians = 16,
  135864. /** To degrees (from radians) */
  135865. Degrees = 17
  135866. }
  135867. /**
  135868. * Block used to apply trigonometry operation to floats
  135869. */
  135870. export class TrigonometryBlock extends NodeMaterialBlock {
  135871. /**
  135872. * Gets or sets the operation applied by the block
  135873. */
  135874. operation: TrigonometryBlockOperations;
  135875. /**
  135876. * Creates a new TrigonometryBlock
  135877. * @param name defines the block name
  135878. */
  135879. constructor(name: string);
  135880. /**
  135881. * Gets the current class name
  135882. * @returns the class name
  135883. */
  135884. getClassName(): string;
  135885. /**
  135886. * Gets the input component
  135887. */
  135888. get input(): NodeMaterialConnectionPoint;
  135889. /**
  135890. * Gets the output component
  135891. */
  135892. get output(): NodeMaterialConnectionPoint;
  135893. protected _buildBlock(state: NodeMaterialBuildState): this;
  135894. serialize(): any;
  135895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135896. protected _dumpPropertiesCode(): string;
  135897. }
  135898. }
  135899. declare module BABYLON {
  135900. /**
  135901. * Block used to create a Color3/4 out of individual inputs (one for each component)
  135902. */
  135903. export class ColorMergerBlock extends NodeMaterialBlock {
  135904. /**
  135905. * Create a new ColorMergerBlock
  135906. * @param name defines the block name
  135907. */
  135908. constructor(name: string);
  135909. /**
  135910. * Gets the current class name
  135911. * @returns the class name
  135912. */
  135913. getClassName(): string;
  135914. /**
  135915. * Gets the rgb component (input)
  135916. */
  135917. get rgbIn(): NodeMaterialConnectionPoint;
  135918. /**
  135919. * Gets the r component (input)
  135920. */
  135921. get r(): NodeMaterialConnectionPoint;
  135922. /**
  135923. * Gets the g component (input)
  135924. */
  135925. get g(): NodeMaterialConnectionPoint;
  135926. /**
  135927. * Gets the b component (input)
  135928. */
  135929. get b(): NodeMaterialConnectionPoint;
  135930. /**
  135931. * Gets the a component (input)
  135932. */
  135933. get a(): NodeMaterialConnectionPoint;
  135934. /**
  135935. * Gets the rgba component (output)
  135936. */
  135937. get rgba(): NodeMaterialConnectionPoint;
  135938. /**
  135939. * Gets the rgb component (output)
  135940. */
  135941. get rgbOut(): NodeMaterialConnectionPoint;
  135942. /**
  135943. * Gets the rgb component (output)
  135944. * @deprecated Please use rgbOut instead.
  135945. */
  135946. get rgb(): NodeMaterialConnectionPoint;
  135947. protected _buildBlock(state: NodeMaterialBuildState): this;
  135948. }
  135949. }
  135950. declare module BABYLON {
  135951. /**
  135952. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  135953. */
  135954. export class VectorMergerBlock extends NodeMaterialBlock {
  135955. /**
  135956. * Create a new VectorMergerBlock
  135957. * @param name defines the block name
  135958. */
  135959. constructor(name: string);
  135960. /**
  135961. * Gets the current class name
  135962. * @returns the class name
  135963. */
  135964. getClassName(): string;
  135965. /**
  135966. * Gets the xyz component (input)
  135967. */
  135968. get xyzIn(): NodeMaterialConnectionPoint;
  135969. /**
  135970. * Gets the xy component (input)
  135971. */
  135972. get xyIn(): NodeMaterialConnectionPoint;
  135973. /**
  135974. * Gets the x component (input)
  135975. */
  135976. get x(): NodeMaterialConnectionPoint;
  135977. /**
  135978. * Gets the y component (input)
  135979. */
  135980. get y(): NodeMaterialConnectionPoint;
  135981. /**
  135982. * Gets the z component (input)
  135983. */
  135984. get z(): NodeMaterialConnectionPoint;
  135985. /**
  135986. * Gets the w component (input)
  135987. */
  135988. get w(): NodeMaterialConnectionPoint;
  135989. /**
  135990. * Gets the xyzw component (output)
  135991. */
  135992. get xyzw(): NodeMaterialConnectionPoint;
  135993. /**
  135994. * Gets the xyz component (output)
  135995. */
  135996. get xyzOut(): NodeMaterialConnectionPoint;
  135997. /**
  135998. * Gets the xy component (output)
  135999. */
  136000. get xyOut(): NodeMaterialConnectionPoint;
  136001. /**
  136002. * Gets the xy component (output)
  136003. * @deprecated Please use xyOut instead.
  136004. */
  136005. get xy(): NodeMaterialConnectionPoint;
  136006. /**
  136007. * Gets the xyz component (output)
  136008. * @deprecated Please use xyzOut instead.
  136009. */
  136010. get xyz(): NodeMaterialConnectionPoint;
  136011. protected _buildBlock(state: NodeMaterialBuildState): this;
  136012. }
  136013. }
  136014. declare module BABYLON {
  136015. /**
  136016. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136017. */
  136018. export class ColorSplitterBlock extends NodeMaterialBlock {
  136019. /**
  136020. * Create a new ColorSplitterBlock
  136021. * @param name defines the block name
  136022. */
  136023. constructor(name: string);
  136024. /**
  136025. * Gets the current class name
  136026. * @returns the class name
  136027. */
  136028. getClassName(): string;
  136029. /**
  136030. * Gets the rgba component (input)
  136031. */
  136032. get rgba(): NodeMaterialConnectionPoint;
  136033. /**
  136034. * Gets the rgb component (input)
  136035. */
  136036. get rgbIn(): NodeMaterialConnectionPoint;
  136037. /**
  136038. * Gets the rgb component (output)
  136039. */
  136040. get rgbOut(): NodeMaterialConnectionPoint;
  136041. /**
  136042. * Gets the r component (output)
  136043. */
  136044. get r(): NodeMaterialConnectionPoint;
  136045. /**
  136046. * Gets the g component (output)
  136047. */
  136048. get g(): NodeMaterialConnectionPoint;
  136049. /**
  136050. * Gets the b component (output)
  136051. */
  136052. get b(): NodeMaterialConnectionPoint;
  136053. /**
  136054. * Gets the a component (output)
  136055. */
  136056. get a(): NodeMaterialConnectionPoint;
  136057. protected _inputRename(name: string): string;
  136058. protected _outputRename(name: string): string;
  136059. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136060. }
  136061. }
  136062. declare module BABYLON {
  136063. /**
  136064. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136065. */
  136066. export class VectorSplitterBlock extends NodeMaterialBlock {
  136067. /**
  136068. * Create a new VectorSplitterBlock
  136069. * @param name defines the block name
  136070. */
  136071. constructor(name: string);
  136072. /**
  136073. * Gets the current class name
  136074. * @returns the class name
  136075. */
  136076. getClassName(): string;
  136077. /**
  136078. * Gets the xyzw component (input)
  136079. */
  136080. get xyzw(): NodeMaterialConnectionPoint;
  136081. /**
  136082. * Gets the xyz component (input)
  136083. */
  136084. get xyzIn(): NodeMaterialConnectionPoint;
  136085. /**
  136086. * Gets the xy component (input)
  136087. */
  136088. get xyIn(): NodeMaterialConnectionPoint;
  136089. /**
  136090. * Gets the xyz component (output)
  136091. */
  136092. get xyzOut(): NodeMaterialConnectionPoint;
  136093. /**
  136094. * Gets the xy component (output)
  136095. */
  136096. get xyOut(): NodeMaterialConnectionPoint;
  136097. /**
  136098. * Gets the x component (output)
  136099. */
  136100. get x(): NodeMaterialConnectionPoint;
  136101. /**
  136102. * Gets the y component (output)
  136103. */
  136104. get y(): NodeMaterialConnectionPoint;
  136105. /**
  136106. * Gets the z component (output)
  136107. */
  136108. get z(): NodeMaterialConnectionPoint;
  136109. /**
  136110. * Gets the w component (output)
  136111. */
  136112. get w(): NodeMaterialConnectionPoint;
  136113. protected _inputRename(name: string): string;
  136114. protected _outputRename(name: string): string;
  136115. protected _buildBlock(state: NodeMaterialBuildState): this;
  136116. }
  136117. }
  136118. declare module BABYLON {
  136119. /**
  136120. * Block used to lerp between 2 values
  136121. */
  136122. export class LerpBlock extends NodeMaterialBlock {
  136123. /**
  136124. * Creates a new LerpBlock
  136125. * @param name defines the block name
  136126. */
  136127. constructor(name: string);
  136128. /**
  136129. * Gets the current class name
  136130. * @returns the class name
  136131. */
  136132. getClassName(): string;
  136133. /**
  136134. * Gets the left operand input component
  136135. */
  136136. get left(): NodeMaterialConnectionPoint;
  136137. /**
  136138. * Gets the right operand input component
  136139. */
  136140. get right(): NodeMaterialConnectionPoint;
  136141. /**
  136142. * Gets the gradient operand input component
  136143. */
  136144. get gradient(): NodeMaterialConnectionPoint;
  136145. /**
  136146. * Gets the output component
  136147. */
  136148. get output(): NodeMaterialConnectionPoint;
  136149. protected _buildBlock(state: NodeMaterialBuildState): this;
  136150. }
  136151. }
  136152. declare module BABYLON {
  136153. /**
  136154. * Block used to divide 2 vectors
  136155. */
  136156. export class DivideBlock extends NodeMaterialBlock {
  136157. /**
  136158. * Creates a new DivideBlock
  136159. * @param name defines the block name
  136160. */
  136161. constructor(name: string);
  136162. /**
  136163. * Gets the current class name
  136164. * @returns the class name
  136165. */
  136166. getClassName(): string;
  136167. /**
  136168. * Gets the left operand input component
  136169. */
  136170. get left(): NodeMaterialConnectionPoint;
  136171. /**
  136172. * Gets the right operand input component
  136173. */
  136174. get right(): NodeMaterialConnectionPoint;
  136175. /**
  136176. * Gets the output component
  136177. */
  136178. get output(): NodeMaterialConnectionPoint;
  136179. protected _buildBlock(state: NodeMaterialBuildState): this;
  136180. }
  136181. }
  136182. declare module BABYLON {
  136183. /**
  136184. * Block used to subtract 2 vectors
  136185. */
  136186. export class SubtractBlock extends NodeMaterialBlock {
  136187. /**
  136188. * Creates a new SubtractBlock
  136189. * @param name defines the block name
  136190. */
  136191. constructor(name: string);
  136192. /**
  136193. * Gets the current class name
  136194. * @returns the class name
  136195. */
  136196. getClassName(): string;
  136197. /**
  136198. * Gets the left operand input component
  136199. */
  136200. get left(): NodeMaterialConnectionPoint;
  136201. /**
  136202. * Gets the right operand input component
  136203. */
  136204. get right(): NodeMaterialConnectionPoint;
  136205. /**
  136206. * Gets the output component
  136207. */
  136208. get output(): NodeMaterialConnectionPoint;
  136209. protected _buildBlock(state: NodeMaterialBuildState): this;
  136210. }
  136211. }
  136212. declare module BABYLON {
  136213. /**
  136214. * Block used to step a value
  136215. */
  136216. export class StepBlock extends NodeMaterialBlock {
  136217. /**
  136218. * Creates a new StepBlock
  136219. * @param name defines the block name
  136220. */
  136221. constructor(name: string);
  136222. /**
  136223. * Gets the current class name
  136224. * @returns the class name
  136225. */
  136226. getClassName(): string;
  136227. /**
  136228. * Gets the value operand input component
  136229. */
  136230. get value(): NodeMaterialConnectionPoint;
  136231. /**
  136232. * Gets the edge operand input component
  136233. */
  136234. get edge(): NodeMaterialConnectionPoint;
  136235. /**
  136236. * Gets the output component
  136237. */
  136238. get output(): NodeMaterialConnectionPoint;
  136239. protected _buildBlock(state: NodeMaterialBuildState): this;
  136240. }
  136241. }
  136242. declare module BABYLON {
  136243. /**
  136244. * Block used to get the opposite (1 - x) of a value
  136245. */
  136246. export class OneMinusBlock extends NodeMaterialBlock {
  136247. /**
  136248. * Creates a new OneMinusBlock
  136249. * @param name defines the block name
  136250. */
  136251. constructor(name: string);
  136252. /**
  136253. * Gets the current class name
  136254. * @returns the class name
  136255. */
  136256. getClassName(): string;
  136257. /**
  136258. * Gets the input component
  136259. */
  136260. get input(): NodeMaterialConnectionPoint;
  136261. /**
  136262. * Gets the output component
  136263. */
  136264. get output(): NodeMaterialConnectionPoint;
  136265. protected _buildBlock(state: NodeMaterialBuildState): this;
  136266. }
  136267. }
  136268. declare module BABYLON {
  136269. /**
  136270. * Block used to get the view direction
  136271. */
  136272. export class ViewDirectionBlock extends NodeMaterialBlock {
  136273. /**
  136274. * Creates a new ViewDirectionBlock
  136275. * @param name defines the block name
  136276. */
  136277. constructor(name: string);
  136278. /**
  136279. * Gets the current class name
  136280. * @returns the class name
  136281. */
  136282. getClassName(): string;
  136283. /**
  136284. * Gets the world position component
  136285. */
  136286. get worldPosition(): NodeMaterialConnectionPoint;
  136287. /**
  136288. * Gets the camera position component
  136289. */
  136290. get cameraPosition(): NodeMaterialConnectionPoint;
  136291. /**
  136292. * Gets the output component
  136293. */
  136294. get output(): NodeMaterialConnectionPoint;
  136295. autoConfigure(material: NodeMaterial): void;
  136296. protected _buildBlock(state: NodeMaterialBuildState): this;
  136297. }
  136298. }
  136299. declare module BABYLON {
  136300. /**
  136301. * Block used to compute fresnel value
  136302. */
  136303. export class FresnelBlock extends NodeMaterialBlock {
  136304. /**
  136305. * Create a new FresnelBlock
  136306. * @param name defines the block name
  136307. */
  136308. constructor(name: string);
  136309. /**
  136310. * Gets the current class name
  136311. * @returns the class name
  136312. */
  136313. getClassName(): string;
  136314. /**
  136315. * Gets the world normal input component
  136316. */
  136317. get worldNormal(): NodeMaterialConnectionPoint;
  136318. /**
  136319. * Gets the view direction input component
  136320. */
  136321. get viewDirection(): NodeMaterialConnectionPoint;
  136322. /**
  136323. * Gets the bias input component
  136324. */
  136325. get bias(): NodeMaterialConnectionPoint;
  136326. /**
  136327. * Gets the camera (or eye) position component
  136328. */
  136329. get power(): NodeMaterialConnectionPoint;
  136330. /**
  136331. * Gets the fresnel output component
  136332. */
  136333. get fresnel(): NodeMaterialConnectionPoint;
  136334. autoConfigure(material: NodeMaterial): void;
  136335. protected _buildBlock(state: NodeMaterialBuildState): this;
  136336. }
  136337. }
  136338. declare module BABYLON {
  136339. /**
  136340. * Block used to get the max of 2 values
  136341. */
  136342. export class MaxBlock extends NodeMaterialBlock {
  136343. /**
  136344. * Creates a new MaxBlock
  136345. * @param name defines the block name
  136346. */
  136347. constructor(name: string);
  136348. /**
  136349. * Gets the current class name
  136350. * @returns the class name
  136351. */
  136352. getClassName(): string;
  136353. /**
  136354. * Gets the left operand input component
  136355. */
  136356. get left(): NodeMaterialConnectionPoint;
  136357. /**
  136358. * Gets the right operand input component
  136359. */
  136360. get right(): NodeMaterialConnectionPoint;
  136361. /**
  136362. * Gets the output component
  136363. */
  136364. get output(): NodeMaterialConnectionPoint;
  136365. protected _buildBlock(state: NodeMaterialBuildState): this;
  136366. }
  136367. }
  136368. declare module BABYLON {
  136369. /**
  136370. * Block used to get the min of 2 values
  136371. */
  136372. export class MinBlock extends NodeMaterialBlock {
  136373. /**
  136374. * Creates a new MinBlock
  136375. * @param name defines the block name
  136376. */
  136377. constructor(name: string);
  136378. /**
  136379. * Gets the current class name
  136380. * @returns the class name
  136381. */
  136382. getClassName(): string;
  136383. /**
  136384. * Gets the left operand input component
  136385. */
  136386. get left(): NodeMaterialConnectionPoint;
  136387. /**
  136388. * Gets the right operand input component
  136389. */
  136390. get right(): NodeMaterialConnectionPoint;
  136391. /**
  136392. * Gets the output component
  136393. */
  136394. get output(): NodeMaterialConnectionPoint;
  136395. protected _buildBlock(state: NodeMaterialBuildState): this;
  136396. }
  136397. }
  136398. declare module BABYLON {
  136399. /**
  136400. * Block used to get the distance between 2 values
  136401. */
  136402. export class DistanceBlock extends NodeMaterialBlock {
  136403. /**
  136404. * Creates a new DistanceBlock
  136405. * @param name defines the block name
  136406. */
  136407. constructor(name: string);
  136408. /**
  136409. * Gets the current class name
  136410. * @returns the class name
  136411. */
  136412. getClassName(): string;
  136413. /**
  136414. * Gets the left operand input component
  136415. */
  136416. get left(): NodeMaterialConnectionPoint;
  136417. /**
  136418. * Gets the right operand input component
  136419. */
  136420. get right(): NodeMaterialConnectionPoint;
  136421. /**
  136422. * Gets the output component
  136423. */
  136424. get output(): NodeMaterialConnectionPoint;
  136425. protected _buildBlock(state: NodeMaterialBuildState): this;
  136426. }
  136427. }
  136428. declare module BABYLON {
  136429. /**
  136430. * Block used to get the length of a vector
  136431. */
  136432. export class LengthBlock extends NodeMaterialBlock {
  136433. /**
  136434. * Creates a new LengthBlock
  136435. * @param name defines the block name
  136436. */
  136437. constructor(name: string);
  136438. /**
  136439. * Gets the current class name
  136440. * @returns the class name
  136441. */
  136442. getClassName(): string;
  136443. /**
  136444. * Gets the value input component
  136445. */
  136446. get value(): NodeMaterialConnectionPoint;
  136447. /**
  136448. * Gets the output component
  136449. */
  136450. get output(): NodeMaterialConnectionPoint;
  136451. protected _buildBlock(state: NodeMaterialBuildState): this;
  136452. }
  136453. }
  136454. declare module BABYLON {
  136455. /**
  136456. * Block used to get negative version of a value (i.e. x * -1)
  136457. */
  136458. export class NegateBlock extends NodeMaterialBlock {
  136459. /**
  136460. * Creates a new NegateBlock
  136461. * @param name defines the block name
  136462. */
  136463. constructor(name: string);
  136464. /**
  136465. * Gets the current class name
  136466. * @returns the class name
  136467. */
  136468. getClassName(): string;
  136469. /**
  136470. * Gets the value input component
  136471. */
  136472. get value(): NodeMaterialConnectionPoint;
  136473. /**
  136474. * Gets the output component
  136475. */
  136476. get output(): NodeMaterialConnectionPoint;
  136477. protected _buildBlock(state: NodeMaterialBuildState): this;
  136478. }
  136479. }
  136480. declare module BABYLON {
  136481. /**
  136482. * Block used to get the value of the first parameter raised to the power of the second
  136483. */
  136484. export class PowBlock extends NodeMaterialBlock {
  136485. /**
  136486. * Creates a new PowBlock
  136487. * @param name defines the block name
  136488. */
  136489. constructor(name: string);
  136490. /**
  136491. * Gets the current class name
  136492. * @returns the class name
  136493. */
  136494. getClassName(): string;
  136495. /**
  136496. * Gets the value operand input component
  136497. */
  136498. get value(): NodeMaterialConnectionPoint;
  136499. /**
  136500. * Gets the power operand input component
  136501. */
  136502. get power(): NodeMaterialConnectionPoint;
  136503. /**
  136504. * Gets the output component
  136505. */
  136506. get output(): NodeMaterialConnectionPoint;
  136507. protected _buildBlock(state: NodeMaterialBuildState): this;
  136508. }
  136509. }
  136510. declare module BABYLON {
  136511. /**
  136512. * Block used to get a random number
  136513. */
  136514. export class RandomNumberBlock extends NodeMaterialBlock {
  136515. /**
  136516. * Creates a new RandomNumberBlock
  136517. * @param name defines the block name
  136518. */
  136519. constructor(name: string);
  136520. /**
  136521. * Gets the current class name
  136522. * @returns the class name
  136523. */
  136524. getClassName(): string;
  136525. /**
  136526. * Gets the seed input component
  136527. */
  136528. get seed(): NodeMaterialConnectionPoint;
  136529. /**
  136530. * Gets the output component
  136531. */
  136532. get output(): NodeMaterialConnectionPoint;
  136533. protected _buildBlock(state: NodeMaterialBuildState): this;
  136534. }
  136535. }
  136536. declare module BABYLON {
  136537. /**
  136538. * Block used to compute arc tangent of 2 values
  136539. */
  136540. export class ArcTan2Block extends NodeMaterialBlock {
  136541. /**
  136542. * Creates a new ArcTan2Block
  136543. * @param name defines the block name
  136544. */
  136545. constructor(name: string);
  136546. /**
  136547. * Gets the current class name
  136548. * @returns the class name
  136549. */
  136550. getClassName(): string;
  136551. /**
  136552. * Gets the x operand input component
  136553. */
  136554. get x(): NodeMaterialConnectionPoint;
  136555. /**
  136556. * Gets the y operand input component
  136557. */
  136558. get y(): NodeMaterialConnectionPoint;
  136559. /**
  136560. * Gets the output component
  136561. */
  136562. get output(): NodeMaterialConnectionPoint;
  136563. protected _buildBlock(state: NodeMaterialBuildState): this;
  136564. }
  136565. }
  136566. declare module BABYLON {
  136567. /**
  136568. * Block used to smooth step a value
  136569. */
  136570. export class SmoothStepBlock extends NodeMaterialBlock {
  136571. /**
  136572. * Creates a new SmoothStepBlock
  136573. * @param name defines the block name
  136574. */
  136575. constructor(name: string);
  136576. /**
  136577. * Gets the current class name
  136578. * @returns the class name
  136579. */
  136580. getClassName(): string;
  136581. /**
  136582. * Gets the value operand input component
  136583. */
  136584. get value(): NodeMaterialConnectionPoint;
  136585. /**
  136586. * Gets the first edge operand input component
  136587. */
  136588. get edge0(): NodeMaterialConnectionPoint;
  136589. /**
  136590. * Gets the second edge operand input component
  136591. */
  136592. get edge1(): NodeMaterialConnectionPoint;
  136593. /**
  136594. * Gets the output component
  136595. */
  136596. get output(): NodeMaterialConnectionPoint;
  136597. protected _buildBlock(state: NodeMaterialBuildState): this;
  136598. }
  136599. }
  136600. declare module BABYLON {
  136601. /**
  136602. * Block used to get the reciprocal (1 / x) of a value
  136603. */
  136604. export class ReciprocalBlock extends NodeMaterialBlock {
  136605. /**
  136606. * Creates a new ReciprocalBlock
  136607. * @param name defines the block name
  136608. */
  136609. constructor(name: string);
  136610. /**
  136611. * Gets the current class name
  136612. * @returns the class name
  136613. */
  136614. getClassName(): string;
  136615. /**
  136616. * Gets the input component
  136617. */
  136618. get input(): NodeMaterialConnectionPoint;
  136619. /**
  136620. * Gets the output component
  136621. */
  136622. get output(): NodeMaterialConnectionPoint;
  136623. protected _buildBlock(state: NodeMaterialBuildState): this;
  136624. }
  136625. }
  136626. declare module BABYLON {
  136627. /**
  136628. * Block used to replace a color by another one
  136629. */
  136630. export class ReplaceColorBlock extends NodeMaterialBlock {
  136631. /**
  136632. * Creates a new ReplaceColorBlock
  136633. * @param name defines the block name
  136634. */
  136635. constructor(name: string);
  136636. /**
  136637. * Gets the current class name
  136638. * @returns the class name
  136639. */
  136640. getClassName(): string;
  136641. /**
  136642. * Gets the value input component
  136643. */
  136644. get value(): NodeMaterialConnectionPoint;
  136645. /**
  136646. * Gets the reference input component
  136647. */
  136648. get reference(): NodeMaterialConnectionPoint;
  136649. /**
  136650. * Gets the distance input component
  136651. */
  136652. get distance(): NodeMaterialConnectionPoint;
  136653. /**
  136654. * Gets the replacement input component
  136655. */
  136656. get replacement(): NodeMaterialConnectionPoint;
  136657. /**
  136658. * Gets the output component
  136659. */
  136660. get output(): NodeMaterialConnectionPoint;
  136661. protected _buildBlock(state: NodeMaterialBuildState): this;
  136662. }
  136663. }
  136664. declare module BABYLON {
  136665. /**
  136666. * Block used to posterize a value
  136667. * @see https://en.wikipedia.org/wiki/Posterization
  136668. */
  136669. export class PosterizeBlock extends NodeMaterialBlock {
  136670. /**
  136671. * Creates a new PosterizeBlock
  136672. * @param name defines the block name
  136673. */
  136674. constructor(name: string);
  136675. /**
  136676. * Gets the current class name
  136677. * @returns the class name
  136678. */
  136679. getClassName(): string;
  136680. /**
  136681. * Gets the value input component
  136682. */
  136683. get value(): NodeMaterialConnectionPoint;
  136684. /**
  136685. * Gets the steps input component
  136686. */
  136687. get steps(): NodeMaterialConnectionPoint;
  136688. /**
  136689. * Gets the output component
  136690. */
  136691. get output(): NodeMaterialConnectionPoint;
  136692. protected _buildBlock(state: NodeMaterialBuildState): this;
  136693. }
  136694. }
  136695. declare module BABYLON {
  136696. /**
  136697. * Operations supported by the Wave block
  136698. */
  136699. export enum WaveBlockKind {
  136700. /** SawTooth */
  136701. SawTooth = 0,
  136702. /** Square */
  136703. Square = 1,
  136704. /** Triangle */
  136705. Triangle = 2
  136706. }
  136707. /**
  136708. * Block used to apply wave operation to floats
  136709. */
  136710. export class WaveBlock extends NodeMaterialBlock {
  136711. /**
  136712. * Gets or sets the kibnd of wave to be applied by the block
  136713. */
  136714. kind: WaveBlockKind;
  136715. /**
  136716. * Creates a new WaveBlock
  136717. * @param name defines the block name
  136718. */
  136719. constructor(name: string);
  136720. /**
  136721. * Gets the current class name
  136722. * @returns the class name
  136723. */
  136724. getClassName(): string;
  136725. /**
  136726. * Gets the input component
  136727. */
  136728. get input(): NodeMaterialConnectionPoint;
  136729. /**
  136730. * Gets the output component
  136731. */
  136732. get output(): NodeMaterialConnectionPoint;
  136733. protected _buildBlock(state: NodeMaterialBuildState): this;
  136734. serialize(): any;
  136735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136736. }
  136737. }
  136738. declare module BABYLON {
  136739. /**
  136740. * Class used to store a color step for the GradientBlock
  136741. */
  136742. export class GradientBlockColorStep {
  136743. /**
  136744. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136745. */
  136746. step: number;
  136747. /**
  136748. * Gets or sets the color associated with this step
  136749. */
  136750. color: Color3;
  136751. /**
  136752. * Creates a new GradientBlockColorStep
  136753. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  136754. * @param color defines the color associated with this step
  136755. */
  136756. constructor(
  136757. /**
  136758. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136759. */
  136760. step: number,
  136761. /**
  136762. * Gets or sets the color associated with this step
  136763. */
  136764. color: Color3);
  136765. }
  136766. /**
  136767. * Block used to return a color from a gradient based on an input value between 0 and 1
  136768. */
  136769. export class GradientBlock extends NodeMaterialBlock {
  136770. /**
  136771. * Gets or sets the list of color steps
  136772. */
  136773. colorSteps: GradientBlockColorStep[];
  136774. /**
  136775. * Creates a new GradientBlock
  136776. * @param name defines the block name
  136777. */
  136778. constructor(name: string);
  136779. /**
  136780. * Gets the current class name
  136781. * @returns the class name
  136782. */
  136783. getClassName(): string;
  136784. /**
  136785. * Gets the gradient input component
  136786. */
  136787. get gradient(): NodeMaterialConnectionPoint;
  136788. /**
  136789. * Gets the output component
  136790. */
  136791. get output(): NodeMaterialConnectionPoint;
  136792. private _writeColorConstant;
  136793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136794. serialize(): any;
  136795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136796. protected _dumpPropertiesCode(): string;
  136797. }
  136798. }
  136799. declare module BABYLON {
  136800. /**
  136801. * Block used to normalize lerp between 2 values
  136802. */
  136803. export class NLerpBlock extends NodeMaterialBlock {
  136804. /**
  136805. * Creates a new NLerpBlock
  136806. * @param name defines the block name
  136807. */
  136808. constructor(name: string);
  136809. /**
  136810. * Gets the current class name
  136811. * @returns the class name
  136812. */
  136813. getClassName(): string;
  136814. /**
  136815. * Gets the left operand input component
  136816. */
  136817. get left(): NodeMaterialConnectionPoint;
  136818. /**
  136819. * Gets the right operand input component
  136820. */
  136821. get right(): NodeMaterialConnectionPoint;
  136822. /**
  136823. * Gets the gradient operand input component
  136824. */
  136825. get gradient(): NodeMaterialConnectionPoint;
  136826. /**
  136827. * Gets the output component
  136828. */
  136829. get output(): NodeMaterialConnectionPoint;
  136830. protected _buildBlock(state: NodeMaterialBuildState): this;
  136831. }
  136832. }
  136833. declare module BABYLON {
  136834. /**
  136835. * block used to Generate a Worley Noise 3D Noise Pattern
  136836. */
  136837. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  136838. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  136839. manhattanDistance: boolean;
  136840. /**
  136841. * Creates a new WorleyNoise3DBlock
  136842. * @param name defines the block name
  136843. */
  136844. constructor(name: string);
  136845. /**
  136846. * Gets the current class name
  136847. * @returns the class name
  136848. */
  136849. getClassName(): string;
  136850. /**
  136851. * Gets the seed input component
  136852. */
  136853. get seed(): NodeMaterialConnectionPoint;
  136854. /**
  136855. * Gets the jitter input component
  136856. */
  136857. get jitter(): NodeMaterialConnectionPoint;
  136858. /**
  136859. * Gets the output component
  136860. */
  136861. get output(): NodeMaterialConnectionPoint;
  136862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136863. /**
  136864. * Exposes the properties to the UI?
  136865. */
  136866. protected _dumpPropertiesCode(): string;
  136867. /**
  136868. * Exposes the properties to the Seralize?
  136869. */
  136870. serialize(): any;
  136871. /**
  136872. * Exposes the properties to the deseralize?
  136873. */
  136874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136875. }
  136876. }
  136877. declare module BABYLON {
  136878. /**
  136879. * block used to Generate a Simplex Perlin 3d Noise Pattern
  136880. */
  136881. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  136882. /**
  136883. * Creates a new SimplexPerlin3DBlock
  136884. * @param name defines the block name
  136885. */
  136886. constructor(name: string);
  136887. /**
  136888. * Gets the current class name
  136889. * @returns the class name
  136890. */
  136891. getClassName(): string;
  136892. /**
  136893. * Gets the seed operand input component
  136894. */
  136895. get seed(): NodeMaterialConnectionPoint;
  136896. /**
  136897. * Gets the output component
  136898. */
  136899. get output(): NodeMaterialConnectionPoint;
  136900. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136901. }
  136902. }
  136903. declare module BABYLON {
  136904. /**
  136905. * Block used to blend normals
  136906. */
  136907. export class NormalBlendBlock extends NodeMaterialBlock {
  136908. /**
  136909. * Creates a new NormalBlendBlock
  136910. * @param name defines the block name
  136911. */
  136912. constructor(name: string);
  136913. /**
  136914. * Gets the current class name
  136915. * @returns the class name
  136916. */
  136917. getClassName(): string;
  136918. /**
  136919. * Gets the first input component
  136920. */
  136921. get normalMap0(): NodeMaterialConnectionPoint;
  136922. /**
  136923. * Gets the second input component
  136924. */
  136925. get normalMap1(): NodeMaterialConnectionPoint;
  136926. /**
  136927. * Gets the output component
  136928. */
  136929. get output(): NodeMaterialConnectionPoint;
  136930. protected _buildBlock(state: NodeMaterialBuildState): this;
  136931. }
  136932. }
  136933. declare module BABYLON {
  136934. /**
  136935. * Block used to rotate a 2d vector by a given angle
  136936. */
  136937. export class Rotate2dBlock extends NodeMaterialBlock {
  136938. /**
  136939. * Creates a new Rotate2dBlock
  136940. * @param name defines the block name
  136941. */
  136942. constructor(name: string);
  136943. /**
  136944. * Gets the current class name
  136945. * @returns the class name
  136946. */
  136947. getClassName(): string;
  136948. /**
  136949. * Gets the input vector
  136950. */
  136951. get input(): NodeMaterialConnectionPoint;
  136952. /**
  136953. * Gets the input angle
  136954. */
  136955. get angle(): NodeMaterialConnectionPoint;
  136956. /**
  136957. * Gets the output component
  136958. */
  136959. get output(): NodeMaterialConnectionPoint;
  136960. autoConfigure(material: NodeMaterial): void;
  136961. protected _buildBlock(state: NodeMaterialBuildState): this;
  136962. }
  136963. }
  136964. declare module BABYLON {
  136965. /**
  136966. * Block used to get the reflected vector from a direction and a normal
  136967. */
  136968. export class ReflectBlock extends NodeMaterialBlock {
  136969. /**
  136970. * Creates a new ReflectBlock
  136971. * @param name defines the block name
  136972. */
  136973. constructor(name: string);
  136974. /**
  136975. * Gets the current class name
  136976. * @returns the class name
  136977. */
  136978. getClassName(): string;
  136979. /**
  136980. * Gets the incident component
  136981. */
  136982. get incident(): NodeMaterialConnectionPoint;
  136983. /**
  136984. * Gets the normal component
  136985. */
  136986. get normal(): NodeMaterialConnectionPoint;
  136987. /**
  136988. * Gets the output component
  136989. */
  136990. get output(): NodeMaterialConnectionPoint;
  136991. protected _buildBlock(state: NodeMaterialBuildState): this;
  136992. }
  136993. }
  136994. declare module BABYLON {
  136995. /**
  136996. * Block used to get the refracted vector from a direction and a normal
  136997. */
  136998. export class RefractBlock extends NodeMaterialBlock {
  136999. /**
  137000. * Creates a new RefractBlock
  137001. * @param name defines the block name
  137002. */
  137003. constructor(name: string);
  137004. /**
  137005. * Gets the current class name
  137006. * @returns the class name
  137007. */
  137008. getClassName(): string;
  137009. /**
  137010. * Gets the incident component
  137011. */
  137012. get incident(): NodeMaterialConnectionPoint;
  137013. /**
  137014. * Gets the normal component
  137015. */
  137016. get normal(): NodeMaterialConnectionPoint;
  137017. /**
  137018. * Gets the index of refraction component
  137019. */
  137020. get ior(): NodeMaterialConnectionPoint;
  137021. /**
  137022. * Gets the output component
  137023. */
  137024. get output(): NodeMaterialConnectionPoint;
  137025. protected _buildBlock(state: NodeMaterialBuildState): this;
  137026. }
  137027. }
  137028. declare module BABYLON {
  137029. /**
  137030. * Block used to desaturate a color
  137031. */
  137032. export class DesaturateBlock extends NodeMaterialBlock {
  137033. /**
  137034. * Creates a new DesaturateBlock
  137035. * @param name defines the block name
  137036. */
  137037. constructor(name: string);
  137038. /**
  137039. * Gets the current class name
  137040. * @returns the class name
  137041. */
  137042. getClassName(): string;
  137043. /**
  137044. * Gets the color operand input component
  137045. */
  137046. get color(): NodeMaterialConnectionPoint;
  137047. /**
  137048. * Gets the level operand input component
  137049. */
  137050. get level(): NodeMaterialConnectionPoint;
  137051. /**
  137052. * Gets the output component
  137053. */
  137054. get output(): NodeMaterialConnectionPoint;
  137055. protected _buildBlock(state: NodeMaterialBuildState): this;
  137056. }
  137057. }
  137058. declare module BABYLON {
  137059. /**
  137060. * Block used to implement the ambient occlusion module of the PBR material
  137061. */
  137062. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137063. /**
  137064. * Create a new AmbientOcclusionBlock
  137065. * @param name defines the block name
  137066. */
  137067. constructor(name: string);
  137068. /**
  137069. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137070. */
  137071. useAmbientInGrayScale: boolean;
  137072. /**
  137073. * Initialize the block and prepare the context for build
  137074. * @param state defines the state that will be used for the build
  137075. */
  137076. initialize(state: NodeMaterialBuildState): void;
  137077. /**
  137078. * Gets the current class name
  137079. * @returns the class name
  137080. */
  137081. getClassName(): string;
  137082. /**
  137083. * Gets the texture input component
  137084. */
  137085. get texture(): NodeMaterialConnectionPoint;
  137086. /**
  137087. * Gets the texture intensity component
  137088. */
  137089. get intensity(): NodeMaterialConnectionPoint;
  137090. /**
  137091. * Gets the direct light intensity input component
  137092. */
  137093. get directLightIntensity(): NodeMaterialConnectionPoint;
  137094. /**
  137095. * Gets the ambient occlusion object output component
  137096. */
  137097. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137098. /**
  137099. * Gets the main code of the block (fragment side)
  137100. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137101. * @returns the shader code
  137102. */
  137103. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137105. protected _buildBlock(state: NodeMaterialBuildState): this;
  137106. protected _dumpPropertiesCode(): string;
  137107. serialize(): any;
  137108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137109. }
  137110. }
  137111. declare module BABYLON {
  137112. /**
  137113. * Block used to implement the reflection module of the PBR material
  137114. */
  137115. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137116. /** @hidden */
  137117. _defineLODReflectionAlpha: string;
  137118. /** @hidden */
  137119. _defineLinearSpecularReflection: string;
  137120. private _vEnvironmentIrradianceName;
  137121. /** @hidden */
  137122. _vReflectionMicrosurfaceInfosName: string;
  137123. /** @hidden */
  137124. _vReflectionInfosName: string;
  137125. private _scene;
  137126. /**
  137127. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137128. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137129. * It's less burden on the user side in the editor part.
  137130. */
  137131. /** @hidden */
  137132. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137133. /** @hidden */
  137134. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137135. /** @hidden */
  137136. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137137. /**
  137138. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137139. * diffuse part of the IBL.
  137140. */
  137141. useSphericalHarmonics: boolean;
  137142. /**
  137143. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137144. */
  137145. forceIrradianceInFragment: boolean;
  137146. /**
  137147. * Create a new ReflectionBlock
  137148. * @param name defines the block name
  137149. */
  137150. constructor(name: string);
  137151. /**
  137152. * Gets the current class name
  137153. * @returns the class name
  137154. */
  137155. getClassName(): string;
  137156. /**
  137157. * Gets the position input component
  137158. */
  137159. get position(): NodeMaterialConnectionPoint;
  137160. /**
  137161. * Gets the world position input component
  137162. */
  137163. get worldPosition(): NodeMaterialConnectionPoint;
  137164. /**
  137165. * Gets the world normal input component
  137166. */
  137167. get worldNormal(): NodeMaterialConnectionPoint;
  137168. /**
  137169. * Gets the world input component
  137170. */
  137171. get world(): NodeMaterialConnectionPoint;
  137172. /**
  137173. * Gets the camera (or eye) position component
  137174. */
  137175. get cameraPosition(): NodeMaterialConnectionPoint;
  137176. /**
  137177. * Gets the view input component
  137178. */
  137179. get view(): NodeMaterialConnectionPoint;
  137180. /**
  137181. * Gets the color input component
  137182. */
  137183. get color(): NodeMaterialConnectionPoint;
  137184. /**
  137185. * Gets the reflection object output component
  137186. */
  137187. get reflection(): NodeMaterialConnectionPoint;
  137188. /**
  137189. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137190. */
  137191. get hasTexture(): boolean;
  137192. /**
  137193. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137194. */
  137195. get reflectionColor(): string;
  137196. protected _getTexture(): Nullable<BaseTexture>;
  137197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137198. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137199. /**
  137200. * Gets the code to inject in the vertex shader
  137201. * @param state current state of the node material building
  137202. * @returns the shader code
  137203. */
  137204. handleVertexSide(state: NodeMaterialBuildState): string;
  137205. /**
  137206. * Gets the main code of the block (fragment side)
  137207. * @param state current state of the node material building
  137208. * @param normalVarName name of the existing variable corresponding to the normal
  137209. * @returns the shader code
  137210. */
  137211. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137212. protected _buildBlock(state: NodeMaterialBuildState): this;
  137213. protected _dumpPropertiesCode(): string;
  137214. serialize(): any;
  137215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137216. }
  137217. }
  137218. declare module BABYLON {
  137219. /**
  137220. * Block used to implement the sheen module of the PBR material
  137221. */
  137222. export class SheenBlock extends NodeMaterialBlock {
  137223. /**
  137224. * Create a new SheenBlock
  137225. * @param name defines the block name
  137226. */
  137227. constructor(name: string);
  137228. /**
  137229. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137230. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137231. * making it easier to setup and tweak the effect
  137232. */
  137233. albedoScaling: boolean;
  137234. /**
  137235. * Defines if the sheen is linked to the sheen color.
  137236. */
  137237. linkSheenWithAlbedo: boolean;
  137238. /**
  137239. * Initialize the block and prepare the context for build
  137240. * @param state defines the state that will be used for the build
  137241. */
  137242. initialize(state: NodeMaterialBuildState): void;
  137243. /**
  137244. * Gets the current class name
  137245. * @returns the class name
  137246. */
  137247. getClassName(): string;
  137248. /**
  137249. * Gets the intensity input component
  137250. */
  137251. get intensity(): NodeMaterialConnectionPoint;
  137252. /**
  137253. * Gets the color input component
  137254. */
  137255. get color(): NodeMaterialConnectionPoint;
  137256. /**
  137257. * Gets the roughness input component
  137258. */
  137259. get roughness(): NodeMaterialConnectionPoint;
  137260. /**
  137261. * Gets the texture input component
  137262. */
  137263. get texture(): NodeMaterialConnectionPoint;
  137264. /**
  137265. * Gets the sheen object output component
  137266. */
  137267. get sheen(): NodeMaterialConnectionPoint;
  137268. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137269. /**
  137270. * Gets the main code of the block (fragment side)
  137271. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137272. * @returns the shader code
  137273. */
  137274. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137275. protected _buildBlock(state: NodeMaterialBuildState): this;
  137276. protected _dumpPropertiesCode(): string;
  137277. serialize(): any;
  137278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137279. }
  137280. }
  137281. declare module BABYLON {
  137282. /**
  137283. * Block used to implement the reflectivity module of the PBR material
  137284. */
  137285. export class ReflectivityBlock extends NodeMaterialBlock {
  137286. /**
  137287. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137288. */
  137289. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137290. /**
  137291. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137292. */
  137293. useMetallnessFromMetallicTextureBlue: boolean;
  137294. /**
  137295. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137296. */
  137297. useRoughnessFromMetallicTextureAlpha: boolean;
  137298. /**
  137299. * Specifies if the metallic texture contains the roughness information in its green channel.
  137300. */
  137301. useRoughnessFromMetallicTextureGreen: boolean;
  137302. /**
  137303. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137304. */
  137305. useMetallicF0FactorFromMetallicTexture: boolean;
  137306. /**
  137307. * Create a new ReflectivityBlock
  137308. * @param name defines the block name
  137309. */
  137310. constructor(name: string);
  137311. /**
  137312. * Initialize the block and prepare the context for build
  137313. * @param state defines the state that will be used for the build
  137314. */
  137315. initialize(state: NodeMaterialBuildState): void;
  137316. /**
  137317. * Gets the current class name
  137318. * @returns the class name
  137319. */
  137320. getClassName(): string;
  137321. /**
  137322. * Gets the metallic input component
  137323. */
  137324. get metallic(): NodeMaterialConnectionPoint;
  137325. /**
  137326. * Gets the roughness input component
  137327. */
  137328. get roughness(): NodeMaterialConnectionPoint;
  137329. /**
  137330. * Gets the texture input component
  137331. */
  137332. get texture(): NodeMaterialConnectionPoint;
  137333. /**
  137334. * Gets the reflectivity object output component
  137335. */
  137336. get reflectivity(): NodeMaterialConnectionPoint;
  137337. /**
  137338. * Gets the main code of the block (fragment side)
  137339. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137340. * @returns the shader code
  137341. */
  137342. getCode(aoIntensityVarName: string): string;
  137343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137344. protected _buildBlock(state: NodeMaterialBuildState): this;
  137345. protected _dumpPropertiesCode(): string;
  137346. serialize(): any;
  137347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137348. }
  137349. }
  137350. declare module BABYLON {
  137351. /**
  137352. * Block used to implement the anisotropy module of the PBR material
  137353. */
  137354. export class AnisotropyBlock extends NodeMaterialBlock {
  137355. /**
  137356. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137357. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137358. * It's less burden on the user side in the editor part.
  137359. */
  137360. /** @hidden */
  137361. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137362. /** @hidden */
  137363. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137364. /**
  137365. * Create a new AnisotropyBlock
  137366. * @param name defines the block name
  137367. */
  137368. constructor(name: string);
  137369. /**
  137370. * Initialize the block and prepare the context for build
  137371. * @param state defines the state that will be used for the build
  137372. */
  137373. initialize(state: NodeMaterialBuildState): void;
  137374. /**
  137375. * Gets the current class name
  137376. * @returns the class name
  137377. */
  137378. getClassName(): string;
  137379. /**
  137380. * Gets the intensity input component
  137381. */
  137382. get intensity(): NodeMaterialConnectionPoint;
  137383. /**
  137384. * Gets the direction input component
  137385. */
  137386. get direction(): NodeMaterialConnectionPoint;
  137387. /**
  137388. * Gets the texture input component
  137389. */
  137390. get texture(): NodeMaterialConnectionPoint;
  137391. /**
  137392. * Gets the uv input component
  137393. */
  137394. get uv(): NodeMaterialConnectionPoint;
  137395. /**
  137396. * Gets the worldTangent input component
  137397. */
  137398. get worldTangent(): NodeMaterialConnectionPoint;
  137399. /**
  137400. * Gets the anisotropy object output component
  137401. */
  137402. get anisotropy(): NodeMaterialConnectionPoint;
  137403. private _generateTBNSpace;
  137404. /**
  137405. * Gets the main code of the block (fragment side)
  137406. * @param state current state of the node material building
  137407. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137408. * @returns the shader code
  137409. */
  137410. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137412. protected _buildBlock(state: NodeMaterialBuildState): this;
  137413. }
  137414. }
  137415. declare module BABYLON {
  137416. /**
  137417. * Block used to implement the clear coat module of the PBR material
  137418. */
  137419. export class ClearCoatBlock extends NodeMaterialBlock {
  137420. private _scene;
  137421. /**
  137422. * Create a new ClearCoatBlock
  137423. * @param name defines the block name
  137424. */
  137425. constructor(name: string);
  137426. /**
  137427. * Initialize the block and prepare the context for build
  137428. * @param state defines the state that will be used for the build
  137429. */
  137430. initialize(state: NodeMaterialBuildState): void;
  137431. /**
  137432. * Gets the current class name
  137433. * @returns the class name
  137434. */
  137435. getClassName(): string;
  137436. /**
  137437. * Gets the intensity input component
  137438. */
  137439. get intensity(): NodeMaterialConnectionPoint;
  137440. /**
  137441. * Gets the roughness input component
  137442. */
  137443. get roughness(): NodeMaterialConnectionPoint;
  137444. /**
  137445. * Gets the ior input component
  137446. */
  137447. get ior(): NodeMaterialConnectionPoint;
  137448. /**
  137449. * Gets the texture input component
  137450. */
  137451. get texture(): NodeMaterialConnectionPoint;
  137452. /**
  137453. * Gets the bump texture input component
  137454. */
  137455. get bumpTexture(): NodeMaterialConnectionPoint;
  137456. /**
  137457. * Gets the uv input component
  137458. */
  137459. get uv(): NodeMaterialConnectionPoint;
  137460. /**
  137461. * Gets the tint color input component
  137462. */
  137463. get tintColor(): NodeMaterialConnectionPoint;
  137464. /**
  137465. * Gets the tint "at distance" input component
  137466. */
  137467. get tintAtDistance(): NodeMaterialConnectionPoint;
  137468. /**
  137469. * Gets the tint thickness input component
  137470. */
  137471. get tintThickness(): NodeMaterialConnectionPoint;
  137472. /**
  137473. * Gets the tint texture input component
  137474. */
  137475. get tintTexture(): NodeMaterialConnectionPoint;
  137476. /**
  137477. * Gets the world tangent input component
  137478. */
  137479. get worldTangent(): NodeMaterialConnectionPoint;
  137480. /**
  137481. * Gets the clear coat object output component
  137482. */
  137483. get clearcoat(): NodeMaterialConnectionPoint;
  137484. autoConfigure(material: NodeMaterial): void;
  137485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137487. private _generateTBNSpace;
  137488. /**
  137489. * Gets the main code of the block (fragment side)
  137490. * @param state current state of the node material building
  137491. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137492. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137493. * @param worldPosVarName name of the variable holding the world position
  137494. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137495. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137496. * @param worldNormalVarName name of the variable holding the world normal
  137497. * @returns the shader code
  137498. */
  137499. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137500. protected _buildBlock(state: NodeMaterialBuildState): this;
  137501. }
  137502. }
  137503. declare module BABYLON {
  137504. /**
  137505. * Block used to implement the sub surface module of the PBR material
  137506. */
  137507. export class SubSurfaceBlock extends NodeMaterialBlock {
  137508. /**
  137509. * Create a new SubSurfaceBlock
  137510. * @param name defines the block name
  137511. */
  137512. constructor(name: string);
  137513. /**
  137514. * Stores the intensity of the different subsurface effects in the thickness texture.
  137515. * * the green channel is the translucency intensity.
  137516. * * the blue channel is the scattering intensity.
  137517. * * the alpha channel is the refraction intensity.
  137518. */
  137519. useMaskFromThicknessTexture: boolean;
  137520. /**
  137521. * Initialize the block and prepare the context for build
  137522. * @param state defines the state that will be used for the build
  137523. */
  137524. initialize(state: NodeMaterialBuildState): void;
  137525. /**
  137526. * Gets the current class name
  137527. * @returns the class name
  137528. */
  137529. getClassName(): string;
  137530. /**
  137531. * Gets the min thickness input component
  137532. */
  137533. get minThickness(): NodeMaterialConnectionPoint;
  137534. /**
  137535. * Gets the max thickness input component
  137536. */
  137537. get maxThickness(): NodeMaterialConnectionPoint;
  137538. /**
  137539. * Gets the thickness texture component
  137540. */
  137541. get thicknessTexture(): NodeMaterialConnectionPoint;
  137542. /**
  137543. * Gets the tint color input component
  137544. */
  137545. get tintColor(): NodeMaterialConnectionPoint;
  137546. /**
  137547. * Gets the translucency intensity input component
  137548. */
  137549. get translucencyIntensity(): NodeMaterialConnectionPoint;
  137550. /**
  137551. * Gets the translucency diffusion distance input component
  137552. */
  137553. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  137554. /**
  137555. * Gets the refraction object parameters
  137556. */
  137557. get refraction(): NodeMaterialConnectionPoint;
  137558. /**
  137559. * Gets the sub surface object output component
  137560. */
  137561. get subsurface(): NodeMaterialConnectionPoint;
  137562. autoConfigure(material: NodeMaterial): void;
  137563. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137564. /**
  137565. * Gets the main code of the block (fragment side)
  137566. * @param state current state of the node material building
  137567. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  137568. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137569. * @param worldPosVarName name of the variable holding the world position
  137570. * @returns the shader code
  137571. */
  137572. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  137573. protected _buildBlock(state: NodeMaterialBuildState): this;
  137574. }
  137575. }
  137576. declare module BABYLON {
  137577. /**
  137578. * Block used to implement the PBR metallic/roughness model
  137579. */
  137580. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  137581. /**
  137582. * Gets or sets the light associated with this block
  137583. */
  137584. light: Nullable<Light>;
  137585. private _lightId;
  137586. private _scene;
  137587. private _environmentBRDFTexture;
  137588. private _environmentBrdfSamplerName;
  137589. private _vNormalWName;
  137590. private _invertNormalName;
  137591. /**
  137592. * Create a new ReflectionBlock
  137593. * @param name defines the block name
  137594. */
  137595. constructor(name: string);
  137596. /**
  137597. * Intensity of the direct lights e.g. the four lights available in your scene.
  137598. * This impacts both the direct diffuse and specular highlights.
  137599. */
  137600. directIntensity: number;
  137601. /**
  137602. * Intensity of the environment e.g. how much the environment will light the object
  137603. * either through harmonics for rough material or through the refelction for shiny ones.
  137604. */
  137605. environmentIntensity: number;
  137606. /**
  137607. * This is a special control allowing the reduction of the specular highlights coming from the
  137608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137609. */
  137610. specularIntensity: number;
  137611. /**
  137612. * Defines the falloff type used in this material.
  137613. * It by default is Physical.
  137614. */
  137615. lightFalloff: number;
  137616. /**
  137617. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137618. */
  137619. useAlphaFromAlbedoTexture: boolean;
  137620. /**
  137621. * Specifies that alpha test should be used
  137622. */
  137623. useAlphaTest: boolean;
  137624. /**
  137625. * Defines the alpha limits in alpha test mode.
  137626. */
  137627. alphaTestCutoff: number;
  137628. /**
  137629. * Specifies that alpha blending should be used
  137630. */
  137631. useAlphaBlending: boolean;
  137632. /**
  137633. * Defines if the alpha value should be determined via the rgb values.
  137634. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  137635. */
  137636. opacityRGB: boolean;
  137637. /**
  137638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  137639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137640. */
  137641. useRadianceOverAlpha: boolean;
  137642. /**
  137643. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  137644. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137645. */
  137646. useSpecularOverAlpha: boolean;
  137647. /**
  137648. * Enables specular anti aliasing in the PBR shader.
  137649. * It will both interacts on the Geometry for analytical and IBL lighting.
  137650. * It also prefilter the roughness map based on the bump values.
  137651. */
  137652. enableSpecularAntiAliasing: boolean;
  137653. /**
  137654. * Defines if the material uses energy conservation.
  137655. */
  137656. useEnergyConservation: boolean;
  137657. /**
  137658. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137659. * too much the area relying on ambient texture to define their ambient occlusion.
  137660. */
  137661. useRadianceOcclusion: boolean;
  137662. /**
  137663. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137664. * makes the reflect vector face the model (under horizon).
  137665. */
  137666. useHorizonOcclusion: boolean;
  137667. /**
  137668. * If set to true, no lighting calculations will be applied.
  137669. */
  137670. unlit: boolean;
  137671. /**
  137672. * Force normal to face away from face.
  137673. */
  137674. forceNormalForward: boolean;
  137675. /**
  137676. * Defines the material debug mode.
  137677. * It helps seeing only some components of the material while troubleshooting.
  137678. */
  137679. debugMode: number;
  137680. /**
  137681. * Specify from where on screen the debug mode should start.
  137682. * The value goes from -1 (full screen) to 1 (not visible)
  137683. * It helps with side by side comparison against the final render
  137684. * This defaults to 0
  137685. */
  137686. debugLimit: number;
  137687. /**
  137688. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137689. * You can use the factor to better multiply the final value.
  137690. */
  137691. debugFactor: number;
  137692. /**
  137693. * Initialize the block and prepare the context for build
  137694. * @param state defines the state that will be used for the build
  137695. */
  137696. initialize(state: NodeMaterialBuildState): void;
  137697. /**
  137698. * Gets the current class name
  137699. * @returns the class name
  137700. */
  137701. getClassName(): string;
  137702. /**
  137703. * Gets the world position input component
  137704. */
  137705. get worldPosition(): NodeMaterialConnectionPoint;
  137706. /**
  137707. * Gets the world normal input component
  137708. */
  137709. get worldNormal(): NodeMaterialConnectionPoint;
  137710. /**
  137711. * Gets the perturbed normal input component
  137712. */
  137713. get perturbedNormal(): NodeMaterialConnectionPoint;
  137714. /**
  137715. * Gets the camera position input component
  137716. */
  137717. get cameraPosition(): NodeMaterialConnectionPoint;
  137718. /**
  137719. * Gets the base color input component
  137720. */
  137721. get baseColor(): NodeMaterialConnectionPoint;
  137722. /**
  137723. * Gets the base texture input component
  137724. */
  137725. get baseTexture(): NodeMaterialConnectionPoint;
  137726. /**
  137727. * Gets the opacity texture input component
  137728. */
  137729. get opacityTexture(): NodeMaterialConnectionPoint;
  137730. /**
  137731. * Gets the ambient color input component
  137732. */
  137733. get ambientColor(): NodeMaterialConnectionPoint;
  137734. /**
  137735. * Gets the reflectivity object parameters
  137736. */
  137737. get reflectivity(): NodeMaterialConnectionPoint;
  137738. /**
  137739. * Gets the ambient occlusion object parameters
  137740. */
  137741. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137742. /**
  137743. * Gets the reflection object parameters
  137744. */
  137745. get reflection(): NodeMaterialConnectionPoint;
  137746. /**
  137747. * Gets the sheen object parameters
  137748. */
  137749. get sheen(): NodeMaterialConnectionPoint;
  137750. /**
  137751. * Gets the clear coat object parameters
  137752. */
  137753. get clearcoat(): NodeMaterialConnectionPoint;
  137754. /**
  137755. * Gets the sub surface object parameters
  137756. */
  137757. get subsurface(): NodeMaterialConnectionPoint;
  137758. /**
  137759. * Gets the anisotropy object parameters
  137760. */
  137761. get anisotropy(): NodeMaterialConnectionPoint;
  137762. /**
  137763. * Gets the ambient output component
  137764. */
  137765. get ambient(): NodeMaterialConnectionPoint;
  137766. /**
  137767. * Gets the diffuse output component
  137768. */
  137769. get diffuse(): NodeMaterialConnectionPoint;
  137770. /**
  137771. * Gets the specular output component
  137772. */
  137773. get specular(): NodeMaterialConnectionPoint;
  137774. /**
  137775. * Gets the sheen output component
  137776. */
  137777. get sheenDir(): NodeMaterialConnectionPoint;
  137778. /**
  137779. * Gets the clear coat output component
  137780. */
  137781. get clearcoatDir(): NodeMaterialConnectionPoint;
  137782. /**
  137783. * Gets the indirect diffuse output component
  137784. */
  137785. get diffuseIndirect(): NodeMaterialConnectionPoint;
  137786. /**
  137787. * Gets the indirect specular output component
  137788. */
  137789. get specularIndirect(): NodeMaterialConnectionPoint;
  137790. /**
  137791. * Gets the indirect sheen output component
  137792. */
  137793. get sheenIndirect(): NodeMaterialConnectionPoint;
  137794. /**
  137795. * Gets the indirect clear coat output component
  137796. */
  137797. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  137798. /**
  137799. * Gets the refraction output component
  137800. */
  137801. get refraction(): NodeMaterialConnectionPoint;
  137802. /**
  137803. * Gets the global lighting output component
  137804. */
  137805. get lighting(): NodeMaterialConnectionPoint;
  137806. /**
  137807. * Gets the shadow output component
  137808. */
  137809. get shadow(): NodeMaterialConnectionPoint;
  137810. /**
  137811. * Gets the alpha output component
  137812. */
  137813. get alpha(): NodeMaterialConnectionPoint;
  137814. autoConfigure(material: NodeMaterial): void;
  137815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137816. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  137817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137818. private _injectVertexCode;
  137819. /**
  137820. * Gets the code corresponding to the albedo/opacity module
  137821. * @returns the shader code
  137822. */
  137823. getAlbedoOpacityCode(): string;
  137824. protected _buildBlock(state: NodeMaterialBuildState): this;
  137825. protected _dumpPropertiesCode(): string;
  137826. serialize(): any;
  137827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137828. }
  137829. }
  137830. declare module BABYLON {
  137831. /**
  137832. * Effect Render Options
  137833. */
  137834. export interface IEffectRendererOptions {
  137835. /**
  137836. * Defines the vertices positions.
  137837. */
  137838. positions?: number[];
  137839. /**
  137840. * Defines the indices.
  137841. */
  137842. indices?: number[];
  137843. }
  137844. /**
  137845. * Helper class to render one or more effects.
  137846. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137847. */
  137848. export class EffectRenderer {
  137849. private engine;
  137850. private static _DefaultOptions;
  137851. private _vertexBuffers;
  137852. private _indexBuffer;
  137853. private _fullscreenViewport;
  137854. /**
  137855. * Creates an effect renderer
  137856. * @param engine the engine to use for rendering
  137857. * @param options defines the options of the effect renderer
  137858. */
  137859. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137860. /**
  137861. * Sets the current viewport in normalized coordinates 0-1
  137862. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137863. */
  137864. setViewport(viewport?: Viewport): void;
  137865. /**
  137866. * Binds the embedded attributes buffer to the effect.
  137867. * @param effect Defines the effect to bind the attributes for
  137868. */
  137869. bindBuffers(effect: Effect): void;
  137870. /**
  137871. * Sets the current effect wrapper to use during draw.
  137872. * The effect needs to be ready before calling this api.
  137873. * This also sets the default full screen position attribute.
  137874. * @param effectWrapper Defines the effect to draw with
  137875. */
  137876. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137877. /**
  137878. * Draws a full screen quad.
  137879. */
  137880. draw(): void;
  137881. private isRenderTargetTexture;
  137882. /**
  137883. * renders one or more effects to a specified texture
  137884. * @param effectWrapper the effect to renderer
  137885. * @param outputTexture texture to draw to, if null it will render to the screen.
  137886. */
  137887. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137888. /**
  137889. * Disposes of the effect renderer
  137890. */
  137891. dispose(): void;
  137892. }
  137893. /**
  137894. * Options to create an EffectWrapper
  137895. */
  137896. interface EffectWrapperCreationOptions {
  137897. /**
  137898. * Engine to use to create the effect
  137899. */
  137900. engine: ThinEngine;
  137901. /**
  137902. * Fragment shader for the effect
  137903. */
  137904. fragmentShader: string;
  137905. /**
  137906. * Vertex shader for the effect
  137907. */
  137908. vertexShader?: string;
  137909. /**
  137910. * Attributes to use in the shader
  137911. */
  137912. attributeNames?: Array<string>;
  137913. /**
  137914. * Uniforms to use in the shader
  137915. */
  137916. uniformNames?: Array<string>;
  137917. /**
  137918. * Texture sampler names to use in the shader
  137919. */
  137920. samplerNames?: Array<string>;
  137921. /**
  137922. * The friendly name of the effect displayed in Spector.
  137923. */
  137924. name?: string;
  137925. }
  137926. /**
  137927. * Wraps an effect to be used for rendering
  137928. */
  137929. export class EffectWrapper {
  137930. /**
  137931. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137932. */
  137933. onApplyObservable: Observable<{}>;
  137934. /**
  137935. * The underlying effect
  137936. */
  137937. effect: Effect;
  137938. /**
  137939. * Creates an effect to be renderer
  137940. * @param creationOptions options to create the effect
  137941. */
  137942. constructor(creationOptions: EffectWrapperCreationOptions);
  137943. /**
  137944. * Disposes of the effect wrapper
  137945. */
  137946. dispose(): void;
  137947. }
  137948. }
  137949. declare module BABYLON {
  137950. /**
  137951. * Helper class to push actions to a pool of workers.
  137952. */
  137953. export class WorkerPool implements IDisposable {
  137954. private _workerInfos;
  137955. private _pendingActions;
  137956. /**
  137957. * Constructor
  137958. * @param workers Array of workers to use for actions
  137959. */
  137960. constructor(workers: Array<Worker>);
  137961. /**
  137962. * Terminates all workers and clears any pending actions.
  137963. */
  137964. dispose(): void;
  137965. /**
  137966. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137967. * pended until a worker has completed its action.
  137968. * @param action The action to perform. Call onComplete when the action is complete.
  137969. */
  137970. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137971. private _execute;
  137972. }
  137973. }
  137974. declare module BABYLON {
  137975. /**
  137976. * Configuration for Draco compression
  137977. */
  137978. export interface IDracoCompressionConfiguration {
  137979. /**
  137980. * Configuration for the decoder.
  137981. */
  137982. decoder: {
  137983. /**
  137984. * The url to the WebAssembly module.
  137985. */
  137986. wasmUrl?: string;
  137987. /**
  137988. * The url to the WebAssembly binary.
  137989. */
  137990. wasmBinaryUrl?: string;
  137991. /**
  137992. * The url to the fallback JavaScript module.
  137993. */
  137994. fallbackUrl?: string;
  137995. };
  137996. }
  137997. /**
  137998. * Draco compression (https://google.github.io/draco/)
  137999. *
  138000. * This class wraps the Draco module.
  138001. *
  138002. * **Encoder**
  138003. *
  138004. * The encoder is not currently implemented.
  138005. *
  138006. * **Decoder**
  138007. *
  138008. * 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.
  138009. *
  138010. * To update the configuration, use the following code:
  138011. * ```javascript
  138012. * DracoCompression.Configuration = {
  138013. * decoder: {
  138014. * wasmUrl: "<url to the WebAssembly library>",
  138015. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138016. * fallbackUrl: "<url to the fallback JavaScript library>",
  138017. * }
  138018. * };
  138019. * ```
  138020. *
  138021. * 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.
  138022. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138023. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138024. *
  138025. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138026. * ```javascript
  138027. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138028. * ```
  138029. *
  138030. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138031. */
  138032. export class DracoCompression implements IDisposable {
  138033. private _workerPoolPromise?;
  138034. private _decoderModulePromise?;
  138035. /**
  138036. * The configuration. Defaults to the following urls:
  138037. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138038. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138039. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138040. */
  138041. static Configuration: IDracoCompressionConfiguration;
  138042. /**
  138043. * Returns true if the decoder configuration is available.
  138044. */
  138045. static get DecoderAvailable(): boolean;
  138046. /**
  138047. * Default number of workers to create when creating the draco compression object.
  138048. */
  138049. static DefaultNumWorkers: number;
  138050. private static GetDefaultNumWorkers;
  138051. private static _Default;
  138052. /**
  138053. * Default instance for the draco compression object.
  138054. */
  138055. static get Default(): DracoCompression;
  138056. /**
  138057. * Constructor
  138058. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138059. */
  138060. constructor(numWorkers?: number);
  138061. /**
  138062. * Stop all async operations and release resources.
  138063. */
  138064. dispose(): void;
  138065. /**
  138066. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138067. * @returns a promise that resolves when ready
  138068. */
  138069. whenReadyAsync(): Promise<void>;
  138070. /**
  138071. * Decode Draco compressed mesh data to vertex data.
  138072. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138073. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138074. * @returns A promise that resolves with the decoded vertex data
  138075. */
  138076. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138077. [kind: string]: number;
  138078. }): Promise<VertexData>;
  138079. }
  138080. }
  138081. declare module BABYLON {
  138082. /**
  138083. * Class for building Constructive Solid Geometry
  138084. */
  138085. export class CSG {
  138086. private polygons;
  138087. /**
  138088. * The world matrix
  138089. */
  138090. matrix: Matrix;
  138091. /**
  138092. * Stores the position
  138093. */
  138094. position: Vector3;
  138095. /**
  138096. * Stores the rotation
  138097. */
  138098. rotation: Vector3;
  138099. /**
  138100. * Stores the rotation quaternion
  138101. */
  138102. rotationQuaternion: Nullable<Quaternion>;
  138103. /**
  138104. * Stores the scaling vector
  138105. */
  138106. scaling: Vector3;
  138107. /**
  138108. * Convert the Mesh to CSG
  138109. * @param mesh The Mesh to convert to CSG
  138110. * @returns A new CSG from the Mesh
  138111. */
  138112. static FromMesh(mesh: Mesh): CSG;
  138113. /**
  138114. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138115. * @param polygons Polygons used to construct a CSG solid
  138116. */
  138117. private static FromPolygons;
  138118. /**
  138119. * Clones, or makes a deep copy, of the CSG
  138120. * @returns A new CSG
  138121. */
  138122. clone(): CSG;
  138123. /**
  138124. * Unions this CSG with another CSG
  138125. * @param csg The CSG to union against this CSG
  138126. * @returns The unioned CSG
  138127. */
  138128. union(csg: CSG): CSG;
  138129. /**
  138130. * Unions this CSG with another CSG in place
  138131. * @param csg The CSG to union against this CSG
  138132. */
  138133. unionInPlace(csg: CSG): void;
  138134. /**
  138135. * Subtracts this CSG with another CSG
  138136. * @param csg The CSG to subtract against this CSG
  138137. * @returns A new CSG
  138138. */
  138139. subtract(csg: CSG): CSG;
  138140. /**
  138141. * Subtracts this CSG with another CSG in place
  138142. * @param csg The CSG to subtact against this CSG
  138143. */
  138144. subtractInPlace(csg: CSG): void;
  138145. /**
  138146. * Intersect this CSG with another CSG
  138147. * @param csg The CSG to intersect against this CSG
  138148. * @returns A new CSG
  138149. */
  138150. intersect(csg: CSG): CSG;
  138151. /**
  138152. * Intersects this CSG with another CSG in place
  138153. * @param csg The CSG to intersect against this CSG
  138154. */
  138155. intersectInPlace(csg: CSG): void;
  138156. /**
  138157. * Return a new CSG solid with solid and empty space switched. This solid is
  138158. * not modified.
  138159. * @returns A new CSG solid with solid and empty space switched
  138160. */
  138161. inverse(): CSG;
  138162. /**
  138163. * Inverses the CSG in place
  138164. */
  138165. inverseInPlace(): void;
  138166. /**
  138167. * This is used to keep meshes transformations so they can be restored
  138168. * when we build back a Babylon Mesh
  138169. * NB : All CSG operations are performed in world coordinates
  138170. * @param csg The CSG to copy the transform attributes from
  138171. * @returns This CSG
  138172. */
  138173. copyTransformAttributes(csg: CSG): CSG;
  138174. /**
  138175. * Build Raw mesh from CSG
  138176. * Coordinates here are in world space
  138177. * @param name The name of the mesh geometry
  138178. * @param scene The Scene
  138179. * @param keepSubMeshes Specifies if the submeshes should be kept
  138180. * @returns A new Mesh
  138181. */
  138182. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138183. /**
  138184. * Build Mesh from CSG taking material and transforms into account
  138185. * @param name The name of the Mesh
  138186. * @param material The material of the Mesh
  138187. * @param scene The Scene
  138188. * @param keepSubMeshes Specifies if submeshes should be kept
  138189. * @returns The new Mesh
  138190. */
  138191. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138192. }
  138193. }
  138194. declare module BABYLON {
  138195. /**
  138196. * Class used to create a trail following a mesh
  138197. */
  138198. export class TrailMesh extends Mesh {
  138199. private _generator;
  138200. private _autoStart;
  138201. private _running;
  138202. private _diameter;
  138203. private _length;
  138204. private _sectionPolygonPointsCount;
  138205. private _sectionVectors;
  138206. private _sectionNormalVectors;
  138207. private _beforeRenderObserver;
  138208. /**
  138209. * @constructor
  138210. * @param name The value used by scene.getMeshByName() to do a lookup.
  138211. * @param generator The mesh or transform node to generate a trail.
  138212. * @param scene The scene to add this mesh to.
  138213. * @param diameter Diameter of trailing mesh. Default is 1.
  138214. * @param length Length of trailing mesh. Default is 60.
  138215. * @param autoStart Automatically start trailing mesh. Default true.
  138216. */
  138217. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138218. /**
  138219. * "TrailMesh"
  138220. * @returns "TrailMesh"
  138221. */
  138222. getClassName(): string;
  138223. private _createMesh;
  138224. /**
  138225. * Start trailing mesh.
  138226. */
  138227. start(): void;
  138228. /**
  138229. * Stop trailing mesh.
  138230. */
  138231. stop(): void;
  138232. /**
  138233. * Update trailing mesh geometry.
  138234. */
  138235. update(): void;
  138236. /**
  138237. * Returns a new TrailMesh object.
  138238. * @param name is a string, the name given to the new mesh
  138239. * @param newGenerator use new generator object for cloned trail mesh
  138240. * @returns a new mesh
  138241. */
  138242. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138243. /**
  138244. * Serializes this trail mesh
  138245. * @param serializationObject object to write serialization to
  138246. */
  138247. serialize(serializationObject: any): void;
  138248. /**
  138249. * Parses a serialized trail mesh
  138250. * @param parsedMesh the serialized mesh
  138251. * @param scene the scene to create the trail mesh in
  138252. * @returns the created trail mesh
  138253. */
  138254. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138255. }
  138256. }
  138257. declare module BABYLON {
  138258. /**
  138259. * Class containing static functions to help procedurally build meshes
  138260. */
  138261. export class TiledBoxBuilder {
  138262. /**
  138263. * Creates a box mesh
  138264. * 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)
  138265. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138269. * @param name defines the name of the mesh
  138270. * @param options defines the options used to create the mesh
  138271. * @param scene defines the hosting scene
  138272. * @returns the box mesh
  138273. */
  138274. static CreateTiledBox(name: string, options: {
  138275. pattern?: number;
  138276. width?: number;
  138277. height?: number;
  138278. depth?: number;
  138279. tileSize?: number;
  138280. tileWidth?: number;
  138281. tileHeight?: number;
  138282. alignHorizontal?: number;
  138283. alignVertical?: number;
  138284. faceUV?: Vector4[];
  138285. faceColors?: Color4[];
  138286. sideOrientation?: number;
  138287. updatable?: boolean;
  138288. }, scene?: Nullable<Scene>): Mesh;
  138289. }
  138290. }
  138291. declare module BABYLON {
  138292. /**
  138293. * Class containing static functions to help procedurally build meshes
  138294. */
  138295. export class TorusKnotBuilder {
  138296. /**
  138297. * Creates a torus knot mesh
  138298. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138299. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138300. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138301. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138305. * @param name defines the name of the mesh
  138306. * @param options defines the options used to create the mesh
  138307. * @param scene defines the hosting scene
  138308. * @returns the torus knot mesh
  138309. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138310. */
  138311. static CreateTorusKnot(name: string, options: {
  138312. radius?: number;
  138313. tube?: number;
  138314. radialSegments?: number;
  138315. tubularSegments?: number;
  138316. p?: number;
  138317. q?: number;
  138318. updatable?: boolean;
  138319. sideOrientation?: number;
  138320. frontUVs?: Vector4;
  138321. backUVs?: Vector4;
  138322. }, scene: any): Mesh;
  138323. }
  138324. }
  138325. declare module BABYLON {
  138326. /**
  138327. * Polygon
  138328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138329. */
  138330. export class Polygon {
  138331. /**
  138332. * Creates a rectangle
  138333. * @param xmin bottom X coord
  138334. * @param ymin bottom Y coord
  138335. * @param xmax top X coord
  138336. * @param ymax top Y coord
  138337. * @returns points that make the resulting rectation
  138338. */
  138339. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138340. /**
  138341. * Creates a circle
  138342. * @param radius radius of circle
  138343. * @param cx scale in x
  138344. * @param cy scale in y
  138345. * @param numberOfSides number of sides that make up the circle
  138346. * @returns points that make the resulting circle
  138347. */
  138348. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138349. /**
  138350. * Creates a polygon from input string
  138351. * @param input Input polygon data
  138352. * @returns the parsed points
  138353. */
  138354. static Parse(input: string): Vector2[];
  138355. /**
  138356. * Starts building a polygon from x and y coordinates
  138357. * @param x x coordinate
  138358. * @param y y coordinate
  138359. * @returns the started path2
  138360. */
  138361. static StartingAt(x: number, y: number): Path2;
  138362. }
  138363. /**
  138364. * Builds a polygon
  138365. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138366. */
  138367. export class PolygonMeshBuilder {
  138368. private _points;
  138369. private _outlinepoints;
  138370. private _holes;
  138371. private _name;
  138372. private _scene;
  138373. private _epoints;
  138374. private _eholes;
  138375. private _addToepoint;
  138376. /**
  138377. * Babylon reference to the earcut plugin.
  138378. */
  138379. bjsEarcut: any;
  138380. /**
  138381. * Creates a PolygonMeshBuilder
  138382. * @param name name of the builder
  138383. * @param contours Path of the polygon
  138384. * @param scene scene to add to when creating the mesh
  138385. * @param earcutInjection can be used to inject your own earcut reference
  138386. */
  138387. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138388. /**
  138389. * Adds a whole within the polygon
  138390. * @param hole Array of points defining the hole
  138391. * @returns this
  138392. */
  138393. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138394. /**
  138395. * Creates the polygon
  138396. * @param updatable If the mesh should be updatable
  138397. * @param depth The depth of the mesh created
  138398. * @returns the created mesh
  138399. */
  138400. build(updatable?: boolean, depth?: number): Mesh;
  138401. /**
  138402. * Creates the polygon
  138403. * @param depth The depth of the mesh created
  138404. * @returns the created VertexData
  138405. */
  138406. buildVertexData(depth?: number): VertexData;
  138407. /**
  138408. * Adds a side to the polygon
  138409. * @param positions points that make the polygon
  138410. * @param normals normals of the polygon
  138411. * @param uvs uvs of the polygon
  138412. * @param indices indices of the polygon
  138413. * @param bounds bounds of the polygon
  138414. * @param points points of the polygon
  138415. * @param depth depth of the polygon
  138416. * @param flip flip of the polygon
  138417. */
  138418. private addSide;
  138419. }
  138420. }
  138421. declare module BABYLON {
  138422. /**
  138423. * Class containing static functions to help procedurally build meshes
  138424. */
  138425. export class PolygonBuilder {
  138426. /**
  138427. * Creates a polygon mesh
  138428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138429. * * 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
  138430. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  138433. * * Remember you can only change the shape positions, not their number when updating a polygon
  138434. * @param name defines the name of the mesh
  138435. * @param options defines the options used to create the mesh
  138436. * @param scene defines the hosting scene
  138437. * @param earcutInjection can be used to inject your own earcut reference
  138438. * @returns the polygon mesh
  138439. */
  138440. static CreatePolygon(name: string, options: {
  138441. shape: Vector3[];
  138442. holes?: Vector3[][];
  138443. depth?: number;
  138444. faceUV?: Vector4[];
  138445. faceColors?: Color4[];
  138446. updatable?: boolean;
  138447. sideOrientation?: number;
  138448. frontUVs?: Vector4;
  138449. backUVs?: Vector4;
  138450. wrap?: boolean;
  138451. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138452. /**
  138453. * Creates an extruded polygon mesh, with depth in the Y direction.
  138454. * * 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)
  138455. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138456. * @param name defines the name of the mesh
  138457. * @param options defines the options used to create the mesh
  138458. * @param scene defines the hosting scene
  138459. * @param earcutInjection can be used to inject your own earcut reference
  138460. * @returns the polygon mesh
  138461. */
  138462. static ExtrudePolygon(name: string, options: {
  138463. shape: Vector3[];
  138464. holes?: Vector3[][];
  138465. depth?: number;
  138466. faceUV?: Vector4[];
  138467. faceColors?: Color4[];
  138468. updatable?: boolean;
  138469. sideOrientation?: number;
  138470. frontUVs?: Vector4;
  138471. backUVs?: Vector4;
  138472. wrap?: boolean;
  138473. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138474. }
  138475. }
  138476. declare module BABYLON {
  138477. /**
  138478. * Class containing static functions to help procedurally build meshes
  138479. */
  138480. export class LatheBuilder {
  138481. /**
  138482. * Creates lathe mesh.
  138483. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138484. * * 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
  138485. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138486. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138487. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138488. * * 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
  138489. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138490. * * 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
  138491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138495. * @param name defines the name of the mesh
  138496. * @param options defines the options used to create the mesh
  138497. * @param scene defines the hosting scene
  138498. * @returns the lathe mesh
  138499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138500. */
  138501. static CreateLathe(name: string, options: {
  138502. shape: Vector3[];
  138503. radius?: number;
  138504. tessellation?: number;
  138505. clip?: number;
  138506. arc?: number;
  138507. closed?: boolean;
  138508. updatable?: boolean;
  138509. sideOrientation?: number;
  138510. frontUVs?: Vector4;
  138511. backUVs?: Vector4;
  138512. cap?: number;
  138513. invertUV?: boolean;
  138514. }, scene?: Nullable<Scene>): Mesh;
  138515. }
  138516. }
  138517. declare module BABYLON {
  138518. /**
  138519. * Class containing static functions to help procedurally build meshes
  138520. */
  138521. export class TiledPlaneBuilder {
  138522. /**
  138523. * Creates a tiled plane mesh
  138524. * * The parameter `pattern` will, depending on value, do nothing or
  138525. * * * flip (reflect about central vertical) alternate tiles across and up
  138526. * * * flip every tile on alternate rows
  138527. * * * rotate (180 degs) alternate tiles across and up
  138528. * * * rotate every tile on alternate rows
  138529. * * * flip and rotate alternate tiles across and up
  138530. * * * flip and rotate every tile on alternate rows
  138531. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138532. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138535. * * 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)
  138536. * * 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)
  138537. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138538. * @param name defines the name of the mesh
  138539. * @param options defines the options used to create the mesh
  138540. * @param scene defines the hosting scene
  138541. * @returns the box mesh
  138542. */
  138543. static CreateTiledPlane(name: string, options: {
  138544. pattern?: number;
  138545. tileSize?: number;
  138546. tileWidth?: number;
  138547. tileHeight?: number;
  138548. size?: number;
  138549. width?: number;
  138550. height?: number;
  138551. alignHorizontal?: number;
  138552. alignVertical?: number;
  138553. sideOrientation?: number;
  138554. frontUVs?: Vector4;
  138555. backUVs?: Vector4;
  138556. updatable?: boolean;
  138557. }, scene?: Nullable<Scene>): Mesh;
  138558. }
  138559. }
  138560. declare module BABYLON {
  138561. /**
  138562. * Class containing static functions to help procedurally build meshes
  138563. */
  138564. export class TubeBuilder {
  138565. /**
  138566. * Creates a tube mesh.
  138567. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138568. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138569. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138570. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138571. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138572. * * 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)
  138573. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138574. * * 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
  138575. * * 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
  138576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138578. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138580. * @param name defines the name of the mesh
  138581. * @param options defines the options used to create the mesh
  138582. * @param scene defines the hosting scene
  138583. * @returns the tube mesh
  138584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138585. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138586. */
  138587. static CreateTube(name: string, options: {
  138588. path: Vector3[];
  138589. radius?: number;
  138590. tessellation?: number;
  138591. radiusFunction?: {
  138592. (i: number, distance: number): number;
  138593. };
  138594. cap?: number;
  138595. arc?: number;
  138596. updatable?: boolean;
  138597. sideOrientation?: number;
  138598. frontUVs?: Vector4;
  138599. backUVs?: Vector4;
  138600. instance?: Mesh;
  138601. invertUV?: boolean;
  138602. }, scene?: Nullable<Scene>): Mesh;
  138603. }
  138604. }
  138605. declare module BABYLON {
  138606. /**
  138607. * Class containing static functions to help procedurally build meshes
  138608. */
  138609. export class IcoSphereBuilder {
  138610. /**
  138611. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138612. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138613. * * 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`)
  138614. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138615. * * 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
  138616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138619. * @param name defines the name of the mesh
  138620. * @param options defines the options used to create the mesh
  138621. * @param scene defines the hosting scene
  138622. * @returns the icosahedron mesh
  138623. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138624. */
  138625. static CreateIcoSphere(name: string, options: {
  138626. radius?: number;
  138627. radiusX?: number;
  138628. radiusY?: number;
  138629. radiusZ?: number;
  138630. flat?: boolean;
  138631. subdivisions?: number;
  138632. sideOrientation?: number;
  138633. frontUVs?: Vector4;
  138634. backUVs?: Vector4;
  138635. updatable?: boolean;
  138636. }, scene?: Nullable<Scene>): Mesh;
  138637. }
  138638. }
  138639. declare module BABYLON {
  138640. /**
  138641. * Class containing static functions to help procedurally build meshes
  138642. */
  138643. export class DecalBuilder {
  138644. /**
  138645. * Creates a decal mesh.
  138646. * 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
  138647. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  138648. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  138649. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  138650. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  138651. * @param name defines the name of the mesh
  138652. * @param sourceMesh defines the mesh where the decal must be applied
  138653. * @param options defines the options used to create the mesh
  138654. * @param scene defines the hosting scene
  138655. * @returns the decal mesh
  138656. * @see https://doc.babylonjs.com/how_to/decals
  138657. */
  138658. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  138659. position?: Vector3;
  138660. normal?: Vector3;
  138661. size?: Vector3;
  138662. angle?: number;
  138663. }): Mesh;
  138664. }
  138665. }
  138666. declare module BABYLON {
  138667. /**
  138668. * Class containing static functions to help procedurally build meshes
  138669. */
  138670. export class MeshBuilder {
  138671. /**
  138672. * Creates a box mesh
  138673. * * The parameter `size` sets the size (float) of each box side (default 1)
  138674. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  138675. * * 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)
  138676. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138680. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138681. * @param name defines the name of the mesh
  138682. * @param options defines the options used to create the mesh
  138683. * @param scene defines the hosting scene
  138684. * @returns the box mesh
  138685. */
  138686. static CreateBox(name: string, options: {
  138687. size?: number;
  138688. width?: number;
  138689. height?: number;
  138690. depth?: number;
  138691. faceUV?: Vector4[];
  138692. faceColors?: Color4[];
  138693. sideOrientation?: number;
  138694. frontUVs?: Vector4;
  138695. backUVs?: Vector4;
  138696. wrap?: boolean;
  138697. topBaseAt?: number;
  138698. bottomBaseAt?: number;
  138699. updatable?: boolean;
  138700. }, scene?: Nullable<Scene>): Mesh;
  138701. /**
  138702. * Creates a tiled box mesh
  138703. * * faceTiles sets the pattern, tile size and number of tiles for a face
  138704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138705. * @param name defines the name of the mesh
  138706. * @param options defines the options used to create the mesh
  138707. * @param scene defines the hosting scene
  138708. * @returns the tiled box mesh
  138709. */
  138710. static CreateTiledBox(name: string, options: {
  138711. pattern?: number;
  138712. size?: number;
  138713. width?: number;
  138714. height?: number;
  138715. depth: number;
  138716. tileSize?: number;
  138717. tileWidth?: number;
  138718. tileHeight?: number;
  138719. faceUV?: Vector4[];
  138720. faceColors?: Color4[];
  138721. alignHorizontal?: number;
  138722. alignVertical?: number;
  138723. sideOrientation?: number;
  138724. updatable?: boolean;
  138725. }, scene?: Nullable<Scene>): Mesh;
  138726. /**
  138727. * Creates a sphere mesh
  138728. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  138729. * * 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`)
  138730. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  138731. * * 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
  138732. * * 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)
  138733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138736. * @param name defines the name of the mesh
  138737. * @param options defines the options used to create the mesh
  138738. * @param scene defines the hosting scene
  138739. * @returns the sphere mesh
  138740. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  138741. */
  138742. static CreateSphere(name: string, options: {
  138743. segments?: number;
  138744. diameter?: number;
  138745. diameterX?: number;
  138746. diameterY?: number;
  138747. diameterZ?: number;
  138748. arc?: number;
  138749. slice?: number;
  138750. sideOrientation?: number;
  138751. frontUVs?: Vector4;
  138752. backUVs?: Vector4;
  138753. updatable?: boolean;
  138754. }, scene?: Nullable<Scene>): Mesh;
  138755. /**
  138756. * Creates a plane polygonal mesh. By default, this is a disc
  138757. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  138758. * * 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
  138759. * * 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
  138760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138763. * @param name defines the name of the mesh
  138764. * @param options defines the options used to create the mesh
  138765. * @param scene defines the hosting scene
  138766. * @returns the plane polygonal mesh
  138767. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  138768. */
  138769. static CreateDisc(name: string, options: {
  138770. radius?: number;
  138771. tessellation?: number;
  138772. arc?: number;
  138773. updatable?: boolean;
  138774. sideOrientation?: number;
  138775. frontUVs?: Vector4;
  138776. backUVs?: Vector4;
  138777. }, scene?: Nullable<Scene>): Mesh;
  138778. /**
  138779. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138780. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138781. * * 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`)
  138782. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138783. * * 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
  138784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138787. * @param name defines the name of the mesh
  138788. * @param options defines the options used to create the mesh
  138789. * @param scene defines the hosting scene
  138790. * @returns the icosahedron mesh
  138791. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138792. */
  138793. static CreateIcoSphere(name: string, options: {
  138794. radius?: number;
  138795. radiusX?: number;
  138796. radiusY?: number;
  138797. radiusZ?: number;
  138798. flat?: boolean;
  138799. subdivisions?: number;
  138800. sideOrientation?: number;
  138801. frontUVs?: Vector4;
  138802. backUVs?: Vector4;
  138803. updatable?: boolean;
  138804. }, scene?: Nullable<Scene>): Mesh;
  138805. /**
  138806. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138807. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138808. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138809. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138810. * * 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
  138811. * * 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
  138812. * * 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
  138813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138815. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138816. * * 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
  138817. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138818. * * 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
  138819. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138821. * @param name defines the name of the mesh
  138822. * @param options defines the options used to create the mesh
  138823. * @param scene defines the hosting scene
  138824. * @returns the ribbon mesh
  138825. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138826. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138827. */
  138828. static CreateRibbon(name: string, options: {
  138829. pathArray: Vector3[][];
  138830. closeArray?: boolean;
  138831. closePath?: boolean;
  138832. offset?: number;
  138833. updatable?: boolean;
  138834. sideOrientation?: number;
  138835. frontUVs?: Vector4;
  138836. backUVs?: Vector4;
  138837. instance?: Mesh;
  138838. invertUV?: boolean;
  138839. uvs?: Vector2[];
  138840. colors?: Color4[];
  138841. }, scene?: Nullable<Scene>): Mesh;
  138842. /**
  138843. * Creates a cylinder or a cone mesh
  138844. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  138845. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  138846. * * 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.
  138847. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  138848. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  138849. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  138850. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  138851. * * 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).
  138852. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  138853. * * 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).
  138854. * * 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
  138855. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  138856. * * 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
  138857. * * 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.
  138858. * * If `enclose` is false, a ring surface is one element.
  138859. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  138860. * * 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
  138861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138864. * @param name defines the name of the mesh
  138865. * @param options defines the options used to create the mesh
  138866. * @param scene defines the hosting scene
  138867. * @returns the cylinder mesh
  138868. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  138869. */
  138870. static CreateCylinder(name: string, options: {
  138871. height?: number;
  138872. diameterTop?: number;
  138873. diameterBottom?: number;
  138874. diameter?: number;
  138875. tessellation?: number;
  138876. subdivisions?: number;
  138877. arc?: number;
  138878. faceColors?: Color4[];
  138879. faceUV?: Vector4[];
  138880. updatable?: boolean;
  138881. hasRings?: boolean;
  138882. enclose?: boolean;
  138883. cap?: number;
  138884. sideOrientation?: number;
  138885. frontUVs?: Vector4;
  138886. backUVs?: Vector4;
  138887. }, scene?: Nullable<Scene>): Mesh;
  138888. /**
  138889. * Creates a torus mesh
  138890. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  138891. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  138892. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  138893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138896. * @param name defines the name of the mesh
  138897. * @param options defines the options used to create the mesh
  138898. * @param scene defines the hosting scene
  138899. * @returns the torus mesh
  138900. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  138901. */
  138902. static CreateTorus(name: string, options: {
  138903. diameter?: number;
  138904. thickness?: number;
  138905. tessellation?: number;
  138906. updatable?: boolean;
  138907. sideOrientation?: number;
  138908. frontUVs?: Vector4;
  138909. backUVs?: Vector4;
  138910. }, scene?: Nullable<Scene>): Mesh;
  138911. /**
  138912. * Creates a torus knot mesh
  138913. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138914. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138915. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138916. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138920. * @param name defines the name of the mesh
  138921. * @param options defines the options used to create the mesh
  138922. * @param scene defines the hosting scene
  138923. * @returns the torus knot mesh
  138924. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138925. */
  138926. static CreateTorusKnot(name: string, options: {
  138927. radius?: number;
  138928. tube?: number;
  138929. radialSegments?: number;
  138930. tubularSegments?: number;
  138931. p?: number;
  138932. q?: number;
  138933. updatable?: boolean;
  138934. sideOrientation?: number;
  138935. frontUVs?: Vector4;
  138936. backUVs?: Vector4;
  138937. }, scene?: Nullable<Scene>): Mesh;
  138938. /**
  138939. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  138940. * * 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
  138941. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  138942. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  138943. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  138944. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  138945. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  138946. * * 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
  138947. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  138948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  138950. * @param name defines the name of the new line system
  138951. * @param options defines the options used to create the line system
  138952. * @param scene defines the hosting scene
  138953. * @returns a new line system mesh
  138954. */
  138955. static CreateLineSystem(name: string, options: {
  138956. lines: Vector3[][];
  138957. updatable?: boolean;
  138958. instance?: Nullable<LinesMesh>;
  138959. colors?: Nullable<Color4[][]>;
  138960. useVertexAlpha?: boolean;
  138961. }, scene: Nullable<Scene>): LinesMesh;
  138962. /**
  138963. * Creates a line mesh
  138964. * 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
  138965. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138966. * * The parameter `points` is an array successive Vector3
  138967. * * 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
  138968. * * The optional parameter `colors` is an array of successive Color4, one per line point
  138969. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  138970. * * When updating an instance, remember that only point positions can change, not the number of points
  138971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  138973. * @param name defines the name of the new line system
  138974. * @param options defines the options used to create the line system
  138975. * @param scene defines the hosting scene
  138976. * @returns a new line mesh
  138977. */
  138978. static CreateLines(name: string, options: {
  138979. points: Vector3[];
  138980. updatable?: boolean;
  138981. instance?: Nullable<LinesMesh>;
  138982. colors?: Color4[];
  138983. useVertexAlpha?: boolean;
  138984. }, scene?: Nullable<Scene>): LinesMesh;
  138985. /**
  138986. * Creates a dashed line mesh
  138987. * * 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
  138988. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138989. * * The parameter `points` is an array successive Vector3
  138990. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  138991. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  138992. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  138993. * * 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
  138994. * * When updating an instance, remember that only point positions can change, not the number of points
  138995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138996. * @param name defines the name of the mesh
  138997. * @param options defines the options used to create the mesh
  138998. * @param scene defines the hosting scene
  138999. * @returns the dashed line mesh
  139000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  139001. */
  139002. static CreateDashedLines(name: string, options: {
  139003. points: Vector3[];
  139004. dashSize?: number;
  139005. gapSize?: number;
  139006. dashNb?: number;
  139007. updatable?: boolean;
  139008. instance?: LinesMesh;
  139009. }, scene?: Nullable<Scene>): LinesMesh;
  139010. /**
  139011. * 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.
  139012. * * 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.
  139013. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139014. * * 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.
  139015. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139016. * * 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
  139017. * * 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
  139018. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  139022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139023. * @param name defines the name of the mesh
  139024. * @param options defines the options used to create the mesh
  139025. * @param scene defines the hosting scene
  139026. * @returns the extruded shape mesh
  139027. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139029. */
  139030. static ExtrudeShape(name: string, options: {
  139031. shape: Vector3[];
  139032. path: Vector3[];
  139033. scale?: number;
  139034. rotation?: number;
  139035. cap?: number;
  139036. updatable?: boolean;
  139037. sideOrientation?: number;
  139038. frontUVs?: Vector4;
  139039. backUVs?: Vector4;
  139040. instance?: Mesh;
  139041. invertUV?: boolean;
  139042. }, scene?: Nullable<Scene>): Mesh;
  139043. /**
  139044. * Creates an custom extruded shape mesh.
  139045. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139046. * * 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.
  139047. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139048. * * 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
  139049. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139050. * * 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
  139051. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139052. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139053. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139054. * * 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
  139055. * * 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
  139056. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139061. * @param name defines the name of the mesh
  139062. * @param options defines the options used to create the mesh
  139063. * @param scene defines the hosting scene
  139064. * @returns the custom extruded shape mesh
  139065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139066. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139068. */
  139069. static ExtrudeShapeCustom(name: string, options: {
  139070. shape: Vector3[];
  139071. path: Vector3[];
  139072. scaleFunction?: any;
  139073. rotationFunction?: any;
  139074. ribbonCloseArray?: boolean;
  139075. ribbonClosePath?: boolean;
  139076. cap?: number;
  139077. updatable?: boolean;
  139078. sideOrientation?: number;
  139079. frontUVs?: Vector4;
  139080. backUVs?: Vector4;
  139081. instance?: Mesh;
  139082. invertUV?: boolean;
  139083. }, scene?: Nullable<Scene>): Mesh;
  139084. /**
  139085. * Creates lathe mesh.
  139086. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139087. * * 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
  139088. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139089. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139090. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139091. * * 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
  139092. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139093. * * 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
  139094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139098. * @param name defines the name of the mesh
  139099. * @param options defines the options used to create the mesh
  139100. * @param scene defines the hosting scene
  139101. * @returns the lathe mesh
  139102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139103. */
  139104. static CreateLathe(name: string, options: {
  139105. shape: Vector3[];
  139106. radius?: number;
  139107. tessellation?: number;
  139108. clip?: number;
  139109. arc?: number;
  139110. closed?: boolean;
  139111. updatable?: boolean;
  139112. sideOrientation?: number;
  139113. frontUVs?: Vector4;
  139114. backUVs?: Vector4;
  139115. cap?: number;
  139116. invertUV?: boolean;
  139117. }, scene?: Nullable<Scene>): Mesh;
  139118. /**
  139119. * Creates a tiled plane mesh
  139120. * * You can set a limited pattern arrangement with the tiles
  139121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139124. * @param name defines the name of the mesh
  139125. * @param options defines the options used to create the mesh
  139126. * @param scene defines the hosting scene
  139127. * @returns the plane mesh
  139128. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139129. */
  139130. static CreateTiledPlane(name: string, options: {
  139131. pattern?: number;
  139132. tileSize?: number;
  139133. tileWidth?: number;
  139134. tileHeight?: number;
  139135. size?: number;
  139136. width?: number;
  139137. height?: number;
  139138. alignHorizontal?: number;
  139139. alignVertical?: number;
  139140. sideOrientation?: number;
  139141. frontUVs?: Vector4;
  139142. backUVs?: Vector4;
  139143. updatable?: boolean;
  139144. }, scene?: Nullable<Scene>): Mesh;
  139145. /**
  139146. * Creates a plane mesh
  139147. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139148. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139149. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139153. * @param name defines the name of the mesh
  139154. * @param options defines the options used to create the mesh
  139155. * @param scene defines the hosting scene
  139156. * @returns the plane mesh
  139157. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139158. */
  139159. static CreatePlane(name: string, options: {
  139160. size?: number;
  139161. width?: number;
  139162. height?: number;
  139163. sideOrientation?: number;
  139164. frontUVs?: Vector4;
  139165. backUVs?: Vector4;
  139166. updatable?: boolean;
  139167. sourcePlane?: Plane;
  139168. }, scene?: Nullable<Scene>): Mesh;
  139169. /**
  139170. * Creates a ground mesh
  139171. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139172. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139174. * @param name defines the name of the mesh
  139175. * @param options defines the options used to create the mesh
  139176. * @param scene defines the hosting scene
  139177. * @returns the ground mesh
  139178. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139179. */
  139180. static CreateGround(name: string, options: {
  139181. width?: number;
  139182. height?: number;
  139183. subdivisions?: number;
  139184. subdivisionsX?: number;
  139185. subdivisionsY?: number;
  139186. updatable?: boolean;
  139187. }, scene?: Nullable<Scene>): Mesh;
  139188. /**
  139189. * Creates a tiled ground mesh
  139190. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139191. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139192. * * 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
  139193. * * 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
  139194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139195. * @param name defines the name of the mesh
  139196. * @param options defines the options used to create the mesh
  139197. * @param scene defines the hosting scene
  139198. * @returns the tiled ground mesh
  139199. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139200. */
  139201. static CreateTiledGround(name: string, options: {
  139202. xmin: number;
  139203. zmin: number;
  139204. xmax: number;
  139205. zmax: number;
  139206. subdivisions?: {
  139207. w: number;
  139208. h: number;
  139209. };
  139210. precision?: {
  139211. w: number;
  139212. h: number;
  139213. };
  139214. updatable?: boolean;
  139215. }, scene?: Nullable<Scene>): Mesh;
  139216. /**
  139217. * Creates a ground mesh from a height map
  139218. * * The parameter `url` sets the URL of the height map image resource.
  139219. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139220. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139221. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139222. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139223. * * 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.
  139224. * * 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).
  139225. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139227. * @param name defines the name of the mesh
  139228. * @param url defines the url to the height map
  139229. * @param options defines the options used to create the mesh
  139230. * @param scene defines the hosting scene
  139231. * @returns the ground mesh
  139232. * @see https://doc.babylonjs.com/babylon101/height_map
  139233. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139234. */
  139235. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139236. width?: number;
  139237. height?: number;
  139238. subdivisions?: number;
  139239. minHeight?: number;
  139240. maxHeight?: number;
  139241. colorFilter?: Color3;
  139242. alphaFilter?: number;
  139243. updatable?: boolean;
  139244. onReady?: (mesh: GroundMesh) => void;
  139245. }, scene?: Nullable<Scene>): GroundMesh;
  139246. /**
  139247. * Creates a polygon mesh
  139248. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139249. * * 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
  139250. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  139253. * * Remember you can only change the shape positions, not their number when updating a polygon
  139254. * @param name defines the name of the mesh
  139255. * @param options defines the options used to create the mesh
  139256. * @param scene defines the hosting scene
  139257. * @param earcutInjection can be used to inject your own earcut reference
  139258. * @returns the polygon mesh
  139259. */
  139260. static CreatePolygon(name: string, options: {
  139261. shape: Vector3[];
  139262. holes?: Vector3[][];
  139263. depth?: number;
  139264. faceUV?: Vector4[];
  139265. faceColors?: Color4[];
  139266. updatable?: boolean;
  139267. sideOrientation?: number;
  139268. frontUVs?: Vector4;
  139269. backUVs?: Vector4;
  139270. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139271. /**
  139272. * Creates an extruded polygon mesh, with depth in the Y direction.
  139273. * * 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)
  139274. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139275. * @param name defines the name of the mesh
  139276. * @param options defines the options used to create the mesh
  139277. * @param scene defines the hosting scene
  139278. * @param earcutInjection can be used to inject your own earcut reference
  139279. * @returns the polygon mesh
  139280. */
  139281. static ExtrudePolygon(name: string, options: {
  139282. shape: Vector3[];
  139283. holes?: Vector3[][];
  139284. depth?: number;
  139285. faceUV?: Vector4[];
  139286. faceColors?: Color4[];
  139287. updatable?: boolean;
  139288. sideOrientation?: number;
  139289. frontUVs?: Vector4;
  139290. backUVs?: Vector4;
  139291. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139292. /**
  139293. * Creates a tube mesh.
  139294. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139295. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139296. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139297. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139298. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139299. * * 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)
  139300. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139301. * * 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
  139302. * * 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
  139303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139307. * @param name defines the name of the mesh
  139308. * @param options defines the options used to create the mesh
  139309. * @param scene defines the hosting scene
  139310. * @returns the tube mesh
  139311. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139312. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139313. */
  139314. static CreateTube(name: string, options: {
  139315. path: Vector3[];
  139316. radius?: number;
  139317. tessellation?: number;
  139318. radiusFunction?: {
  139319. (i: number, distance: number): number;
  139320. };
  139321. cap?: number;
  139322. arc?: number;
  139323. updatable?: boolean;
  139324. sideOrientation?: number;
  139325. frontUVs?: Vector4;
  139326. backUVs?: Vector4;
  139327. instance?: Mesh;
  139328. invertUV?: boolean;
  139329. }, scene?: Nullable<Scene>): Mesh;
  139330. /**
  139331. * Creates a polyhedron mesh
  139332. * * 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
  139333. * * The parameter `size` (positive float, default 1) sets the polygon size
  139334. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139335. * * 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`
  139336. * * 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
  139337. * * 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)`)
  139338. * * 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
  139339. * * 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
  139340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139343. * @param name defines the name of the mesh
  139344. * @param options defines the options used to create the mesh
  139345. * @param scene defines the hosting scene
  139346. * @returns the polyhedron mesh
  139347. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139348. */
  139349. static CreatePolyhedron(name: string, options: {
  139350. type?: number;
  139351. size?: number;
  139352. sizeX?: number;
  139353. sizeY?: number;
  139354. sizeZ?: number;
  139355. custom?: any;
  139356. faceUV?: Vector4[];
  139357. faceColors?: Color4[];
  139358. flat?: boolean;
  139359. updatable?: boolean;
  139360. sideOrientation?: number;
  139361. frontUVs?: Vector4;
  139362. backUVs?: Vector4;
  139363. }, scene?: Nullable<Scene>): Mesh;
  139364. /**
  139365. * Creates a decal mesh.
  139366. * 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
  139367. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139368. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139369. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139370. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139371. * @param name defines the name of the mesh
  139372. * @param sourceMesh defines the mesh where the decal must be applied
  139373. * @param options defines the options used to create the mesh
  139374. * @param scene defines the hosting scene
  139375. * @returns the decal mesh
  139376. * @see https://doc.babylonjs.com/how_to/decals
  139377. */
  139378. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139379. position?: Vector3;
  139380. normal?: Vector3;
  139381. size?: Vector3;
  139382. angle?: number;
  139383. }): Mesh;
  139384. }
  139385. }
  139386. declare module BABYLON {
  139387. /**
  139388. * A simplifier interface for future simplification implementations
  139389. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139390. */
  139391. export interface ISimplifier {
  139392. /**
  139393. * Simplification of a given mesh according to the given settings.
  139394. * Since this requires computation, it is assumed that the function runs async.
  139395. * @param settings The settings of the simplification, including quality and distance
  139396. * @param successCallback A callback that will be called after the mesh was simplified.
  139397. * @param errorCallback in case of an error, this callback will be called. optional.
  139398. */
  139399. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139400. }
  139401. /**
  139402. * Expected simplification settings.
  139403. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139404. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139405. */
  139406. export interface ISimplificationSettings {
  139407. /**
  139408. * Gets or sets the expected quality
  139409. */
  139410. quality: number;
  139411. /**
  139412. * Gets or sets the distance when this optimized version should be used
  139413. */
  139414. distance: number;
  139415. /**
  139416. * Gets an already optimized mesh
  139417. */
  139418. optimizeMesh?: boolean;
  139419. }
  139420. /**
  139421. * Class used to specify simplification options
  139422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139423. */
  139424. export class SimplificationSettings implements ISimplificationSettings {
  139425. /** expected quality */
  139426. quality: number;
  139427. /** distance when this optimized version should be used */
  139428. distance: number;
  139429. /** already optimized mesh */
  139430. optimizeMesh?: boolean | undefined;
  139431. /**
  139432. * Creates a SimplificationSettings
  139433. * @param quality expected quality
  139434. * @param distance distance when this optimized version should be used
  139435. * @param optimizeMesh already optimized mesh
  139436. */
  139437. constructor(
  139438. /** expected quality */
  139439. quality: number,
  139440. /** distance when this optimized version should be used */
  139441. distance: number,
  139442. /** already optimized mesh */
  139443. optimizeMesh?: boolean | undefined);
  139444. }
  139445. /**
  139446. * Interface used to define a simplification task
  139447. */
  139448. export interface ISimplificationTask {
  139449. /**
  139450. * Array of settings
  139451. */
  139452. settings: Array<ISimplificationSettings>;
  139453. /**
  139454. * Simplification type
  139455. */
  139456. simplificationType: SimplificationType;
  139457. /**
  139458. * Mesh to simplify
  139459. */
  139460. mesh: Mesh;
  139461. /**
  139462. * Callback called on success
  139463. */
  139464. successCallback?: () => void;
  139465. /**
  139466. * Defines if parallel processing can be used
  139467. */
  139468. parallelProcessing: boolean;
  139469. }
  139470. /**
  139471. * Queue used to order the simplification tasks
  139472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139473. */
  139474. export class SimplificationQueue {
  139475. private _simplificationArray;
  139476. /**
  139477. * Gets a boolean indicating that the process is still running
  139478. */
  139479. running: boolean;
  139480. /**
  139481. * Creates a new queue
  139482. */
  139483. constructor();
  139484. /**
  139485. * Adds a new simplification task
  139486. * @param task defines a task to add
  139487. */
  139488. addTask(task: ISimplificationTask): void;
  139489. /**
  139490. * Execute next task
  139491. */
  139492. executeNext(): void;
  139493. /**
  139494. * Execute a simplification task
  139495. * @param task defines the task to run
  139496. */
  139497. runSimplification(task: ISimplificationTask): void;
  139498. private getSimplifier;
  139499. }
  139500. /**
  139501. * The implemented types of simplification
  139502. * At the moment only Quadratic Error Decimation is implemented
  139503. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139504. */
  139505. export enum SimplificationType {
  139506. /** Quadratic error decimation */
  139507. QUADRATIC = 0
  139508. }
  139509. /**
  139510. * An implementation of the Quadratic Error simplification algorithm.
  139511. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139512. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139513. * @author RaananW
  139514. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139515. */
  139516. export class QuadraticErrorSimplification implements ISimplifier {
  139517. private _mesh;
  139518. private triangles;
  139519. private vertices;
  139520. private references;
  139521. private _reconstructedMesh;
  139522. /** Gets or sets the number pf sync interations */
  139523. syncIterations: number;
  139524. /** Gets or sets the aggressiveness of the simplifier */
  139525. aggressiveness: number;
  139526. /** Gets or sets the number of allowed iterations for decimation */
  139527. decimationIterations: number;
  139528. /** Gets or sets the espilon to use for bounding box computation */
  139529. boundingBoxEpsilon: number;
  139530. /**
  139531. * Creates a new QuadraticErrorSimplification
  139532. * @param _mesh defines the target mesh
  139533. */
  139534. constructor(_mesh: Mesh);
  139535. /**
  139536. * Simplification of a given mesh according to the given settings.
  139537. * Since this requires computation, it is assumed that the function runs async.
  139538. * @param settings The settings of the simplification, including quality and distance
  139539. * @param successCallback A callback that will be called after the mesh was simplified.
  139540. */
  139541. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  139542. private runDecimation;
  139543. private initWithMesh;
  139544. private init;
  139545. private reconstructMesh;
  139546. private initDecimatedMesh;
  139547. private isFlipped;
  139548. private updateTriangles;
  139549. private identifyBorder;
  139550. private updateMesh;
  139551. private vertexError;
  139552. private calculateError;
  139553. }
  139554. }
  139555. declare module BABYLON {
  139556. interface Scene {
  139557. /** @hidden (Backing field) */
  139558. _simplificationQueue: SimplificationQueue;
  139559. /**
  139560. * Gets or sets the simplification queue attached to the scene
  139561. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139562. */
  139563. simplificationQueue: SimplificationQueue;
  139564. }
  139565. interface Mesh {
  139566. /**
  139567. * Simplify the mesh according to the given array of settings.
  139568. * Function will return immediately and will simplify async
  139569. * @param settings a collection of simplification settings
  139570. * @param parallelProcessing should all levels calculate parallel or one after the other
  139571. * @param simplificationType the type of simplification to run
  139572. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  139573. * @returns the current mesh
  139574. */
  139575. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  139576. }
  139577. /**
  139578. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  139579. * created in a scene
  139580. */
  139581. export class SimplicationQueueSceneComponent implements ISceneComponent {
  139582. /**
  139583. * The component name helpfull to identify the component in the list of scene components.
  139584. */
  139585. readonly name: string;
  139586. /**
  139587. * The scene the component belongs to.
  139588. */
  139589. scene: Scene;
  139590. /**
  139591. * Creates a new instance of the component for the given scene
  139592. * @param scene Defines the scene to register the component in
  139593. */
  139594. constructor(scene: Scene);
  139595. /**
  139596. * Registers the component in a given scene
  139597. */
  139598. register(): void;
  139599. /**
  139600. * Rebuilds the elements related to this component in case of
  139601. * context lost for instance.
  139602. */
  139603. rebuild(): void;
  139604. /**
  139605. * Disposes the component and the associated ressources
  139606. */
  139607. dispose(): void;
  139608. private _beforeCameraUpdate;
  139609. }
  139610. }
  139611. declare module BABYLON {
  139612. /**
  139613. * Navigation plugin interface to add navigation constrained by a navigation mesh
  139614. */
  139615. export interface INavigationEnginePlugin {
  139616. /**
  139617. * plugin name
  139618. */
  139619. name: string;
  139620. /**
  139621. * Creates a navigation mesh
  139622. * @param meshes array of all the geometry used to compute the navigatio mesh
  139623. * @param parameters bunch of parameters used to filter geometry
  139624. */
  139625. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139626. /**
  139627. * Create a navigation mesh debug mesh
  139628. * @param scene is where the mesh will be added
  139629. * @returns debug display mesh
  139630. */
  139631. createDebugNavMesh(scene: Scene): Mesh;
  139632. /**
  139633. * Get a navigation mesh constrained position, closest to the parameter position
  139634. * @param position world position
  139635. * @returns the closest point to position constrained by the navigation mesh
  139636. */
  139637. getClosestPoint(position: Vector3): Vector3;
  139638. /**
  139639. * Get a navigation mesh constrained position, closest to the parameter position
  139640. * @param position world position
  139641. * @param result output the closest point to position constrained by the navigation mesh
  139642. */
  139643. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139644. /**
  139645. * Get a navigation mesh constrained position, within a particular radius
  139646. * @param position world position
  139647. * @param maxRadius the maximum distance to the constrained world position
  139648. * @returns the closest point to position constrained by the navigation mesh
  139649. */
  139650. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139651. /**
  139652. * Get a navigation mesh constrained position, within a particular radius
  139653. * @param position world position
  139654. * @param maxRadius the maximum distance to the constrained world position
  139655. * @param result output the closest point to position constrained by the navigation mesh
  139656. */
  139657. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139658. /**
  139659. * Compute the final position from a segment made of destination-position
  139660. * @param position world position
  139661. * @param destination world position
  139662. * @returns the resulting point along the navmesh
  139663. */
  139664. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139665. /**
  139666. * Compute the final position from a segment made of destination-position
  139667. * @param position world position
  139668. * @param destination world position
  139669. * @param result output the resulting point along the navmesh
  139670. */
  139671. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  139672. /**
  139673. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  139674. * @param start world position
  139675. * @param end world position
  139676. * @returns array containing world position composing the path
  139677. */
  139678. computePath(start: Vector3, end: Vector3): Vector3[];
  139679. /**
  139680. * If this plugin is supported
  139681. * @returns true if plugin is supported
  139682. */
  139683. isSupported(): boolean;
  139684. /**
  139685. * Create a new Crowd so you can add agents
  139686. * @param maxAgents the maximum agent count in the crowd
  139687. * @param maxAgentRadius the maximum radius an agent can have
  139688. * @param scene to attach the crowd to
  139689. * @returns the crowd you can add agents to
  139690. */
  139691. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  139692. /**
  139693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139694. * The queries will try to find a solution within those bounds
  139695. * default is (1,1,1)
  139696. * @param extent x,y,z value that define the extent around the queries point of reference
  139697. */
  139698. setDefaultQueryExtent(extent: Vector3): void;
  139699. /**
  139700. * Get the Bounding box extent specified by setDefaultQueryExtent
  139701. * @returns the box extent values
  139702. */
  139703. getDefaultQueryExtent(): Vector3;
  139704. /**
  139705. * build the navmesh from a previously saved state using getNavmeshData
  139706. * @param data the Uint8Array returned by getNavmeshData
  139707. */
  139708. buildFromNavmeshData(data: Uint8Array): void;
  139709. /**
  139710. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  139711. * @returns data the Uint8Array that can be saved and reused
  139712. */
  139713. getNavmeshData(): Uint8Array;
  139714. /**
  139715. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139716. * @param result output the box extent values
  139717. */
  139718. getDefaultQueryExtentToRef(result: Vector3): void;
  139719. /**
  139720. * Release all resources
  139721. */
  139722. dispose(): void;
  139723. }
  139724. /**
  139725. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  139726. */
  139727. export interface ICrowd {
  139728. /**
  139729. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  139730. * You can attach anything to that node. The node position is updated in the scene update tick.
  139731. * @param pos world position that will be constrained by the navigation mesh
  139732. * @param parameters agent parameters
  139733. * @param transform hooked to the agent that will be update by the scene
  139734. * @returns agent index
  139735. */
  139736. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  139737. /**
  139738. * Returns the agent position in world space
  139739. * @param index agent index returned by addAgent
  139740. * @returns world space position
  139741. */
  139742. getAgentPosition(index: number): Vector3;
  139743. /**
  139744. * Gets the agent position result in world space
  139745. * @param index agent index returned by addAgent
  139746. * @param result output world space position
  139747. */
  139748. getAgentPositionToRef(index: number, result: Vector3): void;
  139749. /**
  139750. * Gets the agent velocity in world space
  139751. * @param index agent index returned by addAgent
  139752. * @returns world space velocity
  139753. */
  139754. getAgentVelocity(index: number): Vector3;
  139755. /**
  139756. * Gets the agent velocity result in world space
  139757. * @param index agent index returned by addAgent
  139758. * @param result output world space velocity
  139759. */
  139760. getAgentVelocityToRef(index: number, result: Vector3): void;
  139761. /**
  139762. * remove a particular agent previously created
  139763. * @param index agent index returned by addAgent
  139764. */
  139765. removeAgent(index: number): void;
  139766. /**
  139767. * get the list of all agents attached to this crowd
  139768. * @returns list of agent indices
  139769. */
  139770. getAgents(): number[];
  139771. /**
  139772. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  139773. * @param deltaTime in seconds
  139774. */
  139775. update(deltaTime: number): void;
  139776. /**
  139777. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  139778. * @param index agent index returned by addAgent
  139779. * @param destination targeted world position
  139780. */
  139781. agentGoto(index: number, destination: Vector3): void;
  139782. /**
  139783. * Teleport the agent to a new position
  139784. * @param index agent index returned by addAgent
  139785. * @param destination targeted world position
  139786. */
  139787. agentTeleport(index: number, destination: Vector3): void;
  139788. /**
  139789. * Update agent parameters
  139790. * @param index agent index returned by addAgent
  139791. * @param parameters agent parameters
  139792. */
  139793. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  139794. /**
  139795. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139796. * The queries will try to find a solution within those bounds
  139797. * default is (1,1,1)
  139798. * @param extent x,y,z value that define the extent around the queries point of reference
  139799. */
  139800. setDefaultQueryExtent(extent: Vector3): void;
  139801. /**
  139802. * Get the Bounding box extent specified by setDefaultQueryExtent
  139803. * @returns the box extent values
  139804. */
  139805. getDefaultQueryExtent(): Vector3;
  139806. /**
  139807. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139808. * @param result output the box extent values
  139809. */
  139810. getDefaultQueryExtentToRef(result: Vector3): void;
  139811. /**
  139812. * Release all resources
  139813. */
  139814. dispose(): void;
  139815. }
  139816. /**
  139817. * Configures an agent
  139818. */
  139819. export interface IAgentParameters {
  139820. /**
  139821. * Agent radius. [Limit: >= 0]
  139822. */
  139823. radius: number;
  139824. /**
  139825. * Agent height. [Limit: > 0]
  139826. */
  139827. height: number;
  139828. /**
  139829. * Maximum allowed acceleration. [Limit: >= 0]
  139830. */
  139831. maxAcceleration: number;
  139832. /**
  139833. * Maximum allowed speed. [Limit: >= 0]
  139834. */
  139835. maxSpeed: number;
  139836. /**
  139837. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  139838. */
  139839. collisionQueryRange: number;
  139840. /**
  139841. * The path visibility optimization range. [Limit: > 0]
  139842. */
  139843. pathOptimizationRange: number;
  139844. /**
  139845. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  139846. */
  139847. separationWeight: number;
  139848. }
  139849. /**
  139850. * Configures the navigation mesh creation
  139851. */
  139852. export interface INavMeshParameters {
  139853. /**
  139854. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  139855. */
  139856. cs: number;
  139857. /**
  139858. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  139859. */
  139860. ch: number;
  139861. /**
  139862. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  139863. */
  139864. walkableSlopeAngle: number;
  139865. /**
  139866. * Minimum floor to 'ceiling' height that will still allow the floor area to
  139867. * be considered walkable. [Limit: >= 3] [Units: vx]
  139868. */
  139869. walkableHeight: number;
  139870. /**
  139871. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  139872. */
  139873. walkableClimb: number;
  139874. /**
  139875. * The distance to erode/shrink the walkable area of the heightfield away from
  139876. * obstructions. [Limit: >=0] [Units: vx]
  139877. */
  139878. walkableRadius: number;
  139879. /**
  139880. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  139881. */
  139882. maxEdgeLen: number;
  139883. /**
  139884. * The maximum distance a simplfied contour's border edges should deviate
  139885. * the original raw contour. [Limit: >=0] [Units: vx]
  139886. */
  139887. maxSimplificationError: number;
  139888. /**
  139889. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  139890. */
  139891. minRegionArea: number;
  139892. /**
  139893. * Any regions with a span count smaller than this value will, if possible,
  139894. * be merged with larger regions. [Limit: >=0] [Units: vx]
  139895. */
  139896. mergeRegionArea: number;
  139897. /**
  139898. * The maximum number of vertices allowed for polygons generated during the
  139899. * contour to polygon conversion process. [Limit: >= 3]
  139900. */
  139901. maxVertsPerPoly: number;
  139902. /**
  139903. * Sets the sampling distance to use when generating the detail mesh.
  139904. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  139905. */
  139906. detailSampleDist: number;
  139907. /**
  139908. * The maximum distance the detail mesh surface should deviate from heightfield
  139909. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  139910. */
  139911. detailSampleMaxError: number;
  139912. }
  139913. }
  139914. declare module BABYLON {
  139915. /**
  139916. * RecastJS navigation plugin
  139917. */
  139918. export class RecastJSPlugin implements INavigationEnginePlugin {
  139919. /**
  139920. * Reference to the Recast library
  139921. */
  139922. bjsRECAST: any;
  139923. /**
  139924. * plugin name
  139925. */
  139926. name: string;
  139927. /**
  139928. * the first navmesh created. We might extend this to support multiple navmeshes
  139929. */
  139930. navMesh: any;
  139931. /**
  139932. * Initializes the recastJS plugin
  139933. * @param recastInjection can be used to inject your own recast reference
  139934. */
  139935. constructor(recastInjection?: any);
  139936. /**
  139937. * Creates a navigation mesh
  139938. * @param meshes array of all the geometry used to compute the navigatio mesh
  139939. * @param parameters bunch of parameters used to filter geometry
  139940. */
  139941. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139942. /**
  139943. * Create a navigation mesh debug mesh
  139944. * @param scene is where the mesh will be added
  139945. * @returns debug display mesh
  139946. */
  139947. createDebugNavMesh(scene: Scene): Mesh;
  139948. /**
  139949. * Get a navigation mesh constrained position, closest to the parameter position
  139950. * @param position world position
  139951. * @returns the closest point to position constrained by the navigation mesh
  139952. */
  139953. getClosestPoint(position: Vector3): Vector3;
  139954. /**
  139955. * Get a navigation mesh constrained position, closest to the parameter position
  139956. * @param position world position
  139957. * @param result output the closest point to position constrained by the navigation mesh
  139958. */
  139959. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139960. /**
  139961. * Get a navigation mesh constrained position, within a particular radius
  139962. * @param position world position
  139963. * @param maxRadius the maximum distance to the constrained world position
  139964. * @returns the closest point to position constrained by the navigation mesh
  139965. */
  139966. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139967. /**
  139968. * Get a navigation mesh constrained position, within a particular radius
  139969. * @param position world position
  139970. * @param maxRadius the maximum distance to the constrained world position
  139971. * @param result output the closest point to position constrained by the navigation mesh
  139972. */
  139973. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139974. /**
  139975. * Compute the final position from a segment made of destination-position
  139976. * @param position world position
  139977. * @param destination world position
  139978. * @returns the resulting point along the navmesh
  139979. */
  139980. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139981. /**
  139982. * Compute the final position from a segment made of destination-position
  139983. * @param position world position
  139984. * @param destination world position
  139985. * @param result output the resulting point along the navmesh
  139986. */
  139987. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  139988. /**
  139989. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  139990. * @param start world position
  139991. * @param end world position
  139992. * @returns array containing world position composing the path
  139993. */
  139994. computePath(start: Vector3, end: Vector3): Vector3[];
  139995. /**
  139996. * Create a new Crowd so you can add agents
  139997. * @param maxAgents the maximum agent count in the crowd
  139998. * @param maxAgentRadius the maximum radius an agent can have
  139999. * @param scene to attach the crowd to
  140000. * @returns the crowd you can add agents to
  140001. */
  140002. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  140003. /**
  140004. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140005. * The queries will try to find a solution within those bounds
  140006. * default is (1,1,1)
  140007. * @param extent x,y,z value that define the extent around the queries point of reference
  140008. */
  140009. setDefaultQueryExtent(extent: Vector3): void;
  140010. /**
  140011. * Get the Bounding box extent specified by setDefaultQueryExtent
  140012. * @returns the box extent values
  140013. */
  140014. getDefaultQueryExtent(): Vector3;
  140015. /**
  140016. * build the navmesh from a previously saved state using getNavmeshData
  140017. * @param data the Uint8Array returned by getNavmeshData
  140018. */
  140019. buildFromNavmeshData(data: Uint8Array): void;
  140020. /**
  140021. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140022. * @returns data the Uint8Array that can be saved and reused
  140023. */
  140024. getNavmeshData(): Uint8Array;
  140025. /**
  140026. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140027. * @param result output the box extent values
  140028. */
  140029. getDefaultQueryExtentToRef(result: Vector3): void;
  140030. /**
  140031. * Disposes
  140032. */
  140033. dispose(): void;
  140034. /**
  140035. * If this plugin is supported
  140036. * @returns true if plugin is supported
  140037. */
  140038. isSupported(): boolean;
  140039. }
  140040. /**
  140041. * Recast detour crowd implementation
  140042. */
  140043. export class RecastJSCrowd implements ICrowd {
  140044. /**
  140045. * Recast/detour plugin
  140046. */
  140047. bjsRECASTPlugin: RecastJSPlugin;
  140048. /**
  140049. * Link to the detour crowd
  140050. */
  140051. recastCrowd: any;
  140052. /**
  140053. * One transform per agent
  140054. */
  140055. transforms: TransformNode[];
  140056. /**
  140057. * All agents created
  140058. */
  140059. agents: number[];
  140060. /**
  140061. * Link to the scene is kept to unregister the crowd from the scene
  140062. */
  140063. private _scene;
  140064. /**
  140065. * Observer for crowd updates
  140066. */
  140067. private _onBeforeAnimationsObserver;
  140068. /**
  140069. * Constructor
  140070. * @param plugin recastJS plugin
  140071. * @param maxAgents the maximum agent count in the crowd
  140072. * @param maxAgentRadius the maximum radius an agent can have
  140073. * @param scene to attach the crowd to
  140074. * @returns the crowd you can add agents to
  140075. */
  140076. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140077. /**
  140078. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140079. * You can attach anything to that node. The node position is updated in the scene update tick.
  140080. * @param pos world position that will be constrained by the navigation mesh
  140081. * @param parameters agent parameters
  140082. * @param transform hooked to the agent that will be update by the scene
  140083. * @returns agent index
  140084. */
  140085. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140086. /**
  140087. * Returns the agent position in world space
  140088. * @param index agent index returned by addAgent
  140089. * @returns world space position
  140090. */
  140091. getAgentPosition(index: number): Vector3;
  140092. /**
  140093. * Returns the agent position result in world space
  140094. * @param index agent index returned by addAgent
  140095. * @param result output world space position
  140096. */
  140097. getAgentPositionToRef(index: number, result: Vector3): void;
  140098. /**
  140099. * Returns the agent velocity in world space
  140100. * @param index agent index returned by addAgent
  140101. * @returns world space velocity
  140102. */
  140103. getAgentVelocity(index: number): Vector3;
  140104. /**
  140105. * Returns the agent velocity result in world space
  140106. * @param index agent index returned by addAgent
  140107. * @param result output world space velocity
  140108. */
  140109. getAgentVelocityToRef(index: number, result: Vector3): void;
  140110. /**
  140111. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140112. * @param index agent index returned by addAgent
  140113. * @param destination targeted world position
  140114. */
  140115. agentGoto(index: number, destination: Vector3): void;
  140116. /**
  140117. * Teleport the agent to a new position
  140118. * @param index agent index returned by addAgent
  140119. * @param destination targeted world position
  140120. */
  140121. agentTeleport(index: number, destination: Vector3): void;
  140122. /**
  140123. * Update agent parameters
  140124. * @param index agent index returned by addAgent
  140125. * @param parameters agent parameters
  140126. */
  140127. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140128. /**
  140129. * remove a particular agent previously created
  140130. * @param index agent index returned by addAgent
  140131. */
  140132. removeAgent(index: number): void;
  140133. /**
  140134. * get the list of all agents attached to this crowd
  140135. * @returns list of agent indices
  140136. */
  140137. getAgents(): number[];
  140138. /**
  140139. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140140. * @param deltaTime in seconds
  140141. */
  140142. update(deltaTime: number): void;
  140143. /**
  140144. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140145. * The queries will try to find a solution within those bounds
  140146. * default is (1,1,1)
  140147. * @param extent x,y,z value that define the extent around the queries point of reference
  140148. */
  140149. setDefaultQueryExtent(extent: Vector3): void;
  140150. /**
  140151. * Get the Bounding box extent specified by setDefaultQueryExtent
  140152. * @returns the box extent values
  140153. */
  140154. getDefaultQueryExtent(): Vector3;
  140155. /**
  140156. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140157. * @param result output the box extent values
  140158. */
  140159. getDefaultQueryExtentToRef(result: Vector3): void;
  140160. /**
  140161. * Release all resources
  140162. */
  140163. dispose(): void;
  140164. }
  140165. }
  140166. declare module BABYLON {
  140167. /**
  140168. * Class used to enable access to IndexedDB
  140169. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140170. */
  140171. export class Database implements IOfflineProvider {
  140172. private _callbackManifestChecked;
  140173. private _currentSceneUrl;
  140174. private _db;
  140175. private _enableSceneOffline;
  140176. private _enableTexturesOffline;
  140177. private _manifestVersionFound;
  140178. private _mustUpdateRessources;
  140179. private _hasReachedQuota;
  140180. private _isSupported;
  140181. private _idbFactory;
  140182. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140183. private static IsUASupportingBlobStorage;
  140184. /**
  140185. * Gets a boolean indicating if Database storate is enabled (off by default)
  140186. */
  140187. static IDBStorageEnabled: boolean;
  140188. /**
  140189. * Gets a boolean indicating if scene must be saved in the database
  140190. */
  140191. get enableSceneOffline(): boolean;
  140192. /**
  140193. * Gets a boolean indicating if textures must be saved in the database
  140194. */
  140195. get enableTexturesOffline(): boolean;
  140196. /**
  140197. * Creates a new Database
  140198. * @param urlToScene defines the url to load the scene
  140199. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140200. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140201. */
  140202. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140203. private static _ParseURL;
  140204. private static _ReturnFullUrlLocation;
  140205. private _checkManifestFile;
  140206. /**
  140207. * Open the database and make it available
  140208. * @param successCallback defines the callback to call on success
  140209. * @param errorCallback defines the callback to call on error
  140210. */
  140211. open(successCallback: () => void, errorCallback: () => void): void;
  140212. /**
  140213. * Loads an image from the database
  140214. * @param url defines the url to load from
  140215. * @param image defines the target DOM image
  140216. */
  140217. loadImage(url: string, image: HTMLImageElement): void;
  140218. private _loadImageFromDBAsync;
  140219. private _saveImageIntoDBAsync;
  140220. private _checkVersionFromDB;
  140221. private _loadVersionFromDBAsync;
  140222. private _saveVersionIntoDBAsync;
  140223. /**
  140224. * Loads a file from database
  140225. * @param url defines the URL to load from
  140226. * @param sceneLoaded defines a callback to call on success
  140227. * @param progressCallBack defines a callback to call when progress changed
  140228. * @param errorCallback defines a callback to call on error
  140229. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140230. */
  140231. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140232. private _loadFileAsync;
  140233. private _saveFileAsync;
  140234. /**
  140235. * Validates if xhr data is correct
  140236. * @param xhr defines the request to validate
  140237. * @param dataType defines the expected data type
  140238. * @returns true if data is correct
  140239. */
  140240. private static _ValidateXHRData;
  140241. }
  140242. }
  140243. declare module BABYLON {
  140244. /** @hidden */
  140245. export var gpuUpdateParticlesPixelShader: {
  140246. name: string;
  140247. shader: string;
  140248. };
  140249. }
  140250. declare module BABYLON {
  140251. /** @hidden */
  140252. export var gpuUpdateParticlesVertexShader: {
  140253. name: string;
  140254. shader: string;
  140255. };
  140256. }
  140257. declare module BABYLON {
  140258. /** @hidden */
  140259. export var clipPlaneFragmentDeclaration2: {
  140260. name: string;
  140261. shader: string;
  140262. };
  140263. }
  140264. declare module BABYLON {
  140265. /** @hidden */
  140266. export var gpuRenderParticlesPixelShader: {
  140267. name: string;
  140268. shader: string;
  140269. };
  140270. }
  140271. declare module BABYLON {
  140272. /** @hidden */
  140273. export var clipPlaneVertexDeclaration2: {
  140274. name: string;
  140275. shader: string;
  140276. };
  140277. }
  140278. declare module BABYLON {
  140279. /** @hidden */
  140280. export var gpuRenderParticlesVertexShader: {
  140281. name: string;
  140282. shader: string;
  140283. };
  140284. }
  140285. declare module BABYLON {
  140286. /**
  140287. * This represents a GPU particle system in Babylon
  140288. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140289. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140290. */
  140291. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140292. /**
  140293. * The layer mask we are rendering the particles through.
  140294. */
  140295. layerMask: number;
  140296. private _capacity;
  140297. private _activeCount;
  140298. private _currentActiveCount;
  140299. private _accumulatedCount;
  140300. private _renderEffect;
  140301. private _updateEffect;
  140302. private _buffer0;
  140303. private _buffer1;
  140304. private _spriteBuffer;
  140305. private _updateVAO;
  140306. private _renderVAO;
  140307. private _targetIndex;
  140308. private _sourceBuffer;
  140309. private _targetBuffer;
  140310. private _engine;
  140311. private _currentRenderId;
  140312. private _started;
  140313. private _stopped;
  140314. private _timeDelta;
  140315. private _randomTexture;
  140316. private _randomTexture2;
  140317. private _attributesStrideSize;
  140318. private _updateEffectOptions;
  140319. private _randomTextureSize;
  140320. private _actualFrame;
  140321. private readonly _rawTextureWidth;
  140322. /**
  140323. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140324. */
  140325. static get IsSupported(): boolean;
  140326. /**
  140327. * An event triggered when the system is disposed.
  140328. */
  140329. onDisposeObservable: Observable<GPUParticleSystem>;
  140330. /**
  140331. * Gets the maximum number of particles active at the same time.
  140332. * @returns The max number of active particles.
  140333. */
  140334. getCapacity(): number;
  140335. /**
  140336. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140337. * to override the particles.
  140338. */
  140339. forceDepthWrite: boolean;
  140340. /**
  140341. * Gets or set the number of active particles
  140342. */
  140343. get activeParticleCount(): number;
  140344. set activeParticleCount(value: number);
  140345. private _preWarmDone;
  140346. /**
  140347. * Specifies if the particles are updated in emitter local space or world space.
  140348. */
  140349. isLocal: boolean;
  140350. /**
  140351. * Is this system ready to be used/rendered
  140352. * @return true if the system is ready
  140353. */
  140354. isReady(): boolean;
  140355. /**
  140356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140357. * @returns True if it has been started, otherwise false.
  140358. */
  140359. isStarted(): boolean;
  140360. /**
  140361. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140362. * @returns True if it has been stopped, otherwise false.
  140363. */
  140364. isStopped(): boolean;
  140365. /**
  140366. * Gets a boolean indicating that the system is stopping
  140367. * @returns true if the system is currently stopping
  140368. */
  140369. isStopping(): boolean;
  140370. /**
  140371. * Gets the number of particles active at the same time.
  140372. * @returns The number of active particles.
  140373. */
  140374. getActiveCount(): number;
  140375. /**
  140376. * Starts the particle system and begins to emit
  140377. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140378. */
  140379. start(delay?: number): void;
  140380. /**
  140381. * Stops the particle system.
  140382. */
  140383. stop(): void;
  140384. /**
  140385. * Remove all active particles
  140386. */
  140387. reset(): void;
  140388. /**
  140389. * Returns the string "GPUParticleSystem"
  140390. * @returns a string containing the class name
  140391. */
  140392. getClassName(): string;
  140393. private _colorGradientsTexture;
  140394. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140395. /**
  140396. * Adds a new color gradient
  140397. * @param gradient defines the gradient to use (between 0 and 1)
  140398. * @param color1 defines the color to affect to the specified gradient
  140399. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140400. * @returns the current particle system
  140401. */
  140402. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140403. private _refreshColorGradient;
  140404. /** Force the system to rebuild all gradients that need to be resync */
  140405. forceRefreshGradients(): void;
  140406. /**
  140407. * Remove a specific color gradient
  140408. * @param gradient defines the gradient to remove
  140409. * @returns the current particle system
  140410. */
  140411. removeColorGradient(gradient: number): GPUParticleSystem;
  140412. private _angularSpeedGradientsTexture;
  140413. private _sizeGradientsTexture;
  140414. private _velocityGradientsTexture;
  140415. private _limitVelocityGradientsTexture;
  140416. private _dragGradientsTexture;
  140417. private _addFactorGradient;
  140418. /**
  140419. * Adds a new size gradient
  140420. * @param gradient defines the gradient to use (between 0 and 1)
  140421. * @param factor defines the size factor to affect to the specified gradient
  140422. * @returns the current particle system
  140423. */
  140424. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140425. /**
  140426. * Remove a specific size gradient
  140427. * @param gradient defines the gradient to remove
  140428. * @returns the current particle system
  140429. */
  140430. removeSizeGradient(gradient: number): GPUParticleSystem;
  140431. private _refreshFactorGradient;
  140432. /**
  140433. * Adds a new angular speed gradient
  140434. * @param gradient defines the gradient to use (between 0 and 1)
  140435. * @param factor defines the angular speed to affect to the specified gradient
  140436. * @returns the current particle system
  140437. */
  140438. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140439. /**
  140440. * Remove a specific angular speed gradient
  140441. * @param gradient defines the gradient to remove
  140442. * @returns the current particle system
  140443. */
  140444. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140445. /**
  140446. * Adds a new velocity gradient
  140447. * @param gradient defines the gradient to use (between 0 and 1)
  140448. * @param factor defines the velocity to affect to the specified gradient
  140449. * @returns the current particle system
  140450. */
  140451. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140452. /**
  140453. * Remove a specific velocity gradient
  140454. * @param gradient defines the gradient to remove
  140455. * @returns the current particle system
  140456. */
  140457. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140458. /**
  140459. * Adds a new limit velocity gradient
  140460. * @param gradient defines the gradient to use (between 0 and 1)
  140461. * @param factor defines the limit velocity value to affect to the specified gradient
  140462. * @returns the current particle system
  140463. */
  140464. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140465. /**
  140466. * Remove a specific limit velocity gradient
  140467. * @param gradient defines the gradient to remove
  140468. * @returns the current particle system
  140469. */
  140470. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140471. /**
  140472. * Adds a new drag gradient
  140473. * @param gradient defines the gradient to use (between 0 and 1)
  140474. * @param factor defines the drag value to affect to the specified gradient
  140475. * @returns the current particle system
  140476. */
  140477. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140478. /**
  140479. * Remove a specific drag gradient
  140480. * @param gradient defines the gradient to remove
  140481. * @returns the current particle system
  140482. */
  140483. removeDragGradient(gradient: number): GPUParticleSystem;
  140484. /**
  140485. * Not supported by GPUParticleSystem
  140486. * @param gradient defines the gradient to use (between 0 and 1)
  140487. * @param factor defines the emit rate value to affect to the specified gradient
  140488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140489. * @returns the current particle system
  140490. */
  140491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140492. /**
  140493. * Not supported by GPUParticleSystem
  140494. * @param gradient defines the gradient to remove
  140495. * @returns the current particle system
  140496. */
  140497. removeEmitRateGradient(gradient: number): IParticleSystem;
  140498. /**
  140499. * Not supported by GPUParticleSystem
  140500. * @param gradient defines the gradient to use (between 0 and 1)
  140501. * @param factor defines the start size value to affect to the specified gradient
  140502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140503. * @returns the current particle system
  140504. */
  140505. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140506. /**
  140507. * Not supported by GPUParticleSystem
  140508. * @param gradient defines the gradient to remove
  140509. * @returns the current particle system
  140510. */
  140511. removeStartSizeGradient(gradient: number): IParticleSystem;
  140512. /**
  140513. * Not supported by GPUParticleSystem
  140514. * @param gradient defines the gradient to use (between 0 and 1)
  140515. * @param min defines the color remap minimal range
  140516. * @param max defines the color remap maximal range
  140517. * @returns the current particle system
  140518. */
  140519. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140520. /**
  140521. * Not supported by GPUParticleSystem
  140522. * @param gradient defines the gradient to remove
  140523. * @returns the current particle system
  140524. */
  140525. removeColorRemapGradient(): IParticleSystem;
  140526. /**
  140527. * Not supported by GPUParticleSystem
  140528. * @param gradient defines the gradient to use (between 0 and 1)
  140529. * @param min defines the alpha remap minimal range
  140530. * @param max defines the alpha remap maximal range
  140531. * @returns the current particle system
  140532. */
  140533. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140534. /**
  140535. * Not supported by GPUParticleSystem
  140536. * @param gradient defines the gradient to remove
  140537. * @returns the current particle system
  140538. */
  140539. removeAlphaRemapGradient(): IParticleSystem;
  140540. /**
  140541. * Not supported by GPUParticleSystem
  140542. * @param gradient defines the gradient to use (between 0 and 1)
  140543. * @param color defines the color to affect to the specified gradient
  140544. * @returns the current particle system
  140545. */
  140546. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  140547. /**
  140548. * Not supported by GPUParticleSystem
  140549. * @param gradient defines the gradient to remove
  140550. * @returns the current particle system
  140551. */
  140552. removeRampGradient(): IParticleSystem;
  140553. /**
  140554. * Not supported by GPUParticleSystem
  140555. * @returns the list of ramp gradients
  140556. */
  140557. getRampGradients(): Nullable<Array<Color3Gradient>>;
  140558. /**
  140559. * Not supported by GPUParticleSystem
  140560. * Gets or sets a boolean indicating that ramp gradients must be used
  140561. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  140562. */
  140563. get useRampGradients(): boolean;
  140564. set useRampGradients(value: boolean);
  140565. /**
  140566. * Not supported by GPUParticleSystem
  140567. * @param gradient defines the gradient to use (between 0 and 1)
  140568. * @param factor defines the life time factor to affect to the specified gradient
  140569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140570. * @returns the current particle system
  140571. */
  140572. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140573. /**
  140574. * Not supported by GPUParticleSystem
  140575. * @param gradient defines the gradient to remove
  140576. * @returns the current particle system
  140577. */
  140578. removeLifeTimeGradient(gradient: number): IParticleSystem;
  140579. /**
  140580. * Instantiates a GPU particle system.
  140581. * 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.
  140582. * @param name The name of the particle system
  140583. * @param options The options used to create the system
  140584. * @param scene The scene the particle system belongs to
  140585. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  140586. */
  140587. constructor(name: string, options: Partial<{
  140588. capacity: number;
  140589. randomTextureSize: number;
  140590. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  140591. protected _reset(): void;
  140592. private _createUpdateVAO;
  140593. private _createRenderVAO;
  140594. private _initialize;
  140595. /** @hidden */
  140596. _recreateUpdateEffect(): void;
  140597. /** @hidden */
  140598. _recreateRenderEffect(): void;
  140599. /**
  140600. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  140601. * @param preWarm defines if we are in the pre-warmimg phase
  140602. */
  140603. animate(preWarm?: boolean): void;
  140604. private _createFactorGradientTexture;
  140605. private _createSizeGradientTexture;
  140606. private _createAngularSpeedGradientTexture;
  140607. private _createVelocityGradientTexture;
  140608. private _createLimitVelocityGradientTexture;
  140609. private _createDragGradientTexture;
  140610. private _createColorGradientTexture;
  140611. /**
  140612. * Renders the particle system in its current state
  140613. * @param preWarm defines if the system should only update the particles but not render them
  140614. * @returns the current number of particles
  140615. */
  140616. render(preWarm?: boolean): number;
  140617. /**
  140618. * Rebuilds the particle system
  140619. */
  140620. rebuild(): void;
  140621. private _releaseBuffers;
  140622. private _releaseVAOs;
  140623. /**
  140624. * Disposes the particle system and free the associated resources
  140625. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  140626. */
  140627. dispose(disposeTexture?: boolean): void;
  140628. /**
  140629. * Clones the particle system.
  140630. * @param name The name of the cloned object
  140631. * @param newEmitter The new emitter to use
  140632. * @returns the cloned particle system
  140633. */
  140634. clone(name: string, newEmitter: any): GPUParticleSystem;
  140635. /**
  140636. * Serializes the particle system to a JSON object
  140637. * @param serializeTexture defines if the texture must be serialized as well
  140638. * @returns the JSON object
  140639. */
  140640. serialize(serializeTexture?: boolean): any;
  140641. /**
  140642. * Parses a JSON object to create a GPU particle system.
  140643. * @param parsedParticleSystem The JSON object to parse
  140644. * @param scene The scene to create the particle system in
  140645. * @param rootUrl The root url to use to load external dependencies like texture
  140646. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  140647. * @returns the parsed GPU particle system
  140648. */
  140649. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  140650. }
  140651. }
  140652. declare module BABYLON {
  140653. /**
  140654. * Represents a set of particle systems working together to create a specific effect
  140655. */
  140656. export class ParticleSystemSet implements IDisposable {
  140657. /**
  140658. * Gets or sets base Assets URL
  140659. */
  140660. static BaseAssetsUrl: string;
  140661. private _emitterCreationOptions;
  140662. private _emitterNode;
  140663. /**
  140664. * Gets the particle system list
  140665. */
  140666. systems: IParticleSystem[];
  140667. /**
  140668. * Gets the emitter node used with this set
  140669. */
  140670. get emitterNode(): Nullable<TransformNode>;
  140671. /**
  140672. * Creates a new emitter mesh as a sphere
  140673. * @param options defines the options used to create the sphere
  140674. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  140675. * @param scene defines the hosting scene
  140676. */
  140677. setEmitterAsSphere(options: {
  140678. diameter: number;
  140679. segments: number;
  140680. color: Color3;
  140681. }, renderingGroupId: number, scene: Scene): void;
  140682. /**
  140683. * Starts all particle systems of the set
  140684. * @param emitter defines an optional mesh to use as emitter for the particle systems
  140685. */
  140686. start(emitter?: AbstractMesh): void;
  140687. /**
  140688. * Release all associated resources
  140689. */
  140690. dispose(): void;
  140691. /**
  140692. * Serialize the set into a JSON compatible object
  140693. * @param serializeTexture defines if the texture must be serialized as well
  140694. * @returns a JSON compatible representation of the set
  140695. */
  140696. serialize(serializeTexture?: boolean): any;
  140697. /**
  140698. * Parse a new ParticleSystemSet from a serialized source
  140699. * @param data defines a JSON compatible representation of the set
  140700. * @param scene defines the hosting scene
  140701. * @param gpu defines if we want GPU particles or CPU particles
  140702. * @returns a new ParticleSystemSet
  140703. */
  140704. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  140705. }
  140706. }
  140707. declare module BABYLON {
  140708. /**
  140709. * This class is made for on one-liner static method to help creating particle system set.
  140710. */
  140711. export class ParticleHelper {
  140712. /**
  140713. * Gets or sets base Assets URL
  140714. */
  140715. static BaseAssetsUrl: string;
  140716. /** Define the Url to load snippets */
  140717. static SnippetUrl: string;
  140718. /**
  140719. * Create a default particle system that you can tweak
  140720. * @param emitter defines the emitter to use
  140721. * @param capacity defines the system capacity (default is 500 particles)
  140722. * @param scene defines the hosting scene
  140723. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  140724. * @returns the new Particle system
  140725. */
  140726. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  140727. /**
  140728. * This is the main static method (one-liner) of this helper to create different particle systems
  140729. * @param type This string represents the type to the particle system to create
  140730. * @param scene The scene where the particle system should live
  140731. * @param gpu If the system will use gpu
  140732. * @returns the ParticleSystemSet created
  140733. */
  140734. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  140735. /**
  140736. * Static function used to export a particle system to a ParticleSystemSet variable.
  140737. * Please note that the emitter shape is not exported
  140738. * @param systems defines the particle systems to export
  140739. * @returns the created particle system set
  140740. */
  140741. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  140742. /**
  140743. * Creates a particle system from a snippet saved in a remote file
  140744. * @param name defines the name of the particle system to create
  140745. * @param url defines the url to load from
  140746. * @param scene defines the hosting scene
  140747. * @param gpu If the system will use gpu
  140748. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140749. * @returns a promise that will resolve to the new particle system
  140750. */
  140751. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140752. /**
  140753. * Creates a particle system from a snippet saved by the particle system editor
  140754. * @param snippetId defines the snippet to load
  140755. * @param scene defines the hosting scene
  140756. * @param gpu If the system will use gpu
  140757. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140758. * @returns a promise that will resolve to the new particle system
  140759. */
  140760. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140761. }
  140762. }
  140763. declare module BABYLON {
  140764. interface Engine {
  140765. /**
  140766. * Create an effect to use with particle systems.
  140767. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  140768. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  140769. * @param uniformsNames defines a list of attribute names
  140770. * @param samplers defines an array of string used to represent textures
  140771. * @param defines defines the string containing the defines to use to compile the shaders
  140772. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  140773. * @param onCompiled defines a function to call when the effect creation is successful
  140774. * @param onError defines a function to call when the effect creation has failed
  140775. * @returns the new Effect
  140776. */
  140777. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  140778. }
  140779. interface Mesh {
  140780. /**
  140781. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  140782. * @returns an array of IParticleSystem
  140783. */
  140784. getEmittedParticleSystems(): IParticleSystem[];
  140785. /**
  140786. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  140787. * @returns an array of IParticleSystem
  140788. */
  140789. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  140790. }
  140791. /**
  140792. * @hidden
  140793. */
  140794. export var _IDoNeedToBeInTheBuild: number;
  140795. }
  140796. declare module BABYLON {
  140797. /** Defines the 4 color options */
  140798. export enum PointColor {
  140799. /** color value */
  140800. Color = 2,
  140801. /** uv value */
  140802. UV = 1,
  140803. /** random value */
  140804. Random = 0,
  140805. /** stated value */
  140806. Stated = 3
  140807. }
  140808. /**
  140809. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  140810. * 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.
  140811. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  140812. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  140813. *
  140814. * Full documentation here : TO BE ENTERED
  140815. */
  140816. export class PointsCloudSystem implements IDisposable {
  140817. /**
  140818. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  140819. * Example : var p = SPS.particles[i];
  140820. */
  140821. particles: CloudPoint[];
  140822. /**
  140823. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  140824. */
  140825. nbParticles: number;
  140826. /**
  140827. * This a counter for your own usage. It's not set by any SPS functions.
  140828. */
  140829. counter: number;
  140830. /**
  140831. * The PCS name. This name is also given to the underlying mesh.
  140832. */
  140833. name: string;
  140834. /**
  140835. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  140836. */
  140837. mesh: Mesh;
  140838. /**
  140839. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  140840. * Please read :
  140841. */
  140842. vars: any;
  140843. /**
  140844. * @hidden
  140845. */
  140846. _size: number;
  140847. private _scene;
  140848. private _promises;
  140849. private _positions;
  140850. private _indices;
  140851. private _normals;
  140852. private _colors;
  140853. private _uvs;
  140854. private _indices32;
  140855. private _positions32;
  140856. private _colors32;
  140857. private _uvs32;
  140858. private _updatable;
  140859. private _isVisibilityBoxLocked;
  140860. private _alwaysVisible;
  140861. private _groups;
  140862. private _groupCounter;
  140863. private _computeParticleColor;
  140864. private _computeParticleTexture;
  140865. private _computeParticleRotation;
  140866. private _computeBoundingBox;
  140867. private _isReady;
  140868. /**
  140869. * Creates a PCS (Points Cloud System) object
  140870. * @param name (String) is the PCS name, this will be the underlying mesh name
  140871. * @param pointSize (number) is the size for each point
  140872. * @param scene (Scene) is the scene in which the PCS is added
  140873. * @param options defines the options of the PCS e.g.
  140874. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  140875. */
  140876. constructor(name: string, pointSize: number, scene: Scene, options?: {
  140877. updatable?: boolean;
  140878. });
  140879. /**
  140880. * Builds the PCS underlying mesh. Returns a standard Mesh.
  140881. * If no points were added to the PCS, the returned mesh is just a single point.
  140882. * @returns a promise for the created mesh
  140883. */
  140884. buildMeshAsync(): Promise<Mesh>;
  140885. /**
  140886. * @hidden
  140887. */
  140888. private _buildMesh;
  140889. private _addParticle;
  140890. private _randomUnitVector;
  140891. private _getColorIndicesForCoord;
  140892. private _setPointsColorOrUV;
  140893. private _colorFromTexture;
  140894. private _calculateDensity;
  140895. /**
  140896. * Adds points to the PCS in random positions within a unit sphere
  140897. * @param nb (positive integer) the number of particles to be created from this model
  140898. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  140899. * @returns the number of groups in the system
  140900. */
  140901. addPoints(nb: number, pointFunction?: any): number;
  140902. /**
  140903. * Adds points to the PCS from the surface of the model shape
  140904. * @param mesh is any Mesh object that will be used as a surface model for the points
  140905. * @param nb (positive integer) the number of particles to be created from this model
  140906. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140907. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140908. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140909. * @returns the number of groups in the system
  140910. */
  140911. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140912. /**
  140913. * Adds points to the PCS inside the model shape
  140914. * @param mesh is any Mesh object that will be used as a surface model for the points
  140915. * @param nb (positive integer) the number of particles to be created from this model
  140916. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140917. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140918. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140919. * @returns the number of groups in the system
  140920. */
  140921. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140922. /**
  140923. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  140924. * This method calls `updateParticle()` for each particle of the SPS.
  140925. * For an animated SPS, it is usually called within the render loop.
  140926. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  140927. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  140928. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  140929. * @returns the PCS.
  140930. */
  140931. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  140932. /**
  140933. * Disposes the PCS.
  140934. */
  140935. dispose(): void;
  140936. /**
  140937. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  140938. * doc :
  140939. * @returns the PCS.
  140940. */
  140941. refreshVisibleSize(): PointsCloudSystem;
  140942. /**
  140943. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  140944. * @param size the size (float) of the visibility box
  140945. * note : this doesn't lock the PCS mesh bounding box.
  140946. * doc :
  140947. */
  140948. setVisibilityBox(size: number): void;
  140949. /**
  140950. * Gets whether the PCS is always visible or not
  140951. * doc :
  140952. */
  140953. get isAlwaysVisible(): boolean;
  140954. /**
  140955. * Sets the PCS as always visible or not
  140956. * doc :
  140957. */
  140958. set isAlwaysVisible(val: boolean);
  140959. /**
  140960. * Tells to `setParticles()` to compute the particle rotations or not
  140961. * Default value : false. The PCS is faster when it's set to false
  140962. * Note : particle rotations are only applied to parent particles
  140963. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  140964. */
  140965. set computeParticleRotation(val: boolean);
  140966. /**
  140967. * Tells to `setParticles()` to compute the particle colors or not.
  140968. * Default value : true. The PCS is faster when it's set to false.
  140969. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140970. */
  140971. set computeParticleColor(val: boolean);
  140972. set computeParticleTexture(val: boolean);
  140973. /**
  140974. * Gets if `setParticles()` computes the particle colors or not.
  140975. * Default value : false. The PCS is faster when it's set to false.
  140976. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140977. */
  140978. get computeParticleColor(): boolean;
  140979. /**
  140980. * Gets if `setParticles()` computes the particle textures or not.
  140981. * Default value : false. The PCS is faster when it's set to false.
  140982. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  140983. */
  140984. get computeParticleTexture(): boolean;
  140985. /**
  140986. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  140987. */
  140988. set computeBoundingBox(val: boolean);
  140989. /**
  140990. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  140991. */
  140992. get computeBoundingBox(): boolean;
  140993. /**
  140994. * This function does nothing. It may be overwritten to set all the particle first values.
  140995. * The PCS doesn't call this function, you may have to call it by your own.
  140996. * doc :
  140997. */
  140998. initParticles(): void;
  140999. /**
  141000. * This function does nothing. It may be overwritten to recycle a particle
  141001. * The PCS doesn't call this function, you can to call it
  141002. * doc :
  141003. * @param particle The particle to recycle
  141004. * @returns the recycled particle
  141005. */
  141006. recycleParticle(particle: CloudPoint): CloudPoint;
  141007. /**
  141008. * Updates a particle : this function should be overwritten by the user.
  141009. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141010. * doc :
  141011. * @example : just set a particle position or velocity and recycle conditions
  141012. * @param particle The particle to update
  141013. * @returns the updated particle
  141014. */
  141015. updateParticle(particle: CloudPoint): CloudPoint;
  141016. /**
  141017. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141018. * This does nothing and may be overwritten by the user.
  141019. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141020. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141021. * @param update the boolean update value actually passed to setParticles()
  141022. */
  141023. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141024. /**
  141025. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141026. * This will be passed three parameters.
  141027. * This does nothing and may be overwritten by the user.
  141028. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141029. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141030. * @param update the boolean update value actually passed to setParticles()
  141031. */
  141032. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141033. }
  141034. }
  141035. declare module BABYLON {
  141036. /**
  141037. * Represents one particle of a points cloud system.
  141038. */
  141039. export class CloudPoint {
  141040. /**
  141041. * particle global index
  141042. */
  141043. idx: number;
  141044. /**
  141045. * The color of the particle
  141046. */
  141047. color: Nullable<Color4>;
  141048. /**
  141049. * The world space position of the particle.
  141050. */
  141051. position: Vector3;
  141052. /**
  141053. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141054. */
  141055. rotation: Vector3;
  141056. /**
  141057. * The world space rotation quaternion of the particle.
  141058. */
  141059. rotationQuaternion: Nullable<Quaternion>;
  141060. /**
  141061. * The uv of the particle.
  141062. */
  141063. uv: Nullable<Vector2>;
  141064. /**
  141065. * The current speed of the particle.
  141066. */
  141067. velocity: Vector3;
  141068. /**
  141069. * The pivot point in the particle local space.
  141070. */
  141071. pivot: Vector3;
  141072. /**
  141073. * Must the particle be translated from its pivot point in its local space ?
  141074. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141075. * Default : false
  141076. */
  141077. translateFromPivot: boolean;
  141078. /**
  141079. * Index of this particle in the global "positions" array (Internal use)
  141080. * @hidden
  141081. */
  141082. _pos: number;
  141083. /**
  141084. * @hidden Index of this particle in the global "indices" array (Internal use)
  141085. */
  141086. _ind: number;
  141087. /**
  141088. * Group this particle belongs to
  141089. */
  141090. _group: PointsGroup;
  141091. /**
  141092. * Group id of this particle
  141093. */
  141094. groupId: number;
  141095. /**
  141096. * Index of the particle in its group id (Internal use)
  141097. */
  141098. idxInGroup: number;
  141099. /**
  141100. * @hidden Particle BoundingInfo object (Internal use)
  141101. */
  141102. _boundingInfo: BoundingInfo;
  141103. /**
  141104. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141105. */
  141106. _pcs: PointsCloudSystem;
  141107. /**
  141108. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141109. */
  141110. _stillInvisible: boolean;
  141111. /**
  141112. * @hidden Last computed particle rotation matrix
  141113. */
  141114. _rotationMatrix: number[];
  141115. /**
  141116. * Parent particle Id, if any.
  141117. * Default null.
  141118. */
  141119. parentId: Nullable<number>;
  141120. /**
  141121. * @hidden Internal global position in the PCS.
  141122. */
  141123. _globalPosition: Vector3;
  141124. /**
  141125. * Creates a Point Cloud object.
  141126. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141127. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141128. * @param group (PointsGroup) is the group the particle belongs to
  141129. * @param groupId (integer) is the group identifier in the PCS.
  141130. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141131. * @param pcs defines the PCS it is associated to
  141132. */
  141133. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141134. /**
  141135. * get point size
  141136. */
  141137. get size(): Vector3;
  141138. /**
  141139. * Set point size
  141140. */
  141141. set size(scale: Vector3);
  141142. /**
  141143. * Legacy support, changed quaternion to rotationQuaternion
  141144. */
  141145. get quaternion(): Nullable<Quaternion>;
  141146. /**
  141147. * Legacy support, changed quaternion to rotationQuaternion
  141148. */
  141149. set quaternion(q: Nullable<Quaternion>);
  141150. /**
  141151. * Returns a boolean. True if the particle intersects a mesh, else false
  141152. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141153. * @param target is the object (point or mesh) what the intersection is computed against
  141154. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141155. * @returns true if it intersects
  141156. */
  141157. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141158. /**
  141159. * get the rotation matrix of the particle
  141160. * @hidden
  141161. */
  141162. getRotationMatrix(m: Matrix): void;
  141163. }
  141164. /**
  141165. * Represents a group of points in a points cloud system
  141166. * * PCS internal tool, don't use it manually.
  141167. */
  141168. export class PointsGroup {
  141169. /**
  141170. * The group id
  141171. * @hidden
  141172. */
  141173. groupID: number;
  141174. /**
  141175. * image data for group (internal use)
  141176. * @hidden
  141177. */
  141178. _groupImageData: Nullable<ArrayBufferView>;
  141179. /**
  141180. * Image Width (internal use)
  141181. * @hidden
  141182. */
  141183. _groupImgWidth: number;
  141184. /**
  141185. * Image Height (internal use)
  141186. * @hidden
  141187. */
  141188. _groupImgHeight: number;
  141189. /**
  141190. * Custom position function (internal use)
  141191. * @hidden
  141192. */
  141193. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141194. /**
  141195. * density per facet for surface points
  141196. * @hidden
  141197. */
  141198. _groupDensity: number[];
  141199. /**
  141200. * Only when points are colored by texture carries pointer to texture list array
  141201. * @hidden
  141202. */
  141203. _textureNb: number;
  141204. /**
  141205. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141206. * PCS internal tool, don't use it manually.
  141207. * @hidden
  141208. */
  141209. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141210. }
  141211. }
  141212. declare module BABYLON {
  141213. interface Scene {
  141214. /** @hidden (Backing field) */
  141215. _physicsEngine: Nullable<IPhysicsEngine>;
  141216. /** @hidden */
  141217. _physicsTimeAccumulator: number;
  141218. /**
  141219. * Gets the current physics engine
  141220. * @returns a IPhysicsEngine or null if none attached
  141221. */
  141222. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141223. /**
  141224. * Enables physics to the current scene
  141225. * @param gravity defines the scene's gravity for the physics engine
  141226. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141227. * @return a boolean indicating if the physics engine was initialized
  141228. */
  141229. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141230. /**
  141231. * Disables and disposes the physics engine associated with the scene
  141232. */
  141233. disablePhysicsEngine(): void;
  141234. /**
  141235. * Gets a boolean indicating if there is an active physics engine
  141236. * @returns a boolean indicating if there is an active physics engine
  141237. */
  141238. isPhysicsEnabled(): boolean;
  141239. /**
  141240. * Deletes a physics compound impostor
  141241. * @param compound defines the compound to delete
  141242. */
  141243. deleteCompoundImpostor(compound: any): void;
  141244. /**
  141245. * An event triggered when physic simulation is about to be run
  141246. */
  141247. onBeforePhysicsObservable: Observable<Scene>;
  141248. /**
  141249. * An event triggered when physic simulation has been done
  141250. */
  141251. onAfterPhysicsObservable: Observable<Scene>;
  141252. }
  141253. interface AbstractMesh {
  141254. /** @hidden */
  141255. _physicsImpostor: Nullable<PhysicsImpostor>;
  141256. /**
  141257. * Gets or sets impostor used for physic simulation
  141258. * @see http://doc.babylonjs.com/features/physics_engine
  141259. */
  141260. physicsImpostor: Nullable<PhysicsImpostor>;
  141261. /**
  141262. * Gets the current physics impostor
  141263. * @see http://doc.babylonjs.com/features/physics_engine
  141264. * @returns a physics impostor or null
  141265. */
  141266. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141267. /** Apply a physic impulse to the mesh
  141268. * @param force defines the force to apply
  141269. * @param contactPoint defines where to apply the force
  141270. * @returns the current mesh
  141271. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141272. */
  141273. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141274. /**
  141275. * Creates a physic joint between two meshes
  141276. * @param otherMesh defines the other mesh to use
  141277. * @param pivot1 defines the pivot to use on this mesh
  141278. * @param pivot2 defines the pivot to use on the other mesh
  141279. * @param options defines additional options (can be plugin dependent)
  141280. * @returns the current mesh
  141281. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141282. */
  141283. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141284. /** @hidden */
  141285. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141286. }
  141287. /**
  141288. * Defines the physics engine scene component responsible to manage a physics engine
  141289. */
  141290. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141291. /**
  141292. * The component name helpful to identify the component in the list of scene components.
  141293. */
  141294. readonly name: string;
  141295. /**
  141296. * The scene the component belongs to.
  141297. */
  141298. scene: Scene;
  141299. /**
  141300. * Creates a new instance of the component for the given scene
  141301. * @param scene Defines the scene to register the component in
  141302. */
  141303. constructor(scene: Scene);
  141304. /**
  141305. * Registers the component in a given scene
  141306. */
  141307. register(): void;
  141308. /**
  141309. * Rebuilds the elements related to this component in case of
  141310. * context lost for instance.
  141311. */
  141312. rebuild(): void;
  141313. /**
  141314. * Disposes the component and the associated ressources
  141315. */
  141316. dispose(): void;
  141317. }
  141318. }
  141319. declare module BABYLON {
  141320. /**
  141321. * A helper for physics simulations
  141322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141323. */
  141324. export class PhysicsHelper {
  141325. private _scene;
  141326. private _physicsEngine;
  141327. /**
  141328. * Initializes the Physics helper
  141329. * @param scene Babylon.js scene
  141330. */
  141331. constructor(scene: Scene);
  141332. /**
  141333. * Applies a radial explosion impulse
  141334. * @param origin the origin of the explosion
  141335. * @param radiusOrEventOptions the radius or the options of radial explosion
  141336. * @param strength the explosion strength
  141337. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141338. * @returns A physics radial explosion event, or null
  141339. */
  141340. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141341. /**
  141342. * Applies a radial explosion force
  141343. * @param origin the origin of the explosion
  141344. * @param radiusOrEventOptions the radius or the options of radial explosion
  141345. * @param strength the explosion strength
  141346. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141347. * @returns A physics radial explosion event, or null
  141348. */
  141349. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141350. /**
  141351. * Creates a gravitational field
  141352. * @param origin the origin of the explosion
  141353. * @param radiusOrEventOptions the radius or the options of radial explosion
  141354. * @param strength the explosion strength
  141355. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141356. * @returns A physics gravitational field event, or null
  141357. */
  141358. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141359. /**
  141360. * Creates a physics updraft event
  141361. * @param origin the origin of the updraft
  141362. * @param radiusOrEventOptions the radius or the options of the updraft
  141363. * @param strength the strength of the updraft
  141364. * @param height the height of the updraft
  141365. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141366. * @returns A physics updraft event, or null
  141367. */
  141368. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141369. /**
  141370. * Creates a physics vortex event
  141371. * @param origin the of the vortex
  141372. * @param radiusOrEventOptions the radius or the options of the vortex
  141373. * @param strength the strength of the vortex
  141374. * @param height the height of the vortex
  141375. * @returns a Physics vortex event, or null
  141376. * A physics vortex event or null
  141377. */
  141378. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141379. }
  141380. /**
  141381. * Represents a physics radial explosion event
  141382. */
  141383. class PhysicsRadialExplosionEvent {
  141384. private _scene;
  141385. private _options;
  141386. private _sphere;
  141387. private _dataFetched;
  141388. /**
  141389. * Initializes a radial explosioin event
  141390. * @param _scene BabylonJS scene
  141391. * @param _options The options for the vortex event
  141392. */
  141393. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141394. /**
  141395. * Returns the data related to the radial explosion event (sphere).
  141396. * @returns The radial explosion event data
  141397. */
  141398. getData(): PhysicsRadialExplosionEventData;
  141399. /**
  141400. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141401. * @param impostor A physics imposter
  141402. * @param origin the origin of the explosion
  141403. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141404. */
  141405. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141406. /**
  141407. * Triggers affecterd impostors callbacks
  141408. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141409. */
  141410. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141411. /**
  141412. * Disposes the sphere.
  141413. * @param force Specifies if the sphere should be disposed by force
  141414. */
  141415. dispose(force?: boolean): void;
  141416. /*** Helpers ***/
  141417. private _prepareSphere;
  141418. private _intersectsWithSphere;
  141419. }
  141420. /**
  141421. * Represents a gravitational field event
  141422. */
  141423. class PhysicsGravitationalFieldEvent {
  141424. private _physicsHelper;
  141425. private _scene;
  141426. private _origin;
  141427. private _options;
  141428. private _tickCallback;
  141429. private _sphere;
  141430. private _dataFetched;
  141431. /**
  141432. * Initializes the physics gravitational field event
  141433. * @param _physicsHelper A physics helper
  141434. * @param _scene BabylonJS scene
  141435. * @param _origin The origin position of the gravitational field event
  141436. * @param _options The options for the vortex event
  141437. */
  141438. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141439. /**
  141440. * Returns the data related to the gravitational field event (sphere).
  141441. * @returns A gravitational field event
  141442. */
  141443. getData(): PhysicsGravitationalFieldEventData;
  141444. /**
  141445. * Enables the gravitational field.
  141446. */
  141447. enable(): void;
  141448. /**
  141449. * Disables the gravitational field.
  141450. */
  141451. disable(): void;
  141452. /**
  141453. * Disposes the sphere.
  141454. * @param force The force to dispose from the gravitational field event
  141455. */
  141456. dispose(force?: boolean): void;
  141457. private _tick;
  141458. }
  141459. /**
  141460. * Represents a physics updraft event
  141461. */
  141462. class PhysicsUpdraftEvent {
  141463. private _scene;
  141464. private _origin;
  141465. private _options;
  141466. private _physicsEngine;
  141467. private _originTop;
  141468. private _originDirection;
  141469. private _tickCallback;
  141470. private _cylinder;
  141471. private _cylinderPosition;
  141472. private _dataFetched;
  141473. /**
  141474. * Initializes the physics updraft event
  141475. * @param _scene BabylonJS scene
  141476. * @param _origin The origin position of the updraft
  141477. * @param _options The options for the updraft event
  141478. */
  141479. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141480. /**
  141481. * Returns the data related to the updraft event (cylinder).
  141482. * @returns A physics updraft event
  141483. */
  141484. getData(): PhysicsUpdraftEventData;
  141485. /**
  141486. * Enables the updraft.
  141487. */
  141488. enable(): void;
  141489. /**
  141490. * Disables the updraft.
  141491. */
  141492. disable(): void;
  141493. /**
  141494. * Disposes the cylinder.
  141495. * @param force Specifies if the updraft should be disposed by force
  141496. */
  141497. dispose(force?: boolean): void;
  141498. private getImpostorHitData;
  141499. private _tick;
  141500. /*** Helpers ***/
  141501. private _prepareCylinder;
  141502. private _intersectsWithCylinder;
  141503. }
  141504. /**
  141505. * Represents a physics vortex event
  141506. */
  141507. class PhysicsVortexEvent {
  141508. private _scene;
  141509. private _origin;
  141510. private _options;
  141511. private _physicsEngine;
  141512. private _originTop;
  141513. private _tickCallback;
  141514. private _cylinder;
  141515. private _cylinderPosition;
  141516. private _dataFetched;
  141517. /**
  141518. * Initializes the physics vortex event
  141519. * @param _scene The BabylonJS scene
  141520. * @param _origin The origin position of the vortex
  141521. * @param _options The options for the vortex event
  141522. */
  141523. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141524. /**
  141525. * Returns the data related to the vortex event (cylinder).
  141526. * @returns The physics vortex event data
  141527. */
  141528. getData(): PhysicsVortexEventData;
  141529. /**
  141530. * Enables the vortex.
  141531. */
  141532. enable(): void;
  141533. /**
  141534. * Disables the cortex.
  141535. */
  141536. disable(): void;
  141537. /**
  141538. * Disposes the sphere.
  141539. * @param force
  141540. */
  141541. dispose(force?: boolean): void;
  141542. private getImpostorHitData;
  141543. private _tick;
  141544. /*** Helpers ***/
  141545. private _prepareCylinder;
  141546. private _intersectsWithCylinder;
  141547. }
  141548. /**
  141549. * Options fot the radial explosion event
  141550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141551. */
  141552. export class PhysicsRadialExplosionEventOptions {
  141553. /**
  141554. * The radius of the sphere for the radial explosion.
  141555. */
  141556. radius: number;
  141557. /**
  141558. * The strenth of the explosion.
  141559. */
  141560. strength: number;
  141561. /**
  141562. * The strenght of the force in correspondence to the distance of the affected object
  141563. */
  141564. falloff: PhysicsRadialImpulseFalloff;
  141565. /**
  141566. * Sphere options for the radial explosion.
  141567. */
  141568. sphere: {
  141569. segments: number;
  141570. diameter: number;
  141571. };
  141572. /**
  141573. * Sphere options for the radial explosion.
  141574. */
  141575. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  141576. }
  141577. /**
  141578. * Options fot the updraft event
  141579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141580. */
  141581. export class PhysicsUpdraftEventOptions {
  141582. /**
  141583. * The radius of the cylinder for the vortex
  141584. */
  141585. radius: number;
  141586. /**
  141587. * The strenth of the updraft.
  141588. */
  141589. strength: number;
  141590. /**
  141591. * The height of the cylinder for the updraft.
  141592. */
  141593. height: number;
  141594. /**
  141595. * The mode for the the updraft.
  141596. */
  141597. updraftMode: PhysicsUpdraftMode;
  141598. }
  141599. /**
  141600. * Options fot the vortex event
  141601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141602. */
  141603. export class PhysicsVortexEventOptions {
  141604. /**
  141605. * The radius of the cylinder for the vortex
  141606. */
  141607. radius: number;
  141608. /**
  141609. * The strenth of the vortex.
  141610. */
  141611. strength: number;
  141612. /**
  141613. * The height of the cylinder for the vortex.
  141614. */
  141615. height: number;
  141616. /**
  141617. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  141618. */
  141619. centripetalForceThreshold: number;
  141620. /**
  141621. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  141622. */
  141623. centripetalForceMultiplier: number;
  141624. /**
  141625. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  141626. */
  141627. centrifugalForceMultiplier: number;
  141628. /**
  141629. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  141630. */
  141631. updraftForceMultiplier: number;
  141632. }
  141633. /**
  141634. * The strenght of the force in correspondence to the distance of the affected object
  141635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141636. */
  141637. export enum PhysicsRadialImpulseFalloff {
  141638. /** Defines that impulse is constant in strength across it's whole radius */
  141639. Constant = 0,
  141640. /** Defines that impulse gets weaker if it's further from the origin */
  141641. Linear = 1
  141642. }
  141643. /**
  141644. * The strength of the force in correspondence to the distance of the affected object
  141645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141646. */
  141647. export enum PhysicsUpdraftMode {
  141648. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  141649. Center = 0,
  141650. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  141651. Perpendicular = 1
  141652. }
  141653. /**
  141654. * Interface for a physics hit data
  141655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141656. */
  141657. export interface PhysicsHitData {
  141658. /**
  141659. * The force applied at the contact point
  141660. */
  141661. force: Vector3;
  141662. /**
  141663. * The contact point
  141664. */
  141665. contactPoint: Vector3;
  141666. /**
  141667. * The distance from the origin to the contact point
  141668. */
  141669. distanceFromOrigin: number;
  141670. }
  141671. /**
  141672. * Interface for radial explosion event data
  141673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141674. */
  141675. export interface PhysicsRadialExplosionEventData {
  141676. /**
  141677. * A sphere used for the radial explosion event
  141678. */
  141679. sphere: Mesh;
  141680. }
  141681. /**
  141682. * Interface for gravitational field event data
  141683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141684. */
  141685. export interface PhysicsGravitationalFieldEventData {
  141686. /**
  141687. * A sphere mesh used for the gravitational field event
  141688. */
  141689. sphere: Mesh;
  141690. }
  141691. /**
  141692. * Interface for updraft event data
  141693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141694. */
  141695. export interface PhysicsUpdraftEventData {
  141696. /**
  141697. * A cylinder used for the updraft event
  141698. */
  141699. cylinder: Mesh;
  141700. }
  141701. /**
  141702. * Interface for vortex event data
  141703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141704. */
  141705. export interface PhysicsVortexEventData {
  141706. /**
  141707. * A cylinder used for the vortex event
  141708. */
  141709. cylinder: Mesh;
  141710. }
  141711. /**
  141712. * Interface for an affected physics impostor
  141713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141714. */
  141715. export interface PhysicsAffectedImpostorWithData {
  141716. /**
  141717. * The impostor affected by the effect
  141718. */
  141719. impostor: PhysicsImpostor;
  141720. /**
  141721. * The data about the hit/horce from the explosion
  141722. */
  141723. hitData: PhysicsHitData;
  141724. }
  141725. }
  141726. declare module BABYLON {
  141727. /** @hidden */
  141728. export var blackAndWhitePixelShader: {
  141729. name: string;
  141730. shader: string;
  141731. };
  141732. }
  141733. declare module BABYLON {
  141734. /**
  141735. * Post process used to render in black and white
  141736. */
  141737. export class BlackAndWhitePostProcess extends PostProcess {
  141738. /**
  141739. * Linear about to convert he result to black and white (default: 1)
  141740. */
  141741. degree: number;
  141742. /**
  141743. * Creates a black and white post process
  141744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  141745. * @param name The name of the effect.
  141746. * @param options The required width/height ratio to downsize to before computing the render pass.
  141747. * @param camera The camera to apply the render pass to.
  141748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141749. * @param engine The engine which the post process will be applied. (default: current engine)
  141750. * @param reusable If the post process can be reused on the same frame. (default: false)
  141751. */
  141752. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141753. }
  141754. }
  141755. declare module BABYLON {
  141756. /**
  141757. * This represents a set of one or more post processes in Babylon.
  141758. * A post process can be used to apply a shader to a texture after it is rendered.
  141759. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  141760. */
  141761. export class PostProcessRenderEffect {
  141762. private _postProcesses;
  141763. private _getPostProcesses;
  141764. private _singleInstance;
  141765. private _cameras;
  141766. private _indicesForCamera;
  141767. /**
  141768. * Name of the effect
  141769. * @hidden
  141770. */
  141771. _name: string;
  141772. /**
  141773. * Instantiates a post process render effect.
  141774. * A post process can be used to apply a shader to a texture after it is rendered.
  141775. * @param engine The engine the effect is tied to
  141776. * @param name The name of the effect
  141777. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  141778. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  141779. */
  141780. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  141781. /**
  141782. * Checks if all the post processes in the effect are supported.
  141783. */
  141784. get isSupported(): boolean;
  141785. /**
  141786. * Updates the current state of the effect
  141787. * @hidden
  141788. */
  141789. _update(): void;
  141790. /**
  141791. * Attaches the effect on cameras
  141792. * @param cameras The camera to attach to.
  141793. * @hidden
  141794. */
  141795. _attachCameras(cameras: Camera): void;
  141796. /**
  141797. * Attaches the effect on cameras
  141798. * @param cameras The camera to attach to.
  141799. * @hidden
  141800. */
  141801. _attachCameras(cameras: Camera[]): void;
  141802. /**
  141803. * Detaches the effect on cameras
  141804. * @param cameras The camera to detatch from.
  141805. * @hidden
  141806. */
  141807. _detachCameras(cameras: Camera): void;
  141808. /**
  141809. * Detatches the effect on cameras
  141810. * @param cameras The camera to detatch from.
  141811. * @hidden
  141812. */
  141813. _detachCameras(cameras: Camera[]): void;
  141814. /**
  141815. * Enables the effect on given cameras
  141816. * @param cameras The camera to enable.
  141817. * @hidden
  141818. */
  141819. _enable(cameras: Camera): void;
  141820. /**
  141821. * Enables the effect on given cameras
  141822. * @param cameras The camera to enable.
  141823. * @hidden
  141824. */
  141825. _enable(cameras: Nullable<Camera[]>): void;
  141826. /**
  141827. * Disables the effect on the given cameras
  141828. * @param cameras The camera to disable.
  141829. * @hidden
  141830. */
  141831. _disable(cameras: Camera): void;
  141832. /**
  141833. * Disables the effect on the given cameras
  141834. * @param cameras The camera to disable.
  141835. * @hidden
  141836. */
  141837. _disable(cameras: Nullable<Camera[]>): void;
  141838. /**
  141839. * Gets a list of the post processes contained in the effect.
  141840. * @param camera The camera to get the post processes on.
  141841. * @returns The list of the post processes in the effect.
  141842. */
  141843. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  141844. }
  141845. }
  141846. declare module BABYLON {
  141847. /** @hidden */
  141848. export var extractHighlightsPixelShader: {
  141849. name: string;
  141850. shader: string;
  141851. };
  141852. }
  141853. declare module BABYLON {
  141854. /**
  141855. * 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.
  141856. */
  141857. export class ExtractHighlightsPostProcess extends PostProcess {
  141858. /**
  141859. * The luminance threshold, pixels below this value will be set to black.
  141860. */
  141861. threshold: number;
  141862. /** @hidden */
  141863. _exposure: number;
  141864. /**
  141865. * Post process which has the input texture to be used when performing highlight extraction
  141866. * @hidden
  141867. */
  141868. _inputPostProcess: Nullable<PostProcess>;
  141869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141870. }
  141871. }
  141872. declare module BABYLON {
  141873. /** @hidden */
  141874. export var bloomMergePixelShader: {
  141875. name: string;
  141876. shader: string;
  141877. };
  141878. }
  141879. declare module BABYLON {
  141880. /**
  141881. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  141882. */
  141883. export class BloomMergePostProcess extends PostProcess {
  141884. /** Weight of the bloom to be added to the original input. */
  141885. weight: number;
  141886. /**
  141887. * Creates a new instance of @see BloomMergePostProcess
  141888. * @param name The name of the effect.
  141889. * @param originalFromInput Post process which's input will be used for the merge.
  141890. * @param blurred Blurred highlights post process which's output will be used.
  141891. * @param weight Weight of the bloom to be added to the original input.
  141892. * @param options The required width/height ratio to downsize to before computing the render pass.
  141893. * @param camera The camera to apply the render pass to.
  141894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141895. * @param engine The engine which the post process will be applied. (default: current engine)
  141896. * @param reusable If the post process can be reused on the same frame. (default: false)
  141897. * @param textureType Type of textures used when performing the post process. (default: 0)
  141898. * @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)
  141899. */
  141900. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  141901. /** Weight of the bloom to be added to the original input. */
  141902. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141903. }
  141904. }
  141905. declare module BABYLON {
  141906. /**
  141907. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  141908. */
  141909. export class BloomEffect extends PostProcessRenderEffect {
  141910. private bloomScale;
  141911. /**
  141912. * @hidden Internal
  141913. */
  141914. _effects: Array<PostProcess>;
  141915. /**
  141916. * @hidden Internal
  141917. */
  141918. _downscale: ExtractHighlightsPostProcess;
  141919. private _blurX;
  141920. private _blurY;
  141921. private _merge;
  141922. /**
  141923. * The luminance threshold to find bright areas of the image to bloom.
  141924. */
  141925. get threshold(): number;
  141926. set threshold(value: number);
  141927. /**
  141928. * The strength of the bloom.
  141929. */
  141930. get weight(): number;
  141931. set weight(value: number);
  141932. /**
  141933. * Specifies the size of the bloom blur kernel, relative to the final output size
  141934. */
  141935. get kernel(): number;
  141936. set kernel(value: number);
  141937. /**
  141938. * Creates a new instance of @see BloomEffect
  141939. * @param scene The scene the effect belongs to.
  141940. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  141941. * @param bloomKernel The size of the kernel to be used when applying the blur.
  141942. * @param bloomWeight The the strength of bloom.
  141943. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  141944. * @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)
  141945. */
  141946. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  141947. /**
  141948. * Disposes each of the internal effects for a given camera.
  141949. * @param camera The camera to dispose the effect on.
  141950. */
  141951. disposeEffects(camera: Camera): void;
  141952. /**
  141953. * @hidden Internal
  141954. */
  141955. _updateEffects(): void;
  141956. /**
  141957. * Internal
  141958. * @returns if all the contained post processes are ready.
  141959. * @hidden
  141960. */
  141961. _isReady(): boolean;
  141962. }
  141963. }
  141964. declare module BABYLON {
  141965. /** @hidden */
  141966. export var chromaticAberrationPixelShader: {
  141967. name: string;
  141968. shader: string;
  141969. };
  141970. }
  141971. declare module BABYLON {
  141972. /**
  141973. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  141974. */
  141975. export class ChromaticAberrationPostProcess extends PostProcess {
  141976. /**
  141977. * The amount of seperation of rgb channels (default: 30)
  141978. */
  141979. aberrationAmount: number;
  141980. /**
  141981. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  141982. */
  141983. radialIntensity: number;
  141984. /**
  141985. * 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))
  141986. */
  141987. direction: Vector2;
  141988. /**
  141989. * 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))
  141990. */
  141991. centerPosition: Vector2;
  141992. /**
  141993. * Creates a new instance ChromaticAberrationPostProcess
  141994. * @param name The name of the effect.
  141995. * @param screenWidth The width of the screen to apply the effect on.
  141996. * @param screenHeight The height of the screen to apply the effect on.
  141997. * @param options The required width/height ratio to downsize to before computing the render pass.
  141998. * @param camera The camera to apply the render pass to.
  141999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142000. * @param engine The engine which the post process will be applied. (default: current engine)
  142001. * @param reusable If the post process can be reused on the same frame. (default: false)
  142002. * @param textureType Type of textures used when performing the post process. (default: 0)
  142003. * @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)
  142004. */
  142005. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142006. }
  142007. }
  142008. declare module BABYLON {
  142009. /** @hidden */
  142010. export var circleOfConfusionPixelShader: {
  142011. name: string;
  142012. shader: string;
  142013. };
  142014. }
  142015. declare module BABYLON {
  142016. /**
  142017. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142018. */
  142019. export class CircleOfConfusionPostProcess extends PostProcess {
  142020. /**
  142021. * 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.
  142022. */
  142023. lensSize: number;
  142024. /**
  142025. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142026. */
  142027. fStop: number;
  142028. /**
  142029. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142030. */
  142031. focusDistance: number;
  142032. /**
  142033. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142034. */
  142035. focalLength: number;
  142036. private _depthTexture;
  142037. /**
  142038. * Creates a new instance CircleOfConfusionPostProcess
  142039. * @param name The name of the effect.
  142040. * @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.
  142041. * @param options The required width/height ratio to downsize to before computing the render pass.
  142042. * @param camera The camera to apply the render pass to.
  142043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142044. * @param engine The engine which the post process will be applied. (default: current engine)
  142045. * @param reusable If the post process can be reused on the same frame. (default: false)
  142046. * @param textureType Type of textures used when performing the post process. (default: 0)
  142047. * @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)
  142048. */
  142049. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142050. /**
  142051. * 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.
  142052. */
  142053. set depthTexture(value: RenderTargetTexture);
  142054. }
  142055. }
  142056. declare module BABYLON {
  142057. /** @hidden */
  142058. export var colorCorrectionPixelShader: {
  142059. name: string;
  142060. shader: string;
  142061. };
  142062. }
  142063. declare module BABYLON {
  142064. /**
  142065. *
  142066. * This post-process allows the modification of rendered colors by using
  142067. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142068. *
  142069. * The object needs to be provided an url to a texture containing the color
  142070. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142071. * Use an image editing software to tweak the LUT to match your needs.
  142072. *
  142073. * For an example of a color LUT, see here:
  142074. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142075. * For explanations on color grading, see here:
  142076. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142077. *
  142078. */
  142079. export class ColorCorrectionPostProcess extends PostProcess {
  142080. private _colorTableTexture;
  142081. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142082. }
  142083. }
  142084. declare module BABYLON {
  142085. /** @hidden */
  142086. export var convolutionPixelShader: {
  142087. name: string;
  142088. shader: string;
  142089. };
  142090. }
  142091. declare module BABYLON {
  142092. /**
  142093. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142094. * input texture to perform effects such as edge detection or sharpening
  142095. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142096. */
  142097. export class ConvolutionPostProcess extends PostProcess {
  142098. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142099. kernel: number[];
  142100. /**
  142101. * Creates a new instance ConvolutionPostProcess
  142102. * @param name The name of the effect.
  142103. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142104. * @param options The required width/height ratio to downsize to before computing the render pass.
  142105. * @param camera The camera to apply the render pass to.
  142106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142107. * @param engine The engine which the post process will be applied. (default: current engine)
  142108. * @param reusable If the post process can be reused on the same frame. (default: false)
  142109. * @param textureType Type of textures used when performing the post process. (default: 0)
  142110. */
  142111. constructor(name: string,
  142112. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142113. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142114. /**
  142115. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142116. */
  142117. static EdgeDetect0Kernel: number[];
  142118. /**
  142119. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142120. */
  142121. static EdgeDetect1Kernel: number[];
  142122. /**
  142123. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142124. */
  142125. static EdgeDetect2Kernel: number[];
  142126. /**
  142127. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142128. */
  142129. static SharpenKernel: number[];
  142130. /**
  142131. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142132. */
  142133. static EmbossKernel: number[];
  142134. /**
  142135. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142136. */
  142137. static GaussianKernel: number[];
  142138. }
  142139. }
  142140. declare module BABYLON {
  142141. /**
  142142. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142143. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142144. * based on samples that have a large difference in distance than the center pixel.
  142145. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142146. */
  142147. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142148. direction: Vector2;
  142149. /**
  142150. * Creates a new instance CircleOfConfusionPostProcess
  142151. * @param name The name of the effect.
  142152. * @param scene The scene the effect belongs to.
  142153. * @param direction The direction the blur should be applied.
  142154. * @param kernel The size of the kernel used to blur.
  142155. * @param options The required width/height ratio to downsize to before computing the render pass.
  142156. * @param camera The camera to apply the render pass to.
  142157. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142158. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142160. * @param engine The engine which the post process will be applied. (default: current engine)
  142161. * @param reusable If the post process can be reused on the same frame. (default: false)
  142162. * @param textureType Type of textures used when performing the post process. (default: 0)
  142163. * @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)
  142164. */
  142165. 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);
  142166. }
  142167. }
  142168. declare module BABYLON {
  142169. /** @hidden */
  142170. export var depthOfFieldMergePixelShader: {
  142171. name: string;
  142172. shader: string;
  142173. };
  142174. }
  142175. declare module BABYLON {
  142176. /**
  142177. * Options to be set when merging outputs from the default pipeline.
  142178. */
  142179. export class DepthOfFieldMergePostProcessOptions {
  142180. /**
  142181. * The original image to merge on top of
  142182. */
  142183. originalFromInput: PostProcess;
  142184. /**
  142185. * Parameters to perform the merge of the depth of field effect
  142186. */
  142187. depthOfField?: {
  142188. circleOfConfusion: PostProcess;
  142189. blurSteps: Array<PostProcess>;
  142190. };
  142191. /**
  142192. * Parameters to perform the merge of bloom effect
  142193. */
  142194. bloom?: {
  142195. blurred: PostProcess;
  142196. weight: number;
  142197. };
  142198. }
  142199. /**
  142200. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142201. */
  142202. export class DepthOfFieldMergePostProcess extends PostProcess {
  142203. private blurSteps;
  142204. /**
  142205. * Creates a new instance of DepthOfFieldMergePostProcess
  142206. * @param name The name of the effect.
  142207. * @param originalFromInput Post process which's input will be used for the merge.
  142208. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142209. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142210. * @param options The required width/height ratio to downsize to before computing the render pass.
  142211. * @param camera The camera to apply the render pass to.
  142212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142213. * @param engine The engine which the post process will be applied. (default: current engine)
  142214. * @param reusable If the post process can be reused on the same frame. (default: false)
  142215. * @param textureType Type of textures used when performing the post process. (default: 0)
  142216. * @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)
  142217. */
  142218. 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);
  142219. /**
  142220. * Updates the effect with the current post process compile time values and recompiles the shader.
  142221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142224. * @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
  142225. * @param onCompiled Called when the shader has been compiled.
  142226. * @param onError Called if there is an error when compiling a shader.
  142227. */
  142228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142229. }
  142230. }
  142231. declare module BABYLON {
  142232. /**
  142233. * Specifies the level of max blur that should be applied when using the depth of field effect
  142234. */
  142235. export enum DepthOfFieldEffectBlurLevel {
  142236. /**
  142237. * Subtle blur
  142238. */
  142239. Low = 0,
  142240. /**
  142241. * Medium blur
  142242. */
  142243. Medium = 1,
  142244. /**
  142245. * Large blur
  142246. */
  142247. High = 2
  142248. }
  142249. /**
  142250. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142251. */
  142252. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142253. private _circleOfConfusion;
  142254. /**
  142255. * @hidden Internal, blurs from high to low
  142256. */
  142257. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142258. private _depthOfFieldBlurY;
  142259. private _dofMerge;
  142260. /**
  142261. * @hidden Internal post processes in depth of field effect
  142262. */
  142263. _effects: Array<PostProcess>;
  142264. /**
  142265. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142266. */
  142267. set focalLength(value: number);
  142268. get focalLength(): number;
  142269. /**
  142270. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142271. */
  142272. set fStop(value: number);
  142273. get fStop(): number;
  142274. /**
  142275. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142276. */
  142277. set focusDistance(value: number);
  142278. get focusDistance(): number;
  142279. /**
  142280. * 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.
  142281. */
  142282. set lensSize(value: number);
  142283. get lensSize(): number;
  142284. /**
  142285. * Creates a new instance DepthOfFieldEffect
  142286. * @param scene The scene the effect belongs to.
  142287. * @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.
  142288. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142289. * @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)
  142290. */
  142291. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142292. /**
  142293. * Get the current class name of the current effet
  142294. * @returns "DepthOfFieldEffect"
  142295. */
  142296. getClassName(): string;
  142297. /**
  142298. * 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.
  142299. */
  142300. set depthTexture(value: RenderTargetTexture);
  142301. /**
  142302. * Disposes each of the internal effects for a given camera.
  142303. * @param camera The camera to dispose the effect on.
  142304. */
  142305. disposeEffects(camera: Camera): void;
  142306. /**
  142307. * @hidden Internal
  142308. */
  142309. _updateEffects(): void;
  142310. /**
  142311. * Internal
  142312. * @returns if all the contained post processes are ready.
  142313. * @hidden
  142314. */
  142315. _isReady(): boolean;
  142316. }
  142317. }
  142318. declare module BABYLON {
  142319. /** @hidden */
  142320. export var displayPassPixelShader: {
  142321. name: string;
  142322. shader: string;
  142323. };
  142324. }
  142325. declare module BABYLON {
  142326. /**
  142327. * DisplayPassPostProcess which produces an output the same as it's input
  142328. */
  142329. export class DisplayPassPostProcess extends PostProcess {
  142330. /**
  142331. * Creates the DisplayPassPostProcess
  142332. * @param name The name of the effect.
  142333. * @param options The required width/height ratio to downsize to before computing the render pass.
  142334. * @param camera The camera to apply the render pass to.
  142335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142336. * @param engine The engine which the post process will be applied. (default: current engine)
  142337. * @param reusable If the post process can be reused on the same frame. (default: false)
  142338. */
  142339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142340. }
  142341. }
  142342. declare module BABYLON {
  142343. /** @hidden */
  142344. export var filterPixelShader: {
  142345. name: string;
  142346. shader: string;
  142347. };
  142348. }
  142349. declare module BABYLON {
  142350. /**
  142351. * Applies a kernel filter to the image
  142352. */
  142353. export class FilterPostProcess extends PostProcess {
  142354. /** The matrix to be applied to the image */
  142355. kernelMatrix: Matrix;
  142356. /**
  142357. *
  142358. * @param name The name of the effect.
  142359. * @param kernelMatrix The matrix to be applied to the image
  142360. * @param options The required width/height ratio to downsize to before computing the render pass.
  142361. * @param camera The camera to apply the render pass to.
  142362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142363. * @param engine The engine which the post process will be applied. (default: current engine)
  142364. * @param reusable If the post process can be reused on the same frame. (default: false)
  142365. */
  142366. constructor(name: string,
  142367. /** The matrix to be applied to the image */
  142368. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142369. }
  142370. }
  142371. declare module BABYLON {
  142372. /** @hidden */
  142373. export var fxaaPixelShader: {
  142374. name: string;
  142375. shader: string;
  142376. };
  142377. }
  142378. declare module BABYLON {
  142379. /** @hidden */
  142380. export var fxaaVertexShader: {
  142381. name: string;
  142382. shader: string;
  142383. };
  142384. }
  142385. declare module BABYLON {
  142386. /**
  142387. * Fxaa post process
  142388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142389. */
  142390. export class FxaaPostProcess extends PostProcess {
  142391. /** @hidden */
  142392. texelWidth: number;
  142393. /** @hidden */
  142394. texelHeight: number;
  142395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142396. private _getDefines;
  142397. }
  142398. }
  142399. declare module BABYLON {
  142400. /** @hidden */
  142401. export var grainPixelShader: {
  142402. name: string;
  142403. shader: string;
  142404. };
  142405. }
  142406. declare module BABYLON {
  142407. /**
  142408. * The GrainPostProcess adds noise to the image at mid luminance levels
  142409. */
  142410. export class GrainPostProcess extends PostProcess {
  142411. /**
  142412. * The intensity of the grain added (default: 30)
  142413. */
  142414. intensity: number;
  142415. /**
  142416. * If the grain should be randomized on every frame
  142417. */
  142418. animated: boolean;
  142419. /**
  142420. * Creates a new instance of @see GrainPostProcess
  142421. * @param name The name of the effect.
  142422. * @param options The required width/height ratio to downsize to before computing the render pass.
  142423. * @param camera The camera to apply the render pass to.
  142424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142425. * @param engine The engine which the post process will be applied. (default: current engine)
  142426. * @param reusable If the post process can be reused on the same frame. (default: false)
  142427. * @param textureType Type of textures used when performing the post process. (default: 0)
  142428. * @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)
  142429. */
  142430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142431. }
  142432. }
  142433. declare module BABYLON {
  142434. /** @hidden */
  142435. export var highlightsPixelShader: {
  142436. name: string;
  142437. shader: string;
  142438. };
  142439. }
  142440. declare module BABYLON {
  142441. /**
  142442. * Extracts highlights from the image
  142443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142444. */
  142445. export class HighlightsPostProcess extends PostProcess {
  142446. /**
  142447. * Extracts highlights from the image
  142448. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142449. * @param name The name of the effect.
  142450. * @param options The required width/height ratio to downsize to before computing the render pass.
  142451. * @param camera The camera to apply the render pass to.
  142452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142453. * @param engine The engine which the post process will be applied. (default: current engine)
  142454. * @param reusable If the post process can be reused on the same frame. (default: false)
  142455. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142456. */
  142457. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142458. }
  142459. }
  142460. declare module BABYLON {
  142461. /** @hidden */
  142462. export var mrtFragmentDeclaration: {
  142463. name: string;
  142464. shader: string;
  142465. };
  142466. }
  142467. declare module BABYLON {
  142468. /** @hidden */
  142469. export var geometryPixelShader: {
  142470. name: string;
  142471. shader: string;
  142472. };
  142473. }
  142474. declare module BABYLON {
  142475. /** @hidden */
  142476. export var geometryVertexShader: {
  142477. name: string;
  142478. shader: string;
  142479. };
  142480. }
  142481. declare module BABYLON {
  142482. /** @hidden */
  142483. interface ISavedTransformationMatrix {
  142484. world: Matrix;
  142485. viewProjection: Matrix;
  142486. }
  142487. /**
  142488. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142489. */
  142490. export class GeometryBufferRenderer {
  142491. /**
  142492. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142493. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142494. */
  142495. static readonly POSITION_TEXTURE_TYPE: number;
  142496. /**
  142497. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142498. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142499. */
  142500. static readonly VELOCITY_TEXTURE_TYPE: number;
  142501. /**
  142502. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142503. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142504. */
  142505. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142506. /**
  142507. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142508. * in order to compute objects velocities when enableVelocity is set to "true"
  142509. * @hidden
  142510. */
  142511. _previousTransformationMatrices: {
  142512. [index: number]: ISavedTransformationMatrix;
  142513. };
  142514. /**
  142515. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142516. * in order to compute objects velocities when enableVelocity is set to "true"
  142517. * @hidden
  142518. */
  142519. _previousBonesTransformationMatrices: {
  142520. [index: number]: Float32Array;
  142521. };
  142522. /**
  142523. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142524. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142525. */
  142526. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142527. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142528. renderTransparentMeshes: boolean;
  142529. private _scene;
  142530. private _multiRenderTarget;
  142531. private _ratio;
  142532. private _enablePosition;
  142533. private _enableVelocity;
  142534. private _enableReflectivity;
  142535. private _positionIndex;
  142536. private _velocityIndex;
  142537. private _reflectivityIndex;
  142538. protected _effect: Effect;
  142539. protected _cachedDefines: string;
  142540. /**
  142541. * Set the render list (meshes to be rendered) used in the G buffer.
  142542. */
  142543. set renderList(meshes: Mesh[]);
  142544. /**
  142545. * Gets wether or not G buffer are supported by the running hardware.
  142546. * This requires draw buffer supports
  142547. */
  142548. get isSupported(): boolean;
  142549. /**
  142550. * Returns the index of the given texture type in the G-Buffer textures array
  142551. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  142552. * @returns the index of the given texture type in the G-Buffer textures array
  142553. */
  142554. getTextureIndex(textureType: number): number;
  142555. /**
  142556. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  142557. */
  142558. get enablePosition(): boolean;
  142559. /**
  142560. * Sets whether or not objects positions are enabled for the G buffer.
  142561. */
  142562. set enablePosition(enable: boolean);
  142563. /**
  142564. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  142565. */
  142566. get enableVelocity(): boolean;
  142567. /**
  142568. * Sets wether or not objects velocities are enabled for the G buffer.
  142569. */
  142570. set enableVelocity(enable: boolean);
  142571. /**
  142572. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  142573. */
  142574. get enableReflectivity(): boolean;
  142575. /**
  142576. * Sets wether or not objects roughness are enabled for the G buffer.
  142577. */
  142578. set enableReflectivity(enable: boolean);
  142579. /**
  142580. * Gets the scene associated with the buffer.
  142581. */
  142582. get scene(): Scene;
  142583. /**
  142584. * Gets the ratio used by the buffer during its creation.
  142585. * How big is the buffer related to the main canvas.
  142586. */
  142587. get ratio(): number;
  142588. /** @hidden */
  142589. static _SceneComponentInitialization: (scene: Scene) => void;
  142590. /**
  142591. * Creates a new G Buffer for the scene
  142592. * @param scene The scene the buffer belongs to
  142593. * @param ratio How big is the buffer related to the main canvas.
  142594. */
  142595. constructor(scene: Scene, ratio?: number);
  142596. /**
  142597. * Checks wether everything is ready to render a submesh to the G buffer.
  142598. * @param subMesh the submesh to check readiness for
  142599. * @param useInstances is the mesh drawn using instance or not
  142600. * @returns true if ready otherwise false
  142601. */
  142602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142603. /**
  142604. * Gets the current underlying G Buffer.
  142605. * @returns the buffer
  142606. */
  142607. getGBuffer(): MultiRenderTarget;
  142608. /**
  142609. * Gets the number of samples used to render the buffer (anti aliasing).
  142610. */
  142611. get samples(): number;
  142612. /**
  142613. * Sets the number of samples used to render the buffer (anti aliasing).
  142614. */
  142615. set samples(value: number);
  142616. /**
  142617. * Disposes the renderer and frees up associated resources.
  142618. */
  142619. dispose(): void;
  142620. protected _createRenderTargets(): void;
  142621. private _copyBonesTransformationMatrices;
  142622. }
  142623. }
  142624. declare module BABYLON {
  142625. interface Scene {
  142626. /** @hidden (Backing field) */
  142627. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142628. /**
  142629. * Gets or Sets the current geometry buffer associated to the scene.
  142630. */
  142631. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142632. /**
  142633. * Enables a GeometryBufferRender and associates it with the scene
  142634. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  142635. * @returns the GeometryBufferRenderer
  142636. */
  142637. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  142638. /**
  142639. * Disables the GeometryBufferRender associated with the scene
  142640. */
  142641. disableGeometryBufferRenderer(): void;
  142642. }
  142643. /**
  142644. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  142645. * in several rendering techniques.
  142646. */
  142647. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  142648. /**
  142649. * The component name helpful to identify the component in the list of scene components.
  142650. */
  142651. readonly name: string;
  142652. /**
  142653. * The scene the component belongs to.
  142654. */
  142655. scene: Scene;
  142656. /**
  142657. * Creates a new instance of the component for the given scene
  142658. * @param scene Defines the scene to register the component in
  142659. */
  142660. constructor(scene: Scene);
  142661. /**
  142662. * Registers the component in a given scene
  142663. */
  142664. register(): void;
  142665. /**
  142666. * Rebuilds the elements related to this component in case of
  142667. * context lost for instance.
  142668. */
  142669. rebuild(): void;
  142670. /**
  142671. * Disposes the component and the associated ressources
  142672. */
  142673. dispose(): void;
  142674. private _gatherRenderTargets;
  142675. }
  142676. }
  142677. declare module BABYLON {
  142678. /** @hidden */
  142679. export var motionBlurPixelShader: {
  142680. name: string;
  142681. shader: string;
  142682. };
  142683. }
  142684. declare module BABYLON {
  142685. /**
  142686. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  142687. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  142688. * As an example, all you have to do is to create the post-process:
  142689. * var mb = new BABYLON.MotionBlurPostProcess(
  142690. * 'mb', // The name of the effect.
  142691. * scene, // The scene containing the objects to blur according to their velocity.
  142692. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  142693. * camera // The camera to apply the render pass to.
  142694. * );
  142695. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  142696. */
  142697. export class MotionBlurPostProcess extends PostProcess {
  142698. /**
  142699. * Defines how much the image is blurred by the movement. Default value is equal to 1
  142700. */
  142701. motionStrength: number;
  142702. /**
  142703. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  142704. */
  142705. get motionBlurSamples(): number;
  142706. /**
  142707. * Sets the number of iterations to be used for motion blur quality
  142708. */
  142709. set motionBlurSamples(samples: number);
  142710. private _motionBlurSamples;
  142711. private _geometryBufferRenderer;
  142712. /**
  142713. * Creates a new instance MotionBlurPostProcess
  142714. * @param name The name of the effect.
  142715. * @param scene The scene containing the objects to blur according to their velocity.
  142716. * @param options The required width/height ratio to downsize to before computing the render pass.
  142717. * @param camera The camera to apply the render pass to.
  142718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142719. * @param engine The engine which the post process will be applied. (default: current engine)
  142720. * @param reusable If the post process can be reused on the same frame. (default: false)
  142721. * @param textureType Type of textures used when performing the post process. (default: 0)
  142722. * @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)
  142723. */
  142724. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142725. /**
  142726. * Excludes the given skinned mesh from computing bones velocities.
  142727. * 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.
  142728. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  142729. */
  142730. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142731. /**
  142732. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  142733. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  142734. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  142735. */
  142736. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142737. /**
  142738. * Disposes the post process.
  142739. * @param camera The camera to dispose the post process on.
  142740. */
  142741. dispose(camera?: Camera): void;
  142742. }
  142743. }
  142744. declare module BABYLON {
  142745. /** @hidden */
  142746. export var refractionPixelShader: {
  142747. name: string;
  142748. shader: string;
  142749. };
  142750. }
  142751. declare module BABYLON {
  142752. /**
  142753. * Post process which applies a refractin texture
  142754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142755. */
  142756. export class RefractionPostProcess extends PostProcess {
  142757. /** the base color of the refraction (used to taint the rendering) */
  142758. color: Color3;
  142759. /** simulated refraction depth */
  142760. depth: number;
  142761. /** the coefficient of the base color (0 to remove base color tainting) */
  142762. colorLevel: number;
  142763. private _refTexture;
  142764. private _ownRefractionTexture;
  142765. /**
  142766. * Gets or sets the refraction texture
  142767. * Please note that you are responsible for disposing the texture if you set it manually
  142768. */
  142769. get refractionTexture(): Texture;
  142770. set refractionTexture(value: Texture);
  142771. /**
  142772. * Initializes the RefractionPostProcess
  142773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142774. * @param name The name of the effect.
  142775. * @param refractionTextureUrl Url of the refraction texture to use
  142776. * @param color the base color of the refraction (used to taint the rendering)
  142777. * @param depth simulated refraction depth
  142778. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  142779. * @param camera The camera to apply the render pass to.
  142780. * @param options The required width/height ratio to downsize to before computing the render pass.
  142781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142782. * @param engine The engine which the post process will be applied. (default: current engine)
  142783. * @param reusable If the post process can be reused on the same frame. (default: false)
  142784. */
  142785. constructor(name: string, refractionTextureUrl: string,
  142786. /** the base color of the refraction (used to taint the rendering) */
  142787. color: Color3,
  142788. /** simulated refraction depth */
  142789. depth: number,
  142790. /** the coefficient of the base color (0 to remove base color tainting) */
  142791. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142792. /**
  142793. * Disposes of the post process
  142794. * @param camera Camera to dispose post process on
  142795. */
  142796. dispose(camera: Camera): void;
  142797. }
  142798. }
  142799. declare module BABYLON {
  142800. /** @hidden */
  142801. export var sharpenPixelShader: {
  142802. name: string;
  142803. shader: string;
  142804. };
  142805. }
  142806. declare module BABYLON {
  142807. /**
  142808. * The SharpenPostProcess applies a sharpen kernel to every pixel
  142809. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142810. */
  142811. export class SharpenPostProcess extends PostProcess {
  142812. /**
  142813. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  142814. */
  142815. colorAmount: number;
  142816. /**
  142817. * How much sharpness should be applied (default: 0.3)
  142818. */
  142819. edgeAmount: number;
  142820. /**
  142821. * Creates a new instance ConvolutionPostProcess
  142822. * @param name The name of the effect.
  142823. * @param options The required width/height ratio to downsize to before computing the render pass.
  142824. * @param camera The camera to apply the render pass to.
  142825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142826. * @param engine The engine which the post process will be applied. (default: current engine)
  142827. * @param reusable If the post process can be reused on the same frame. (default: false)
  142828. * @param textureType Type of textures used when performing the post process. (default: 0)
  142829. * @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)
  142830. */
  142831. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142832. }
  142833. }
  142834. declare module BABYLON {
  142835. /**
  142836. * PostProcessRenderPipeline
  142837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142838. */
  142839. export class PostProcessRenderPipeline {
  142840. private engine;
  142841. private _renderEffects;
  142842. private _renderEffectsForIsolatedPass;
  142843. /**
  142844. * List of inspectable custom properties (used by the Inspector)
  142845. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  142846. */
  142847. inspectableCustomProperties: IInspectable[];
  142848. /**
  142849. * @hidden
  142850. */
  142851. protected _cameras: Camera[];
  142852. /** @hidden */
  142853. _name: string;
  142854. /**
  142855. * Gets pipeline name
  142856. */
  142857. get name(): string;
  142858. /** Gets the list of attached cameras */
  142859. get cameras(): Camera[];
  142860. /**
  142861. * Initializes a PostProcessRenderPipeline
  142862. * @param engine engine to add the pipeline to
  142863. * @param name name of the pipeline
  142864. */
  142865. constructor(engine: Engine, name: string);
  142866. /**
  142867. * Gets the class name
  142868. * @returns "PostProcessRenderPipeline"
  142869. */
  142870. getClassName(): string;
  142871. /**
  142872. * If all the render effects in the pipeline are supported
  142873. */
  142874. get isSupported(): boolean;
  142875. /**
  142876. * Adds an effect to the pipeline
  142877. * @param renderEffect the effect to add
  142878. */
  142879. addEffect(renderEffect: PostProcessRenderEffect): void;
  142880. /** @hidden */
  142881. _rebuild(): void;
  142882. /** @hidden */
  142883. _enableEffect(renderEffectName: string, cameras: Camera): void;
  142884. /** @hidden */
  142885. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  142886. /** @hidden */
  142887. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142888. /** @hidden */
  142889. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142890. /** @hidden */
  142891. _attachCameras(cameras: Camera, unique: boolean): void;
  142892. /** @hidden */
  142893. _attachCameras(cameras: Camera[], unique: boolean): void;
  142894. /** @hidden */
  142895. _detachCameras(cameras: Camera): void;
  142896. /** @hidden */
  142897. _detachCameras(cameras: Nullable<Camera[]>): void;
  142898. /** @hidden */
  142899. _update(): void;
  142900. /** @hidden */
  142901. _reset(): void;
  142902. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  142903. /**
  142904. * Disposes of the pipeline
  142905. */
  142906. dispose(): void;
  142907. }
  142908. }
  142909. declare module BABYLON {
  142910. /**
  142911. * PostProcessRenderPipelineManager class
  142912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142913. */
  142914. export class PostProcessRenderPipelineManager {
  142915. private _renderPipelines;
  142916. /**
  142917. * Initializes a PostProcessRenderPipelineManager
  142918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142919. */
  142920. constructor();
  142921. /**
  142922. * Gets the list of supported render pipelines
  142923. */
  142924. get supportedPipelines(): PostProcessRenderPipeline[];
  142925. /**
  142926. * Adds a pipeline to the manager
  142927. * @param renderPipeline The pipeline to add
  142928. */
  142929. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  142930. /**
  142931. * Attaches a camera to the pipeline
  142932. * @param renderPipelineName The name of the pipeline to attach to
  142933. * @param cameras the camera to attach
  142934. * @param unique if the camera can be attached multiple times to the pipeline
  142935. */
  142936. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  142937. /**
  142938. * Detaches a camera from the pipeline
  142939. * @param renderPipelineName The name of the pipeline to detach from
  142940. * @param cameras the camera to detach
  142941. */
  142942. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  142943. /**
  142944. * Enables an effect by name on a pipeline
  142945. * @param renderPipelineName the name of the pipeline to enable the effect in
  142946. * @param renderEffectName the name of the effect to enable
  142947. * @param cameras the cameras that the effect should be enabled on
  142948. */
  142949. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142950. /**
  142951. * Disables an effect by name on a pipeline
  142952. * @param renderPipelineName the name of the pipeline to disable the effect in
  142953. * @param renderEffectName the name of the effect to disable
  142954. * @param cameras the cameras that the effect should be disabled on
  142955. */
  142956. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142957. /**
  142958. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  142959. */
  142960. update(): void;
  142961. /** @hidden */
  142962. _rebuild(): void;
  142963. /**
  142964. * Disposes of the manager and pipelines
  142965. */
  142966. dispose(): void;
  142967. }
  142968. }
  142969. declare module BABYLON {
  142970. interface Scene {
  142971. /** @hidden (Backing field) */
  142972. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142973. /**
  142974. * Gets the postprocess render pipeline manager
  142975. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142976. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  142977. */
  142978. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142979. }
  142980. /**
  142981. * Defines the Render Pipeline scene component responsible to rendering pipelines
  142982. */
  142983. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  142984. /**
  142985. * The component name helpfull to identify the component in the list of scene components.
  142986. */
  142987. readonly name: string;
  142988. /**
  142989. * The scene the component belongs to.
  142990. */
  142991. scene: Scene;
  142992. /**
  142993. * Creates a new instance of the component for the given scene
  142994. * @param scene Defines the scene to register the component in
  142995. */
  142996. constructor(scene: Scene);
  142997. /**
  142998. * Registers the component in a given scene
  142999. */
  143000. register(): void;
  143001. /**
  143002. * Rebuilds the elements related to this component in case of
  143003. * context lost for instance.
  143004. */
  143005. rebuild(): void;
  143006. /**
  143007. * Disposes the component and the associated ressources
  143008. */
  143009. dispose(): void;
  143010. private _gatherRenderTargets;
  143011. }
  143012. }
  143013. declare module BABYLON {
  143014. /**
  143015. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143016. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143017. */
  143018. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143019. private _scene;
  143020. private _camerasToBeAttached;
  143021. /**
  143022. * ID of the sharpen post process,
  143023. */
  143024. private readonly SharpenPostProcessId;
  143025. /**
  143026. * @ignore
  143027. * ID of the image processing post process;
  143028. */
  143029. readonly ImageProcessingPostProcessId: string;
  143030. /**
  143031. * @ignore
  143032. * ID of the Fast Approximate Anti-Aliasing post process;
  143033. */
  143034. readonly FxaaPostProcessId: string;
  143035. /**
  143036. * ID of the chromatic aberration post process,
  143037. */
  143038. private readonly ChromaticAberrationPostProcessId;
  143039. /**
  143040. * ID of the grain post process
  143041. */
  143042. private readonly GrainPostProcessId;
  143043. /**
  143044. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143045. */
  143046. sharpen: SharpenPostProcess;
  143047. private _sharpenEffect;
  143048. private bloom;
  143049. /**
  143050. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143051. */
  143052. depthOfField: DepthOfFieldEffect;
  143053. /**
  143054. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143055. */
  143056. fxaa: FxaaPostProcess;
  143057. /**
  143058. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143059. */
  143060. imageProcessing: ImageProcessingPostProcess;
  143061. /**
  143062. * Chromatic aberration post process which will shift rgb colors in the image
  143063. */
  143064. chromaticAberration: ChromaticAberrationPostProcess;
  143065. private _chromaticAberrationEffect;
  143066. /**
  143067. * Grain post process which add noise to the image
  143068. */
  143069. grain: GrainPostProcess;
  143070. private _grainEffect;
  143071. /**
  143072. * Glow post process which adds a glow to emissive areas of the image
  143073. */
  143074. private _glowLayer;
  143075. /**
  143076. * Animations which can be used to tweak settings over a period of time
  143077. */
  143078. animations: Animation[];
  143079. private _imageProcessingConfigurationObserver;
  143080. private _sharpenEnabled;
  143081. private _bloomEnabled;
  143082. private _depthOfFieldEnabled;
  143083. private _depthOfFieldBlurLevel;
  143084. private _fxaaEnabled;
  143085. private _imageProcessingEnabled;
  143086. private _defaultPipelineTextureType;
  143087. private _bloomScale;
  143088. private _chromaticAberrationEnabled;
  143089. private _grainEnabled;
  143090. private _buildAllowed;
  143091. /**
  143092. * Gets active scene
  143093. */
  143094. get scene(): Scene;
  143095. /**
  143096. * Enable or disable the sharpen process from the pipeline
  143097. */
  143098. set sharpenEnabled(enabled: boolean);
  143099. get sharpenEnabled(): boolean;
  143100. private _resizeObserver;
  143101. private _hardwareScaleLevel;
  143102. private _bloomKernel;
  143103. /**
  143104. * Specifies the size of the bloom blur kernel, relative to the final output size
  143105. */
  143106. get bloomKernel(): number;
  143107. set bloomKernel(value: number);
  143108. /**
  143109. * Specifies the weight of the bloom in the final rendering
  143110. */
  143111. private _bloomWeight;
  143112. /**
  143113. * Specifies the luma threshold for the area that will be blurred by the bloom
  143114. */
  143115. private _bloomThreshold;
  143116. private _hdr;
  143117. /**
  143118. * The strength of the bloom.
  143119. */
  143120. set bloomWeight(value: number);
  143121. get bloomWeight(): number;
  143122. /**
  143123. * The strength of the bloom.
  143124. */
  143125. set bloomThreshold(value: number);
  143126. get bloomThreshold(): number;
  143127. /**
  143128. * The scale of the bloom, lower value will provide better performance.
  143129. */
  143130. set bloomScale(value: number);
  143131. get bloomScale(): number;
  143132. /**
  143133. * Enable or disable the bloom from the pipeline
  143134. */
  143135. set bloomEnabled(enabled: boolean);
  143136. get bloomEnabled(): boolean;
  143137. private _rebuildBloom;
  143138. /**
  143139. * If the depth of field is enabled.
  143140. */
  143141. get depthOfFieldEnabled(): boolean;
  143142. set depthOfFieldEnabled(enabled: boolean);
  143143. /**
  143144. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143145. */
  143146. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143147. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143148. /**
  143149. * If the anti aliasing is enabled.
  143150. */
  143151. set fxaaEnabled(enabled: boolean);
  143152. get fxaaEnabled(): boolean;
  143153. private _samples;
  143154. /**
  143155. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143156. */
  143157. set samples(sampleCount: number);
  143158. get samples(): number;
  143159. /**
  143160. * If image processing is enabled.
  143161. */
  143162. set imageProcessingEnabled(enabled: boolean);
  143163. get imageProcessingEnabled(): boolean;
  143164. /**
  143165. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143166. */
  143167. set glowLayerEnabled(enabled: boolean);
  143168. get glowLayerEnabled(): boolean;
  143169. /**
  143170. * Gets the glow layer (or null if not defined)
  143171. */
  143172. get glowLayer(): Nullable<GlowLayer>;
  143173. /**
  143174. * Enable or disable the chromaticAberration process from the pipeline
  143175. */
  143176. set chromaticAberrationEnabled(enabled: boolean);
  143177. get chromaticAberrationEnabled(): boolean;
  143178. /**
  143179. * Enable or disable the grain process from the pipeline
  143180. */
  143181. set grainEnabled(enabled: boolean);
  143182. get grainEnabled(): boolean;
  143183. /**
  143184. * @constructor
  143185. * @param name - The rendering pipeline name (default: "")
  143186. * @param hdr - If high dynamic range textures should be used (default: true)
  143187. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143188. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143189. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143190. */
  143191. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143192. /**
  143193. * Get the class name
  143194. * @returns "DefaultRenderingPipeline"
  143195. */
  143196. getClassName(): string;
  143197. /**
  143198. * Force the compilation of the entire pipeline.
  143199. */
  143200. prepare(): void;
  143201. private _hasCleared;
  143202. private _prevPostProcess;
  143203. private _prevPrevPostProcess;
  143204. private _setAutoClearAndTextureSharing;
  143205. private _depthOfFieldSceneObserver;
  143206. private _buildPipeline;
  143207. private _disposePostProcesses;
  143208. /**
  143209. * Adds a camera to the pipeline
  143210. * @param camera the camera to be added
  143211. */
  143212. addCamera(camera: Camera): void;
  143213. /**
  143214. * Removes a camera from the pipeline
  143215. * @param camera the camera to remove
  143216. */
  143217. removeCamera(camera: Camera): void;
  143218. /**
  143219. * Dispose of the pipeline and stop all post processes
  143220. */
  143221. dispose(): void;
  143222. /**
  143223. * Serialize the rendering pipeline (Used when exporting)
  143224. * @returns the serialized object
  143225. */
  143226. serialize(): any;
  143227. /**
  143228. * Parse the serialized pipeline
  143229. * @param source Source pipeline.
  143230. * @param scene The scene to load the pipeline to.
  143231. * @param rootUrl The URL of the serialized pipeline.
  143232. * @returns An instantiated pipeline from the serialized object.
  143233. */
  143234. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143235. }
  143236. }
  143237. declare module BABYLON {
  143238. /** @hidden */
  143239. export var lensHighlightsPixelShader: {
  143240. name: string;
  143241. shader: string;
  143242. };
  143243. }
  143244. declare module BABYLON {
  143245. /** @hidden */
  143246. export var depthOfFieldPixelShader: {
  143247. name: string;
  143248. shader: string;
  143249. };
  143250. }
  143251. declare module BABYLON {
  143252. /**
  143253. * BABYLON.JS Chromatic Aberration GLSL Shader
  143254. * Author: Olivier Guyot
  143255. * Separates very slightly R, G and B colors on the edges of the screen
  143256. * Inspired by Francois Tarlier & Martins Upitis
  143257. */
  143258. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143259. /**
  143260. * @ignore
  143261. * The chromatic aberration PostProcess id in the pipeline
  143262. */
  143263. LensChromaticAberrationEffect: string;
  143264. /**
  143265. * @ignore
  143266. * The highlights enhancing PostProcess id in the pipeline
  143267. */
  143268. HighlightsEnhancingEffect: string;
  143269. /**
  143270. * @ignore
  143271. * The depth-of-field PostProcess id in the pipeline
  143272. */
  143273. LensDepthOfFieldEffect: string;
  143274. private _scene;
  143275. private _depthTexture;
  143276. private _grainTexture;
  143277. private _chromaticAberrationPostProcess;
  143278. private _highlightsPostProcess;
  143279. private _depthOfFieldPostProcess;
  143280. private _edgeBlur;
  143281. private _grainAmount;
  143282. private _chromaticAberration;
  143283. private _distortion;
  143284. private _highlightsGain;
  143285. private _highlightsThreshold;
  143286. private _dofDistance;
  143287. private _dofAperture;
  143288. private _dofDarken;
  143289. private _dofPentagon;
  143290. private _blurNoise;
  143291. /**
  143292. * @constructor
  143293. *
  143294. * Effect parameters are as follow:
  143295. * {
  143296. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143297. * edge_blur: number; // from 0 to x (1 for realism)
  143298. * distortion: number; // from 0 to x (1 for realism)
  143299. * grain_amount: number; // from 0 to 1
  143300. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143301. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143302. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143303. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143304. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143305. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143306. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143307. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143308. * }
  143309. * Note: if an effect parameter is unset, effect is disabled
  143310. *
  143311. * @param name The rendering pipeline name
  143312. * @param parameters - An object containing all parameters (see above)
  143313. * @param scene The scene linked to this pipeline
  143314. * @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)
  143315. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143316. */
  143317. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143318. /**
  143319. * Get the class name
  143320. * @returns "LensRenderingPipeline"
  143321. */
  143322. getClassName(): string;
  143323. /**
  143324. * Gets associated scene
  143325. */
  143326. get scene(): Scene;
  143327. /**
  143328. * Gets or sets the edge blur
  143329. */
  143330. get edgeBlur(): number;
  143331. set edgeBlur(value: number);
  143332. /**
  143333. * Gets or sets the grain amount
  143334. */
  143335. get grainAmount(): number;
  143336. set grainAmount(value: number);
  143337. /**
  143338. * Gets or sets the chromatic aberration amount
  143339. */
  143340. get chromaticAberration(): number;
  143341. set chromaticAberration(value: number);
  143342. /**
  143343. * Gets or sets the depth of field aperture
  143344. */
  143345. get dofAperture(): number;
  143346. set dofAperture(value: number);
  143347. /**
  143348. * Gets or sets the edge distortion
  143349. */
  143350. get edgeDistortion(): number;
  143351. set edgeDistortion(value: number);
  143352. /**
  143353. * Gets or sets the depth of field distortion
  143354. */
  143355. get dofDistortion(): number;
  143356. set dofDistortion(value: number);
  143357. /**
  143358. * Gets or sets the darken out of focus amount
  143359. */
  143360. get darkenOutOfFocus(): number;
  143361. set darkenOutOfFocus(value: number);
  143362. /**
  143363. * Gets or sets a boolean indicating if blur noise is enabled
  143364. */
  143365. get blurNoise(): boolean;
  143366. set blurNoise(value: boolean);
  143367. /**
  143368. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143369. */
  143370. get pentagonBokeh(): boolean;
  143371. set pentagonBokeh(value: boolean);
  143372. /**
  143373. * Gets or sets the highlight grain amount
  143374. */
  143375. get highlightsGain(): number;
  143376. set highlightsGain(value: number);
  143377. /**
  143378. * Gets or sets the highlight threshold
  143379. */
  143380. get highlightsThreshold(): number;
  143381. set highlightsThreshold(value: number);
  143382. /**
  143383. * Sets the amount of blur at the edges
  143384. * @param amount blur amount
  143385. */
  143386. setEdgeBlur(amount: number): void;
  143387. /**
  143388. * Sets edge blur to 0
  143389. */
  143390. disableEdgeBlur(): void;
  143391. /**
  143392. * Sets the amout of grain
  143393. * @param amount Amount of grain
  143394. */
  143395. setGrainAmount(amount: number): void;
  143396. /**
  143397. * Set grain amount to 0
  143398. */
  143399. disableGrain(): void;
  143400. /**
  143401. * Sets the chromatic aberration amount
  143402. * @param amount amount of chromatic aberration
  143403. */
  143404. setChromaticAberration(amount: number): void;
  143405. /**
  143406. * Sets chromatic aberration amount to 0
  143407. */
  143408. disableChromaticAberration(): void;
  143409. /**
  143410. * Sets the EdgeDistortion amount
  143411. * @param amount amount of EdgeDistortion
  143412. */
  143413. setEdgeDistortion(amount: number): void;
  143414. /**
  143415. * Sets edge distortion to 0
  143416. */
  143417. disableEdgeDistortion(): void;
  143418. /**
  143419. * Sets the FocusDistance amount
  143420. * @param amount amount of FocusDistance
  143421. */
  143422. setFocusDistance(amount: number): void;
  143423. /**
  143424. * Disables depth of field
  143425. */
  143426. disableDepthOfField(): void;
  143427. /**
  143428. * Sets the Aperture amount
  143429. * @param amount amount of Aperture
  143430. */
  143431. setAperture(amount: number): void;
  143432. /**
  143433. * Sets the DarkenOutOfFocus amount
  143434. * @param amount amount of DarkenOutOfFocus
  143435. */
  143436. setDarkenOutOfFocus(amount: number): void;
  143437. private _pentagonBokehIsEnabled;
  143438. /**
  143439. * Creates a pentagon bokeh effect
  143440. */
  143441. enablePentagonBokeh(): void;
  143442. /**
  143443. * Disables the pentagon bokeh effect
  143444. */
  143445. disablePentagonBokeh(): void;
  143446. /**
  143447. * Enables noise blur
  143448. */
  143449. enableNoiseBlur(): void;
  143450. /**
  143451. * Disables noise blur
  143452. */
  143453. disableNoiseBlur(): void;
  143454. /**
  143455. * Sets the HighlightsGain amount
  143456. * @param amount amount of HighlightsGain
  143457. */
  143458. setHighlightsGain(amount: number): void;
  143459. /**
  143460. * Sets the HighlightsThreshold amount
  143461. * @param amount amount of HighlightsThreshold
  143462. */
  143463. setHighlightsThreshold(amount: number): void;
  143464. /**
  143465. * Disables highlights
  143466. */
  143467. disableHighlights(): void;
  143468. /**
  143469. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143470. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143471. */
  143472. dispose(disableDepthRender?: boolean): void;
  143473. private _createChromaticAberrationPostProcess;
  143474. private _createHighlightsPostProcess;
  143475. private _createDepthOfFieldPostProcess;
  143476. private _createGrainTexture;
  143477. }
  143478. }
  143479. declare module BABYLON {
  143480. /** @hidden */
  143481. export var ssao2PixelShader: {
  143482. name: string;
  143483. shader: string;
  143484. };
  143485. }
  143486. declare module BABYLON {
  143487. /** @hidden */
  143488. export var ssaoCombinePixelShader: {
  143489. name: string;
  143490. shader: string;
  143491. };
  143492. }
  143493. declare module BABYLON {
  143494. /**
  143495. * Render pipeline to produce ssao effect
  143496. */
  143497. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143498. /**
  143499. * @ignore
  143500. * The PassPostProcess id in the pipeline that contains the original scene color
  143501. */
  143502. SSAOOriginalSceneColorEffect: string;
  143503. /**
  143504. * @ignore
  143505. * The SSAO PostProcess id in the pipeline
  143506. */
  143507. SSAORenderEffect: string;
  143508. /**
  143509. * @ignore
  143510. * The horizontal blur PostProcess id in the pipeline
  143511. */
  143512. SSAOBlurHRenderEffect: string;
  143513. /**
  143514. * @ignore
  143515. * The vertical blur PostProcess id in the pipeline
  143516. */
  143517. SSAOBlurVRenderEffect: string;
  143518. /**
  143519. * @ignore
  143520. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143521. */
  143522. SSAOCombineRenderEffect: string;
  143523. /**
  143524. * The output strength of the SSAO post-process. Default value is 1.0.
  143525. */
  143526. totalStrength: number;
  143527. /**
  143528. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143529. */
  143530. maxZ: number;
  143531. /**
  143532. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143533. */
  143534. minZAspect: number;
  143535. private _samples;
  143536. /**
  143537. * Number of samples used for the SSAO calculations. Default value is 8
  143538. */
  143539. set samples(n: number);
  143540. get samples(): number;
  143541. private _textureSamples;
  143542. /**
  143543. * Number of samples to use for antialiasing
  143544. */
  143545. set textureSamples(n: number);
  143546. get textureSamples(): number;
  143547. /**
  143548. * Ratio object used for SSAO ratio and blur ratio
  143549. */
  143550. private _ratio;
  143551. /**
  143552. * Dynamically generated sphere sampler.
  143553. */
  143554. private _sampleSphere;
  143555. /**
  143556. * Blur filter offsets
  143557. */
  143558. private _samplerOffsets;
  143559. private _expensiveBlur;
  143560. /**
  143561. * If bilateral blur should be used
  143562. */
  143563. set expensiveBlur(b: boolean);
  143564. get expensiveBlur(): boolean;
  143565. /**
  143566. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  143567. */
  143568. radius: number;
  143569. /**
  143570. * The base color of the SSAO post-process
  143571. * The final result is "base + ssao" between [0, 1]
  143572. */
  143573. base: number;
  143574. /**
  143575. * Support test.
  143576. */
  143577. static get IsSupported(): boolean;
  143578. private _scene;
  143579. private _depthTexture;
  143580. private _normalTexture;
  143581. private _randomTexture;
  143582. private _originalColorPostProcess;
  143583. private _ssaoPostProcess;
  143584. private _blurHPostProcess;
  143585. private _blurVPostProcess;
  143586. private _ssaoCombinePostProcess;
  143587. /**
  143588. * Gets active scene
  143589. */
  143590. get scene(): Scene;
  143591. /**
  143592. * @constructor
  143593. * @param name The rendering pipeline name
  143594. * @param scene The scene linked to this pipeline
  143595. * @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 }
  143596. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143597. */
  143598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143599. /**
  143600. * Get the class name
  143601. * @returns "SSAO2RenderingPipeline"
  143602. */
  143603. getClassName(): string;
  143604. /**
  143605. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143606. */
  143607. dispose(disableGeometryBufferRenderer?: boolean): void;
  143608. private _createBlurPostProcess;
  143609. /** @hidden */
  143610. _rebuild(): void;
  143611. private _bits;
  143612. private _radicalInverse_VdC;
  143613. private _hammersley;
  143614. private _hemisphereSample_uniform;
  143615. private _generateHemisphere;
  143616. private _createSSAOPostProcess;
  143617. private _createSSAOCombinePostProcess;
  143618. private _createRandomTexture;
  143619. /**
  143620. * Serialize the rendering pipeline (Used when exporting)
  143621. * @returns the serialized object
  143622. */
  143623. serialize(): any;
  143624. /**
  143625. * Parse the serialized pipeline
  143626. * @param source Source pipeline.
  143627. * @param scene The scene to load the pipeline to.
  143628. * @param rootUrl The URL of the serialized pipeline.
  143629. * @returns An instantiated pipeline from the serialized object.
  143630. */
  143631. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  143632. }
  143633. }
  143634. declare module BABYLON {
  143635. /** @hidden */
  143636. export var ssaoPixelShader: {
  143637. name: string;
  143638. shader: string;
  143639. };
  143640. }
  143641. declare module BABYLON {
  143642. /**
  143643. * Render pipeline to produce ssao effect
  143644. */
  143645. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  143646. /**
  143647. * @ignore
  143648. * The PassPostProcess id in the pipeline that contains the original scene color
  143649. */
  143650. SSAOOriginalSceneColorEffect: string;
  143651. /**
  143652. * @ignore
  143653. * The SSAO PostProcess id in the pipeline
  143654. */
  143655. SSAORenderEffect: string;
  143656. /**
  143657. * @ignore
  143658. * The horizontal blur PostProcess id in the pipeline
  143659. */
  143660. SSAOBlurHRenderEffect: string;
  143661. /**
  143662. * @ignore
  143663. * The vertical blur PostProcess id in the pipeline
  143664. */
  143665. SSAOBlurVRenderEffect: string;
  143666. /**
  143667. * @ignore
  143668. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143669. */
  143670. SSAOCombineRenderEffect: string;
  143671. /**
  143672. * The output strength of the SSAO post-process. Default value is 1.0.
  143673. */
  143674. totalStrength: number;
  143675. /**
  143676. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  143677. */
  143678. radius: number;
  143679. /**
  143680. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  143681. * Must not be equal to fallOff and superior to fallOff.
  143682. * Default value is 0.0075
  143683. */
  143684. area: number;
  143685. /**
  143686. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  143687. * Must not be equal to area and inferior to area.
  143688. * Default value is 0.000001
  143689. */
  143690. fallOff: number;
  143691. /**
  143692. * The base color of the SSAO post-process
  143693. * The final result is "base + ssao" between [0, 1]
  143694. */
  143695. base: number;
  143696. private _scene;
  143697. private _depthTexture;
  143698. private _randomTexture;
  143699. private _originalColorPostProcess;
  143700. private _ssaoPostProcess;
  143701. private _blurHPostProcess;
  143702. private _blurVPostProcess;
  143703. private _ssaoCombinePostProcess;
  143704. private _firstUpdate;
  143705. /**
  143706. * Gets active scene
  143707. */
  143708. get scene(): Scene;
  143709. /**
  143710. * @constructor
  143711. * @param name - The rendering pipeline name
  143712. * @param scene - The scene linked to this pipeline
  143713. * @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 }
  143714. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  143715. */
  143716. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143717. /**
  143718. * Get the class name
  143719. * @returns "SSAORenderingPipeline"
  143720. */
  143721. getClassName(): string;
  143722. /**
  143723. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143724. */
  143725. dispose(disableDepthRender?: boolean): void;
  143726. private _createBlurPostProcess;
  143727. /** @hidden */
  143728. _rebuild(): void;
  143729. private _createSSAOPostProcess;
  143730. private _createSSAOCombinePostProcess;
  143731. private _createRandomTexture;
  143732. }
  143733. }
  143734. declare module BABYLON {
  143735. /** @hidden */
  143736. export var screenSpaceReflectionPixelShader: {
  143737. name: string;
  143738. shader: string;
  143739. };
  143740. }
  143741. declare module BABYLON {
  143742. /**
  143743. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  143744. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  143745. */
  143746. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  143747. /**
  143748. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  143749. */
  143750. threshold: number;
  143751. /**
  143752. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  143753. */
  143754. strength: number;
  143755. /**
  143756. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  143757. */
  143758. reflectionSpecularFalloffExponent: number;
  143759. /**
  143760. * 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]
  143761. */
  143762. step: number;
  143763. /**
  143764. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  143765. */
  143766. roughnessFactor: number;
  143767. private _geometryBufferRenderer;
  143768. private _enableSmoothReflections;
  143769. private _reflectionSamples;
  143770. private _smoothSteps;
  143771. /**
  143772. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  143773. * @param name The name of the effect.
  143774. * @param scene The scene containing the objects to calculate reflections.
  143775. * @param options The required width/height ratio to downsize to before computing the render pass.
  143776. * @param camera The camera to apply the render pass to.
  143777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143778. * @param engine The engine which the post process will be applied. (default: current engine)
  143779. * @param reusable If the post process can be reused on the same frame. (default: false)
  143780. * @param textureType Type of textures used when performing the post process. (default: 0)
  143781. * @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)
  143782. */
  143783. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143784. /**
  143785. * Gets wether or not smoothing reflections is enabled.
  143786. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143787. */
  143788. get enableSmoothReflections(): boolean;
  143789. /**
  143790. * Sets wether or not smoothing reflections is enabled.
  143791. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143792. */
  143793. set enableSmoothReflections(enabled: boolean);
  143794. /**
  143795. * Gets the number of samples taken while computing reflections. More samples count is high,
  143796. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143797. */
  143798. get reflectionSamples(): number;
  143799. /**
  143800. * Sets the number of samples taken while computing reflections. More samples count is high,
  143801. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143802. */
  143803. set reflectionSamples(samples: number);
  143804. /**
  143805. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  143806. * more the post-process will require GPU power and can generate a drop in FPS.
  143807. * Default value (5.0) work pretty well in all cases but can be adjusted.
  143808. */
  143809. get smoothSteps(): number;
  143810. set smoothSteps(steps: number);
  143811. private _updateEffectDefines;
  143812. }
  143813. }
  143814. declare module BABYLON {
  143815. /** @hidden */
  143816. export var standardPixelShader: {
  143817. name: string;
  143818. shader: string;
  143819. };
  143820. }
  143821. declare module BABYLON {
  143822. /**
  143823. * Standard rendering pipeline
  143824. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  143825. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  143826. */
  143827. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143828. /**
  143829. * Public members
  143830. */
  143831. /**
  143832. * Post-process which contains the original scene color before the pipeline applies all the effects
  143833. */
  143834. originalPostProcess: Nullable<PostProcess>;
  143835. /**
  143836. * Post-process used to down scale an image x4
  143837. */
  143838. downSampleX4PostProcess: Nullable<PostProcess>;
  143839. /**
  143840. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  143841. */
  143842. brightPassPostProcess: Nullable<PostProcess>;
  143843. /**
  143844. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  143845. */
  143846. blurHPostProcesses: PostProcess[];
  143847. /**
  143848. * Post-process array storing all the vertical blur post-processes used by the pipeline
  143849. */
  143850. blurVPostProcesses: PostProcess[];
  143851. /**
  143852. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  143853. */
  143854. textureAdderPostProcess: Nullable<PostProcess>;
  143855. /**
  143856. * Post-process used to create volumetric lighting effect
  143857. */
  143858. volumetricLightPostProcess: Nullable<PostProcess>;
  143859. /**
  143860. * Post-process used to smooth the previous volumetric light post-process on the X axis
  143861. */
  143862. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  143863. /**
  143864. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  143865. */
  143866. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  143867. /**
  143868. * Post-process used to merge the volumetric light effect and the real scene color
  143869. */
  143870. volumetricLightMergePostProces: Nullable<PostProcess>;
  143871. /**
  143872. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  143873. */
  143874. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  143875. /**
  143876. * Base post-process used to calculate the average luminance of the final image for HDR
  143877. */
  143878. luminancePostProcess: Nullable<PostProcess>;
  143879. /**
  143880. * Post-processes used to create down sample post-processes in order to get
  143881. * the average luminance of the final image for HDR
  143882. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  143883. */
  143884. luminanceDownSamplePostProcesses: PostProcess[];
  143885. /**
  143886. * Post-process used to create a HDR effect (light adaptation)
  143887. */
  143888. hdrPostProcess: Nullable<PostProcess>;
  143889. /**
  143890. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  143891. */
  143892. textureAdderFinalPostProcess: Nullable<PostProcess>;
  143893. /**
  143894. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  143895. */
  143896. lensFlareFinalPostProcess: Nullable<PostProcess>;
  143897. /**
  143898. * Post-process used to merge the final HDR post-process and the real scene color
  143899. */
  143900. hdrFinalPostProcess: Nullable<PostProcess>;
  143901. /**
  143902. * Post-process used to create a lens flare effect
  143903. */
  143904. lensFlarePostProcess: Nullable<PostProcess>;
  143905. /**
  143906. * Post-process that merges the result of the lens flare post-process and the real scene color
  143907. */
  143908. lensFlareComposePostProcess: Nullable<PostProcess>;
  143909. /**
  143910. * Post-process used to create a motion blur effect
  143911. */
  143912. motionBlurPostProcess: Nullable<PostProcess>;
  143913. /**
  143914. * Post-process used to create a depth of field effect
  143915. */
  143916. depthOfFieldPostProcess: Nullable<PostProcess>;
  143917. /**
  143918. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143919. */
  143920. fxaaPostProcess: Nullable<FxaaPostProcess>;
  143921. /**
  143922. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  143923. */
  143924. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  143925. /**
  143926. * Represents the brightness threshold in order to configure the illuminated surfaces
  143927. */
  143928. brightThreshold: number;
  143929. /**
  143930. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  143931. */
  143932. blurWidth: number;
  143933. /**
  143934. * Sets if the blur for highlighted surfaces must be only horizontal
  143935. */
  143936. horizontalBlur: boolean;
  143937. /**
  143938. * Gets the overall exposure used by the pipeline
  143939. */
  143940. get exposure(): number;
  143941. /**
  143942. * Sets the overall exposure used by the pipeline
  143943. */
  143944. set exposure(value: number);
  143945. /**
  143946. * Texture used typically to simulate "dirty" on camera lens
  143947. */
  143948. lensTexture: Nullable<Texture>;
  143949. /**
  143950. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  143951. */
  143952. volumetricLightCoefficient: number;
  143953. /**
  143954. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  143955. */
  143956. volumetricLightPower: number;
  143957. /**
  143958. * Used the set the blur intensity to smooth the volumetric lights
  143959. */
  143960. volumetricLightBlurScale: number;
  143961. /**
  143962. * Light (spot or directional) used to generate the volumetric lights rays
  143963. * The source light must have a shadow generate so the pipeline can get its
  143964. * depth map
  143965. */
  143966. sourceLight: Nullable<SpotLight | DirectionalLight>;
  143967. /**
  143968. * For eye adaptation, represents the minimum luminance the eye can see
  143969. */
  143970. hdrMinimumLuminance: number;
  143971. /**
  143972. * For eye adaptation, represents the decrease luminance speed
  143973. */
  143974. hdrDecreaseRate: number;
  143975. /**
  143976. * For eye adaptation, represents the increase luminance speed
  143977. */
  143978. hdrIncreaseRate: number;
  143979. /**
  143980. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143981. */
  143982. get hdrAutoExposure(): boolean;
  143983. /**
  143984. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143985. */
  143986. set hdrAutoExposure(value: boolean);
  143987. /**
  143988. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  143989. */
  143990. lensColorTexture: Nullable<Texture>;
  143991. /**
  143992. * The overall strengh for the lens flare effect
  143993. */
  143994. lensFlareStrength: number;
  143995. /**
  143996. * Dispersion coefficient for lens flare ghosts
  143997. */
  143998. lensFlareGhostDispersal: number;
  143999. /**
  144000. * Main lens flare halo width
  144001. */
  144002. lensFlareHaloWidth: number;
  144003. /**
  144004. * Based on the lens distortion effect, defines how much the lens flare result
  144005. * is distorted
  144006. */
  144007. lensFlareDistortionStrength: number;
  144008. /**
  144009. * Configures the blur intensity used for for lens flare (halo)
  144010. */
  144011. lensFlareBlurWidth: number;
  144012. /**
  144013. * Lens star texture must be used to simulate rays on the flares and is available
  144014. * in the documentation
  144015. */
  144016. lensStarTexture: Nullable<Texture>;
  144017. /**
  144018. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144019. * flare effect by taking account of the dirt texture
  144020. */
  144021. lensFlareDirtTexture: Nullable<Texture>;
  144022. /**
  144023. * Represents the focal length for the depth of field effect
  144024. */
  144025. depthOfFieldDistance: number;
  144026. /**
  144027. * Represents the blur intensity for the blurred part of the depth of field effect
  144028. */
  144029. depthOfFieldBlurWidth: number;
  144030. /**
  144031. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144032. */
  144033. get motionStrength(): number;
  144034. /**
  144035. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144036. */
  144037. set motionStrength(strength: number);
  144038. /**
  144039. * Gets wether or not the motion blur post-process is object based or screen based.
  144040. */
  144041. get objectBasedMotionBlur(): boolean;
  144042. /**
  144043. * Sets wether or not the motion blur post-process should be object based or screen based
  144044. */
  144045. set objectBasedMotionBlur(value: boolean);
  144046. /**
  144047. * List of animations for the pipeline (IAnimatable implementation)
  144048. */
  144049. animations: Animation[];
  144050. /**
  144051. * Private members
  144052. */
  144053. private _scene;
  144054. private _currentDepthOfFieldSource;
  144055. private _basePostProcess;
  144056. private _fixedExposure;
  144057. private _currentExposure;
  144058. private _hdrAutoExposure;
  144059. private _hdrCurrentLuminance;
  144060. private _motionStrength;
  144061. private _isObjectBasedMotionBlur;
  144062. private _floatTextureType;
  144063. private _camerasToBeAttached;
  144064. private _ratio;
  144065. private _bloomEnabled;
  144066. private _depthOfFieldEnabled;
  144067. private _vlsEnabled;
  144068. private _lensFlareEnabled;
  144069. private _hdrEnabled;
  144070. private _motionBlurEnabled;
  144071. private _fxaaEnabled;
  144072. private _screenSpaceReflectionsEnabled;
  144073. private _motionBlurSamples;
  144074. private _volumetricLightStepsCount;
  144075. private _samples;
  144076. /**
  144077. * @ignore
  144078. * Specifies if the bloom pipeline is enabled
  144079. */
  144080. get BloomEnabled(): boolean;
  144081. set BloomEnabled(enabled: boolean);
  144082. /**
  144083. * @ignore
  144084. * Specifies if the depth of field pipeline is enabed
  144085. */
  144086. get DepthOfFieldEnabled(): boolean;
  144087. set DepthOfFieldEnabled(enabled: boolean);
  144088. /**
  144089. * @ignore
  144090. * Specifies if the lens flare pipeline is enabed
  144091. */
  144092. get LensFlareEnabled(): boolean;
  144093. set LensFlareEnabled(enabled: boolean);
  144094. /**
  144095. * @ignore
  144096. * Specifies if the HDR pipeline is enabled
  144097. */
  144098. get HDREnabled(): boolean;
  144099. set HDREnabled(enabled: boolean);
  144100. /**
  144101. * @ignore
  144102. * Specifies if the volumetric lights scattering effect is enabled
  144103. */
  144104. get VLSEnabled(): boolean;
  144105. set VLSEnabled(enabled: boolean);
  144106. /**
  144107. * @ignore
  144108. * Specifies if the motion blur effect is enabled
  144109. */
  144110. get MotionBlurEnabled(): boolean;
  144111. set MotionBlurEnabled(enabled: boolean);
  144112. /**
  144113. * Specifies if anti-aliasing is enabled
  144114. */
  144115. get fxaaEnabled(): boolean;
  144116. set fxaaEnabled(enabled: boolean);
  144117. /**
  144118. * Specifies if screen space reflections are enabled.
  144119. */
  144120. get screenSpaceReflectionsEnabled(): boolean;
  144121. set screenSpaceReflectionsEnabled(enabled: boolean);
  144122. /**
  144123. * Specifies the number of steps used to calculate the volumetric lights
  144124. * Typically in interval [50, 200]
  144125. */
  144126. get volumetricLightStepsCount(): number;
  144127. set volumetricLightStepsCount(count: number);
  144128. /**
  144129. * Specifies the number of samples used for the motion blur effect
  144130. * Typically in interval [16, 64]
  144131. */
  144132. get motionBlurSamples(): number;
  144133. set motionBlurSamples(samples: number);
  144134. /**
  144135. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144136. */
  144137. get samples(): number;
  144138. set samples(sampleCount: number);
  144139. /**
  144140. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144141. * @constructor
  144142. * @param name The rendering pipeline name
  144143. * @param scene The scene linked to this pipeline
  144144. * @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)
  144145. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144146. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144147. */
  144148. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144149. private _buildPipeline;
  144150. private _createDownSampleX4PostProcess;
  144151. private _createBrightPassPostProcess;
  144152. private _createBlurPostProcesses;
  144153. private _createTextureAdderPostProcess;
  144154. private _createVolumetricLightPostProcess;
  144155. private _createLuminancePostProcesses;
  144156. private _createHdrPostProcess;
  144157. private _createLensFlarePostProcess;
  144158. private _createDepthOfFieldPostProcess;
  144159. private _createMotionBlurPostProcess;
  144160. private _getDepthTexture;
  144161. private _disposePostProcesses;
  144162. /**
  144163. * Dispose of the pipeline and stop all post processes
  144164. */
  144165. dispose(): void;
  144166. /**
  144167. * Serialize the rendering pipeline (Used when exporting)
  144168. * @returns the serialized object
  144169. */
  144170. serialize(): any;
  144171. /**
  144172. * Parse the serialized pipeline
  144173. * @param source Source pipeline.
  144174. * @param scene The scene to load the pipeline to.
  144175. * @param rootUrl The URL of the serialized pipeline.
  144176. * @returns An instantiated pipeline from the serialized object.
  144177. */
  144178. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144179. /**
  144180. * Luminance steps
  144181. */
  144182. static LuminanceSteps: number;
  144183. }
  144184. }
  144185. declare module BABYLON {
  144186. /** @hidden */
  144187. export var stereoscopicInterlacePixelShader: {
  144188. name: string;
  144189. shader: string;
  144190. };
  144191. }
  144192. declare module BABYLON {
  144193. /**
  144194. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144195. */
  144196. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144197. private _stepSize;
  144198. private _passedProcess;
  144199. /**
  144200. * Initializes a StereoscopicInterlacePostProcessI
  144201. * @param name The name of the effect.
  144202. * @param rigCameras The rig cameras to be appled to the post process
  144203. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144204. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144206. * @param engine The engine which the post process will be applied. (default: current engine)
  144207. * @param reusable If the post process can be reused on the same frame. (default: false)
  144208. */
  144209. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144210. }
  144211. /**
  144212. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144213. */
  144214. export class StereoscopicInterlacePostProcess extends PostProcess {
  144215. private _stepSize;
  144216. private _passedProcess;
  144217. /**
  144218. * Initializes a StereoscopicInterlacePostProcess
  144219. * @param name The name of the effect.
  144220. * @param rigCameras The rig cameras to be appled to the post process
  144221. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144223. * @param engine The engine which the post process will be applied. (default: current engine)
  144224. * @param reusable If the post process can be reused on the same frame. (default: false)
  144225. */
  144226. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144227. }
  144228. }
  144229. declare module BABYLON {
  144230. /** @hidden */
  144231. export var tonemapPixelShader: {
  144232. name: string;
  144233. shader: string;
  144234. };
  144235. }
  144236. declare module BABYLON {
  144237. /** Defines operator used for tonemapping */
  144238. export enum TonemappingOperator {
  144239. /** Hable */
  144240. Hable = 0,
  144241. /** Reinhard */
  144242. Reinhard = 1,
  144243. /** HejiDawson */
  144244. HejiDawson = 2,
  144245. /** Photographic */
  144246. Photographic = 3
  144247. }
  144248. /**
  144249. * Defines a post process to apply tone mapping
  144250. */
  144251. export class TonemapPostProcess extends PostProcess {
  144252. private _operator;
  144253. /** Defines the required exposure adjustement */
  144254. exposureAdjustment: number;
  144255. /**
  144256. * Creates a new TonemapPostProcess
  144257. * @param name defines the name of the postprocess
  144258. * @param _operator defines the operator to use
  144259. * @param exposureAdjustment defines the required exposure adjustement
  144260. * @param camera defines the camera to use (can be null)
  144261. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144262. * @param engine defines the hosting engine (can be ignore if camera is set)
  144263. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144264. */
  144265. constructor(name: string, _operator: TonemappingOperator,
  144266. /** Defines the required exposure adjustement */
  144267. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144268. }
  144269. }
  144270. declare module BABYLON {
  144271. /** @hidden */
  144272. export var volumetricLightScatteringPixelShader: {
  144273. name: string;
  144274. shader: string;
  144275. };
  144276. }
  144277. declare module BABYLON {
  144278. /** @hidden */
  144279. export var volumetricLightScatteringPassVertexShader: {
  144280. name: string;
  144281. shader: string;
  144282. };
  144283. }
  144284. declare module BABYLON {
  144285. /** @hidden */
  144286. export var volumetricLightScatteringPassPixelShader: {
  144287. name: string;
  144288. shader: string;
  144289. };
  144290. }
  144291. declare module BABYLON {
  144292. /**
  144293. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144294. */
  144295. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144296. private _volumetricLightScatteringPass;
  144297. private _volumetricLightScatteringRTT;
  144298. private _viewPort;
  144299. private _screenCoordinates;
  144300. private _cachedDefines;
  144301. /**
  144302. * If not undefined, the mesh position is computed from the attached node position
  144303. */
  144304. attachedNode: {
  144305. position: Vector3;
  144306. };
  144307. /**
  144308. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144309. */
  144310. customMeshPosition: Vector3;
  144311. /**
  144312. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144313. */
  144314. useCustomMeshPosition: boolean;
  144315. /**
  144316. * If the post-process should inverse the light scattering direction
  144317. */
  144318. invert: boolean;
  144319. /**
  144320. * The internal mesh used by the post-process
  144321. */
  144322. mesh: Mesh;
  144323. /**
  144324. * @hidden
  144325. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144326. */
  144327. get useDiffuseColor(): boolean;
  144328. set useDiffuseColor(useDiffuseColor: boolean);
  144329. /**
  144330. * Array containing the excluded meshes not rendered in the internal pass
  144331. */
  144332. excludedMeshes: AbstractMesh[];
  144333. /**
  144334. * Controls the overall intensity of the post-process
  144335. */
  144336. exposure: number;
  144337. /**
  144338. * Dissipates each sample's contribution in range [0, 1]
  144339. */
  144340. decay: number;
  144341. /**
  144342. * Controls the overall intensity of each sample
  144343. */
  144344. weight: number;
  144345. /**
  144346. * Controls the density of each sample
  144347. */
  144348. density: number;
  144349. /**
  144350. * @constructor
  144351. * @param name The post-process name
  144352. * @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)
  144353. * @param camera The camera that the post-process will be attached to
  144354. * @param mesh The mesh used to create the light scattering
  144355. * @param samples The post-process quality, default 100
  144356. * @param samplingModeThe post-process filtering mode
  144357. * @param engine The babylon engine
  144358. * @param reusable If the post-process is reusable
  144359. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144360. */
  144361. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144362. /**
  144363. * Returns the string "VolumetricLightScatteringPostProcess"
  144364. * @returns "VolumetricLightScatteringPostProcess"
  144365. */
  144366. getClassName(): string;
  144367. private _isReady;
  144368. /**
  144369. * Sets the new light position for light scattering effect
  144370. * @param position The new custom light position
  144371. */
  144372. setCustomMeshPosition(position: Vector3): void;
  144373. /**
  144374. * Returns the light position for light scattering effect
  144375. * @return Vector3 The custom light position
  144376. */
  144377. getCustomMeshPosition(): Vector3;
  144378. /**
  144379. * Disposes the internal assets and detaches the post-process from the camera
  144380. */
  144381. dispose(camera: Camera): void;
  144382. /**
  144383. * Returns the render target texture used by the post-process
  144384. * @return the render target texture used by the post-process
  144385. */
  144386. getPass(): RenderTargetTexture;
  144387. private _meshExcluded;
  144388. private _createPass;
  144389. private _updateMeshScreenCoordinates;
  144390. /**
  144391. * Creates a default mesh for the Volumeric Light Scattering post-process
  144392. * @param name The mesh name
  144393. * @param scene The scene where to create the mesh
  144394. * @return the default mesh
  144395. */
  144396. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144397. }
  144398. }
  144399. declare module BABYLON {
  144400. interface Scene {
  144401. /** @hidden (Backing field) */
  144402. _boundingBoxRenderer: BoundingBoxRenderer;
  144403. /** @hidden (Backing field) */
  144404. _forceShowBoundingBoxes: boolean;
  144405. /**
  144406. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144407. */
  144408. forceShowBoundingBoxes: boolean;
  144409. /**
  144410. * Gets the bounding box renderer associated with the scene
  144411. * @returns a BoundingBoxRenderer
  144412. */
  144413. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144414. }
  144415. interface AbstractMesh {
  144416. /** @hidden (Backing field) */
  144417. _showBoundingBox: boolean;
  144418. /**
  144419. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144420. */
  144421. showBoundingBox: boolean;
  144422. }
  144423. /**
  144424. * Component responsible of rendering the bounding box of the meshes in a scene.
  144425. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144426. */
  144427. export class BoundingBoxRenderer implements ISceneComponent {
  144428. /**
  144429. * The component name helpfull to identify the component in the list of scene components.
  144430. */
  144431. readonly name: string;
  144432. /**
  144433. * The scene the component belongs to.
  144434. */
  144435. scene: Scene;
  144436. /**
  144437. * Color of the bounding box lines placed in front of an object
  144438. */
  144439. frontColor: Color3;
  144440. /**
  144441. * Color of the bounding box lines placed behind an object
  144442. */
  144443. backColor: Color3;
  144444. /**
  144445. * Defines if the renderer should show the back lines or not
  144446. */
  144447. showBackLines: boolean;
  144448. /**
  144449. * @hidden
  144450. */
  144451. renderList: SmartArray<BoundingBox>;
  144452. private _colorShader;
  144453. private _vertexBuffers;
  144454. private _indexBuffer;
  144455. private _fillIndexBuffer;
  144456. private _fillIndexData;
  144457. /**
  144458. * Instantiates a new bounding box renderer in a scene.
  144459. * @param scene the scene the renderer renders in
  144460. */
  144461. constructor(scene: Scene);
  144462. /**
  144463. * Registers the component in a given scene
  144464. */
  144465. register(): void;
  144466. private _evaluateSubMesh;
  144467. private _activeMesh;
  144468. private _prepareRessources;
  144469. private _createIndexBuffer;
  144470. /**
  144471. * Rebuilds the elements related to this component in case of
  144472. * context lost for instance.
  144473. */
  144474. rebuild(): void;
  144475. /**
  144476. * @hidden
  144477. */
  144478. reset(): void;
  144479. /**
  144480. * Render the bounding boxes of a specific rendering group
  144481. * @param renderingGroupId defines the rendering group to render
  144482. */
  144483. render(renderingGroupId: number): void;
  144484. /**
  144485. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144486. * @param mesh Define the mesh to render the occlusion bounding box for
  144487. */
  144488. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144489. /**
  144490. * Dispose and release the resources attached to this renderer.
  144491. */
  144492. dispose(): void;
  144493. }
  144494. }
  144495. declare module BABYLON {
  144496. interface Scene {
  144497. /** @hidden (Backing field) */
  144498. _depthRenderer: {
  144499. [id: string]: DepthRenderer;
  144500. };
  144501. /**
  144502. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144503. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144504. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144505. * @returns the created depth renderer
  144506. */
  144507. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144508. /**
  144509. * Disables a depth renderer for a given camera
  144510. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144511. */
  144512. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144513. }
  144514. /**
  144515. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144516. * in several rendering techniques.
  144517. */
  144518. export class DepthRendererSceneComponent implements ISceneComponent {
  144519. /**
  144520. * The component name helpfull to identify the component in the list of scene components.
  144521. */
  144522. readonly name: string;
  144523. /**
  144524. * The scene the component belongs to.
  144525. */
  144526. scene: Scene;
  144527. /**
  144528. * Creates a new instance of the component for the given scene
  144529. * @param scene Defines the scene to register the component in
  144530. */
  144531. constructor(scene: Scene);
  144532. /**
  144533. * Registers the component in a given scene
  144534. */
  144535. register(): void;
  144536. /**
  144537. * Rebuilds the elements related to this component in case of
  144538. * context lost for instance.
  144539. */
  144540. rebuild(): void;
  144541. /**
  144542. * Disposes the component and the associated ressources
  144543. */
  144544. dispose(): void;
  144545. private _gatherRenderTargets;
  144546. private _gatherActiveCameraRenderTargets;
  144547. }
  144548. }
  144549. declare module BABYLON {
  144550. /** @hidden */
  144551. export var outlinePixelShader: {
  144552. name: string;
  144553. shader: string;
  144554. };
  144555. }
  144556. declare module BABYLON {
  144557. /** @hidden */
  144558. export var outlineVertexShader: {
  144559. name: string;
  144560. shader: string;
  144561. };
  144562. }
  144563. declare module BABYLON {
  144564. interface Scene {
  144565. /** @hidden */
  144566. _outlineRenderer: OutlineRenderer;
  144567. /**
  144568. * Gets the outline renderer associated with the scene
  144569. * @returns a OutlineRenderer
  144570. */
  144571. getOutlineRenderer(): OutlineRenderer;
  144572. }
  144573. interface AbstractMesh {
  144574. /** @hidden (Backing field) */
  144575. _renderOutline: boolean;
  144576. /**
  144577. * Gets or sets a boolean indicating if the outline must be rendered as well
  144578. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  144579. */
  144580. renderOutline: boolean;
  144581. /** @hidden (Backing field) */
  144582. _renderOverlay: boolean;
  144583. /**
  144584. * Gets or sets a boolean indicating if the overlay must be rendered as well
  144585. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  144586. */
  144587. renderOverlay: boolean;
  144588. }
  144589. /**
  144590. * This class is responsible to draw bothe outline/overlay of meshes.
  144591. * It should not be used directly but through the available method on mesh.
  144592. */
  144593. export class OutlineRenderer implements ISceneComponent {
  144594. /**
  144595. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  144596. */
  144597. private static _StencilReference;
  144598. /**
  144599. * The name of the component. Each component must have a unique name.
  144600. */
  144601. name: string;
  144602. /**
  144603. * The scene the component belongs to.
  144604. */
  144605. scene: Scene;
  144606. /**
  144607. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  144608. */
  144609. zOffset: number;
  144610. private _engine;
  144611. private _effect;
  144612. private _cachedDefines;
  144613. private _savedDepthWrite;
  144614. /**
  144615. * Instantiates a new outline renderer. (There could be only one per scene).
  144616. * @param scene Defines the scene it belongs to
  144617. */
  144618. constructor(scene: Scene);
  144619. /**
  144620. * Register the component to one instance of a scene.
  144621. */
  144622. register(): void;
  144623. /**
  144624. * Rebuilds the elements related to this component in case of
  144625. * context lost for instance.
  144626. */
  144627. rebuild(): void;
  144628. /**
  144629. * Disposes the component and the associated ressources.
  144630. */
  144631. dispose(): void;
  144632. /**
  144633. * Renders the outline in the canvas.
  144634. * @param subMesh Defines the sumesh to render
  144635. * @param batch Defines the batch of meshes in case of instances
  144636. * @param useOverlay Defines if the rendering is for the overlay or the outline
  144637. */
  144638. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  144639. /**
  144640. * Returns whether or not the outline renderer is ready for a given submesh.
  144641. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  144642. * @param subMesh Defines the submesh to check readyness for
  144643. * @param useInstances Defines wheter wee are trying to render instances or not
  144644. * @returns true if ready otherwise false
  144645. */
  144646. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144647. private _beforeRenderingMesh;
  144648. private _afterRenderingMesh;
  144649. }
  144650. }
  144651. declare module BABYLON {
  144652. /**
  144653. * Defines the basic options interface of a Sprite Frame Source Size.
  144654. */
  144655. export interface ISpriteJSONSpriteSourceSize {
  144656. /**
  144657. * number of the original width of the Frame
  144658. */
  144659. w: number;
  144660. /**
  144661. * number of the original height of the Frame
  144662. */
  144663. h: number;
  144664. }
  144665. /**
  144666. * Defines the basic options interface of a Sprite Frame Data.
  144667. */
  144668. export interface ISpriteJSONSpriteFrameData {
  144669. /**
  144670. * number of the x offset of the Frame
  144671. */
  144672. x: number;
  144673. /**
  144674. * number of the y offset of the Frame
  144675. */
  144676. y: number;
  144677. /**
  144678. * number of the width of the Frame
  144679. */
  144680. w: number;
  144681. /**
  144682. * number of the height of the Frame
  144683. */
  144684. h: number;
  144685. }
  144686. /**
  144687. * Defines the basic options interface of a JSON Sprite.
  144688. */
  144689. export interface ISpriteJSONSprite {
  144690. /**
  144691. * string name of the Frame
  144692. */
  144693. filename: string;
  144694. /**
  144695. * ISpriteJSONSpriteFrame basic object of the frame data
  144696. */
  144697. frame: ISpriteJSONSpriteFrameData;
  144698. /**
  144699. * boolean to flag is the frame was rotated.
  144700. */
  144701. rotated: boolean;
  144702. /**
  144703. * boolean to flag is the frame was trimmed.
  144704. */
  144705. trimmed: boolean;
  144706. /**
  144707. * ISpriteJSONSpriteFrame basic object of the source data
  144708. */
  144709. spriteSourceSize: ISpriteJSONSpriteFrameData;
  144710. /**
  144711. * ISpriteJSONSpriteFrame basic object of the source data
  144712. */
  144713. sourceSize: ISpriteJSONSpriteSourceSize;
  144714. }
  144715. /**
  144716. * Defines the basic options interface of a JSON atlas.
  144717. */
  144718. export interface ISpriteJSONAtlas {
  144719. /**
  144720. * Array of objects that contain the frame data.
  144721. */
  144722. frames: Array<ISpriteJSONSprite>;
  144723. /**
  144724. * object basic object containing the sprite meta data.
  144725. */
  144726. meta?: object;
  144727. }
  144728. }
  144729. declare module BABYLON {
  144730. /** @hidden */
  144731. export var spriteMapPixelShader: {
  144732. name: string;
  144733. shader: string;
  144734. };
  144735. }
  144736. declare module BABYLON {
  144737. /** @hidden */
  144738. export var spriteMapVertexShader: {
  144739. name: string;
  144740. shader: string;
  144741. };
  144742. }
  144743. declare module BABYLON {
  144744. /**
  144745. * Defines the basic options interface of a SpriteMap
  144746. */
  144747. export interface ISpriteMapOptions {
  144748. /**
  144749. * Vector2 of the number of cells in the grid.
  144750. */
  144751. stageSize?: Vector2;
  144752. /**
  144753. * Vector2 of the size of the output plane in World Units.
  144754. */
  144755. outputSize?: Vector2;
  144756. /**
  144757. * Vector3 of the position of the output plane in World Units.
  144758. */
  144759. outputPosition?: Vector3;
  144760. /**
  144761. * Vector3 of the rotation of the output plane.
  144762. */
  144763. outputRotation?: Vector3;
  144764. /**
  144765. * number of layers that the system will reserve in resources.
  144766. */
  144767. layerCount?: number;
  144768. /**
  144769. * number of max animation frames a single cell will reserve in resources.
  144770. */
  144771. maxAnimationFrames?: number;
  144772. /**
  144773. * number cell index of the base tile when the system compiles.
  144774. */
  144775. baseTile?: number;
  144776. /**
  144777. * boolean flip the sprite after its been repositioned by the framing data.
  144778. */
  144779. flipU?: boolean;
  144780. /**
  144781. * Vector3 scalar of the global RGB values of the SpriteMap.
  144782. */
  144783. colorMultiply?: Vector3;
  144784. }
  144785. /**
  144786. * Defines the IDisposable interface in order to be cleanable from resources.
  144787. */
  144788. export interface ISpriteMap extends IDisposable {
  144789. /**
  144790. * String name of the SpriteMap.
  144791. */
  144792. name: string;
  144793. /**
  144794. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  144795. */
  144796. atlasJSON: ISpriteJSONAtlas;
  144797. /**
  144798. * Texture of the SpriteMap.
  144799. */
  144800. spriteSheet: Texture;
  144801. /**
  144802. * The parameters to initialize the SpriteMap with.
  144803. */
  144804. options: ISpriteMapOptions;
  144805. }
  144806. /**
  144807. * Class used to manage a grid restricted sprite deployment on an Output plane.
  144808. */
  144809. export class SpriteMap implements ISpriteMap {
  144810. /** The Name of the spriteMap */
  144811. name: string;
  144812. /** The JSON file with the frame and meta data */
  144813. atlasJSON: ISpriteJSONAtlas;
  144814. /** The systems Sprite Sheet Texture */
  144815. spriteSheet: Texture;
  144816. /** Arguments passed with the Constructor */
  144817. options: ISpriteMapOptions;
  144818. /** Public Sprite Storage array, parsed from atlasJSON */
  144819. sprites: Array<ISpriteJSONSprite>;
  144820. /** Returns the Number of Sprites in the System */
  144821. get spriteCount(): number;
  144822. /** Returns the Position of Output Plane*/
  144823. get position(): Vector3;
  144824. /** Returns the Position of Output Plane*/
  144825. set position(v: Vector3);
  144826. /** Returns the Rotation of Output Plane*/
  144827. get rotation(): Vector3;
  144828. /** Returns the Rotation of Output Plane*/
  144829. set rotation(v: Vector3);
  144830. /** Sets the AnimationMap*/
  144831. get animationMap(): RawTexture;
  144832. /** Sets the AnimationMap*/
  144833. set animationMap(v: RawTexture);
  144834. /** Scene that the SpriteMap was created in */
  144835. private _scene;
  144836. /** Texture Buffer of Float32 that holds tile frame data*/
  144837. private _frameMap;
  144838. /** Texture Buffers of Float32 that holds tileMap data*/
  144839. private _tileMaps;
  144840. /** Texture Buffer of Float32 that holds Animation Data*/
  144841. private _animationMap;
  144842. /** Custom ShaderMaterial Central to the System*/
  144843. private _material;
  144844. /** Custom ShaderMaterial Central to the System*/
  144845. private _output;
  144846. /** Systems Time Ticker*/
  144847. private _time;
  144848. /**
  144849. * Creates a new SpriteMap
  144850. * @param name defines the SpriteMaps Name
  144851. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  144852. * @param spriteSheet is the Texture that the Sprites are on.
  144853. * @param options a basic deployment configuration
  144854. * @param scene The Scene that the map is deployed on
  144855. */
  144856. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  144857. /**
  144858. * Returns tileID location
  144859. * @returns Vector2 the cell position ID
  144860. */
  144861. getTileID(): Vector2;
  144862. /**
  144863. * Gets the UV location of the mouse over the SpriteMap.
  144864. * @returns Vector2 the UV position of the mouse interaction
  144865. */
  144866. getMousePosition(): Vector2;
  144867. /**
  144868. * Creates the "frame" texture Buffer
  144869. * -------------------------------------
  144870. * Structure of frames
  144871. * "filename": "Falling-Water-2.png",
  144872. * "frame": {"x":69,"y":103,"w":24,"h":32},
  144873. * "rotated": true,
  144874. * "trimmed": true,
  144875. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  144876. * "sourceSize": {"w":32,"h":32}
  144877. * @returns RawTexture of the frameMap
  144878. */
  144879. private _createFrameBuffer;
  144880. /**
  144881. * Creates the tileMap texture Buffer
  144882. * @param buffer normally and array of numbers, or a false to generate from scratch
  144883. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  144884. * @returns RawTexture of the tileMap
  144885. */
  144886. private _createTileBuffer;
  144887. /**
  144888. * Modifies the data of the tileMaps
  144889. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  144890. * @param pos is the iVector2 Coordinates of the Tile
  144891. * @param tile The SpriteIndex of the new Tile
  144892. */
  144893. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  144894. /**
  144895. * Creates the animationMap texture Buffer
  144896. * @param buffer normally and array of numbers, or a false to generate from scratch
  144897. * @returns RawTexture of the animationMap
  144898. */
  144899. private _createTileAnimationBuffer;
  144900. /**
  144901. * Modifies the data of the animationMap
  144902. * @param cellID is the Index of the Sprite
  144903. * @param _frame is the target Animation frame
  144904. * @param toCell is the Target Index of the next frame of the animation
  144905. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  144906. * @param speed is a global scalar of the time variable on the map.
  144907. */
  144908. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  144909. /**
  144910. * Exports the .tilemaps file
  144911. */
  144912. saveTileMaps(): void;
  144913. /**
  144914. * Imports the .tilemaps file
  144915. * @param url of the .tilemaps file
  144916. */
  144917. loadTileMaps(url: string): void;
  144918. /**
  144919. * Release associated resources
  144920. */
  144921. dispose(): void;
  144922. }
  144923. }
  144924. declare module BABYLON {
  144925. /**
  144926. * Class used to manage multiple sprites of different sizes on the same spritesheet
  144927. * @see http://doc.babylonjs.com/babylon101/sprites
  144928. */
  144929. export class SpritePackedManager extends SpriteManager {
  144930. /** defines the packed manager's name */
  144931. name: string;
  144932. /**
  144933. * Creates a new sprite manager from a packed sprite sheet
  144934. * @param name defines the manager's name
  144935. * @param imgUrl defines the sprite sheet url
  144936. * @param capacity defines the maximum allowed number of sprites
  144937. * @param scene defines the hosting scene
  144938. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  144939. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  144940. * @param samplingMode defines the smapling mode to use with spritesheet
  144941. * @param fromPacked set to true; do not alter
  144942. */
  144943. constructor(
  144944. /** defines the packed manager's name */
  144945. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  144946. }
  144947. }
  144948. declare module BABYLON {
  144949. /**
  144950. * Defines the list of states available for a task inside a AssetsManager
  144951. */
  144952. export enum AssetTaskState {
  144953. /**
  144954. * Initialization
  144955. */
  144956. INIT = 0,
  144957. /**
  144958. * Running
  144959. */
  144960. RUNNING = 1,
  144961. /**
  144962. * Done
  144963. */
  144964. DONE = 2,
  144965. /**
  144966. * Error
  144967. */
  144968. ERROR = 3
  144969. }
  144970. /**
  144971. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  144972. */
  144973. export abstract class AbstractAssetTask {
  144974. /**
  144975. * Task name
  144976. */ name: string;
  144977. /**
  144978. * Callback called when the task is successful
  144979. */
  144980. onSuccess: (task: any) => void;
  144981. /**
  144982. * Callback called when the task is not successful
  144983. */
  144984. onError: (task: any, message?: string, exception?: any) => void;
  144985. /**
  144986. * Creates a new AssetsManager
  144987. * @param name defines the name of the task
  144988. */
  144989. constructor(
  144990. /**
  144991. * Task name
  144992. */ name: string);
  144993. private _isCompleted;
  144994. private _taskState;
  144995. private _errorObject;
  144996. /**
  144997. * Get if the task is completed
  144998. */
  144999. get isCompleted(): boolean;
  145000. /**
  145001. * Gets the current state of the task
  145002. */
  145003. get taskState(): AssetTaskState;
  145004. /**
  145005. * Gets the current error object (if task is in error)
  145006. */
  145007. get errorObject(): {
  145008. message?: string;
  145009. exception?: any;
  145010. };
  145011. /**
  145012. * Internal only
  145013. * @hidden
  145014. */
  145015. _setErrorObject(message?: string, exception?: any): void;
  145016. /**
  145017. * Execute the current task
  145018. * @param scene defines the scene where you want your assets to be loaded
  145019. * @param onSuccess is a callback called when the task is successfully executed
  145020. * @param onError is a callback called if an error occurs
  145021. */
  145022. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145023. /**
  145024. * Execute the current task
  145025. * @param scene defines the scene where you want your assets to be loaded
  145026. * @param onSuccess is a callback called when the task is successfully executed
  145027. * @param onError is a callback called if an error occurs
  145028. */
  145029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145030. /**
  145031. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145032. * This can be used with failed tasks that have the reason for failure fixed.
  145033. */
  145034. reset(): void;
  145035. private onErrorCallback;
  145036. private onDoneCallback;
  145037. }
  145038. /**
  145039. * Define the interface used by progress events raised during assets loading
  145040. */
  145041. export interface IAssetsProgressEvent {
  145042. /**
  145043. * Defines the number of remaining tasks to process
  145044. */
  145045. remainingCount: number;
  145046. /**
  145047. * Defines the total number of tasks
  145048. */
  145049. totalCount: number;
  145050. /**
  145051. * Defines the task that was just processed
  145052. */
  145053. task: AbstractAssetTask;
  145054. }
  145055. /**
  145056. * Class used to share progress information about assets loading
  145057. */
  145058. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145059. /**
  145060. * Defines the number of remaining tasks to process
  145061. */
  145062. remainingCount: number;
  145063. /**
  145064. * Defines the total number of tasks
  145065. */
  145066. totalCount: number;
  145067. /**
  145068. * Defines the task that was just processed
  145069. */
  145070. task: AbstractAssetTask;
  145071. /**
  145072. * Creates a AssetsProgressEvent
  145073. * @param remainingCount defines the number of remaining tasks to process
  145074. * @param totalCount defines the total number of tasks
  145075. * @param task defines the task that was just processed
  145076. */
  145077. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145078. }
  145079. /**
  145080. * Define a task used by AssetsManager to load meshes
  145081. */
  145082. export class MeshAssetTask extends AbstractAssetTask {
  145083. /**
  145084. * Defines the name of the task
  145085. */
  145086. name: string;
  145087. /**
  145088. * Defines the list of mesh's names you want to load
  145089. */
  145090. meshesNames: any;
  145091. /**
  145092. * Defines the root url to use as a base to load your meshes and associated resources
  145093. */
  145094. rootUrl: string;
  145095. /**
  145096. * Defines the filename or File of the scene to load from
  145097. */
  145098. sceneFilename: string | File;
  145099. /**
  145100. * Gets the list of loaded meshes
  145101. */
  145102. loadedMeshes: Array<AbstractMesh>;
  145103. /**
  145104. * Gets the list of loaded particle systems
  145105. */
  145106. loadedParticleSystems: Array<IParticleSystem>;
  145107. /**
  145108. * Gets the list of loaded skeletons
  145109. */
  145110. loadedSkeletons: Array<Skeleton>;
  145111. /**
  145112. * Gets the list of loaded animation groups
  145113. */
  145114. loadedAnimationGroups: Array<AnimationGroup>;
  145115. /**
  145116. * Callback called when the task is successful
  145117. */
  145118. onSuccess: (task: MeshAssetTask) => void;
  145119. /**
  145120. * Callback called when the task is successful
  145121. */
  145122. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145123. /**
  145124. * Creates a new MeshAssetTask
  145125. * @param name defines the name of the task
  145126. * @param meshesNames defines the list of mesh's names you want to load
  145127. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145128. * @param sceneFilename defines the filename or File of the scene to load from
  145129. */
  145130. constructor(
  145131. /**
  145132. * Defines the name of the task
  145133. */
  145134. name: string,
  145135. /**
  145136. * Defines the list of mesh's names you want to load
  145137. */
  145138. meshesNames: any,
  145139. /**
  145140. * Defines the root url to use as a base to load your meshes and associated resources
  145141. */
  145142. rootUrl: string,
  145143. /**
  145144. * Defines the filename or File of the scene to load from
  145145. */
  145146. sceneFilename: string | File);
  145147. /**
  145148. * Execute the current task
  145149. * @param scene defines the scene where you want your assets to be loaded
  145150. * @param onSuccess is a callback called when the task is successfully executed
  145151. * @param onError is a callback called if an error occurs
  145152. */
  145153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145154. }
  145155. /**
  145156. * Define a task used by AssetsManager to load text content
  145157. */
  145158. export class TextFileAssetTask extends AbstractAssetTask {
  145159. /**
  145160. * Defines the name of the task
  145161. */
  145162. name: string;
  145163. /**
  145164. * Defines the location of the file to load
  145165. */
  145166. url: string;
  145167. /**
  145168. * Gets the loaded text string
  145169. */
  145170. text: string;
  145171. /**
  145172. * Callback called when the task is successful
  145173. */
  145174. onSuccess: (task: TextFileAssetTask) => void;
  145175. /**
  145176. * Callback called when the task is successful
  145177. */
  145178. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145179. /**
  145180. * Creates a new TextFileAssetTask object
  145181. * @param name defines the name of the task
  145182. * @param url defines the location of the file to load
  145183. */
  145184. constructor(
  145185. /**
  145186. * Defines the name of the task
  145187. */
  145188. name: string,
  145189. /**
  145190. * Defines the location of the file to load
  145191. */
  145192. url: string);
  145193. /**
  145194. * Execute the current task
  145195. * @param scene defines the scene where you want your assets to be loaded
  145196. * @param onSuccess is a callback called when the task is successfully executed
  145197. * @param onError is a callback called if an error occurs
  145198. */
  145199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145200. }
  145201. /**
  145202. * Define a task used by AssetsManager to load binary data
  145203. */
  145204. export class BinaryFileAssetTask extends AbstractAssetTask {
  145205. /**
  145206. * Defines the name of the task
  145207. */
  145208. name: string;
  145209. /**
  145210. * Defines the location of the file to load
  145211. */
  145212. url: string;
  145213. /**
  145214. * Gets the lodaded data (as an array buffer)
  145215. */
  145216. data: ArrayBuffer;
  145217. /**
  145218. * Callback called when the task is successful
  145219. */
  145220. onSuccess: (task: BinaryFileAssetTask) => void;
  145221. /**
  145222. * Callback called when the task is successful
  145223. */
  145224. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145225. /**
  145226. * Creates a new BinaryFileAssetTask object
  145227. * @param name defines the name of the new task
  145228. * @param url defines the location of the file to load
  145229. */
  145230. constructor(
  145231. /**
  145232. * Defines the name of the task
  145233. */
  145234. name: string,
  145235. /**
  145236. * Defines the location of the file to load
  145237. */
  145238. url: string);
  145239. /**
  145240. * Execute the current task
  145241. * @param scene defines the scene where you want your assets to be loaded
  145242. * @param onSuccess is a callback called when the task is successfully executed
  145243. * @param onError is a callback called if an error occurs
  145244. */
  145245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145246. }
  145247. /**
  145248. * Define a task used by AssetsManager to load images
  145249. */
  145250. export class ImageAssetTask extends AbstractAssetTask {
  145251. /**
  145252. * Defines the name of the task
  145253. */
  145254. name: string;
  145255. /**
  145256. * Defines the location of the image to load
  145257. */
  145258. url: string;
  145259. /**
  145260. * Gets the loaded images
  145261. */
  145262. image: HTMLImageElement;
  145263. /**
  145264. * Callback called when the task is successful
  145265. */
  145266. onSuccess: (task: ImageAssetTask) => void;
  145267. /**
  145268. * Callback called when the task is successful
  145269. */
  145270. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145271. /**
  145272. * Creates a new ImageAssetTask
  145273. * @param name defines the name of the task
  145274. * @param url defines the location of the image to load
  145275. */
  145276. constructor(
  145277. /**
  145278. * Defines the name of the task
  145279. */
  145280. name: string,
  145281. /**
  145282. * Defines the location of the image to load
  145283. */
  145284. url: string);
  145285. /**
  145286. * Execute the current task
  145287. * @param scene defines the scene where you want your assets to be loaded
  145288. * @param onSuccess is a callback called when the task is successfully executed
  145289. * @param onError is a callback called if an error occurs
  145290. */
  145291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145292. }
  145293. /**
  145294. * Defines the interface used by texture loading tasks
  145295. */
  145296. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145297. /**
  145298. * Gets the loaded texture
  145299. */
  145300. texture: TEX;
  145301. }
  145302. /**
  145303. * Define a task used by AssetsManager to load 2D textures
  145304. */
  145305. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145306. /**
  145307. * Defines the name of the task
  145308. */
  145309. name: string;
  145310. /**
  145311. * Defines the location of the file to load
  145312. */
  145313. url: string;
  145314. /**
  145315. * Defines if mipmap should not be generated (default is false)
  145316. */
  145317. noMipmap?: boolean | undefined;
  145318. /**
  145319. * Defines if texture must be inverted on Y axis (default is true)
  145320. */
  145321. invertY: boolean;
  145322. /**
  145323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145324. */
  145325. samplingMode: number;
  145326. /**
  145327. * Gets the loaded texture
  145328. */
  145329. texture: Texture;
  145330. /**
  145331. * Callback called when the task is successful
  145332. */
  145333. onSuccess: (task: TextureAssetTask) => void;
  145334. /**
  145335. * Callback called when the task is successful
  145336. */
  145337. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145338. /**
  145339. * Creates a new TextureAssetTask object
  145340. * @param name defines the name of the task
  145341. * @param url defines the location of the file to load
  145342. * @param noMipmap defines if mipmap should not be generated (default is false)
  145343. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145344. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145345. */
  145346. constructor(
  145347. /**
  145348. * Defines the name of the task
  145349. */
  145350. name: string,
  145351. /**
  145352. * Defines the location of the file to load
  145353. */
  145354. url: string,
  145355. /**
  145356. * Defines if mipmap should not be generated (default is false)
  145357. */
  145358. noMipmap?: boolean | undefined,
  145359. /**
  145360. * Defines if texture must be inverted on Y axis (default is true)
  145361. */
  145362. invertY?: boolean,
  145363. /**
  145364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145365. */
  145366. samplingMode?: number);
  145367. /**
  145368. * Execute the current task
  145369. * @param scene defines the scene where you want your assets to be loaded
  145370. * @param onSuccess is a callback called when the task is successfully executed
  145371. * @param onError is a callback called if an error occurs
  145372. */
  145373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145374. }
  145375. /**
  145376. * Define a task used by AssetsManager to load cube textures
  145377. */
  145378. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145379. /**
  145380. * Defines the name of the task
  145381. */
  145382. name: string;
  145383. /**
  145384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145385. */
  145386. url: string;
  145387. /**
  145388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145389. */
  145390. extensions?: string[] | undefined;
  145391. /**
  145392. * Defines if mipmaps should not be generated (default is false)
  145393. */
  145394. noMipmap?: boolean | undefined;
  145395. /**
  145396. * Defines the explicit list of files (undefined by default)
  145397. */
  145398. files?: string[] | undefined;
  145399. /**
  145400. * Gets the loaded texture
  145401. */
  145402. texture: CubeTexture;
  145403. /**
  145404. * Callback called when the task is successful
  145405. */
  145406. onSuccess: (task: CubeTextureAssetTask) => void;
  145407. /**
  145408. * Callback called when the task is successful
  145409. */
  145410. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145411. /**
  145412. * Creates a new CubeTextureAssetTask
  145413. * @param name defines the name of the task
  145414. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145415. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145417. * @param files defines the explicit list of files (undefined by default)
  145418. */
  145419. constructor(
  145420. /**
  145421. * Defines the name of the task
  145422. */
  145423. name: string,
  145424. /**
  145425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145426. */
  145427. url: string,
  145428. /**
  145429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145430. */
  145431. extensions?: string[] | undefined,
  145432. /**
  145433. * Defines if mipmaps should not be generated (default is false)
  145434. */
  145435. noMipmap?: boolean | undefined,
  145436. /**
  145437. * Defines the explicit list of files (undefined by default)
  145438. */
  145439. files?: string[] | undefined);
  145440. /**
  145441. * Execute the current task
  145442. * @param scene defines the scene where you want your assets to be loaded
  145443. * @param onSuccess is a callback called when the task is successfully executed
  145444. * @param onError is a callback called if an error occurs
  145445. */
  145446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145447. }
  145448. /**
  145449. * Define a task used by AssetsManager to load HDR cube textures
  145450. */
  145451. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145452. /**
  145453. * Defines the name of the task
  145454. */
  145455. name: string;
  145456. /**
  145457. * Defines the location of the file to load
  145458. */
  145459. url: string;
  145460. /**
  145461. * Defines the desired size (the more it increases the longer the generation will be)
  145462. */
  145463. size: number;
  145464. /**
  145465. * Defines if mipmaps should not be generated (default is false)
  145466. */
  145467. noMipmap: boolean;
  145468. /**
  145469. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145470. */
  145471. generateHarmonics: boolean;
  145472. /**
  145473. * 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)
  145474. */
  145475. gammaSpace: boolean;
  145476. /**
  145477. * Internal Use Only
  145478. */
  145479. reserved: boolean;
  145480. /**
  145481. * Gets the loaded texture
  145482. */
  145483. texture: HDRCubeTexture;
  145484. /**
  145485. * Callback called when the task is successful
  145486. */
  145487. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145488. /**
  145489. * Callback called when the task is successful
  145490. */
  145491. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145492. /**
  145493. * Creates a new HDRCubeTextureAssetTask object
  145494. * @param name defines the name of the task
  145495. * @param url defines the location of the file to load
  145496. * @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.
  145497. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145498. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145499. * @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)
  145500. * @param reserved Internal use only
  145501. */
  145502. constructor(
  145503. /**
  145504. * Defines the name of the task
  145505. */
  145506. name: string,
  145507. /**
  145508. * Defines the location of the file to load
  145509. */
  145510. url: string,
  145511. /**
  145512. * Defines the desired size (the more it increases the longer the generation will be)
  145513. */
  145514. size: number,
  145515. /**
  145516. * Defines if mipmaps should not be generated (default is false)
  145517. */
  145518. noMipmap?: boolean,
  145519. /**
  145520. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145521. */
  145522. generateHarmonics?: boolean,
  145523. /**
  145524. * 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)
  145525. */
  145526. gammaSpace?: boolean,
  145527. /**
  145528. * Internal Use Only
  145529. */
  145530. reserved?: boolean);
  145531. /**
  145532. * Execute the current task
  145533. * @param scene defines the scene where you want your assets to be loaded
  145534. * @param onSuccess is a callback called when the task is successfully executed
  145535. * @param onError is a callback called if an error occurs
  145536. */
  145537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145538. }
  145539. /**
  145540. * Define a task used by AssetsManager to load Equirectangular cube textures
  145541. */
  145542. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  145543. /**
  145544. * Defines the name of the task
  145545. */
  145546. name: string;
  145547. /**
  145548. * Defines the location of the file to load
  145549. */
  145550. url: string;
  145551. /**
  145552. * Defines the desired size (the more it increases the longer the generation will be)
  145553. */
  145554. size: number;
  145555. /**
  145556. * Defines if mipmaps should not be generated (default is false)
  145557. */
  145558. noMipmap: boolean;
  145559. /**
  145560. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145561. * but the standard material would require them in Gamma space) (default is true)
  145562. */
  145563. gammaSpace: boolean;
  145564. /**
  145565. * Gets the loaded texture
  145566. */
  145567. texture: EquiRectangularCubeTexture;
  145568. /**
  145569. * Callback called when the task is successful
  145570. */
  145571. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  145572. /**
  145573. * Callback called when the task is successful
  145574. */
  145575. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  145576. /**
  145577. * Creates a new EquiRectangularCubeTextureAssetTask object
  145578. * @param name defines the name of the task
  145579. * @param url defines the location of the file to load
  145580. * @param size defines the desired size (the more it increases the longer the generation will be)
  145581. * If the size is omitted this implies you are using a preprocessed cubemap.
  145582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145583. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  145584. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  145585. * (default is true)
  145586. */
  145587. constructor(
  145588. /**
  145589. * Defines the name of the task
  145590. */
  145591. name: string,
  145592. /**
  145593. * Defines the location of the file to load
  145594. */
  145595. url: string,
  145596. /**
  145597. * Defines the desired size (the more it increases the longer the generation will be)
  145598. */
  145599. size: number,
  145600. /**
  145601. * Defines if mipmaps should not be generated (default is false)
  145602. */
  145603. noMipmap?: boolean,
  145604. /**
  145605. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145606. * but the standard material would require them in Gamma space) (default is true)
  145607. */
  145608. gammaSpace?: boolean);
  145609. /**
  145610. * Execute the current task
  145611. * @param scene defines the scene where you want your assets to be loaded
  145612. * @param onSuccess is a callback called when the task is successfully executed
  145613. * @param onError is a callback called if an error occurs
  145614. */
  145615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145616. }
  145617. /**
  145618. * This class can be used to easily import assets into a scene
  145619. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  145620. */
  145621. export class AssetsManager {
  145622. private _scene;
  145623. private _isLoading;
  145624. protected _tasks: AbstractAssetTask[];
  145625. protected _waitingTasksCount: number;
  145626. protected _totalTasksCount: number;
  145627. /**
  145628. * Callback called when all tasks are processed
  145629. */
  145630. onFinish: (tasks: AbstractAssetTask[]) => void;
  145631. /**
  145632. * Callback called when a task is successful
  145633. */
  145634. onTaskSuccess: (task: AbstractAssetTask) => void;
  145635. /**
  145636. * Callback called when a task had an error
  145637. */
  145638. onTaskError: (task: AbstractAssetTask) => void;
  145639. /**
  145640. * Callback called when a task is done (whatever the result is)
  145641. */
  145642. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  145643. /**
  145644. * Observable called when all tasks are processed
  145645. */
  145646. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  145647. /**
  145648. * Observable called when a task had an error
  145649. */
  145650. onTaskErrorObservable: Observable<AbstractAssetTask>;
  145651. /**
  145652. * Observable called when all tasks were executed
  145653. */
  145654. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  145655. /**
  145656. * Observable called when a task is done (whatever the result is)
  145657. */
  145658. onProgressObservable: Observable<IAssetsProgressEvent>;
  145659. /**
  145660. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  145661. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  145662. */
  145663. useDefaultLoadingScreen: boolean;
  145664. /**
  145665. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  145666. * when all assets have been downloaded.
  145667. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  145668. */
  145669. autoHideLoadingUI: boolean;
  145670. /**
  145671. * Creates a new AssetsManager
  145672. * @param scene defines the scene to work on
  145673. */
  145674. constructor(scene: Scene);
  145675. /**
  145676. * Add a MeshAssetTask to the list of active tasks
  145677. * @param taskName defines the name of the new task
  145678. * @param meshesNames defines the name of meshes to load
  145679. * @param rootUrl defines the root url to use to locate files
  145680. * @param sceneFilename defines the filename of the scene file
  145681. * @returns a new MeshAssetTask object
  145682. */
  145683. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  145684. /**
  145685. * Add a TextFileAssetTask to the list of active tasks
  145686. * @param taskName defines the name of the new task
  145687. * @param url defines the url of the file to load
  145688. * @returns a new TextFileAssetTask object
  145689. */
  145690. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  145691. /**
  145692. * Add a BinaryFileAssetTask to the list of active tasks
  145693. * @param taskName defines the name of the new task
  145694. * @param url defines the url of the file to load
  145695. * @returns a new BinaryFileAssetTask object
  145696. */
  145697. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  145698. /**
  145699. * Add a ImageAssetTask to the list of active tasks
  145700. * @param taskName defines the name of the new task
  145701. * @param url defines the url of the file to load
  145702. * @returns a new ImageAssetTask object
  145703. */
  145704. addImageTask(taskName: string, url: string): ImageAssetTask;
  145705. /**
  145706. * Add a TextureAssetTask to the list of active tasks
  145707. * @param taskName defines the name of the new task
  145708. * @param url defines the url of the file to load
  145709. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145710. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  145711. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145712. * @returns a new TextureAssetTask object
  145713. */
  145714. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  145715. /**
  145716. * Add a CubeTextureAssetTask to the list of active tasks
  145717. * @param taskName defines the name of the new task
  145718. * @param url defines the url of the file to load
  145719. * @param extensions defines the extension to use to load the cube map (can be null)
  145720. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145721. * @param files defines the list of files to load (can be null)
  145722. * @returns a new CubeTextureAssetTask object
  145723. */
  145724. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  145725. /**
  145726. *
  145727. * Add a HDRCubeTextureAssetTask to the list of active tasks
  145728. * @param taskName defines the name of the new task
  145729. * @param url defines the url of the file to load
  145730. * @param size defines the size you want for the cubemap (can be null)
  145731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145732. * @param generateHarmonics defines if you want to automatically generate (true by default)
  145733. * @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)
  145734. * @param reserved Internal use only
  145735. * @returns a new HDRCubeTextureAssetTask object
  145736. */
  145737. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  145738. /**
  145739. *
  145740. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  145741. * @param taskName defines the name of the new task
  145742. * @param url defines the url of the file to load
  145743. * @param size defines the size you want for the cubemap (can be null)
  145744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145745. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  145746. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  145747. * @returns a new EquiRectangularCubeTextureAssetTask object
  145748. */
  145749. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  145750. /**
  145751. * Remove a task from the assets manager.
  145752. * @param task the task to remove
  145753. */
  145754. removeTask(task: AbstractAssetTask): void;
  145755. private _decreaseWaitingTasksCount;
  145756. private _runTask;
  145757. /**
  145758. * Reset the AssetsManager and remove all tasks
  145759. * @return the current instance of the AssetsManager
  145760. */
  145761. reset(): AssetsManager;
  145762. /**
  145763. * Start the loading process
  145764. * @return the current instance of the AssetsManager
  145765. */
  145766. load(): AssetsManager;
  145767. /**
  145768. * Start the loading process as an async operation
  145769. * @return a promise returning the list of failed tasks
  145770. */
  145771. loadAsync(): Promise<void>;
  145772. }
  145773. }
  145774. declare module BABYLON {
  145775. /**
  145776. * Wrapper class for promise with external resolve and reject.
  145777. */
  145778. export class Deferred<T> {
  145779. /**
  145780. * The promise associated with this deferred object.
  145781. */
  145782. readonly promise: Promise<T>;
  145783. private _resolve;
  145784. private _reject;
  145785. /**
  145786. * The resolve method of the promise associated with this deferred object.
  145787. */
  145788. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  145789. /**
  145790. * The reject method of the promise associated with this deferred object.
  145791. */
  145792. get reject(): (reason?: any) => void;
  145793. /**
  145794. * Constructor for this deferred object.
  145795. */
  145796. constructor();
  145797. }
  145798. }
  145799. declare module BABYLON {
  145800. /**
  145801. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  145802. */
  145803. export class MeshExploder {
  145804. private _centerMesh;
  145805. private _meshes;
  145806. private _meshesOrigins;
  145807. private _toCenterVectors;
  145808. private _scaledDirection;
  145809. private _newPosition;
  145810. private _centerPosition;
  145811. /**
  145812. * Explodes meshes from a center mesh.
  145813. * @param meshes The meshes to explode.
  145814. * @param centerMesh The mesh to be center of explosion.
  145815. */
  145816. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  145817. private _setCenterMesh;
  145818. /**
  145819. * Get class name
  145820. * @returns "MeshExploder"
  145821. */
  145822. getClassName(): string;
  145823. /**
  145824. * "Exploded meshes"
  145825. * @returns Array of meshes with the centerMesh at index 0.
  145826. */
  145827. getMeshes(): Array<Mesh>;
  145828. /**
  145829. * Explodes meshes giving a specific direction
  145830. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  145831. */
  145832. explode(direction?: number): void;
  145833. }
  145834. }
  145835. declare module BABYLON {
  145836. /**
  145837. * Class used to help managing file picking and drag'n'drop
  145838. */
  145839. export class FilesInput {
  145840. /**
  145841. * List of files ready to be loaded
  145842. */
  145843. static get FilesToLoad(): {
  145844. [key: string]: File;
  145845. };
  145846. /**
  145847. * Callback called when a file is processed
  145848. */
  145849. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  145850. private _engine;
  145851. private _currentScene;
  145852. private _sceneLoadedCallback;
  145853. private _progressCallback;
  145854. private _additionalRenderLoopLogicCallback;
  145855. private _textureLoadingCallback;
  145856. private _startingProcessingFilesCallback;
  145857. private _onReloadCallback;
  145858. private _errorCallback;
  145859. private _elementToMonitor;
  145860. private _sceneFileToLoad;
  145861. private _filesToLoad;
  145862. /**
  145863. * Creates a new FilesInput
  145864. * @param engine defines the rendering engine
  145865. * @param scene defines the hosting scene
  145866. * @param sceneLoadedCallback callback called when scene is loaded
  145867. * @param progressCallback callback called to track progress
  145868. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  145869. * @param textureLoadingCallback callback called when a texture is loading
  145870. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  145871. * @param onReloadCallback callback called when a reload is requested
  145872. * @param errorCallback callback call if an error occurs
  145873. */
  145874. 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);
  145875. private _dragEnterHandler;
  145876. private _dragOverHandler;
  145877. private _dropHandler;
  145878. /**
  145879. * Calls this function to listen to drag'n'drop events on a specific DOM element
  145880. * @param elementToMonitor defines the DOM element to track
  145881. */
  145882. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  145883. /**
  145884. * Release all associated resources
  145885. */
  145886. dispose(): void;
  145887. private renderFunction;
  145888. private drag;
  145889. private drop;
  145890. private _traverseFolder;
  145891. private _processFiles;
  145892. /**
  145893. * Load files from a drop event
  145894. * @param event defines the drop event to use as source
  145895. */
  145896. loadFiles(event: any): void;
  145897. private _processReload;
  145898. /**
  145899. * Reload the current scene from the loaded files
  145900. */
  145901. reload(): void;
  145902. }
  145903. }
  145904. declare module BABYLON {
  145905. /**
  145906. * Defines the root class used to create scene optimization to use with SceneOptimizer
  145907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145908. */
  145909. export class SceneOptimization {
  145910. /**
  145911. * Defines the priority of this optimization (0 by default which means first in the list)
  145912. */
  145913. priority: number;
  145914. /**
  145915. * Gets a string describing the action executed by the current optimization
  145916. * @returns description string
  145917. */
  145918. getDescription(): string;
  145919. /**
  145920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145921. * @param scene defines the current scene where to apply this optimization
  145922. * @param optimizer defines the current optimizer
  145923. * @returns true if everything that can be done was applied
  145924. */
  145925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145926. /**
  145927. * Creates the SceneOptimization object
  145928. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145929. * @param desc defines the description associated with the optimization
  145930. */
  145931. constructor(
  145932. /**
  145933. * Defines the priority of this optimization (0 by default which means first in the list)
  145934. */
  145935. priority?: number);
  145936. }
  145937. /**
  145938. * Defines an optimization used to reduce the size of render target textures
  145939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145940. */
  145941. export class TextureOptimization extends SceneOptimization {
  145942. /**
  145943. * Defines the priority of this optimization (0 by default which means first in the list)
  145944. */
  145945. priority: number;
  145946. /**
  145947. * 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
  145948. */
  145949. maximumSize: number;
  145950. /**
  145951. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145952. */
  145953. step: number;
  145954. /**
  145955. * Gets a string describing the action executed by the current optimization
  145956. * @returns description string
  145957. */
  145958. getDescription(): string;
  145959. /**
  145960. * Creates the TextureOptimization object
  145961. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145962. * @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
  145963. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145964. */
  145965. constructor(
  145966. /**
  145967. * Defines the priority of this optimization (0 by default which means first in the list)
  145968. */
  145969. priority?: number,
  145970. /**
  145971. * 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
  145972. */
  145973. maximumSize?: number,
  145974. /**
  145975. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145976. */
  145977. step?: number);
  145978. /**
  145979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145980. * @param scene defines the current scene where to apply this optimization
  145981. * @param optimizer defines the current optimizer
  145982. * @returns true if everything that can be done was applied
  145983. */
  145984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145985. }
  145986. /**
  145987. * Defines an optimization used to increase or decrease the rendering resolution
  145988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145989. */
  145990. export class HardwareScalingOptimization extends SceneOptimization {
  145991. /**
  145992. * Defines the priority of this optimization (0 by default which means first in the list)
  145993. */
  145994. priority: number;
  145995. /**
  145996. * Defines the maximum scale to use (2 by default)
  145997. */
  145998. maximumScale: number;
  145999. /**
  146000. * Defines the step to use between two passes (0.5 by default)
  146001. */
  146002. step: number;
  146003. private _currentScale;
  146004. private _directionOffset;
  146005. /**
  146006. * Gets a string describing the action executed by the current optimization
  146007. * @return description string
  146008. */
  146009. getDescription(): string;
  146010. /**
  146011. * Creates the HardwareScalingOptimization object
  146012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146013. * @param maximumScale defines the maximum scale to use (2 by default)
  146014. * @param step defines the step to use between two passes (0.5 by default)
  146015. */
  146016. constructor(
  146017. /**
  146018. * Defines the priority of this optimization (0 by default which means first in the list)
  146019. */
  146020. priority?: number,
  146021. /**
  146022. * Defines the maximum scale to use (2 by default)
  146023. */
  146024. maximumScale?: number,
  146025. /**
  146026. * Defines the step to use between two passes (0.5 by default)
  146027. */
  146028. step?: number);
  146029. /**
  146030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146031. * @param scene defines the current scene where to apply this optimization
  146032. * @param optimizer defines the current optimizer
  146033. * @returns true if everything that can be done was applied
  146034. */
  146035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146036. }
  146037. /**
  146038. * Defines an optimization used to remove shadows
  146039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146040. */
  146041. export class ShadowsOptimization extends SceneOptimization {
  146042. /**
  146043. * Gets a string describing the action executed by the current optimization
  146044. * @return description string
  146045. */
  146046. getDescription(): string;
  146047. /**
  146048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146049. * @param scene defines the current scene where to apply this optimization
  146050. * @param optimizer defines the current optimizer
  146051. * @returns true if everything that can be done was applied
  146052. */
  146053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146054. }
  146055. /**
  146056. * Defines an optimization used to turn post-processes off
  146057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146058. */
  146059. export class PostProcessesOptimization extends SceneOptimization {
  146060. /**
  146061. * Gets a string describing the action executed by the current optimization
  146062. * @return description string
  146063. */
  146064. getDescription(): string;
  146065. /**
  146066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146067. * @param scene defines the current scene where to apply this optimization
  146068. * @param optimizer defines the current optimizer
  146069. * @returns true if everything that can be done was applied
  146070. */
  146071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146072. }
  146073. /**
  146074. * Defines an optimization used to turn lens flares off
  146075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146076. */
  146077. export class LensFlaresOptimization extends SceneOptimization {
  146078. /**
  146079. * Gets a string describing the action executed by the current optimization
  146080. * @return description string
  146081. */
  146082. getDescription(): string;
  146083. /**
  146084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146085. * @param scene defines the current scene where to apply this optimization
  146086. * @param optimizer defines the current optimizer
  146087. * @returns true if everything that can be done was applied
  146088. */
  146089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146090. }
  146091. /**
  146092. * Defines an optimization based on user defined callback.
  146093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146094. */
  146095. export class CustomOptimization extends SceneOptimization {
  146096. /**
  146097. * Callback called to apply the custom optimization.
  146098. */
  146099. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146100. /**
  146101. * Callback called to get custom description
  146102. */
  146103. onGetDescription: () => string;
  146104. /**
  146105. * Gets a string describing the action executed by the current optimization
  146106. * @returns description string
  146107. */
  146108. getDescription(): string;
  146109. /**
  146110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146111. * @param scene defines the current scene where to apply this optimization
  146112. * @param optimizer defines the current optimizer
  146113. * @returns true if everything that can be done was applied
  146114. */
  146115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146116. }
  146117. /**
  146118. * Defines an optimization used to turn particles off
  146119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146120. */
  146121. export class ParticlesOptimization extends SceneOptimization {
  146122. /**
  146123. * Gets a string describing the action executed by the current optimization
  146124. * @return description string
  146125. */
  146126. getDescription(): string;
  146127. /**
  146128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146129. * @param scene defines the current scene where to apply this optimization
  146130. * @param optimizer defines the current optimizer
  146131. * @returns true if everything that can be done was applied
  146132. */
  146133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146134. }
  146135. /**
  146136. * Defines an optimization used to turn render targets off
  146137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146138. */
  146139. export class RenderTargetsOptimization extends SceneOptimization {
  146140. /**
  146141. * Gets a string describing the action executed by the current optimization
  146142. * @return description string
  146143. */
  146144. getDescription(): string;
  146145. /**
  146146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146147. * @param scene defines the current scene where to apply this optimization
  146148. * @param optimizer defines the current optimizer
  146149. * @returns true if everything that can be done was applied
  146150. */
  146151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146152. }
  146153. /**
  146154. * Defines an optimization used to merge meshes with compatible materials
  146155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146156. */
  146157. export class MergeMeshesOptimization extends SceneOptimization {
  146158. private static _UpdateSelectionTree;
  146159. /**
  146160. * Gets or sets a boolean which defines if optimization octree has to be updated
  146161. */
  146162. static get UpdateSelectionTree(): boolean;
  146163. /**
  146164. * Gets or sets a boolean which defines if optimization octree has to be updated
  146165. */
  146166. static set UpdateSelectionTree(value: boolean);
  146167. /**
  146168. * Gets a string describing the action executed by the current optimization
  146169. * @return description string
  146170. */
  146171. getDescription(): string;
  146172. private _canBeMerged;
  146173. /**
  146174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146175. * @param scene defines the current scene where to apply this optimization
  146176. * @param optimizer defines the current optimizer
  146177. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146178. * @returns true if everything that can be done was applied
  146179. */
  146180. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146181. }
  146182. /**
  146183. * Defines a list of options used by SceneOptimizer
  146184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146185. */
  146186. export class SceneOptimizerOptions {
  146187. /**
  146188. * Defines the target frame rate to reach (60 by default)
  146189. */
  146190. targetFrameRate: number;
  146191. /**
  146192. * Defines the interval between two checkes (2000ms by default)
  146193. */
  146194. trackerDuration: number;
  146195. /**
  146196. * Gets the list of optimizations to apply
  146197. */
  146198. optimizations: SceneOptimization[];
  146199. /**
  146200. * Creates a new list of options used by SceneOptimizer
  146201. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146202. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146203. */
  146204. constructor(
  146205. /**
  146206. * Defines the target frame rate to reach (60 by default)
  146207. */
  146208. targetFrameRate?: number,
  146209. /**
  146210. * Defines the interval between two checkes (2000ms by default)
  146211. */
  146212. trackerDuration?: number);
  146213. /**
  146214. * Add a new optimization
  146215. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146216. * @returns the current SceneOptimizerOptions
  146217. */
  146218. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146219. /**
  146220. * Add a new custom optimization
  146221. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146222. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146223. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146224. * @returns the current SceneOptimizerOptions
  146225. */
  146226. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146227. /**
  146228. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146229. * @param targetFrameRate defines the target frame rate (60 by default)
  146230. * @returns a SceneOptimizerOptions object
  146231. */
  146232. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146233. /**
  146234. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146235. * @param targetFrameRate defines the target frame rate (60 by default)
  146236. * @returns a SceneOptimizerOptions object
  146237. */
  146238. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146239. /**
  146240. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146241. * @param targetFrameRate defines the target frame rate (60 by default)
  146242. * @returns a SceneOptimizerOptions object
  146243. */
  146244. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146245. }
  146246. /**
  146247. * Class used to run optimizations in order to reach a target frame rate
  146248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146249. */
  146250. export class SceneOptimizer implements IDisposable {
  146251. private _isRunning;
  146252. private _options;
  146253. private _scene;
  146254. private _currentPriorityLevel;
  146255. private _targetFrameRate;
  146256. private _trackerDuration;
  146257. private _currentFrameRate;
  146258. private _sceneDisposeObserver;
  146259. private _improvementMode;
  146260. /**
  146261. * Defines an observable called when the optimizer reaches the target frame rate
  146262. */
  146263. onSuccessObservable: Observable<SceneOptimizer>;
  146264. /**
  146265. * Defines an observable called when the optimizer enables an optimization
  146266. */
  146267. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146268. /**
  146269. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146270. */
  146271. onFailureObservable: Observable<SceneOptimizer>;
  146272. /**
  146273. * Gets a boolean indicating if the optimizer is in improvement mode
  146274. */
  146275. get isInImprovementMode(): boolean;
  146276. /**
  146277. * Gets the current priority level (0 at start)
  146278. */
  146279. get currentPriorityLevel(): number;
  146280. /**
  146281. * Gets the current frame rate checked by the SceneOptimizer
  146282. */
  146283. get currentFrameRate(): number;
  146284. /**
  146285. * Gets or sets the current target frame rate (60 by default)
  146286. */
  146287. get targetFrameRate(): number;
  146288. /**
  146289. * Gets or sets the current target frame rate (60 by default)
  146290. */
  146291. set targetFrameRate(value: number);
  146292. /**
  146293. * Gets or sets the current interval between two checks (every 2000ms by default)
  146294. */
  146295. get trackerDuration(): number;
  146296. /**
  146297. * Gets or sets the current interval between two checks (every 2000ms by default)
  146298. */
  146299. set trackerDuration(value: number);
  146300. /**
  146301. * Gets the list of active optimizations
  146302. */
  146303. get optimizations(): SceneOptimization[];
  146304. /**
  146305. * Creates a new SceneOptimizer
  146306. * @param scene defines the scene to work on
  146307. * @param options defines the options to use with the SceneOptimizer
  146308. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146309. * @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)
  146310. */
  146311. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146312. /**
  146313. * Stops the current optimizer
  146314. */
  146315. stop(): void;
  146316. /**
  146317. * Reset the optimizer to initial step (current priority level = 0)
  146318. */
  146319. reset(): void;
  146320. /**
  146321. * Start the optimizer. By default it will try to reach a specific framerate
  146322. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146323. */
  146324. start(): void;
  146325. private _checkCurrentState;
  146326. /**
  146327. * Release all resources
  146328. */
  146329. dispose(): void;
  146330. /**
  146331. * Helper function to create a SceneOptimizer with one single line of code
  146332. * @param scene defines the scene to work on
  146333. * @param options defines the options to use with the SceneOptimizer
  146334. * @param onSuccess defines a callback to call on success
  146335. * @param onFailure defines a callback to call on failure
  146336. * @returns the new SceneOptimizer object
  146337. */
  146338. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146339. }
  146340. }
  146341. declare module BABYLON {
  146342. /**
  146343. * Class used to serialize a scene into a string
  146344. */
  146345. export class SceneSerializer {
  146346. /**
  146347. * Clear cache used by a previous serialization
  146348. */
  146349. static ClearCache(): void;
  146350. /**
  146351. * Serialize a scene into a JSON compatible object
  146352. * @param scene defines the scene to serialize
  146353. * @returns a JSON compatible object
  146354. */
  146355. static Serialize(scene: Scene): any;
  146356. /**
  146357. * Serialize a mesh into a JSON compatible object
  146358. * @param toSerialize defines the mesh to serialize
  146359. * @param withParents defines if parents must be serialized as well
  146360. * @param withChildren defines if children must be serialized as well
  146361. * @returns a JSON compatible object
  146362. */
  146363. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146364. }
  146365. }
  146366. declare module BABYLON {
  146367. /**
  146368. * Class used to host texture specific utilities
  146369. */
  146370. export class TextureTools {
  146371. /**
  146372. * Uses the GPU to create a copy texture rescaled at a given size
  146373. * @param texture Texture to copy from
  146374. * @param width defines the desired width
  146375. * @param height defines the desired height
  146376. * @param useBilinearMode defines if bilinear mode has to be used
  146377. * @return the generated texture
  146378. */
  146379. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146380. }
  146381. }
  146382. declare module BABYLON {
  146383. /**
  146384. * This represents the different options available for the video capture.
  146385. */
  146386. export interface VideoRecorderOptions {
  146387. /** Defines the mime type of the video. */
  146388. mimeType: string;
  146389. /** Defines the FPS the video should be recorded at. */
  146390. fps: number;
  146391. /** Defines the chunk size for the recording data. */
  146392. recordChunckSize: number;
  146393. /** The audio tracks to attach to the recording. */
  146394. audioTracks?: MediaStreamTrack[];
  146395. }
  146396. /**
  146397. * This can help with recording videos from BabylonJS.
  146398. * This is based on the available WebRTC functionalities of the browser.
  146399. *
  146400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146401. */
  146402. export class VideoRecorder {
  146403. private static readonly _defaultOptions;
  146404. /**
  146405. * Returns whether or not the VideoRecorder is available in your browser.
  146406. * @param engine Defines the Babylon Engine.
  146407. * @returns true if supported otherwise false.
  146408. */
  146409. static IsSupported(engine: Engine): boolean;
  146410. private readonly _options;
  146411. private _canvas;
  146412. private _mediaRecorder;
  146413. private _recordedChunks;
  146414. private _fileName;
  146415. private _resolve;
  146416. private _reject;
  146417. /**
  146418. * True when a recording is already in progress.
  146419. */
  146420. get isRecording(): boolean;
  146421. /**
  146422. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146423. * @param engine Defines the BabylonJS Engine you wish to record.
  146424. * @param options Defines options that can be used to customize the capture.
  146425. */
  146426. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146427. /**
  146428. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146429. */
  146430. stopRecording(): void;
  146431. /**
  146432. * Starts recording the canvas for a max duration specified in parameters.
  146433. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146434. * If null no automatic download will start and you can rely on the promise to get the data back.
  146435. * @param maxDuration Defines the maximum recording time in seconds.
  146436. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146437. * @return A promise callback at the end of the recording with the video data in Blob.
  146438. */
  146439. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146440. /**
  146441. * Releases internal resources used during the recording.
  146442. */
  146443. dispose(): void;
  146444. private _handleDataAvailable;
  146445. private _handleError;
  146446. private _handleStop;
  146447. }
  146448. }
  146449. declare module BABYLON {
  146450. /**
  146451. * Class containing a set of static utilities functions for screenshots
  146452. */
  146453. export class ScreenshotTools {
  146454. /**
  146455. * Captures a screenshot of the current rendering
  146456. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146457. * @param engine defines the rendering engine
  146458. * @param camera defines the source camera
  146459. * @param size This parameter can be set to a single number or to an object with the
  146460. * following (optional) properties: precision, width, height. If a single number is passed,
  146461. * it will be used for both width and height. If an object is passed, the screenshot size
  146462. * will be derived from the parameters. The precision property is a multiplier allowing
  146463. * rendering at a higher or lower resolution
  146464. * @param successCallback defines the callback receives a single parameter which contains the
  146465. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146466. * src parameter of an <img> to display it
  146467. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146468. * Check your browser for supported MIME types
  146469. */
  146470. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146471. /**
  146472. * Captures a screenshot of the current rendering
  146473. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146474. * @param engine defines the rendering engine
  146475. * @param camera defines the source camera
  146476. * @param size This parameter can be set to a single number or to an object with the
  146477. * following (optional) properties: precision, width, height. If a single number is passed,
  146478. * it will be used for both width and height. If an object is passed, the screenshot size
  146479. * will be derived from the parameters. The precision property is a multiplier allowing
  146480. * rendering at a higher or lower resolution
  146481. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146482. * Check your browser for supported MIME types
  146483. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146484. * to the src parameter of an <img> to display it
  146485. */
  146486. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146487. /**
  146488. * Generates an image screenshot from the specified camera.
  146489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146490. * @param engine The engine to use for rendering
  146491. * @param camera The camera to use for rendering
  146492. * @param size This parameter can be set to a single number or to an object with the
  146493. * following (optional) properties: precision, width, height. If a single number is passed,
  146494. * it will be used for both width and height. If an object is passed, the screenshot size
  146495. * will be derived from the parameters. The precision property is a multiplier allowing
  146496. * rendering at a higher or lower resolution
  146497. * @param successCallback The callback receives a single parameter which contains the
  146498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146499. * src parameter of an <img> to display it
  146500. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146501. * Check your browser for supported MIME types
  146502. * @param samples Texture samples (default: 1)
  146503. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146504. * @param fileName A name for for the downloaded file.
  146505. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146506. */
  146507. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146508. /**
  146509. * Generates an image screenshot from the specified camera.
  146510. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146511. * @param engine The engine to use for rendering
  146512. * @param camera The camera to use for rendering
  146513. * @param size This parameter can be set to a single number or to an object with the
  146514. * following (optional) properties: precision, width, height. If a single number is passed,
  146515. * it will be used for both width and height. If an object is passed, the screenshot size
  146516. * will be derived from the parameters. The precision property is a multiplier allowing
  146517. * rendering at a higher or lower resolution
  146518. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146519. * Check your browser for supported MIME types
  146520. * @param samples Texture samples (default: 1)
  146521. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146522. * @param fileName A name for for the downloaded file.
  146523. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146524. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146525. * to the src parameter of an <img> to display it
  146526. */
  146527. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146528. /**
  146529. * Gets height and width for screenshot size
  146530. * @private
  146531. */
  146532. private static _getScreenshotSize;
  146533. }
  146534. }
  146535. declare module BABYLON {
  146536. /**
  146537. * Interface for a data buffer
  146538. */
  146539. export interface IDataBuffer {
  146540. /**
  146541. * Reads bytes from the data buffer.
  146542. * @param byteOffset The byte offset to read
  146543. * @param byteLength The byte length to read
  146544. * @returns A promise that resolves when the bytes are read
  146545. */
  146546. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  146547. /**
  146548. * The byte length of the buffer.
  146549. */
  146550. readonly byteLength: number;
  146551. }
  146552. /**
  146553. * Utility class for reading from a data buffer
  146554. */
  146555. export class DataReader {
  146556. /**
  146557. * The data buffer associated with this data reader.
  146558. */
  146559. readonly buffer: IDataBuffer;
  146560. /**
  146561. * The current byte offset from the beginning of the data buffer.
  146562. */
  146563. byteOffset: number;
  146564. private _dataView;
  146565. private _dataByteOffset;
  146566. /**
  146567. * Constructor
  146568. * @param buffer The buffer to read
  146569. */
  146570. constructor(buffer: IDataBuffer);
  146571. /**
  146572. * Loads the given byte length.
  146573. * @param byteLength The byte length to load
  146574. * @returns A promise that resolves when the load is complete
  146575. */
  146576. loadAsync(byteLength: number): Promise<void>;
  146577. /**
  146578. * Read a unsigned 32-bit integer from the currently loaded data range.
  146579. * @returns The 32-bit integer read
  146580. */
  146581. readUint32(): number;
  146582. /**
  146583. * Read a byte array from the currently loaded data range.
  146584. * @param byteLength The byte length to read
  146585. * @returns The byte array read
  146586. */
  146587. readUint8Array(byteLength: number): Uint8Array;
  146588. /**
  146589. * Read a string from the currently loaded data range.
  146590. * @param byteLength The byte length to read
  146591. * @returns The string read
  146592. */
  146593. readString(byteLength: number): string;
  146594. /**
  146595. * Skips the given byte length the currently loaded data range.
  146596. * @param byteLength The byte length to skip
  146597. */
  146598. skipBytes(byteLength: number): void;
  146599. }
  146600. }
  146601. declare module BABYLON {
  146602. /**
  146603. * Class for storing data to local storage if available or in-memory storage otherwise
  146604. */
  146605. export class DataStorage {
  146606. private static _Storage;
  146607. private static _GetStorage;
  146608. /**
  146609. * Reads a string from the data storage
  146610. * @param key The key to read
  146611. * @param defaultValue The value if the key doesn't exist
  146612. * @returns The string value
  146613. */
  146614. static ReadString(key: string, defaultValue: string): string;
  146615. /**
  146616. * Writes a string to the data storage
  146617. * @param key The key to write
  146618. * @param value The value to write
  146619. */
  146620. static WriteString(key: string, value: string): void;
  146621. /**
  146622. * Reads a boolean from the data storage
  146623. * @param key The key to read
  146624. * @param defaultValue The value if the key doesn't exist
  146625. * @returns The boolean value
  146626. */
  146627. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  146628. /**
  146629. * Writes a boolean to the data storage
  146630. * @param key The key to write
  146631. * @param value The value to write
  146632. */
  146633. static WriteBoolean(key: string, value: boolean): void;
  146634. /**
  146635. * Reads a number from the data storage
  146636. * @param key The key to read
  146637. * @param defaultValue The value if the key doesn't exist
  146638. * @returns The number value
  146639. */
  146640. static ReadNumber(key: string, defaultValue: number): number;
  146641. /**
  146642. * Writes a number to the data storage
  146643. * @param key The key to write
  146644. * @param value The value to write
  146645. */
  146646. static WriteNumber(key: string, value: number): void;
  146647. }
  146648. }
  146649. declare module BABYLON {
  146650. /**
  146651. * Options used for hit testing
  146652. */
  146653. export interface IWebXRLegacyHitTestOptions {
  146654. /**
  146655. * Only test when user interacted with the scene. Default - hit test every frame
  146656. */
  146657. testOnPointerDownOnly?: boolean;
  146658. /**
  146659. * The node to use to transform the local results to world coordinates
  146660. */
  146661. worldParentNode?: TransformNode;
  146662. }
  146663. /**
  146664. * Interface defining the babylon result of raycasting/hit-test
  146665. */
  146666. export interface IWebXRLegacyHitResult {
  146667. /**
  146668. * Transformation matrix that can be applied to a node that will put it in the hit point location
  146669. */
  146670. transformationMatrix: Matrix;
  146671. /**
  146672. * The native hit test result
  146673. */
  146674. xrHitResult: XRHitResult | XRHitTestResult;
  146675. }
  146676. /**
  146677. * The currently-working hit-test module.
  146678. * Hit test (or Ray-casting) is used to interact with the real world.
  146679. * For further information read here - https://github.com/immersive-web/hit-test
  146680. */
  146681. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  146682. /**
  146683. * options to use when constructing this feature
  146684. */
  146685. readonly options: IWebXRLegacyHitTestOptions;
  146686. private _direction;
  146687. private _mat;
  146688. private _onSelectEnabled;
  146689. private _origin;
  146690. /**
  146691. * The module's name
  146692. */
  146693. static readonly Name: string;
  146694. /**
  146695. * The (Babylon) version of this module.
  146696. * This is an integer representing the implementation version.
  146697. * This number does not correspond to the WebXR specs version
  146698. */
  146699. static readonly Version: number;
  146700. /**
  146701. * Populated with the last native XR Hit Results
  146702. */
  146703. lastNativeXRHitResults: XRHitResult[];
  146704. /**
  146705. * Triggered when new babylon (transformed) hit test results are available
  146706. */
  146707. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  146708. /**
  146709. * Creates a new instance of the (legacy version) hit test feature
  146710. * @param _xrSessionManager an instance of WebXRSessionManager
  146711. * @param options options to use when constructing this feature
  146712. */
  146713. constructor(_xrSessionManager: WebXRSessionManager,
  146714. /**
  146715. * options to use when constructing this feature
  146716. */
  146717. options?: IWebXRLegacyHitTestOptions);
  146718. /**
  146719. * execute a hit test with an XR Ray
  146720. *
  146721. * @param xrSession a native xrSession that will execute this hit test
  146722. * @param xrRay the ray (position and direction) to use for ray-casting
  146723. * @param referenceSpace native XR reference space to use for the hit-test
  146724. * @param filter filter function that will filter the results
  146725. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146726. */
  146727. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  146728. /**
  146729. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  146730. * @param event the (select) event to use to select with
  146731. * @param referenceSpace the reference space to use for this hit test
  146732. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146733. */
  146734. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  146735. /**
  146736. * attach this feature
  146737. * Will usually be called by the features manager
  146738. *
  146739. * @returns true if successful.
  146740. */
  146741. attach(): boolean;
  146742. /**
  146743. * detach this feature.
  146744. * Will usually be called by the features manager
  146745. *
  146746. * @returns true if successful.
  146747. */
  146748. detach(): boolean;
  146749. /**
  146750. * Dispose this feature and all of the resources attached
  146751. */
  146752. dispose(): void;
  146753. protected _onXRFrame(frame: XRFrame): void;
  146754. private _onHitTestResults;
  146755. private _onSelect;
  146756. }
  146757. }
  146758. declare module BABYLON {
  146759. /**
  146760. * Options used in the plane detector module
  146761. */
  146762. export interface IWebXRPlaneDetectorOptions {
  146763. /**
  146764. * The node to use to transform the local results to world coordinates
  146765. */
  146766. worldParentNode?: TransformNode;
  146767. }
  146768. /**
  146769. * A babylon interface for a WebXR plane.
  146770. * A Plane is actually a polygon, built from N points in space
  146771. *
  146772. * Supported in chrome 79, not supported in canary 81 ATM
  146773. */
  146774. export interface IWebXRPlane {
  146775. /**
  146776. * a babylon-assigned ID for this polygon
  146777. */
  146778. id: number;
  146779. /**
  146780. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  146781. */
  146782. polygonDefinition: Array<Vector3>;
  146783. /**
  146784. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  146785. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  146786. */
  146787. transformationMatrix: Matrix;
  146788. /**
  146789. * the native xr-plane object
  146790. */
  146791. xrPlane: XRPlane;
  146792. }
  146793. /**
  146794. * The plane detector is used to detect planes in the real world when in AR
  146795. * For more information see https://github.com/immersive-web/real-world-geometry/
  146796. */
  146797. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  146798. private _options;
  146799. private _detectedPlanes;
  146800. private _enabled;
  146801. private _lastFrameDetected;
  146802. /**
  146803. * The module's name
  146804. */
  146805. static readonly Name: string;
  146806. /**
  146807. * The (Babylon) version of this module.
  146808. * This is an integer representing the implementation version.
  146809. * This number does not correspond to the WebXR specs version
  146810. */
  146811. static readonly Version: number;
  146812. /**
  146813. * Observers registered here will be executed when a new plane was added to the session
  146814. */
  146815. onPlaneAddedObservable: Observable<IWebXRPlane>;
  146816. /**
  146817. * Observers registered here will be executed when a plane is no longer detected in the session
  146818. */
  146819. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  146820. /**
  146821. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  146822. * This can execute N times every frame
  146823. */
  146824. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  146825. /**
  146826. * construct a new Plane Detector
  146827. * @param _xrSessionManager an instance of xr Session manager
  146828. * @param _options configuration to use when constructing this feature
  146829. */
  146830. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  146831. /**
  146832. * Dispose this feature and all of the resources attached
  146833. */
  146834. dispose(): void;
  146835. protected _onXRFrame(frame: XRFrame): void;
  146836. private _init;
  146837. private _updatePlaneWithXRPlane;
  146838. /**
  146839. * avoiding using Array.find for global support.
  146840. * @param xrPlane the plane to find in the array
  146841. */
  146842. private findIndexInPlaneArray;
  146843. }
  146844. }
  146845. declare module BABYLON {
  146846. /**
  146847. * Configuration options of the anchor system
  146848. */
  146849. export interface IWebXRAnchorSystemOptions {
  146850. /**
  146851. * Should a new anchor be added every time a select event is triggered
  146852. */
  146853. addAnchorOnSelect?: boolean;
  146854. /**
  146855. * should the anchor system use plane detection.
  146856. * If set to true, the plane-detection feature should be set using setPlaneDetector
  146857. */
  146858. usePlaneDetection?: boolean;
  146859. /**
  146860. * a node that will be used to convert local to world coordinates
  146861. */
  146862. worldParentNode?: TransformNode;
  146863. }
  146864. /**
  146865. * A babylon container for an XR Anchor
  146866. */
  146867. export interface IWebXRAnchor {
  146868. /**
  146869. * A babylon-assigned ID for this anchor
  146870. */
  146871. id: number;
  146872. /**
  146873. * Transformation matrix to apply to an object attached to this anchor
  146874. */
  146875. transformationMatrix: Matrix;
  146876. /**
  146877. * The native anchor object
  146878. */
  146879. xrAnchor: XRAnchor;
  146880. }
  146881. /**
  146882. * An implementation of the anchor system of WebXR.
  146883. * Note that the current documented implementation is not available in any browser. Future implementations
  146884. * will use the frame to create an anchor and not the session or a detected plane
  146885. * For further information see https://github.com/immersive-web/anchors/
  146886. */
  146887. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  146888. private _options;
  146889. private _enabled;
  146890. private _hitTestModule;
  146891. private _lastFrameDetected;
  146892. private _onSelect;
  146893. private _planeDetector;
  146894. private _trackedAnchors;
  146895. /**
  146896. * The module's name
  146897. */
  146898. static readonly Name: string;
  146899. /**
  146900. * The (Babylon) version of this module.
  146901. * This is an integer representing the implementation version.
  146902. * This number does not correspond to the WebXR specs version
  146903. */
  146904. static readonly Version: number;
  146905. /**
  146906. * Observers registered here will be executed when a new anchor was added to the session
  146907. */
  146908. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  146909. /**
  146910. * Observers registered here will be executed when an anchor was removed from the session
  146911. */
  146912. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  146913. /**
  146914. * Observers registered here will be executed when an existing anchor updates
  146915. * This can execute N times every frame
  146916. */
  146917. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  146918. /**
  146919. * constructs a new anchor system
  146920. * @param _xrSessionManager an instance of WebXRSessionManager
  146921. * @param _options configuration object for this feature
  146922. */
  146923. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  146924. /**
  146925. * Add anchor at a specific XR point.
  146926. *
  146927. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  146928. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  146929. * @returns a promise the fulfills when the anchor was created
  146930. */
  146931. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  146932. /**
  146933. * attach this feature
  146934. * Will usually be called by the features manager
  146935. *
  146936. * @returns true if successful.
  146937. */
  146938. attach(): boolean;
  146939. /**
  146940. * detach this feature.
  146941. * Will usually be called by the features manager
  146942. *
  146943. * @returns true if successful.
  146944. */
  146945. detach(): boolean;
  146946. /**
  146947. * Dispose this feature and all of the resources attached
  146948. */
  146949. dispose(): void;
  146950. /**
  146951. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  146952. * @param hitTestModule the hit-test module to use.
  146953. */
  146954. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  146955. /**
  146956. * set the plane detector to use in order to create anchors from frames
  146957. * @param planeDetector the plane-detector module to use
  146958. * @param enable enable plane-anchors. default is true
  146959. */
  146960. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  146961. protected _onXRFrame(frame: XRFrame): void;
  146962. /**
  146963. * avoiding using Array.find for global support.
  146964. * @param xrAnchor the plane to find in the array
  146965. */
  146966. private _findIndexInAnchorArray;
  146967. private _updateAnchorWithXRFrame;
  146968. }
  146969. }
  146970. declare module BABYLON {
  146971. /**
  146972. * Options interface for the background remover plugin
  146973. */
  146974. export interface IWebXRBackgroundRemoverOptions {
  146975. /**
  146976. * Further background meshes to disable when entering AR
  146977. */
  146978. backgroundMeshes?: AbstractMesh[];
  146979. /**
  146980. * flags to configure the removal of the environment helper.
  146981. * If not set, the entire background will be removed. If set, flags should be set as well.
  146982. */
  146983. environmentHelperRemovalFlags?: {
  146984. /**
  146985. * Should the skybox be removed (default false)
  146986. */
  146987. skyBox?: boolean;
  146988. /**
  146989. * Should the ground be removed (default false)
  146990. */
  146991. ground?: boolean;
  146992. };
  146993. /**
  146994. * don't disable the environment helper
  146995. */
  146996. ignoreEnvironmentHelper?: boolean;
  146997. }
  146998. /**
  146999. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  147000. */
  147001. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  147002. /**
  147003. * read-only options to be used in this module
  147004. */
  147005. readonly options: IWebXRBackgroundRemoverOptions;
  147006. /**
  147007. * The module's name
  147008. */
  147009. static readonly Name: string;
  147010. /**
  147011. * The (Babylon) version of this module.
  147012. * This is an integer representing the implementation version.
  147013. * This number does not correspond to the WebXR specs version
  147014. */
  147015. static readonly Version: number;
  147016. /**
  147017. * registered observers will be triggered when the background state changes
  147018. */
  147019. onBackgroundStateChangedObservable: Observable<boolean>;
  147020. /**
  147021. * constructs a new background remover module
  147022. * @param _xrSessionManager the session manager for this module
  147023. * @param options read-only options to be used in this module
  147024. */
  147025. constructor(_xrSessionManager: WebXRSessionManager,
  147026. /**
  147027. * read-only options to be used in this module
  147028. */
  147029. options?: IWebXRBackgroundRemoverOptions);
  147030. /**
  147031. * attach this feature
  147032. * Will usually be called by the features manager
  147033. *
  147034. * @returns true if successful.
  147035. */
  147036. attach(): boolean;
  147037. /**
  147038. * detach this feature.
  147039. * Will usually be called by the features manager
  147040. *
  147041. * @returns true if successful.
  147042. */
  147043. detach(): boolean;
  147044. /**
  147045. * Dispose this feature and all of the resources attached
  147046. */
  147047. dispose(): void;
  147048. protected _onXRFrame(_xrFrame: XRFrame): void;
  147049. private _setBackgroundState;
  147050. }
  147051. }
  147052. declare module BABYLON {
  147053. /**
  147054. * Options for the controller physics feature
  147055. */
  147056. export class IWebXRControllerPhysicsOptions {
  147057. /**
  147058. * Should the headset get its own impostor
  147059. */
  147060. enableHeadsetImpostor?: boolean;
  147061. /**
  147062. * Optional parameters for the headset impostor
  147063. */
  147064. headsetImpostorParams?: {
  147065. /**
  147066. * The type of impostor to create. Default is sphere
  147067. */
  147068. impostorType: number;
  147069. /**
  147070. * the size of the impostor. Defaults to 10cm
  147071. */
  147072. impostorSize?: number | {
  147073. width: number;
  147074. height: number;
  147075. depth: number;
  147076. };
  147077. /**
  147078. * Friction definitions
  147079. */
  147080. friction?: number;
  147081. /**
  147082. * Restitution
  147083. */
  147084. restitution?: number;
  147085. };
  147086. /**
  147087. * The physics properties of the future impostors
  147088. */
  147089. physicsProperties?: {
  147090. /**
  147091. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147092. * Note that this requires a physics engine that supports mesh impostors!
  147093. */
  147094. useControllerMesh?: boolean;
  147095. /**
  147096. * The type of impostor to create. Default is sphere
  147097. */
  147098. impostorType?: number;
  147099. /**
  147100. * the size of the impostor. Defaults to 10cm
  147101. */
  147102. impostorSize?: number | {
  147103. width: number;
  147104. height: number;
  147105. depth: number;
  147106. };
  147107. /**
  147108. * Friction definitions
  147109. */
  147110. friction?: number;
  147111. /**
  147112. * Restitution
  147113. */
  147114. restitution?: number;
  147115. };
  147116. /**
  147117. * the xr input to use with this pointer selection
  147118. */
  147119. xrInput: WebXRInput;
  147120. }
  147121. /**
  147122. * Add physics impostor to your webxr controllers,
  147123. * including naive calculation of their linear and angular velocity
  147124. */
  147125. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147126. private readonly _options;
  147127. private _attachController;
  147128. private _controllers;
  147129. private _debugMode;
  147130. private _delta;
  147131. private _headsetImpostor?;
  147132. private _headsetMesh?;
  147133. private _lastTimestamp;
  147134. private _tmpQuaternion;
  147135. private _tmpVector;
  147136. /**
  147137. * The module's name
  147138. */
  147139. static readonly Name: string;
  147140. /**
  147141. * The (Babylon) version of this module.
  147142. * This is an integer representing the implementation version.
  147143. * This number does not correspond to the webxr specs version
  147144. */
  147145. static readonly Version: number;
  147146. /**
  147147. * Construct a new Controller Physics Feature
  147148. * @param _xrSessionManager the corresponding xr session manager
  147149. * @param _options options to create this feature with
  147150. */
  147151. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147152. /**
  147153. * @hidden
  147154. * enable debugging - will show console outputs and the impostor mesh
  147155. */
  147156. _enablePhysicsDebug(): void;
  147157. /**
  147158. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147159. * @param xrController the controller to add
  147160. */
  147161. addController(xrController: WebXRInputSource): void;
  147162. /**
  147163. * attach this feature
  147164. * Will usually be called by the features manager
  147165. *
  147166. * @returns true if successful.
  147167. */
  147168. attach(): boolean;
  147169. /**
  147170. * detach this feature.
  147171. * Will usually be called by the features manager
  147172. *
  147173. * @returns true if successful.
  147174. */
  147175. detach(): boolean;
  147176. /**
  147177. * Get the headset impostor, if enabled
  147178. * @returns the impostor
  147179. */
  147180. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147181. /**
  147182. * Get the physics impostor of a specific controller.
  147183. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147184. * @param controller the controller or the controller id of which to get the impostor
  147185. * @returns the impostor or null
  147186. */
  147187. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147188. /**
  147189. * Update the physics properties provided in the constructor
  147190. * @param newProperties the new properties object
  147191. */
  147192. setPhysicsProperties(newProperties: {
  147193. impostorType?: number;
  147194. impostorSize?: number | {
  147195. width: number;
  147196. height: number;
  147197. depth: number;
  147198. };
  147199. friction?: number;
  147200. restitution?: number;
  147201. }): void;
  147202. protected _onXRFrame(_xrFrame: any): void;
  147203. private _detachController;
  147204. }
  147205. }
  147206. declare module BABYLON {
  147207. /**
  147208. * Options used for hit testing (version 2)
  147209. */
  147210. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147211. /**
  147212. * Do not create a permanent hit test. Will usually be used when only
  147213. * transient inputs are needed.
  147214. */
  147215. disablePermanentHitTest?: boolean;
  147216. /**
  147217. * Enable transient (for example touch-based) hit test inspections
  147218. */
  147219. enableTransientHitTest?: boolean;
  147220. /**
  147221. * Offset ray for the permanent hit test
  147222. */
  147223. offsetRay?: Vector3;
  147224. /**
  147225. * Offset ray for the transient hit test
  147226. */
  147227. transientOffsetRay?: Vector3;
  147228. /**
  147229. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147230. */
  147231. useReferenceSpace?: boolean;
  147232. }
  147233. /**
  147234. * Interface defining the babylon result of hit-test
  147235. */
  147236. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147237. /**
  147238. * The input source that generated this hit test (if transient)
  147239. */
  147240. inputSource?: XRInputSource;
  147241. /**
  147242. * Is this a transient hit test
  147243. */
  147244. isTransient?: boolean;
  147245. /**
  147246. * Position of the hit test result
  147247. */
  147248. position: Vector3;
  147249. /**
  147250. * Rotation of the hit test result
  147251. */
  147252. rotationQuaternion: Quaternion;
  147253. }
  147254. /**
  147255. * The currently-working hit-test module.
  147256. * Hit test (or Ray-casting) is used to interact with the real world.
  147257. * For further information read here - https://github.com/immersive-web/hit-test
  147258. *
  147259. * Tested on chrome (mobile) 80.
  147260. */
  147261. export class WebXRHitTest extends WebXRAbstractFeature {
  147262. /**
  147263. * options to use when constructing this feature
  147264. */
  147265. readonly options: IWebXRHitTestOptions;
  147266. private _tmpMat;
  147267. private _tmpPos;
  147268. private _tmpQuat;
  147269. private _transientXrHitTestSource;
  147270. private _xrHitTestSource;
  147271. private initHitTestSource;
  147272. /**
  147273. * The module's name
  147274. */
  147275. static readonly Name: string;
  147276. /**
  147277. * The (Babylon) version of this module.
  147278. * This is an integer representing the implementation version.
  147279. * This number does not correspond to the WebXR specs version
  147280. */
  147281. static readonly Version: number;
  147282. /**
  147283. * When set to true, each hit test will have its own position/rotation objects
  147284. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147285. * the developers will clone them or copy them as they see fit.
  147286. */
  147287. autoCloneTransformation: boolean;
  147288. /**
  147289. * Populated with the last native XR Hit Results
  147290. */
  147291. lastNativeXRHitResults: XRHitResult[];
  147292. /**
  147293. * Triggered when new babylon (transformed) hit test results are available
  147294. */
  147295. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147296. /**
  147297. * Use this to temporarily pause hit test checks.
  147298. */
  147299. paused: boolean;
  147300. /**
  147301. * Creates a new instance of the hit test feature
  147302. * @param _xrSessionManager an instance of WebXRSessionManager
  147303. * @param options options to use when constructing this feature
  147304. */
  147305. constructor(_xrSessionManager: WebXRSessionManager,
  147306. /**
  147307. * options to use when constructing this feature
  147308. */
  147309. options?: IWebXRHitTestOptions);
  147310. /**
  147311. * attach this feature
  147312. * Will usually be called by the features manager
  147313. *
  147314. * @returns true if successful.
  147315. */
  147316. attach(): boolean;
  147317. /**
  147318. * detach this feature.
  147319. * Will usually be called by the features manager
  147320. *
  147321. * @returns true if successful.
  147322. */
  147323. detach(): boolean;
  147324. /**
  147325. * Dispose this feature and all of the resources attached
  147326. */
  147327. dispose(): void;
  147328. protected _onXRFrame(frame: XRFrame): void;
  147329. private _processWebXRHitTestResult;
  147330. }
  147331. }
  147332. declare module BABYLON {
  147333. /**
  147334. * The motion controller class for all microsoft mixed reality controllers
  147335. */
  147336. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147337. protected readonly _mapping: {
  147338. defaultButton: {
  147339. valueNodeName: string;
  147340. unpressedNodeName: string;
  147341. pressedNodeName: string;
  147342. };
  147343. defaultAxis: {
  147344. valueNodeName: string;
  147345. minNodeName: string;
  147346. maxNodeName: string;
  147347. };
  147348. buttons: {
  147349. "xr-standard-trigger": {
  147350. rootNodeName: string;
  147351. componentProperty: string;
  147352. states: string[];
  147353. };
  147354. "xr-standard-squeeze": {
  147355. rootNodeName: string;
  147356. componentProperty: string;
  147357. states: string[];
  147358. };
  147359. "xr-standard-touchpad": {
  147360. rootNodeName: string;
  147361. labelAnchorNodeName: string;
  147362. touchPointNodeName: string;
  147363. };
  147364. "xr-standard-thumbstick": {
  147365. rootNodeName: string;
  147366. componentProperty: string;
  147367. states: string[];
  147368. };
  147369. };
  147370. axes: {
  147371. "xr-standard-touchpad": {
  147372. "x-axis": {
  147373. rootNodeName: string;
  147374. };
  147375. "y-axis": {
  147376. rootNodeName: string;
  147377. };
  147378. };
  147379. "xr-standard-thumbstick": {
  147380. "x-axis": {
  147381. rootNodeName: string;
  147382. };
  147383. "y-axis": {
  147384. rootNodeName: string;
  147385. };
  147386. };
  147387. };
  147388. };
  147389. /**
  147390. * The base url used to load the left and right controller models
  147391. */
  147392. static MODEL_BASE_URL: string;
  147393. /**
  147394. * The name of the left controller model file
  147395. */
  147396. static MODEL_LEFT_FILENAME: string;
  147397. /**
  147398. * The name of the right controller model file
  147399. */
  147400. static MODEL_RIGHT_FILENAME: string;
  147401. profileId: string;
  147402. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147403. protected _getFilenameAndPath(): {
  147404. filename: string;
  147405. path: string;
  147406. };
  147407. protected _getModelLoadingConstraints(): boolean;
  147408. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147409. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147410. protected _updateModel(): void;
  147411. }
  147412. }
  147413. declare module BABYLON {
  147414. /**
  147415. * The motion controller class for oculus touch (quest, rift).
  147416. * This class supports legacy mapping as well the standard xr mapping
  147417. */
  147418. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147419. private _forceLegacyControllers;
  147420. private _modelRootNode;
  147421. /**
  147422. * The base url used to load the left and right controller models
  147423. */
  147424. static MODEL_BASE_URL: string;
  147425. /**
  147426. * The name of the left controller model file
  147427. */
  147428. static MODEL_LEFT_FILENAME: string;
  147429. /**
  147430. * The name of the right controller model file
  147431. */
  147432. static MODEL_RIGHT_FILENAME: string;
  147433. /**
  147434. * Base Url for the Quest controller model.
  147435. */
  147436. static QUEST_MODEL_BASE_URL: string;
  147437. profileId: string;
  147438. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147439. protected _getFilenameAndPath(): {
  147440. filename: string;
  147441. path: string;
  147442. };
  147443. protected _getModelLoadingConstraints(): boolean;
  147444. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147445. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147446. protected _updateModel(): void;
  147447. /**
  147448. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147449. * between the touch and touch 2.
  147450. */
  147451. private _isQuest;
  147452. }
  147453. }
  147454. declare module BABYLON {
  147455. /**
  147456. * The motion controller class for the standard HTC-Vive controllers
  147457. */
  147458. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147459. private _modelRootNode;
  147460. /**
  147461. * The base url used to load the left and right controller models
  147462. */
  147463. static MODEL_BASE_URL: string;
  147464. /**
  147465. * File name for the controller model.
  147466. */
  147467. static MODEL_FILENAME: string;
  147468. profileId: string;
  147469. /**
  147470. * Create a new Vive motion controller object
  147471. * @param scene the scene to use to create this controller
  147472. * @param gamepadObject the corresponding gamepad object
  147473. * @param handedness the handedness of the controller
  147474. */
  147475. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147476. protected _getFilenameAndPath(): {
  147477. filename: string;
  147478. path: string;
  147479. };
  147480. protected _getModelLoadingConstraints(): boolean;
  147481. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147482. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147483. protected _updateModel(): void;
  147484. }
  147485. }
  147486. declare module BABYLON {
  147487. /**
  147488. * A cursor which tracks a point on a path
  147489. */
  147490. export class PathCursor {
  147491. private path;
  147492. /**
  147493. * Stores path cursor callbacks for when an onchange event is triggered
  147494. */
  147495. private _onchange;
  147496. /**
  147497. * The value of the path cursor
  147498. */
  147499. value: number;
  147500. /**
  147501. * The animation array of the path cursor
  147502. */
  147503. animations: Animation[];
  147504. /**
  147505. * Initializes the path cursor
  147506. * @param path The path to track
  147507. */
  147508. constructor(path: Path2);
  147509. /**
  147510. * Gets the cursor point on the path
  147511. * @returns A point on the path cursor at the cursor location
  147512. */
  147513. getPoint(): Vector3;
  147514. /**
  147515. * Moves the cursor ahead by the step amount
  147516. * @param step The amount to move the cursor forward
  147517. * @returns This path cursor
  147518. */
  147519. moveAhead(step?: number): PathCursor;
  147520. /**
  147521. * Moves the cursor behind by the step amount
  147522. * @param step The amount to move the cursor back
  147523. * @returns This path cursor
  147524. */
  147525. moveBack(step?: number): PathCursor;
  147526. /**
  147527. * Moves the cursor by the step amount
  147528. * If the step amount is greater than one, an exception is thrown
  147529. * @param step The amount to move the cursor
  147530. * @returns This path cursor
  147531. */
  147532. move(step: number): PathCursor;
  147533. /**
  147534. * Ensures that the value is limited between zero and one
  147535. * @returns This path cursor
  147536. */
  147537. private ensureLimits;
  147538. /**
  147539. * Runs onchange callbacks on change (used by the animation engine)
  147540. * @returns This path cursor
  147541. */
  147542. private raiseOnChange;
  147543. /**
  147544. * Executes a function on change
  147545. * @param f A path cursor onchange callback
  147546. * @returns This path cursor
  147547. */
  147548. onchange(f: (cursor: PathCursor) => void): PathCursor;
  147549. }
  147550. }
  147551. declare module BABYLON {
  147552. /** @hidden */
  147553. export var blurPixelShader: {
  147554. name: string;
  147555. shader: string;
  147556. };
  147557. }
  147558. declare module BABYLON {
  147559. /** @hidden */
  147560. export var pointCloudVertexDeclaration: {
  147561. name: string;
  147562. shader: string;
  147563. };
  147564. }
  147565. // Mixins
  147566. interface Window {
  147567. mozIndexedDB: IDBFactory;
  147568. webkitIndexedDB: IDBFactory;
  147569. msIndexedDB: IDBFactory;
  147570. webkitURL: typeof URL;
  147571. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  147572. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  147573. WebGLRenderingContext: WebGLRenderingContext;
  147574. MSGesture: MSGesture;
  147575. CANNON: any;
  147576. AudioContext: AudioContext;
  147577. webkitAudioContext: AudioContext;
  147578. PointerEvent: any;
  147579. Math: Math;
  147580. Uint8Array: Uint8ArrayConstructor;
  147581. Float32Array: Float32ArrayConstructor;
  147582. mozURL: typeof URL;
  147583. msURL: typeof URL;
  147584. VRFrameData: any; // WebVR, from specs 1.1
  147585. DracoDecoderModule: any;
  147586. setImmediate(handler: (...args: any[]) => void): number;
  147587. }
  147588. interface HTMLCanvasElement {
  147589. requestPointerLock(): void;
  147590. msRequestPointerLock?(): void;
  147591. mozRequestPointerLock?(): void;
  147592. webkitRequestPointerLock?(): void;
  147593. /** Track wether a record is in progress */
  147594. isRecording: boolean;
  147595. /** Capture Stream method defined by some browsers */
  147596. captureStream(fps?: number): MediaStream;
  147597. }
  147598. interface CanvasRenderingContext2D {
  147599. msImageSmoothingEnabled: boolean;
  147600. }
  147601. interface MouseEvent {
  147602. mozMovementX: number;
  147603. mozMovementY: number;
  147604. webkitMovementX: number;
  147605. webkitMovementY: number;
  147606. msMovementX: number;
  147607. msMovementY: number;
  147608. }
  147609. interface Navigator {
  147610. mozGetVRDevices: (any: any) => any;
  147611. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147612. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147613. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147614. webkitGetGamepads(): Gamepad[];
  147615. msGetGamepads(): Gamepad[];
  147616. webkitGamepads(): Gamepad[];
  147617. }
  147618. interface HTMLVideoElement {
  147619. mozSrcObject: any;
  147620. }
  147621. interface Math {
  147622. fround(x: number): number;
  147623. imul(a: number, b: number): number;
  147624. }
  147625. interface WebGLRenderingContext {
  147626. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  147627. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  147628. vertexAttribDivisor(index: number, divisor: number): void;
  147629. createVertexArray(): any;
  147630. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  147631. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  147632. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  147633. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  147634. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  147635. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  147636. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  147637. // Queries
  147638. createQuery(): WebGLQuery;
  147639. deleteQuery(query: WebGLQuery): void;
  147640. beginQuery(target: number, query: WebGLQuery): void;
  147641. endQuery(target: number): void;
  147642. getQueryParameter(query: WebGLQuery, pname: number): any;
  147643. getQuery(target: number, pname: number): any;
  147644. MAX_SAMPLES: number;
  147645. RGBA8: number;
  147646. READ_FRAMEBUFFER: number;
  147647. DRAW_FRAMEBUFFER: number;
  147648. UNIFORM_BUFFER: number;
  147649. HALF_FLOAT_OES: number;
  147650. RGBA16F: number;
  147651. RGBA32F: number;
  147652. R32F: number;
  147653. RG32F: number;
  147654. RGB32F: number;
  147655. R16F: number;
  147656. RG16F: number;
  147657. RGB16F: number;
  147658. RED: number;
  147659. RG: number;
  147660. R8: number;
  147661. RG8: number;
  147662. UNSIGNED_INT_24_8: number;
  147663. DEPTH24_STENCIL8: number;
  147664. MIN: number;
  147665. MAX: number;
  147666. /* Multiple Render Targets */
  147667. drawBuffers(buffers: number[]): void;
  147668. readBuffer(src: number): void;
  147669. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  147670. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  147671. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  147672. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  147673. // Occlusion Query
  147674. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  147675. ANY_SAMPLES_PASSED: number;
  147676. QUERY_RESULT_AVAILABLE: number;
  147677. QUERY_RESULT: number;
  147678. }
  147679. interface WebGLProgram {
  147680. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  147681. }
  147682. interface EXT_disjoint_timer_query {
  147683. QUERY_COUNTER_BITS_EXT: number;
  147684. TIME_ELAPSED_EXT: number;
  147685. TIMESTAMP_EXT: number;
  147686. GPU_DISJOINT_EXT: number;
  147687. QUERY_RESULT_EXT: number;
  147688. QUERY_RESULT_AVAILABLE_EXT: number;
  147689. queryCounterEXT(query: WebGLQuery, target: number): void;
  147690. createQueryEXT(): WebGLQuery;
  147691. beginQueryEXT(target: number, query: WebGLQuery): void;
  147692. endQueryEXT(target: number): void;
  147693. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  147694. deleteQueryEXT(query: WebGLQuery): void;
  147695. }
  147696. interface WebGLUniformLocation {
  147697. _currentState: any;
  147698. }
  147699. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  147700. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  147701. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  147702. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147703. interface WebGLRenderingContext {
  147704. readonly RASTERIZER_DISCARD: number;
  147705. readonly DEPTH_COMPONENT24: number;
  147706. readonly TEXTURE_3D: number;
  147707. readonly TEXTURE_2D_ARRAY: number;
  147708. readonly TEXTURE_COMPARE_FUNC: number;
  147709. readonly TEXTURE_COMPARE_MODE: number;
  147710. readonly COMPARE_REF_TO_TEXTURE: number;
  147711. readonly TEXTURE_WRAP_R: number;
  147712. readonly HALF_FLOAT: number;
  147713. readonly RGB8: number;
  147714. readonly RED_INTEGER: number;
  147715. readonly RG_INTEGER: number;
  147716. readonly RGB_INTEGER: number;
  147717. readonly RGBA_INTEGER: number;
  147718. readonly R8_SNORM: number;
  147719. readonly RG8_SNORM: number;
  147720. readonly RGB8_SNORM: number;
  147721. readonly RGBA8_SNORM: number;
  147722. readonly R8I: number;
  147723. readonly RG8I: number;
  147724. readonly RGB8I: number;
  147725. readonly RGBA8I: number;
  147726. readonly R8UI: number;
  147727. readonly RG8UI: number;
  147728. readonly RGB8UI: number;
  147729. readonly RGBA8UI: number;
  147730. readonly R16I: number;
  147731. readonly RG16I: number;
  147732. readonly RGB16I: number;
  147733. readonly RGBA16I: number;
  147734. readonly R16UI: number;
  147735. readonly RG16UI: number;
  147736. readonly RGB16UI: number;
  147737. readonly RGBA16UI: number;
  147738. readonly R32I: number;
  147739. readonly RG32I: number;
  147740. readonly RGB32I: number;
  147741. readonly RGBA32I: number;
  147742. readonly R32UI: number;
  147743. readonly RG32UI: number;
  147744. readonly RGB32UI: number;
  147745. readonly RGBA32UI: number;
  147746. readonly RGB10_A2UI: number;
  147747. readonly R11F_G11F_B10F: number;
  147748. readonly RGB9_E5: number;
  147749. readonly RGB10_A2: number;
  147750. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  147751. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  147752. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  147753. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  147754. readonly DEPTH_COMPONENT32F: number;
  147755. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  147756. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  147757. 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;
  147758. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  147759. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  147760. readonly TRANSFORM_FEEDBACK: number;
  147761. readonly INTERLEAVED_ATTRIBS: number;
  147762. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  147763. createTransformFeedback(): WebGLTransformFeedback;
  147764. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  147765. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  147766. beginTransformFeedback(primitiveMode: number): void;
  147767. endTransformFeedback(): void;
  147768. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  147769. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147770. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147771. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147772. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  147773. }
  147774. interface ImageBitmap {
  147775. readonly width: number;
  147776. readonly height: number;
  147777. close(): void;
  147778. }
  147779. interface WebGLQuery extends WebGLObject {
  147780. }
  147781. declare var WebGLQuery: {
  147782. prototype: WebGLQuery;
  147783. new(): WebGLQuery;
  147784. };
  147785. interface WebGLSampler extends WebGLObject {
  147786. }
  147787. declare var WebGLSampler: {
  147788. prototype: WebGLSampler;
  147789. new(): WebGLSampler;
  147790. };
  147791. interface WebGLSync extends WebGLObject {
  147792. }
  147793. declare var WebGLSync: {
  147794. prototype: WebGLSync;
  147795. new(): WebGLSync;
  147796. };
  147797. interface WebGLTransformFeedback extends WebGLObject {
  147798. }
  147799. declare var WebGLTransformFeedback: {
  147800. prototype: WebGLTransformFeedback;
  147801. new(): WebGLTransformFeedback;
  147802. };
  147803. interface WebGLVertexArrayObject extends WebGLObject {
  147804. }
  147805. declare var WebGLVertexArrayObject: {
  147806. prototype: WebGLVertexArrayObject;
  147807. new(): WebGLVertexArrayObject;
  147808. };
  147809. // Type definitions for WebVR API
  147810. // Project: https://w3c.github.io/webvr/
  147811. // Definitions by: six a <https://github.com/lostfictions>
  147812. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147813. interface VRDisplay extends EventTarget {
  147814. /**
  147815. * Dictionary of capabilities describing the VRDisplay.
  147816. */
  147817. readonly capabilities: VRDisplayCapabilities;
  147818. /**
  147819. * z-depth defining the far plane of the eye view frustum
  147820. * enables mapping of values in the render target depth
  147821. * attachment to scene coordinates. Initially set to 10000.0.
  147822. */
  147823. depthFar: number;
  147824. /**
  147825. * z-depth defining the near plane of the eye view frustum
  147826. * enables mapping of values in the render target depth
  147827. * attachment to scene coordinates. Initially set to 0.01.
  147828. */
  147829. depthNear: number;
  147830. /**
  147831. * An identifier for this distinct VRDisplay. Used as an
  147832. * association point in the Gamepad API.
  147833. */
  147834. readonly displayId: number;
  147835. /**
  147836. * A display name, a user-readable name identifying it.
  147837. */
  147838. readonly displayName: string;
  147839. readonly isConnected: boolean;
  147840. readonly isPresenting: boolean;
  147841. /**
  147842. * If this VRDisplay supports room-scale experiences, the optional
  147843. * stage attribute contains details on the room-scale parameters.
  147844. */
  147845. readonly stageParameters: VRStageParameters | null;
  147846. /**
  147847. * Passing the value returned by `requestAnimationFrame` to
  147848. * `cancelAnimationFrame` will unregister the callback.
  147849. * @param handle Define the hanle of the request to cancel
  147850. */
  147851. cancelAnimationFrame(handle: number): void;
  147852. /**
  147853. * Stops presenting to the VRDisplay.
  147854. * @returns a promise to know when it stopped
  147855. */
  147856. exitPresent(): Promise<void>;
  147857. /**
  147858. * Return the current VREyeParameters for the given eye.
  147859. * @param whichEye Define the eye we want the parameter for
  147860. * @returns the eye parameters
  147861. */
  147862. getEyeParameters(whichEye: string): VREyeParameters;
  147863. /**
  147864. * Populates the passed VRFrameData with the information required to render
  147865. * the current frame.
  147866. * @param frameData Define the data structure to populate
  147867. * @returns true if ok otherwise false
  147868. */
  147869. getFrameData(frameData: VRFrameData): boolean;
  147870. /**
  147871. * Get the layers currently being presented.
  147872. * @returns the list of VR layers
  147873. */
  147874. getLayers(): VRLayer[];
  147875. /**
  147876. * Return a VRPose containing the future predicted pose of the VRDisplay
  147877. * when the current frame will be presented. The value returned will not
  147878. * change until JavaScript has returned control to the browser.
  147879. *
  147880. * The VRPose will contain the position, orientation, velocity,
  147881. * and acceleration of each of these properties.
  147882. * @returns the pose object
  147883. */
  147884. getPose(): VRPose;
  147885. /**
  147886. * Return the current instantaneous pose of the VRDisplay, with no
  147887. * prediction applied.
  147888. * @returns the current instantaneous pose
  147889. */
  147890. getImmediatePose(): VRPose;
  147891. /**
  147892. * The callback passed to `requestAnimationFrame` will be called
  147893. * any time a new frame should be rendered. When the VRDisplay is
  147894. * presenting the callback will be called at the native refresh
  147895. * rate of the HMD. When not presenting this function acts
  147896. * identically to how window.requestAnimationFrame acts. Content should
  147897. * make no assumptions of frame rate or vsync behavior as the HMD runs
  147898. * asynchronously from other displays and at differing refresh rates.
  147899. * @param callback Define the eaction to run next frame
  147900. * @returns the request handle it
  147901. */
  147902. requestAnimationFrame(callback: FrameRequestCallback): number;
  147903. /**
  147904. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  147905. * Repeat calls while already presenting will update the VRLayers being displayed.
  147906. * @param layers Define the list of layer to present
  147907. * @returns a promise to know when the request has been fulfilled
  147908. */
  147909. requestPresent(layers: VRLayer[]): Promise<void>;
  147910. /**
  147911. * Reset the pose for this display, treating its current position and
  147912. * orientation as the "origin/zero" values. VRPose.position,
  147913. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  147914. * updated when calling resetPose(). This should be called in only
  147915. * sitting-space experiences.
  147916. */
  147917. resetPose(): void;
  147918. /**
  147919. * The VRLayer provided to the VRDisplay will be captured and presented
  147920. * in the HMD. Calling this function has the same effect on the source
  147921. * canvas as any other operation that uses its source image, and canvases
  147922. * created without preserveDrawingBuffer set to true will be cleared.
  147923. * @param pose Define the pose to submit
  147924. */
  147925. submitFrame(pose?: VRPose): void;
  147926. }
  147927. declare var VRDisplay: {
  147928. prototype: VRDisplay;
  147929. new(): VRDisplay;
  147930. };
  147931. interface VRLayer {
  147932. leftBounds?: number[] | Float32Array | null;
  147933. rightBounds?: number[] | Float32Array | null;
  147934. source?: HTMLCanvasElement | null;
  147935. }
  147936. interface VRDisplayCapabilities {
  147937. readonly canPresent: boolean;
  147938. readonly hasExternalDisplay: boolean;
  147939. readonly hasOrientation: boolean;
  147940. readonly hasPosition: boolean;
  147941. readonly maxLayers: number;
  147942. }
  147943. interface VREyeParameters {
  147944. /** @deprecated */
  147945. readonly fieldOfView: VRFieldOfView;
  147946. readonly offset: Float32Array;
  147947. readonly renderHeight: number;
  147948. readonly renderWidth: number;
  147949. }
  147950. interface VRFieldOfView {
  147951. readonly downDegrees: number;
  147952. readonly leftDegrees: number;
  147953. readonly rightDegrees: number;
  147954. readonly upDegrees: number;
  147955. }
  147956. interface VRFrameData {
  147957. readonly leftProjectionMatrix: Float32Array;
  147958. readonly leftViewMatrix: Float32Array;
  147959. readonly pose: VRPose;
  147960. readonly rightProjectionMatrix: Float32Array;
  147961. readonly rightViewMatrix: Float32Array;
  147962. readonly timestamp: number;
  147963. }
  147964. interface VRPose {
  147965. readonly angularAcceleration: Float32Array | null;
  147966. readonly angularVelocity: Float32Array | null;
  147967. readonly linearAcceleration: Float32Array | null;
  147968. readonly linearVelocity: Float32Array | null;
  147969. readonly orientation: Float32Array | null;
  147970. readonly position: Float32Array | null;
  147971. readonly timestamp: number;
  147972. }
  147973. interface VRStageParameters {
  147974. sittingToStandingTransform?: Float32Array;
  147975. sizeX?: number;
  147976. sizeY?: number;
  147977. }
  147978. interface Navigator {
  147979. getVRDisplays(): Promise<VRDisplay[]>;
  147980. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  147981. }
  147982. interface Window {
  147983. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  147984. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  147985. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  147986. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147987. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147988. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  147989. }
  147990. interface Gamepad {
  147991. readonly displayId: number;
  147992. }
  147993. type XRSessionMode =
  147994. | "inline"
  147995. | "immersive-vr"
  147996. | "immersive-ar";
  147997. type XRReferenceSpaceType =
  147998. | "viewer"
  147999. | "local"
  148000. | "local-floor"
  148001. | "bounded-floor"
  148002. | "unbounded";
  148003. type XREnvironmentBlendMode =
  148004. | "opaque"
  148005. | "additive"
  148006. | "alpha-blend";
  148007. type XRVisibilityState =
  148008. | "visible"
  148009. | "visible-blurred"
  148010. | "hidden";
  148011. type XRHandedness =
  148012. | "none"
  148013. | "left"
  148014. | "right";
  148015. type XRTargetRayMode =
  148016. | "gaze"
  148017. | "tracked-pointer"
  148018. | "screen";
  148019. type XREye =
  148020. | "none"
  148021. | "left"
  148022. | "right";
  148023. type XREventType =
  148024. | "devicechange"
  148025. | "visibilitychange"
  148026. | "end"
  148027. | "inputsourceschange"
  148028. | "select"
  148029. | "selectstart"
  148030. | "selectend"
  148031. | "squeeze"
  148032. | "squeezestart"
  148033. | "squeezeend"
  148034. | "reset";
  148035. interface XRSpace extends EventTarget {
  148036. }
  148037. interface XRRenderState {
  148038. depthNear?: number;
  148039. depthFar?: number;
  148040. inlineVerticalFieldOfView?: number;
  148041. baseLayer?: XRWebGLLayer;
  148042. }
  148043. interface XRInputSource {
  148044. handedness: XRHandedness;
  148045. targetRayMode: XRTargetRayMode;
  148046. targetRaySpace: XRSpace;
  148047. gripSpace: XRSpace | undefined;
  148048. gamepad: Gamepad | undefined;
  148049. profiles: Array<string>;
  148050. }
  148051. interface XRSessionInit {
  148052. optionalFeatures?: XRReferenceSpaceType[];
  148053. requiredFeatures?: XRReferenceSpaceType[];
  148054. }
  148055. interface XRSession extends XRAnchorCreator {
  148056. addEventListener: Function;
  148057. removeEventListener: Function;
  148058. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148059. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148060. requestAnimationFrame: Function;
  148061. end(): Promise<void>;
  148062. renderState: XRRenderState;
  148063. inputSources: Array<XRInputSource>;
  148064. // hit test
  148065. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148066. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148067. // legacy AR hit test
  148068. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148069. // legacy plane detection
  148070. updateWorldTrackingState(options: {
  148071. planeDetectionState?: { enabled: boolean; }
  148072. }): void;
  148073. }
  148074. interface XRReferenceSpace extends XRSpace {
  148075. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148076. onreset: any;
  148077. }
  148078. type XRPlaneSet = Set<XRPlane>;
  148079. type XRAnchorSet = Set<XRAnchor>;
  148080. interface XRFrame {
  148081. session: XRSession;
  148082. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148083. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148084. // AR
  148085. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148086. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148087. // Anchors
  148088. trackedAnchors?: XRAnchorSet;
  148089. // Planes
  148090. worldInformation: {
  148091. detectedPlanes?: XRPlaneSet;
  148092. };
  148093. }
  148094. interface XRViewerPose extends XRPose {
  148095. views: Array<XRView>;
  148096. }
  148097. interface XRPose {
  148098. transform: XRRigidTransform;
  148099. emulatedPosition: boolean;
  148100. }
  148101. interface XRWebGLLayerOptions {
  148102. antialias?: boolean;
  148103. depth?: boolean;
  148104. stencil?: boolean;
  148105. alpha?: boolean;
  148106. multiview?: boolean;
  148107. framebufferScaleFactor?: number;
  148108. }
  148109. declare var XRWebGLLayer: {
  148110. prototype: XRWebGLLayer;
  148111. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148112. };
  148113. interface XRWebGLLayer {
  148114. framebuffer: WebGLFramebuffer;
  148115. framebufferWidth: number;
  148116. framebufferHeight: number;
  148117. getViewport: Function;
  148118. }
  148119. declare class XRRigidTransform {
  148120. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148121. position: DOMPointReadOnly;
  148122. orientation: DOMPointReadOnly;
  148123. matrix: Float32Array;
  148124. inverse: XRRigidTransform;
  148125. }
  148126. interface XRView {
  148127. eye: XREye;
  148128. projectionMatrix: Float32Array;
  148129. transform: XRRigidTransform;
  148130. }
  148131. interface XRInputSourceChangeEvent {
  148132. session: XRSession;
  148133. removed: Array<XRInputSource>;
  148134. added: Array<XRInputSource>;
  148135. }
  148136. interface XRInputSourceEvent extends Event {
  148137. readonly frame: XRFrame;
  148138. readonly inputSource: XRInputSource;
  148139. }
  148140. // Experimental(er) features
  148141. declare class XRRay {
  148142. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148143. origin: DOMPointReadOnly;
  148144. direction: DOMPointReadOnly;
  148145. matrix: Float32Array;
  148146. }
  148147. declare enum XRHitTestTrackableType {
  148148. "point",
  148149. "plane"
  148150. }
  148151. interface XRHitResult {
  148152. hitMatrix: Float32Array;
  148153. }
  148154. interface XRTransientInputHitTestResult {
  148155. readonly inputSource: XRInputSource;
  148156. readonly results: Array<XRHitTestResult>;
  148157. }
  148158. interface XRHitTestResult {
  148159. getPose(baseSpace: XRSpace): XRPose | undefined;
  148160. }
  148161. interface XRHitTestSource {
  148162. cancel(): void;
  148163. }
  148164. interface XRTransientInputHitTestSource {
  148165. cancel(): void;
  148166. }
  148167. interface XRHitTestOptionsInit {
  148168. space: XRSpace;
  148169. entityTypes?: Array<XRHitTestTrackableType>;
  148170. offsetRay?: XRRay;
  148171. }
  148172. interface XRTransientInputHitTestOptionsInit {
  148173. profile: string;
  148174. entityTypes?: Array<XRHitTestTrackableType>;
  148175. offsetRay?: XRRay;
  148176. }
  148177. interface XRAnchor {
  148178. // remove?
  148179. id?: string;
  148180. anchorSpace: XRSpace;
  148181. lastChangedTime: number;
  148182. detach(): void;
  148183. }
  148184. interface XRPlane extends XRAnchorCreator {
  148185. orientation: "Horizontal" | "Vertical";
  148186. planeSpace: XRSpace;
  148187. polygon: Array<DOMPointReadOnly>;
  148188. lastChangedTime: number;
  148189. }
  148190. interface XRAnchorCreator {
  148191. // AR Anchors
  148192. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148193. }